diff options
author | Chunguang Xu <brookxu@tencent.com> | 2020-11-07 23:58:13 +0800 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2020-12-03 09:42:41 -0500 |
commit | ce3cca337401123c9cf96896fc4e1657bb016bd3 (patch) | |
tree | 6e662010e865fd521778bb0acbcb01a197d3ee44 /fs/ext4 | |
parent | 6bd97bf273bdb4944904e57480f6545bca48ad77 (diff) | |
download | linux-ce3cca337401123c9cf96896fc4e1657bb016bd3.tar.bz2 |
ext4: simplify the code of mb_find_order_for_block
The code of mb_find_order_for_block is a bit obscure, but we can
simplify it with mb_find_buddy(), make the code more concise.
Signed-off-by: Chunguang Xu <brookxu@tencent.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Link: https://lore.kernel.org/r/1604764698-4269-3-git-send-email-brookxu@tencent.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/mballoc.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 5b745551e7a9..29dfeb043050 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -1289,22 +1289,18 @@ static void ext4_mb_unload_buddy(struct ext4_buddy *e4b) static int mb_find_order_for_block(struct ext4_buddy *e4b, int block) { - int order = 1; - int bb_incr = 1 << (e4b->bd_blkbits - 1); + int order = 1, max; void *bb; BUG_ON(e4b->bd_bitmap == e4b->bd_buddy); BUG_ON(block >= (1 << (e4b->bd_blkbits + 3))); - bb = e4b->bd_buddy; while (order <= e4b->bd_blkbits + 1) { - block = block >> 1; - if (!mb_test_bit(block, bb)) { + bb = mb_find_buddy(e4b, order, &max); + if (!mb_test_bit(block >> order, bb)) { /* this block is part of buddy of order 'order' */ return order; } - bb += bb_incr; - bb_incr >>= 1; order++; } return 0; |