diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2012-03-27 10:09:17 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2012-03-27 10:09:17 -0400 |
commit | 7738a53a3a3aa8d82350280ff4bc7df9c3094123 (patch) | |
tree | f51ea4f52ba5bc6688b43737567d6a991235da28 /fs/btrfs | |
parent | fc67c450837ec034174060a25889a55eed741a1d (diff) |
Btrfs: add __get_block_group_index() helper
Add __get_block_group_index() helper to be able to derive block group
index from an arbitary set of flags. Implement get_block_group_index()
in terms of it.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/extent-tree.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index faf52e030315..c44aa9680789 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -5248,22 +5248,29 @@ wait_block_group_cache_done(struct btrfs_block_group_cache *cache) | |||
5248 | return 0; | 5248 | return 0; |
5249 | } | 5249 | } |
5250 | 5250 | ||
5251 | static int get_block_group_index(struct btrfs_block_group_cache *cache) | 5251 | static int __get_block_group_index(u64 flags) |
5252 | { | 5252 | { |
5253 | int index; | 5253 | int index; |
5254 | if (cache->flags & BTRFS_BLOCK_GROUP_RAID10) | 5254 | |
5255 | if (flags & BTRFS_BLOCK_GROUP_RAID10) | ||
5255 | index = 0; | 5256 | index = 0; |
5256 | else if (cache->flags & BTRFS_BLOCK_GROUP_RAID1) | 5257 | else if (flags & BTRFS_BLOCK_GROUP_RAID1) |
5257 | index = 1; | 5258 | index = 1; |
5258 | else if (cache->flags & BTRFS_BLOCK_GROUP_DUP) | 5259 | else if (flags & BTRFS_BLOCK_GROUP_DUP) |
5259 | index = 2; | 5260 | index = 2; |
5260 | else if (cache->flags & BTRFS_BLOCK_GROUP_RAID0) | 5261 | else if (flags & BTRFS_BLOCK_GROUP_RAID0) |
5261 | index = 3; | 5262 | index = 3; |
5262 | else | 5263 | else |
5263 | index = 4; | 5264 | index = 4; |
5265 | |||
5264 | return index; | 5266 | return index; |
5265 | } | 5267 | } |
5266 | 5268 | ||
5269 | static int get_block_group_index(struct btrfs_block_group_cache *cache) | ||
5270 | { | ||
5271 | return __get_block_group_index(cache->flags); | ||
5272 | } | ||
5273 | |||
5267 | enum btrfs_loop_type { | 5274 | enum btrfs_loop_type { |
5268 | LOOP_CACHING_NOWAIT = 0, | 5275 | LOOP_CACHING_NOWAIT = 0, |
5269 | LOOP_CACHING_WAIT = 1, | 5276 | LOOP_CACHING_WAIT = 1, |