btrfsprogs: btrfstune support for extended inode refs

This patch adds an option to btrfstune, '-r' which will enable the extended
inode refs flag on the provided btrfs superblock. We don't have a disable
option at the moment as that would require far more work.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
master
Mark Fasheh 2013-01-31 10:57:53 -08:00 committed by Chris Mason
parent e5701088e2
commit 704a08cb8a
1 changed files with 27 additions and 1 deletions

View File

@ -65,22 +65,40 @@ int update_seeding_flag(struct btrfs_root *root, int set_flag)
return 0;
}
int enable_extrefs_flag(struct btrfs_root *root)
{
struct btrfs_trans_handle *trans;
struct btrfs_super_block *disk_super;
u64 super_flags;
disk_super = &root->fs_info->super_copy;
super_flags = btrfs_super_incompat_flags(disk_super);
super_flags |= BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF;
trans = btrfs_start_transaction(root, 1);
btrfs_set_super_incompat_flags(disk_super, super_flags);
btrfs_commit_transaction(trans, root);
return 0;
}
static void print_usage(void)
{
fprintf(stderr, "usage: btrfstune [options] device\n");
fprintf(stderr, "\t-S value\tenable/disable seeding\n");
fprintf(stderr, "\t-r \t\tenable extended inode refs\n");
}
int main(int argc, char *argv[])
{
struct btrfs_root *root;
int success = 0;
int extrefs_flag = 0;
int seeding_flag = 0;
int seeding_value = 0;
int ret;
while(1) {
int c = getopt(argc, argv, "S:");
int c = getopt(argc, argv, "S:r");
if (c < 0)
break;
switch(c) {
@ -88,6 +106,9 @@ int main(int argc, char *argv[])
seeding_flag = 1;
seeding_value = atoi(optarg);
break;
case 'r':
extrefs_flag = 1;
break;
default:
print_usage();
return 1;
@ -119,6 +140,11 @@ int main(int argc, char *argv[])
success++;
}
if (extrefs_flag) {
enable_extrefs_flag(root);
success++;
}
if (success > 0) {
ret = 0;
} else {