diff options
author | Yu Kuai <yukuai3@huawei.com> | 2024-08-26 09:44:17 +0200 |
---|---|---|
committer | Song Liu <song@kernel.org> | 2024-08-27 19:14:15 +0200 |
commit | 10bc2ac10597ebc0b25afbc72fa4284565548e36 (patch) | |
tree | ab213fb4c6b0b8d8ae37d5f8aeaa593379a77726 /drivers/md/md.c | |
parent | md/md-bitmap: add 'sync_size' into struct md_bitmap_stats (diff) | |
download | linux-10bc2ac10597ebc0b25afbc72fa4284565548e36.tar.xz linux-10bc2ac10597ebc0b25afbc72fa4284565548e36.zip |
md/md-bitmap: add 'file_pages' into struct md_bitmap_stats
There are no functional changes, avoid dereferencing bitmap directly to
prepare inventing a new bitmap.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20240826074452.1490072-8-yukuai1@huaweicloud.com
Signed-off-by: Song Liu <song@kernel.org>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index cde6663c7fcb..06c0918111e3 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -2335,7 +2335,6 @@ super_1_allow_new_offset(struct md_rdev *rdev, unsigned long long new_offset) { /* All necessary checks on new >= old have been done */ - struct bitmap *bitmap; if (new_offset >= rdev->data_offset) return 1; @@ -2352,11 +2351,17 @@ super_1_allow_new_offset(struct md_rdev *rdev, */ if (rdev->sb_start + (32+4)*2 > new_offset) return 0; - bitmap = rdev->mddev->bitmap; - if (bitmap && !rdev->mddev->bitmap_info.file && - rdev->sb_start + rdev->mddev->bitmap_info.offset + - bitmap->storage.file_pages * (PAGE_SIZE>>9) > new_offset) - return 0; + + if (!rdev->mddev->bitmap_info.file) { + struct md_bitmap_stats stats; + int err; + + err = md_bitmap_get_stats(rdev->mddev->bitmap, &stats); + if (!err && rdev->sb_start + rdev->mddev->bitmap_info.offset + + stats.file_pages * (PAGE_SIZE >> 9) > new_offset) + return 0; + } + if (rdev->badblocks.sector + rdev->badblocks.size > new_offset) return 0; |