aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.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/super.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/super.c')
-rw-r--r--fs/btrfs/super.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 934789f7fd33..266d1f35465d 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -164,7 +164,7 @@ enum {
164 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard, 164 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
165 Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed, 165 Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
166 Opt_enospc_debug, Opt_subvolrootid, Opt_defrag, 166 Opt_enospc_debug, Opt_subvolrootid, Opt_defrag,
167 Opt_inode_cache, Opt_err, 167 Opt_inode_cache, Opt_no_space_cache, Opt_err,
168}; 168};
169 169
170static match_table_t tokens = { 170static match_table_t tokens = {
@@ -197,6 +197,7 @@ static match_table_t tokens = {
197 {Opt_subvolrootid, "subvolrootid=%d"}, 197 {Opt_subvolrootid, "subvolrootid=%d"},
198 {Opt_defrag, "autodefrag"}, 198 {Opt_defrag, "autodefrag"},
199 {Opt_inode_cache, "inode_cache"}, 199 {Opt_inode_cache, "inode_cache"},
200 {Opt_no_space_cache, "no_space_cache"},
200 {Opt_err, NULL}, 201 {Opt_err, NULL},
201}; 202};
202 203
@@ -208,14 +209,19 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
208{ 209{
209 struct btrfs_fs_info *info = root->fs_info; 210 struct btrfs_fs_info *info = root->fs_info;
210 substring_t args[MAX_OPT_ARGS]; 211 substring_t args[MAX_OPT_ARGS];
211 char *p, *num, *orig; 212 char *p, *num, *orig = NULL;
213 u64 cache_gen;
212 int intarg; 214 int intarg;
213 int ret = 0; 215 int ret = 0;
214 char *compress_type; 216 char *compress_type;
215 bool compress_force = false; 217 bool compress_force = false;
216 218
219 cache_gen = btrfs_super_cache_generation(&root->fs_info->super_copy);
220 if (cache_gen)
221 btrfs_set_opt(info->mount_opt, SPACE_CACHE);
222
217 if (!options) 223 if (!options)
218 return 0; 224 goto out;
219 225
220 /* 226 /*
221 * strsep changes the string, duplicate it because parse_options 227 * strsep changes the string, duplicate it because parse_options
@@ -362,9 +368,12 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
362 btrfs_set_opt(info->mount_opt, DISCARD); 368 btrfs_set_opt(info->mount_opt, DISCARD);
363 break; 369 break;
364 case Opt_space_cache: 370 case Opt_space_cache:
365 printk(KERN_INFO "btrfs: enabling disk space caching\n");
366 btrfs_set_opt(info->mount_opt, SPACE_CACHE); 371 btrfs_set_opt(info->mount_opt, SPACE_CACHE);
367 break; 372 break;
373 case Opt_no_space_cache:
374 printk(KERN_INFO "btrfs: disabling disk space caching\n");
375 btrfs_clear_opt(info->mount_opt, SPACE_CACHE);
376 break;
368 case Opt_inode_cache: 377 case Opt_inode_cache:
369 printk(KERN_INFO "btrfs: enabling inode map caching\n"); 378 printk(KERN_INFO "btrfs: enabling inode map caching\n");
370 btrfs_set_opt(info->mount_opt, INODE_MAP_CACHE); 379 btrfs_set_opt(info->mount_opt, INODE_MAP_CACHE);
@@ -393,6 +402,8 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
393 } 402 }
394 } 403 }
395out: 404out:
405 if (!ret && btrfs_test_opt(root, SPACE_CACHE))
406 printk(KERN_INFO "btrfs: disk space caching is enabled\n");
396 kfree(orig); 407 kfree(orig);
397 return ret; 408 return ret;
398} 409}
@@ -687,6 +698,8 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs)
687 seq_puts(seq, ",noacl"); 698 seq_puts(seq, ",noacl");
688 if (btrfs_test_opt(root, SPACE_CACHE)) 699 if (btrfs_test_opt(root, SPACE_CACHE))
689 seq_puts(seq, ",space_cache"); 700 seq_puts(seq, ",space_cache");
701 else
702 seq_puts(seq, ",no_space_cache");
690 if (btrfs_test_opt(root, CLEAR_CACHE)) 703 if (btrfs_test_opt(root, CLEAR_CACHE))
691 seq_puts(seq, ",clear_cache"); 704 seq_puts(seq, ",clear_cache");
692 if (btrfs_test_opt(root, USER_SUBVOL_RM_ALLOWED)) 705 if (btrfs_test_opt(root, USER_SUBVOL_RM_ALLOWED))