super.c (f573018491fd823e909d587cfe16758f3dd9e6d6) super.c (523be8a6b3418eb7e0f0f042fe0490345eb5d516)
1/*
2 * fs/f2fs/super.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 592 unchanged lines hidden (view full) ---

601 kmem_cache_free(f2fs_inode_cachep, F2FS_I(inode));
602}
603
604static void f2fs_destroy_inode(struct inode *inode)
605{
606 call_rcu(&inode->i_rcu, f2fs_i_callback);
607}
608
1/*
2 * fs/f2fs/super.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 592 unchanged lines hidden (view full) ---

601 kmem_cache_free(f2fs_inode_cachep, F2FS_I(inode));
602}
603
604static void f2fs_destroy_inode(struct inode *inode)
605{
606 call_rcu(&inode->i_rcu, f2fs_i_callback);
607}
608
609static void destroy_percpu_info(struct f2fs_sb_info *sbi)
610{
611 int i;
612
613 for (i = 0; i < NR_COUNT_TYPE; i++)
614 percpu_counter_destroy(&sbi->nr_pages[i]);
615}
616
609static void f2fs_put_super(struct super_block *sb)
610{
611 struct f2fs_sb_info *sbi = F2FS_SB(sb);
612
613 if (sbi->s_proc) {
614 remove_proc_entry("segment_info", sbi->s_proc);
615 remove_proc_entry("segment_bits", sbi->s_proc);
616 remove_proc_entry(sb->s_id, f2fs_proc_root);

--- 44 unchanged lines hidden (view full) ---

661 kfree(sbi->ckpt);
662 kobject_put(&sbi->s_kobj);
663 wait_for_completion(&sbi->s_kobj_unregister);
664
665 sb->s_fs_info = NULL;
666 if (sbi->s_chksum_driver)
667 crypto_free_shash(sbi->s_chksum_driver);
668 kfree(sbi->raw_super);
617static void f2fs_put_super(struct super_block *sb)
618{
619 struct f2fs_sb_info *sbi = F2FS_SB(sb);
620
621 if (sbi->s_proc) {
622 remove_proc_entry("segment_info", sbi->s_proc);
623 remove_proc_entry("segment_bits", sbi->s_proc);
624 remove_proc_entry(sb->s_id, f2fs_proc_root);

--- 44 unchanged lines hidden (view full) ---

669 kfree(sbi->ckpt);
670 kobject_put(&sbi->s_kobj);
671 wait_for_completion(&sbi->s_kobj_unregister);
672
673 sb->s_fs_info = NULL;
674 if (sbi->s_chksum_driver)
675 crypto_free_shash(sbi->s_chksum_driver);
676 kfree(sbi->raw_super);
677
678 destroy_percpu_info(sbi);
669 kfree(sbi);
670}
671
672int f2fs_sync_fs(struct super_block *sb, int sync)
673{
674 struct f2fs_sb_info *sbi = F2FS_SB(sb);
675 int err = 0;
676

--- 642 unchanged lines hidden (view full) ---

1319 return 1;
1320 }
1321 return 0;
1322}
1323
1324static void init_sb_info(struct f2fs_sb_info *sbi)
1325{
1326 struct f2fs_super_block *raw_super = sbi->raw_super;
679 kfree(sbi);
680}
681
682int f2fs_sync_fs(struct super_block *sb, int sync)
683{
684 struct f2fs_sb_info *sbi = F2FS_SB(sb);
685 int err = 0;
686

--- 642 unchanged lines hidden (view full) ---

1329 return 1;
1330 }
1331 return 0;
1332}
1333
1334static void init_sb_info(struct f2fs_sb_info *sbi)
1335{
1336 struct f2fs_super_block *raw_super = sbi->raw_super;
1327 int i;
1328
1329 sbi->log_sectors_per_block =
1330 le32_to_cpu(raw_super->log_sectors_per_block);
1331 sbi->log_blocksize = le32_to_cpu(raw_super->log_blocksize);
1332 sbi->blocksize = 1 << sbi->log_blocksize;
1333 sbi->log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
1334 sbi->blocks_per_seg = 1 << sbi->log_blocks_per_seg;
1335 sbi->segs_per_sec = le32_to_cpu(raw_super->segs_per_sec);
1336 sbi->secs_per_zone = le32_to_cpu(raw_super->secs_per_zone);
1337 sbi->total_sections = le32_to_cpu(raw_super->section_count);
1338 sbi->total_node_count =
1339 (le32_to_cpu(raw_super->segment_count_nat) / 2)
1340 * sbi->blocks_per_seg * NAT_ENTRY_PER_BLOCK;
1341 sbi->root_ino_num = le32_to_cpu(raw_super->root_ino);
1342 sbi->node_ino_num = le32_to_cpu(raw_super->node_ino);
1343 sbi->meta_ino_num = le32_to_cpu(raw_super->meta_ino);
1344 sbi->cur_victim_sec = NULL_SECNO;
1345 sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH;
1346
1337
1338 sbi->log_sectors_per_block =
1339 le32_to_cpu(raw_super->log_sectors_per_block);
1340 sbi->log_blocksize = le32_to_cpu(raw_super->log_blocksize);
1341 sbi->blocksize = 1 << sbi->log_blocksize;
1342 sbi->log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
1343 sbi->blocks_per_seg = 1 << sbi->log_blocks_per_seg;
1344 sbi->segs_per_sec = le32_to_cpu(raw_super->segs_per_sec);
1345 sbi->secs_per_zone = le32_to_cpu(raw_super->secs_per_zone);
1346 sbi->total_sections = le32_to_cpu(raw_super->section_count);
1347 sbi->total_node_count =
1348 (le32_to_cpu(raw_super->segment_count_nat) / 2)
1349 * sbi->blocks_per_seg * NAT_ENTRY_PER_BLOCK;
1350 sbi->root_ino_num = le32_to_cpu(raw_super->root_ino);
1351 sbi->node_ino_num = le32_to_cpu(raw_super->node_ino);
1352 sbi->meta_ino_num = le32_to_cpu(raw_super->meta_ino);
1353 sbi->cur_victim_sec = NULL_SECNO;
1354 sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH;
1355
1347 for (i = 0; i < NR_COUNT_TYPE; i++)
1348 atomic_set(&sbi->nr_pages[i], 0);
1349
1350 sbi->dir_level = DEF_DIR_LEVEL;
1351 sbi->interval_time[CP_TIME] = DEF_CP_INTERVAL;
1352 sbi->interval_time[REQ_TIME] = DEF_IDLE_INTERVAL;
1353 clear_sbi_flag(sbi, SBI_NEED_FSCK);
1354
1355 INIT_LIST_HEAD(&sbi->s_list);
1356 mutex_init(&sbi->umount_mutex);
1357
1358#ifdef CONFIG_F2FS_FS_ENCRYPTION
1359 memcpy(sbi->key_prefix, F2FS_KEY_DESC_PREFIX,
1360 F2FS_KEY_DESC_PREFIX_SIZE);
1361 sbi->key_prefix_size = F2FS_KEY_DESC_PREFIX_SIZE;
1362#endif
1363}
1364
1356 sbi->dir_level = DEF_DIR_LEVEL;
1357 sbi->interval_time[CP_TIME] = DEF_CP_INTERVAL;
1358 sbi->interval_time[REQ_TIME] = DEF_IDLE_INTERVAL;
1359 clear_sbi_flag(sbi, SBI_NEED_FSCK);
1360
1361 INIT_LIST_HEAD(&sbi->s_list);
1362 mutex_init(&sbi->umount_mutex);
1363
1364#ifdef CONFIG_F2FS_FS_ENCRYPTION
1365 memcpy(sbi->key_prefix, F2FS_KEY_DESC_PREFIX,
1366 F2FS_KEY_DESC_PREFIX_SIZE);
1367 sbi->key_prefix_size = F2FS_KEY_DESC_PREFIX_SIZE;
1368#endif
1369}
1370
1371static int init_percpu_info(struct f2fs_sb_info *sbi)
1372{
1373 int i, err;
1374
1375 for (i = 0; i < NR_COUNT_TYPE; i++) {
1376 err = percpu_counter_init(&sbi->nr_pages[i], 0, GFP_KERNEL);
1377 if (err)
1378 return err;
1379 }
1380 return 0;
1381}
1382
1365/*
1366 * Read f2fs raw super block.
1367 * Because we have two copies of super block, so read both of them
1368 * to get the first valid one. If any one of them is broken, we pass
1369 * them recovery flag back to the caller.
1370 */
1371static int read_raw_super_block(struct f2fs_sb_info *sbi,
1372 struct f2fs_super_block **raw_super,

--- 174 unchanged lines hidden (view full) ---

1547 sbi->write_io[i].sbi = sbi;
1548 sbi->write_io[i].bio = NULL;
1549 }
1550
1551 init_rwsem(&sbi->cp_rwsem);
1552 init_waitqueue_head(&sbi->cp_wait);
1553 init_sb_info(sbi);
1554
1383/*
1384 * Read f2fs raw super block.
1385 * Because we have two copies of super block, so read both of them
1386 * to get the first valid one. If any one of them is broken, we pass
1387 * them recovery flag back to the caller.
1388 */
1389static int read_raw_super_block(struct f2fs_sb_info *sbi,
1390 struct f2fs_super_block **raw_super,

--- 174 unchanged lines hidden (view full) ---

1565 sbi->write_io[i].sbi = sbi;
1566 sbi->write_io[i].bio = NULL;
1567 }
1568
1569 init_rwsem(&sbi->cp_rwsem);
1570 init_waitqueue_head(&sbi->cp_wait);
1571 init_sb_info(sbi);
1572
1573 err = init_percpu_info(sbi);
1574 if (err)
1575 goto free_options;
1576
1555 /* get an inode for meta space */
1556 sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi));
1557 if (IS_ERR(sbi->meta_inode)) {
1558 f2fs_msg(sb, KERN_ERR, "Failed to read F2FS meta data inode");
1559 err = PTR_ERR(sbi->meta_inode);
1560 goto free_options;
1561 }
1562

