aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2014-02-05 09:26:17 -0500
committerDavid Sterba <dsterba@suse.cz>2014-11-12 10:53:13 -0500
commit7e1876aca815029d5c3023a66a91e249eca3e533 (patch)
tree95b45315399590654ef882d2f55cb9944d732598
parent6b5fe46dfa52441f49c7432b1c1b1cb767834708 (diff)
btrfs: switch inode_cache option handling to pending changes
The pending mount option(s) now share namespace and bits with the normal options, and the existing one for (inode_cache) is unset unconditionally at each transaction commit. Introduce a separate namespace for pending changes and enhance the descriptions of the intended change to use separate bits for each action. Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--fs/btrfs/ctree.h4
-rw-r--r--fs/btrfs/disk-io.c4
-rw-r--r--fs/btrfs/inode-map.c2
-rw-r--r--fs/btrfs/super.c4
-rw-r--r--fs/btrfs/transaction.c19
5 files changed, 18 insertions, 15 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index f30b061ef77d..1c9157e4ab0c 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2098,7 +2098,6 @@ struct btrfs_ioctl_defrag_range_args {
2098#define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21) 2098#define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21)
2099#define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22) 2099#define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22)
2100#define BTRFS_MOUNT_RESCAN_UUID_TREE (1 << 23) 2100#define BTRFS_MOUNT_RESCAN_UUID_TREE (1 << 23)
2101#define BTRFS_MOUNT_CHANGE_INODE_CACHE (1 << 24)
2102 2101
2103#define BTRFS_DEFAULT_COMMIT_INTERVAL (30) 2102#define BTRFS_DEFAULT_COMMIT_INTERVAL (30)
2104#define BTRFS_DEFAULT_MAX_INLINE (8192) 2103#define BTRFS_DEFAULT_MAX_INLINE (8192)
@@ -2131,6 +2130,9 @@ struct btrfs_ioctl_defrag_range_args {
2131 * transaction commit) 2130 * transaction commit)
2132 */ 2131 */
2133 2132
2133#define BTRFS_PENDING_SET_INODE_MAP_CACHE (0)
2134#define BTRFS_PENDING_CLEAR_INODE_MAP_CACHE (1)
2135
2134#define btrfs_test_pending(info, opt) \ 2136#define btrfs_test_pending(info, opt) \
2135 test_bit(BTRFS_PENDING_##opt, &(info)->pending_changes) 2137 test_bit(BTRFS_PENDING_##opt, &(info)->pending_changes)
2136#define btrfs_set_pending(info, opt) \ 2138#define btrfs_set_pending(info, opt) \
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index fd80c0d98421..6b406e3f3abe 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2830,10 +2830,6 @@ retry_root_backup:
2830 btrfs_set_opt(fs_info->mount_opt, SSD); 2830 btrfs_set_opt(fs_info->mount_opt, SSD);
2831 } 2831 }
2832 2832
2833 /* Set the real inode map cache flag */
2834 if (btrfs_test_opt(tree_root, CHANGE_INODE_CACHE))
2835 btrfs_set_opt(tree_root->fs_info->mount_opt, INODE_MAP_CACHE);
2836
2837 /* 2833 /*
2838 * Mount does not set all options immediatelly, we can do it now and do 2834 * Mount does not set all options immediatelly, we can do it now and do
2839 * not have to wait for transaction commit 2835 * not have to wait for transaction commit
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index 83d646bd2e4b..4ebd5ebb1ea1 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -178,7 +178,7 @@ static void start_caching(struct btrfs_root *root)
178 root->root_key.objectid); 178 root->root_key.objectid);
179 if (IS_ERR(tsk)) { 179 if (IS_ERR(tsk)) {
180 btrfs_warn(root->fs_info, "failed to start inode caching task"); 180 btrfs_warn(root->fs_info, "failed to start inode caching task");
181 btrfs_clear_and_info(root, CHANGE_INODE_CACHE, 181 btrfs_clear_pending_and_info(root->fs_info, INODE_MAP_CACHE,
182 "disabling inode map caching"); 182 "disabling inode map caching");
183 } 183 }
184} 184}
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 1da16d59e115..65c75d9e9750 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -642,11 +642,11 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
642 "disabling disk space caching"); 642 "disabling disk space caching");
643 break; 643 break;
644 case Opt_inode_cache: 644 case Opt_inode_cache:
645 btrfs_set_and_info(root, CHANGE_INODE_CACHE, 645 btrfs_set_pending_and_info(info, INODE_MAP_CACHE,
646 "enabling inode map caching"); 646 "enabling inode map caching");
647 break; 647 break;
648 case Opt_noinode_cache: 648 case Opt_noinode_cache:
649 btrfs_clear_and_info(root, CHANGE_INODE_CACHE, 649 btrfs_clear_pending_and_info(info, INODE_MAP_CACHE,
650 "disabling inode map caching"); 650 "disabling inode map caching");
651 break; 651 break;
652 case Opt_clear_cache: 652 case Opt_clear_cache:
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 7a4024a55e5c..703238ed7337 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1842,14 +1842,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
1842 } 1842 }
1843 1843
1844 /* 1844 /*
1845 * Since the transaction is done, we should set the inode map cache flag 1845 * Since the transaction is done, we can apply the pending changes
1846 * before any other comming transaction. 1846 * before the next transaction.
1847 */ 1847 */
1848 if (btrfs_test_opt(root, CHANGE_INODE_CACHE))
1849 btrfs_set_opt(root->fs_info->mount_opt, INODE_MAP_CACHE);
1850 else
1851 btrfs_clear_opt(root->fs_info->mount_opt, INODE_MAP_CACHE);
1852
1853 btrfs_apply_pending_changes(root->fs_info); 1848 btrfs_apply_pending_changes(root->fs_info);
1854 1849
1855 /* commit_fs_roots gets rid of all the tree log roots, it is now 1850 /* commit_fs_roots gets rid of all the tree log roots, it is now
@@ -2031,6 +2026,16 @@ void btrfs_apply_pending_changes(struct btrfs_fs_info *fs_info)
2031 if (!prev) 2026 if (!prev)
2032 return; 2027 return;
2033 2028
2029 bit = 1 << BTRFS_PENDING_SET_INODE_MAP_CACHE;
2030 if (prev & bit)
2031 btrfs_set_opt(fs_info->mount_opt, INODE_MAP_CACHE);
2032 prev &= ~bit;
2033
2034 bit = 1 << BTRFS_PENDING_CLEAR_INODE_MAP_CACHE;
2035 if (prev & bit)
2036 btrfs_clear_opt(fs_info->mount_opt, INODE_MAP_CACHE);
2037 prev &= ~bit;
2038
2034 if (prev) 2039 if (prev)
2035 btrfs_warn(fs_info, 2040 btrfs_warn(fs_info,
2036 "unknown pending changes left 0x%lx, ignoring", prev); 2041 "unknown pending changes left 0x%lx, ignoring", prev);