]> git.hungrycats.org Git - linux/commitdiff
btrfs: add stripes filter
authorGabríel Arthúr Pétursson <gabriel@system.is>
Mon, 28 Sep 2015 22:32:41 +0000 (22:32 +0000)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Mon, 5 Oct 2015 21:15:45 +0000 (17:15 -0400)
fs/btrfs/ctree.h
fs/btrfs/volumes.c
fs/btrfs/volumes.h
include/uapi/linux/btrfs.h

index 52c315a5fb24d785ecbac42cd9611074abf39ddb..4f02af9c6af943c3e1778f17b31b4163f53c3e12 100644 (file)
@@ -849,7 +849,11 @@ struct btrfs_disk_balance_args {
        /* BTRFS_BALANCE_ARGS_LIMIT value */
        __le64 limit;
 
-       __le64 unused[7];
+       /* btrfs stripes filter */
+       __le64 sstart;
+       __le64 send;
+
+       __le64 unused[5];
 } __attribute__ ((__packed__));
 
 /*
index dfc276175aaf94e897acdc3e3a81eac5ca254df0..e298d0d5452d7280b05d463050521d0b69eb4a0a 100644 (file)
@@ -3049,6 +3049,18 @@ static int chunk_vrange_filter(struct extent_buffer *leaf,
        return 1;
 }
 
+static int chunk_stripes_filter(struct extent_buffer *leaf,
+                              struct btrfs_chunk *chunk,
+                              struct btrfs_balance_args *bargs)
+{
+       int num_stripes = btrfs_chunk_num_stripes(leaf, chunk);
+
+       if (bargs->sstart <= num_stripes && num_stripes <= bargs->send)
+               return 0;
+
+       return 1;
+}
+
 static int chunk_soft_convert_filter(u64 chunk_type,
                                     struct btrfs_balance_args *bargs)
 {
@@ -3115,6 +3127,12 @@ static int should_balance_chunk(struct btrfs_root *root,
                return 0;
        }
 
+       /* stripes filter */
+       if ((bargs->flags & BTRFS_BALANCE_ARGS_STRIPES) &&
+           chunk_stripes_filter(leaf, chunk, bargs)) {
+               return 0;
+       }
+
        /* soft profile changing mode */
        if ((bargs->flags & BTRFS_BALANCE_ARGS_SOFT) &&
            chunk_soft_convert_filter(chunk_type, bargs)) {
index ebc31331a83746b23b4e99ac146b25fc03b31cc3..38a88cb0773d7b2233a711f79fd2aa3cf992c90e 100644 (file)
@@ -371,6 +371,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_STRIPES     (1ULL << 6)
 
 /*
  * Profile changing flags.  When SOFT is set we won't relocate chunk if
index b6dec05c7196a22511e346242724406eef88265b..a7819d07ad42a28100818c9903bbcaba00c8db6f 100644 (file)
@@ -218,7 +218,11 @@ struct btrfs_balance_args {
        __u64 flags;
 
        __u64 limit;            /* limit number of processed chunks */
-       __u64 unused[7];
+
+       __u64 sstart;
+       __u64 send;
+
+       __u64 unused[5];
 } __attribute__ ((__packed__));
 
 /* report balance progress to userspace */