btrfs-progs: extend balance args to take min/max usage filter

Add the overlapping usage and [usage_min, usage_max] members to the
balance args. The min/max values are interpreted iff the corresponding
flag BTRFS_BALANCE_ARGS_USAGE_RANGE is set.

The minimum boundary is inclusive, maximum is exclusive:
* usage_min <= chunk_usage < usage_max

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2015-10-22 10:19:38 +02:00
parent 0826a8ddb9
commit 40db5cd7ff
4 changed files with 25 additions and 1 deletions

View File

@ -106,6 +106,12 @@ Balances only block groups with usage under the given percentage. The
value of 0 is allowed and will clean up completely unused block groups, this
should not require any new space allocated. You may want to use 'usage=0' in
case balance is returnin ENOSPC and your filesystem is not too full.
+
The argument may be a single value or a range. The single value *N* means *at
most N percent used*, equivalent to *..N* range syntax. Kernels prior to 4.4
accept only the single value format.
+
The minimum boundary is inclusive, maximum is exclusive.
*devid=<id>*::
Balances only block groups which have at least one chunk on the given

View File

@ -355,6 +355,10 @@ static void dump_balance_args(struct btrfs_balance_args *args)
printf(", profiles=%llu", (unsigned long long)args->profiles);
if (args->flags & BTRFS_BALANCE_ARGS_USAGE)
printf(", usage=%llu", (unsigned long long)args->usage);
if (args->flags & BTRFS_BALANCE_ARGS_USAGE_RANGE) {
printf(", usage=");
print_range_u32(args->usage_min, args->usage_max);
}
if (args->flags & BTRFS_BALANCE_ARGS_DEVID)
printf(", devid=%llu", (unsigned long long)args->devid);
if (args->flags & BTRFS_BALANCE_ARGS_DRANGE)

15
ioctl.h
View File

@ -216,7 +216,20 @@ struct btrfs_ioctl_feature_flags {
*/
struct btrfs_balance_args {
__u64 profiles;
__u64 usage;
/*
* usage filter
* BTRFS_BALANCE_ARGS_USAGE with a single value means '0..N'
* BTRFS_BALANCE_ARGS_USAGE_RANGE - range syntax, min..max
*/
union {
__u64 usage;
struct {
__u32 usage_min;
__u32 usage_max;
};
};
__u64 devid;
__u64 pstart;
__u64 pend;

View File

@ -138,6 +138,7 @@ struct map_lookup {
#define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5)
#define BTRFS_BALANCE_ARGS_LIMIT_RANGE (1ULL << 6)
#define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7)
#define BTRFS_BALANCE_ARGS_USAGE_RANGE (1ULL << 10)
/*
* Profile changing flags. When SOFT is set we won't relocate chunk if