aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2014-01-13 00:36:06 -0500
committerChris Mason <clm@fb.com>2014-01-28 16:20:33 -0500
commit3818aea275423236db38a2d2d0a4951bc6da2e01 (patch)
tree8f6c5e005a8be46049554306acf32786eb3c7d32
parentade2e0b3eeca941a5cd486bac21599ff87f288c8 (diff)
btrfs: Add noinode_cache mount option
Add noinode_cache mount option for btrfs. Since inode map cache involves all the btrfs_find_free_ino/return_ino things and if just trigger the mount_opt, an inode number get from inode map cache will not returned to inode map cache. To keep the find and return inode both in the same behavior, a new bit in mount_opt, CHANGE_INODE_CACHE, is introduced for this idea. CHANGE_INODE_CACHE is set/cleared in remounting, and the original INODE_MAP_CACHE is set/cleared according to CHANGE_INODE_CACHE after a success transaction. Since find/return inode is all done between btrfs_start_transaction and btrfs_commit_transaction, this will keep consistent behavior. Also noinode_cache mount option will not stop the caching_kthread. Cc: David Sterba <dsterba@suse.cz> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/disk-io.c4
-rw-r--r--fs/btrfs/super.c10
-rw-r--r--fs/btrfs/transaction.c9
4 files changed, 22 insertions, 2 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 3708fd7ee83a..52c96db0ec0a 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2023,6 +2023,7 @@ struct btrfs_ioctl_defrag_range_args {
2023#define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21) 2023#define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21)
2024#define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22) 2024#define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22)
2025#define BTRFS_MOUNT_RESCAN_UUID_TREE (1 << 23) 2025#define BTRFS_MOUNT_RESCAN_UUID_TREE (1 << 23)
2026#define BTRFS_MOUNT_CHANGE_INODE_CACHE (1 << 24)
2026 2027
2027#define BTRFS_DEFAULT_COMMIT_INTERVAL (30) 2028#define BTRFS_DEFAULT_COMMIT_INTERVAL (30)
2028 2029
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index f0e7bbe14823..4f142c986544 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2776,6 +2776,10 @@ retry_root_backup:
2776 btrfs_set_opt(fs_info->mount_opt, SSD); 2776 btrfs_set_opt(fs_info->mount_opt, SSD);
2777 } 2777 }
2778 2778
2779 /* Set the real inode map cache flag */
2780 if (btrfs_test_opt(tree_root, CHANGE_INODE_CACHE))
2781 btrfs_set_opt(tree_root->fs_info->mount_opt, INODE_MAP_CACHE);
2782
2779#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 2783#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
2780 if (btrfs_test_opt(tree_root, CHECK_INTEGRITY)) { 2784 if (btrfs_test_opt(tree_root, CHECK_INTEGRITY)) {
2781 ret = btrfsic_mount(tree_root, fs_devices, 2785 ret = btrfsic_mount(tree_root, fs_devices,
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index f44cc6a0eb27..362aef44a17b 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -327,7 +327,7 @@ enum {
327 Opt_check_integrity_print_mask, Opt_fatal_errors, Opt_rescan_uuid_tree, 327 Opt_check_integrity_print_mask, Opt_fatal_errors, Opt_rescan_uuid_tree,
328 Opt_commit_interval, Opt_barrier, Opt_nodefrag, Opt_nodiscard, 328 Opt_commit_interval, Opt_barrier, Opt_nodefrag, Opt_nodiscard,
329 Opt_noenospc_debug, Opt_noflushoncommit, Opt_acl, Opt_datacow, 329 Opt_noenospc_debug, Opt_noflushoncommit, Opt_acl, Opt_datacow,
330 Opt_datasum, Opt_treelog, 330 Opt_datasum, Opt_treelog, Opt_noinode_cache,
331 Opt_err, 331 Opt_err,
332}; 332};
333 333
@@ -370,6 +370,7 @@ static match_table_t tokens = {
370 {Opt_defrag, "autodefrag"}, 370 {Opt_defrag, "autodefrag"},
371 {Opt_nodefrag, "noautodefrag"}, 371 {Opt_nodefrag, "noautodefrag"},
372 {Opt_inode_cache, "inode_cache"}, 372 {Opt_inode_cache, "inode_cache"},
373 {Opt_noinode_cache, "noinode_cache"},
373 {Opt_no_space_cache, "nospace_cache"}, 374 {Opt_no_space_cache, "nospace_cache"},
374 {Opt_recovery, "recovery"}, 375 {Opt_recovery, "recovery"},
375 {Opt_skip_balance, "skip_balance"}, 376 {Opt_skip_balance, "skip_balance"},
@@ -627,7 +628,12 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
627 break; 628 break;
628 case Opt_inode_cache: 629 case Opt_inode_cache:
629 btrfs_info(root->fs_info, "enabling inode map caching"); 630 btrfs_info(root->fs_info, "enabling inode map caching");
630 btrfs_set_opt(info->mount_opt, INODE_MAP_CACHE); 631 btrfs_set_opt(info->mount_opt, CHANGE_INODE_CACHE);
632 break;
633 case Opt_noinode_cache:
634 if (btrfs_test_opt(root, CHANGE_INODE_CACHE))
635 btrfs_info(root->fs_info, "disabling inode map caching");
636 btrfs_clear_opt(info->mount_opt, CHANGE_INODE_CACHE);
631 break; 637 break;
632 case Opt_clear_cache: 638 case Opt_clear_cache:
633 btrfs_info(root->fs_info, "force clearing of disk cache"); 639 btrfs_info(root->fs_info, "force clearing of disk cache");
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 5e2bfdaf8d14..34cd83184c4a 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1826,6 +1826,15 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
1826 goto cleanup_transaction; 1826 goto cleanup_transaction;
1827 } 1827 }
1828 1828
1829 /*
1830 * Since the transaction is done, we should set the inode map cache flag
1831 * before any other comming transaction.
1832 */
1833 if (btrfs_test_opt(root, CHANGE_INODE_CACHE))
1834 btrfs_set_opt(root->fs_info->mount_opt, INODE_MAP_CACHE);
1835 else
1836 btrfs_clear_opt(root->fs_info->mount_opt, INODE_MAP_CACHE);
1837
1829 /* commit_fs_roots gets rid of all the tree log roots, it is now 1838 /* commit_fs_roots gets rid of all the tree log roots, it is now
1830 * safe to free the root of tree log roots 1839 * safe to free the root of tree log roots
1831 */ 1840 */