--- 186 unchanged lines hidden (view full) ---

1749 destroy_node_manager(sbi);
1750free_sm:
1751 destroy_segment_manager(sbi);
1752 kfree(sbi->ckpt);
1753free_meta_inode:
1754 make_bad_inode(sbi->meta_inode);
1755 iput(sbi->meta_inode);
1756free_options:
1577 /* get an inode for meta space */
1578 sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi));
1579 if (IS_ERR(sbi->meta_inode)) {
1580 f2fs_msg(sb, KERN_ERR, "Failed to read F2FS meta data inode");
1581 err = PTR_ERR(sbi->meta_inode);
1582 goto free_options;
1583 }
1584

--- 186 unchanged lines hidden (view full) ---

1771 destroy_node_manager(sbi);
1772free_sm:
1773 destroy_segment_manager(sbi);
1774 kfree(sbi->ckpt);
1775free_meta_inode:
1776 make_bad_inode(sbi->meta_inode);
1777 iput(sbi->meta_inode);
1778free_options:
1779 destroy_percpu_info(sbi);
1757 kfree(options);
1758free_sb_buf:
1759 kfree(raw_super);
1760free_sbi:
1761 if (sbi->s_chksum_driver)
1762 crypto_free_shash(sbi->s_chksum_driver);
1763 kfree(sbi);
1764

--- 148 unchanged lines hidden ---
1780 kfree(options);
1781free_sb_buf:
1782 kfree(raw_super);
1783free_sbi:
1784 if (sbi->s_chksum_driver)
1785 crypto_free_shash(sbi->s_chksum_driver);
1786 kfree(sbi);
1787

--- 148 unchanged lines hidden ---