From 45e9bf809816e9992c288af68f72f01e2329c18d Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 12 Oct 2015 00:34:58 +0200 Subject: [PATCH] btrfs-progs: extend balance args to take min/max limit filter Add the overlapping limit and [limit_min, limit_max] members to the balance args. The min/max values are interpreted iff the corresponding flag BTRFS_BALANCE_ARGS_LIMIT_RANGE is set. The minimum and maximum are inclusive. Note that the values are only 32bit, but this should be enough for the foreseeable future. Signed-off-by: David Sterba --- Documentation/btrfs-balance.asciidoc | 6 ++++++ cmds-balance.c | 4 ++++ ioctl.h | 13 ++++++++++++- volumes.h | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Documentation/btrfs-balance.asciidoc b/Documentation/btrfs-balance.asciidoc index d00abdfc..3562a286 100644 --- a/Documentation/btrfs-balance.asciidoc +++ b/Documentation/btrfs-balance.asciidoc @@ -130,6 +130,12 @@ parameters. Process only given number of chunks, after all filters are applied. This can be used to specifically target a chunk in connection with other filters (drange, vrange) or just simply limit the amount of work done by a single balance run. ++ +The argument may be a single value or a range. The single value *N* means *at +most N chunks*, equivalent to *..N* range syntax. Kernels prior to 4.4 accept +only the single value format. ++ +The range minimum and maximum are inclusive. *soft*:: Takes no parameters. Only has meaning when converting between profiles. diff --git a/cmds-balance.c b/cmds-balance.c index c5be6b9c..dd1c8571 100644 --- a/cmds-balance.c +++ b/cmds-balance.c @@ -347,6 +347,10 @@ static void dump_balance_args(struct btrfs_balance_args *args) (unsigned long long)args->vend); if (args->flags & BTRFS_BALANCE_ARGS_LIMIT) printf(", limit=%llu", (unsigned long long)args->limit); + if (args->flags & BTRFS_BALANCE_ARGS_LIMIT_RANGE) { + printf(", limit="); + print_range_u32(args->limit_min, args->limit_max); + } printf("\n"); } diff --git a/ioctl.h b/ioctl.h index dff015a5..e5cf3230 100644 --- a/ioctl.h +++ b/ioctl.h @@ -227,7 +227,18 @@ struct btrfs_balance_args { __u64 flags; - __u64 limit; /* limit number of processed chunks */ + /* + * BTRFS_BALANCE_ARGS_LIMIT with value 'limit' + * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum + * and maximum + */ + union { + __u64 limit; /* limit number of processed chunks */ + struct { + __u32 limit_min; + __u32 limit_max; + }; + }; __u64 unused[7]; } __attribute__ ((__packed__)); diff --git a/volumes.h b/volumes.h index eb434f1b..b6ea1912 100644 --- a/volumes.h +++ b/volumes.h @@ -136,6 +136,7 @@ struct map_lookup { #define BTRFS_BALANCE_ARGS_DRANGE (1ULL << 3) #define BTRFS_BALANCE_ARGS_VRANGE (1ULL << 4) #define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5) +#define BTRFS_BALANCE_ARGS_LIMIT_RANGE (1ULL << 6) /* * Profile changing flags. When SOFT is set we won't relocate chunk if