aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/volumes.c23
-rw-r--r--fs/btrfs/volumes.h1
2 files changed, 24 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index b858242374db..9ff5cd09a256 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2150,6 +2150,23 @@ static int chunk_usage_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset,
2150 return ret; 2150 return ret;
2151} 2151}
2152 2152
2153static int chunk_devid_filter(struct extent_buffer *leaf,
2154 struct btrfs_chunk *chunk,
2155 struct btrfs_balance_args *bargs)
2156{
2157 struct btrfs_stripe *stripe;
2158 int num_stripes = btrfs_chunk_num_stripes(leaf, chunk);
2159 int i;
2160
2161 for (i = 0; i < num_stripes; i++) {
2162 stripe = btrfs_stripe_nr(chunk, i);
2163 if (btrfs_stripe_devid(leaf, stripe) == bargs->devid)
2164 return 0;
2165 }
2166
2167 return 1;
2168}
2169
2153static int should_balance_chunk(struct btrfs_root *root, 2170static int should_balance_chunk(struct btrfs_root *root,
2154 struct extent_buffer *leaf, 2171 struct extent_buffer *leaf,
2155 struct btrfs_chunk *chunk, u64 chunk_offset) 2172 struct btrfs_chunk *chunk, u64 chunk_offset)
@@ -2183,6 +2200,12 @@ static int should_balance_chunk(struct btrfs_root *root,
2183 return 0; 2200 return 0;
2184 } 2201 }
2185 2202
2203 /* devid filter */
2204 if ((bargs->flags & BTRFS_BALANCE_ARGS_DEVID) &&
2205 chunk_devid_filter(leaf, chunk, bargs)) {
2206 return 0;
2207 }
2208
2186 return 1; 2209 return 1;
2187} 2210}
2188 2211
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index eee77fcf812a..7cfec03c29b8 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -201,6 +201,7 @@ struct map_lookup {
201 */ 201 */
202#define BTRFS_BALANCE_ARGS_PROFILES (1ULL << 0) 202#define BTRFS_BALANCE_ARGS_PROFILES (1ULL << 0)
203#define BTRFS_BALANCE_ARGS_USAGE (1ULL << 1) 203#define BTRFS_BALANCE_ARGS_USAGE (1ULL << 1)
204#define BTRFS_BALANCE_ARGS_DEVID (1ULL << 2)
204 205
205struct btrfs_balance_args; 206struct btrfs_balance_args;
206struct btrfs_balance_control { 207struct btrfs_balance_control {