From 704a08cb8ae8735f8538e637a1be822e76e69d3c Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Thu, 31 Jan 2013 10:57:53 -0800 Subject: [PATCH] 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 --- btrfstune.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/btrfstune.c b/btrfstune.c index 6950f74d..6e68bda9 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -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 {