mirror of
https://github.com/kdave/btrfs-progs
synced 2025-03-22 19:06:29 +00:00
btrfs-progs: balance: enhance the usage filter with range
We can do more with the balance usage filter. Enhance it so we can specify also the minimum usage of the block groups to process. The 'usage' filter now accepts a range (a..b, can be partial) and needs kernel support. The 'usage=value' filter is equivalent to 'limit=..value' but works on older kernels as well. The min/max values are 32bit, unlike the single-value limit which is 64bit. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
40db5cd7ff
commit
5a657cad46
@ -244,11 +244,30 @@ static int parse_filters(char *filters, struct btrfs_balance_args *args)
|
||||
"an argument\n");
|
||||
return 1;
|
||||
}
|
||||
if (parse_u64(value, &args->usage) ||
|
||||
args->usage > 100) {
|
||||
fprintf(stderr, "Invalid usage argument: %s\n",
|
||||
value);
|
||||
return 1;
|
||||
if (parse_u64(value, &args->usage)) {
|
||||
if (parse_range_u32(value, &args->usage_min,
|
||||
&args->usage_max)) {
|
||||
fprintf(stderr,
|
||||
"Invalid usage argument: %s\n",
|
||||
value);
|
||||
return 1;
|
||||
}
|
||||
if (args->usage_max > 100) {
|
||||
fprintf(stderr,
|
||||
"Invalid usage argument: %s\n",
|
||||
value);
|
||||
}
|
||||
args->flags &= ~BTRFS_BALANCE_ARGS_USAGE;
|
||||
args->flags |= BTRFS_BALANCE_ARGS_USAGE_RANGE;
|
||||
} else {
|
||||
if (args->usage > 100) {
|
||||
fprintf(stderr,
|
||||
"Invalid usage argument: %s\n",
|
||||
value);
|
||||
return 1;
|
||||
}
|
||||
args->flags &= ~BTRFS_BALANCE_ARGS_USAGE_RANGE;
|
||||
args->flags |= BTRFS_BALANCE_ARGS_USAGE;
|
||||
}
|
||||
args->flags |= BTRFS_BALANCE_ARGS_USAGE;
|
||||
} else if (!strcmp(this_char, "devid")) {
|
||||
|
Loading…
Reference in New Issue
Block a user