summaryrefslogtreecommitdiff
path: root/cmds-balance.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2014-05-07 17:38:00 +0200
committerDavid Sterba <dsterba@suse.cz>2014-08-22 14:55:26 +0200
commit266c81a910540d85cc47463b2a0cb16b0dd4e1e1 (patch)
tree166e14118dced9d29f676640c1c2632dbbe1b691 /cmds-balance.c
parent9875a101330dca0367cd8d2bac9567cfe8e56978 (diff)
downloadbtrfs-progs-266c81a910540d85cc47463b2a0cb16b0dd4e1e1.tar.gz
btrfs-progs: balance filter: add limit of processed chunks
Add more control to the balance behaviour. Usage filter may not be finegrained enough and can lead to moving too many chunks at once. Another example use is in connection with drange+devid or vrange filters that allow to work with a specific chunk or even with a chunk on a given device. The limit filter applies last, the value of 0 means no limiting. CC: Ilya Dryomov <idryomov@gmail.com> CC: Hugo Mills <hugo@carfax.org.uk> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-balance.c')
-rw-r--r--cmds-balance.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/cmds-balance.c b/cmds-balance.c
index 8a743ec..5de51bd 100644
--- a/cmds-balance.c
+++ b/cmds-balance.c
@@ -218,6 +218,18 @@ static int parse_filters(char *filters, struct btrfs_balance_args *args)
args->flags |= BTRFS_BALANCE_ARGS_CONVERT;
} else if (!strcmp(this_char, "soft")) {
args->flags |= BTRFS_BALANCE_ARGS_SOFT;
+ } else if (!strcmp(this_char, "limit")) {
+ if (!value || !*value) {
+ fprintf(stderr,
+ "the limit filter requires an argument\n");
+ return 1;
+ }
+ if (parse_u64(value, &args->limit)) {
+ fprintf(stderr, "Invalid limit argument: %s\n",
+ value);
+ return 1;
+ }
+ args->flags |= BTRFS_BALANCE_ARGS_LIMIT;
} else {
fprintf(stderr, "Unrecognized balance option '%s'\n",
this_char);
@@ -252,6 +264,8 @@ static void dump_balance_args(struct btrfs_balance_args *args)
printf(", vrange=%llu..%llu",
(unsigned long long)args->vstart,
(unsigned long long)args->vend);
+ if (args->flags & BTRFS_BALANCE_ARGS_LIMIT)
+ printf(", limit=%llu", (unsigned long long)args->limit);
printf("\n");
}