summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2015-10-22 10:19:38 +0200
committerDavid Sterba <dsterba@suse.com>2016-01-12 15:01:04 +0100
commit40db5cd7ffcbc4b58d6c82e9ddba01f7e26152ca (patch)
tree5f2b486ae544e16dd9678429f25746234554d09c
parent0826a8ddb90e577c5c359d8bca2571f167029f7e (diff)
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>
-rw-r--r--Documentation/btrfs-balance.asciidoc6
-rw-r--r--cmds-balance.c4
-rw-r--r--ioctl.h15
-rw-r--r--volumes.h1
4 files changed, 25 insertions, 1 deletions
diff --git a/Documentation/btrfs-balance.asciidoc b/Documentation/btrfs-balance.asciidoc
index 9adf7784..92a37784 100644
--- a/Documentation/btrfs-balance.asciidoc
+++ b/Documentation/btrfs-balance.asciidoc
@@ -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
diff --git a/cmds-balance.c b/cmds-balance.c
index 2453101a..2c5d2eb1 100644
--- a/cmds-balance.c
+++ b/cmds-balance.c
@@ -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)
diff --git a/ioctl.h b/ioctl.h
index 0df2444c..771da231 100644
--- a/ioctl.h
+++ b/ioctl.h
@@ -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;
diff --git a/volumes.h b/volumes.h
index f5064304..c0007adc 100644
--- a/volumes.h
+++ b/volumes.h
@@ -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