aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-10-03 14:07:49 -0400
committerJosef Bacik <josef@redhat.com>2011-10-19 15:12:51 -0400
commit73bc187680f94bed498f8a669103cad290e41180 (patch)
treee4e8c9a6baa656dbeb470032956657b294610c61 /fs/btrfs/extent-tree.c
parente27425d614d68daa08f60735982a7c3a0230e855 (diff)
Btrfs: introduce mount option no_space_cache
Some users have requested this and I've found I needed a way to disable cache loading without actually clearing the cache, so introduce the no_space_cache option. Before we check the super blocks cache generation field and if it was populated we always turned space caching on. Now we check this and set the space cache option on, and then parse the mount options so that if we want it off it get's turned off. Then we check the mount option all the places we do the caching work instead of checking the super's cache generation. This makes things more consistent and lets us turn space caching off. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 25b69d0f9135..f9711a82fc54 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -481,7 +481,8 @@ static int cache_block_group(struct btrfs_block_group_cache *cache,
481 * we likely hold important locks. 481 * we likely hold important locks.
482 */ 482 */
483 if (trans && (!trans->transaction->in_commit) && 483 if (trans && (!trans->transaction->in_commit) &&
484 (root && root != root->fs_info->tree_root)) { 484 (root && root != root->fs_info->tree_root) &&
485 btrfs_test_opt(root, SPACE_CACHE)) {
485 spin_lock(&cache->lock); 486 spin_lock(&cache->lock);
486 if (cache->cached != BTRFS_CACHE_NO) { 487 if (cache->cached != BTRFS_CACHE_NO) {
487 spin_unlock(&cache->lock); 488 spin_unlock(&cache->lock);
@@ -4223,7 +4224,7 @@ static int update_block_group(struct btrfs_trans_handle *trans,
4223 spin_lock(&cache->space_info->lock); 4224 spin_lock(&cache->space_info->lock);
4224 spin_lock(&cache->lock); 4225 spin_lock(&cache->lock);
4225 4226
4226 if (btrfs_super_cache_generation(&info->super_copy) != 0 && 4227 if (btrfs_test_opt(root, SPACE_CACHE) &&
4227 cache->disk_cache_state < BTRFS_DC_CLEAR) 4228 cache->disk_cache_state < BTRFS_DC_CLEAR)
4228 cache->disk_cache_state = BTRFS_DC_CLEAR; 4229 cache->disk_cache_state = BTRFS_DC_CLEAR;
4229 4230
@@ -7038,13 +7039,11 @@ int btrfs_read_block_groups(struct btrfs_root *root)
7038 path->reada = 1; 7039 path->reada = 1;
7039 7040
7040 cache_gen = btrfs_super_cache_generation(&root->fs_info->super_copy); 7041 cache_gen = btrfs_super_cache_generation(&root->fs_info->super_copy);
7041 if (cache_gen != 0 && 7042 if (btrfs_test_opt(root, SPACE_CACHE) &&
7042 btrfs_super_generation(&root->fs_info->super_copy) != cache_gen) 7043 btrfs_super_generation(&root->fs_info->super_copy) != cache_gen)
7043 need_clear = 1; 7044 need_clear = 1;
7044 if (btrfs_test_opt(root, CLEAR_CACHE)) 7045 if (btrfs_test_opt(root, CLEAR_CACHE))
7045 need_clear = 1; 7046 need_clear = 1;
7046 if (!btrfs_test_opt(root, SPACE_CACHE) && cache_gen)
7047 printk(KERN_INFO "btrfs: disk space caching is enabled\n");
7048 7047
7049 while (1) { 7048 while (1) {
7050 ret = find_first_block_group(root, path, &key); 7049 ret = find_first_block_group(root, path, &key);