aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabríel Arthúr Pétursson <gabriel@system.is>2015-09-28 22:33:04 +0000
committerDavid Sterba <dsterba@suse.com>2016-01-12 15:01:04 +0100
commit0826a8ddb90e577c5c359d8bca2571f167029f7e (patch)
tree43cad92e0e3f810d3df3c3d07edb421f1723d5e4
parent7dff5c9c9b980e9848e1716434606eb01c16914e (diff)
downloadbtrfs-progs-0826a8ddb90e577c5c359d8bca2571f167029f7e.tar.gz
btrfs-progs-0826a8ddb90e577c5c359d8bca2571f167029f7e.tar.xz
btrfs-progs-0826a8ddb90e577c5c359d8bca2571f167029f7e.zip
btrfs-progs: balance: add stripes filter
Add new balance filter 'stripes=<range>' to process only chunks that are spread accross given number of chunks. The range minimum and maximum are inclusive. Signed-off-by: Gabríel Arthúr Pétursson <gabriel@system.is> [ reworked a bit to use the range helpers, dropped the single value for stripes ] Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--Documentation/btrfs-balance.asciidoc6
-rw-r--r--cmds-balance.c16
-rw-r--r--ioctl.h4
-rw-r--r--volumes.h1
4 files changed, 26 insertions, 1 deletions
diff --git a/Documentation/btrfs-balance.asciidoc b/Documentation/btrfs-balance.asciidoc
index 3562a28..9adf778 100644
--- a/Documentation/btrfs-balance.asciidoc
+++ b/Documentation/btrfs-balance.asciidoc
@@ -137,6 +137,12 @@ only the single value format.
+
The range minimum and maximum are inclusive.
+*stripes*::
+Balances only block groups which have the given number of stripes. The
+parameter is a range specified as <start..end>.
++
+The range minimum and maximum are inclusive.
+
*soft*::
Takes no parameters. Only has meaning when converting between profiles.
When doing convert from one profile to another and soft mode is on,
diff --git a/cmds-balance.c b/cmds-balance.c
index 1715f36..2453101 100644
--- a/cmds-balance.c
+++ b/cmds-balance.c
@@ -319,6 +319,18 @@ static int parse_filters(char *filters, struct btrfs_balance_args *args)
args->flags &= ~BTRFS_BALANCE_ARGS_LIMIT_RANGE;
args->flags |= BTRFS_BALANCE_ARGS_LIMIT;
}
+ } else if (!strcmp(this_char, "stripes")) {
+ if (!value || !*value) {
+ fprintf(stderr,
+ "the stripes filter requires an argument\n");
+ return 1;
+ }
+ if (parse_range_u32(value, &args->stripes_min,
+ &args->stripes_max)) {
+ fprintf(stderr, "Invalid stripes argument\n");
+ return 1;
+ }
+ args->flags |= BTRFS_BALANCE_ARGS_STRIPES_RANGE;
} else {
fprintf(stderr, "Unrecognized balance option '%s'\n",
this_char);
@@ -359,6 +371,10 @@ static void dump_balance_args(struct btrfs_balance_args *args)
printf(", limit=");
print_range_u32(args->limit_min, args->limit_max);
}
+ if (args->flags & BTRFS_BALANCE_ARGS_STRIPES_RANGE) {
+ printf(", stripes=");
+ print_range_u32(args->stripes_min, args->stripes_max);
+ }
printf("\n");
}
diff --git a/ioctl.h b/ioctl.h
index e5cf323..0df2444 100644
--- a/ioctl.h
+++ b/ioctl.h
@@ -239,7 +239,9 @@ struct btrfs_balance_args {
__u32 limit_max;
};
};
- __u64 unused[7];
+ __u32 stripes_min;
+ __u32 stripes_max;
+ __u64 unused[6];
} __attribute__ ((__packed__));
/* report balance progress to userspace */
diff --git a/volumes.h b/volumes.h
index b6ea191..f506430 100644
--- a/volumes.h
+++ b/volumes.h
@@ -137,6 +137,7 @@ struct map_lookup {
#define BTRFS_BALANCE_ARGS_VRANGE (1ULL << 4)
#define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5)
#define BTRFS_BALANCE_ARGS_LIMIT_RANGE (1ULL << 6)
+#define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7)
/*
* Profile changing flags. When SOFT is set we won't relocate chunk if