aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c23
1 files changed, 23 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