btrfs: add ref-verify mount option

This adds the infrastructure for turning ref verify on and off for a
mount, to be used by a later patch.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ enhnance btrfs_print_mod_info to print if ref-verify is compiled in ]
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Josef Bacik 2017-09-29 15:43:48 -04:00 committed by David Sterba
parent 6273b7f8ed
commit fb592373cd
2 changed files with 18 additions and 0 deletions

View File

@ -1335,6 +1335,7 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
#define BTRFS_MOUNT_FRAGMENT_METADATA (1 << 25) #define BTRFS_MOUNT_FRAGMENT_METADATA (1 << 25)
#define BTRFS_MOUNT_FREE_SPACE_TREE (1 << 26) #define BTRFS_MOUNT_FREE_SPACE_TREE (1 << 26)
#define BTRFS_MOUNT_NOLOGREPLAY (1 << 27) #define BTRFS_MOUNT_NOLOGREPLAY (1 << 27)
#define BTRFS_MOUNT_REF_VERIFY (1 << 28)
#define BTRFS_DEFAULT_COMMIT_INTERVAL (30) #define BTRFS_DEFAULT_COMMIT_INTERVAL (30)
#define BTRFS_DEFAULT_MAX_INLINE (2048) #define BTRFS_DEFAULT_MAX_INLINE (2048)

View File

@ -325,6 +325,9 @@ enum {
Opt_nologreplay, Opt_norecovery, Opt_nologreplay, Opt_norecovery,
#ifdef CONFIG_BTRFS_DEBUG #ifdef CONFIG_BTRFS_DEBUG
Opt_fragment_data, Opt_fragment_metadata, Opt_fragment_all, Opt_fragment_data, Opt_fragment_metadata, Opt_fragment_all,
#endif
#ifdef CONFIG_BTRFS_FS_REF_VERIFY
Opt_ref_verify,
#endif #endif
Opt_err, Opt_err,
}; };
@ -386,6 +389,9 @@ static const match_table_t tokens = {
{Opt_fragment_data, "fragment=data"}, {Opt_fragment_data, "fragment=data"},
{Opt_fragment_metadata, "fragment=metadata"}, {Opt_fragment_metadata, "fragment=metadata"},
{Opt_fragment_all, "fragment=all"}, {Opt_fragment_all, "fragment=all"},
#endif
#ifdef CONFIG_BTRFS_FS_REF_VERIFY
{Opt_ref_verify, "ref_verify"},
#endif #endif
{Opt_err, NULL}, {Opt_err, NULL},
}; };
@ -824,6 +830,12 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
btrfs_info(info, "fragmenting data"); btrfs_info(info, "fragmenting data");
btrfs_set_opt(info->mount_opt, FRAGMENT_DATA); btrfs_set_opt(info->mount_opt, FRAGMENT_DATA);
break; break;
#endif
#ifdef CONFIG_BTRFS_FS_REF_VERIFY
case Opt_ref_verify:
btrfs_info(info, "doing ref verification");
btrfs_set_opt(info->mount_opt, REF_VERIFY);
break;
#endif #endif
case Opt_err: case Opt_err:
btrfs_info(info, "unrecognized mount option '%s'", p); btrfs_info(info, "unrecognized mount option '%s'", p);
@ -1305,6 +1317,8 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
if (btrfs_test_opt(info, FRAGMENT_METADATA)) if (btrfs_test_opt(info, FRAGMENT_METADATA))
seq_puts(seq, ",fragment=metadata"); seq_puts(seq, ",fragment=metadata");
#endif #endif
if (btrfs_test_opt(info, REF_VERIFY))
seq_puts(seq, ",ref_verify");
seq_printf(seq, ",subvolid=%llu", seq_printf(seq, ",subvolid=%llu",
BTRFS_I(d_inode(dentry))->root->root_key.objectid); BTRFS_I(d_inode(dentry))->root->root_key.objectid);
seq_puts(seq, ",subvol="); seq_puts(seq, ",subvol=");
@ -2318,6 +2332,9 @@ static void btrfs_print_mod_info(void)
#endif #endif
#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
", integrity-checker=on" ", integrity-checker=on"
#endif
#ifdef CONFIG_BTRFS_FS_REF_VERIFY
", ref-verify=on"
#endif #endif
"\n", "\n",
btrfs_crc32c_impl()); btrfs_crc32c_impl());