From 0826a8ddb90e577c5c359d8bca2571f167029f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabr=C3=ADel=20Arth=C3=BAr=20P=C3=A9tursson?= Date: Mon, 28 Sep 2015 22:33:04 +0000 Subject: btrfs-progs: balance: add stripes filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add new balance filter 'stripes=' 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 [ reworked a bit to use the range helpers, dropped the single value for stripes ] Signed-off-by: David Sterba --- cmds-balance.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cmds-balance.c') 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"); } -- cgit v1.2.1