From 3818aea275423236db38a2d2d0a4951bc6da2e01 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Mon, 13 Jan 2014 13:36:06 +0800 Subject: 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 Signed-off-by: Miao Xie Signed-off-by: Qu Wenruo Signed-off-by: Josef Bacik Signed-off-by: Chris Mason --- fs/btrfs/super.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'fs/btrfs/super.c') diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index f44cc6a..362aef4 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -327,7 +327,7 @@ enum { Opt_check_integrity_print_mask, Opt_fatal_errors, Opt_rescan_uuid_tree, Opt_commit_interval, Opt_barrier, Opt_nodefrag, Opt_nodiscard, Opt_noenospc_debug, Opt_noflushoncommit, Opt_acl, Opt_datacow, - Opt_datasum, Opt_treelog, + Opt_datasum, Opt_treelog, Opt_noinode_cache, Opt_err, }; @@ -370,6 +370,7 @@ static match_table_t tokens = { {Opt_defrag, "autodefrag"}, {Opt_nodefrag, "noautodefrag"}, {Opt_inode_cache, "inode_cache"}, + {Opt_noinode_cache, "noinode_cache"}, {Opt_no_space_cache, "nospace_cache"}, {Opt_recovery, "recovery"}, {Opt_skip_balance, "skip_balance"}, @@ -627,7 +628,12 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) break; case Opt_inode_cache: btrfs_info(root->fs_info, "enabling inode map caching"); - btrfs_set_opt(info->mount_opt, INODE_MAP_CACHE); + btrfs_set_opt(info->mount_opt, CHANGE_INODE_CACHE); + break; + case Opt_noinode_cache: + if (btrfs_test_opt(root, CHANGE_INODE_CACHE)) + btrfs_info(root->fs_info, "disabling inode map caching"); + btrfs_clear_opt(info->mount_opt, CHANGE_INODE_CACHE); break; case Opt_clear_cache: btrfs_info(root->fs_info, "force clearing of disk cache"); -- cgit v1.1