Commit 10bc2ac1 authored by Yu Kuai's avatar Yu Kuai Committed by Song Liu

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: default avatarYu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20240826074452.1490072-8-yukuai1@huaweicloud.comSigned-off-by: default avatarSong Liu <song@kernel.org>
parent ec6bb299
......@@ -2096,6 +2096,7 @@ EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot);
int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
{
struct bitmap_storage *storage;
struct bitmap_counts *counts;
bitmap_super_t *sb;
......@@ -2110,9 +2111,11 @@ int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
stats->missing_pages = counts->missing_pages;
stats->pages = counts->pages;
stats->events_cleared = bitmap->events_cleared;
stats->file = bitmap->storage.file;
storage = &bitmap->storage;
stats->file_pages = storage->file_pages;
stats->file = storage->file;
stats->events_cleared = bitmap->events_cleared;
return 0;
}
EXPORT_SYMBOL_GPL(md_bitmap_get_stats);
......
......@@ -237,6 +237,7 @@ struct bitmap {
struct md_bitmap_stats {
u64 events_cleared;
unsigned long missing_pages;
unsigned long file_pages;
unsigned long sync_size;
unsigned long pages;
struct file *file;
......
......@@ -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)
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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment