Commit d004442f authored by Yu Kuai's avatar Yu Kuai Committed by Song Liu

md/md-bitmap: add 'events_cleared' into struct md_bitmap_stats

Also add a new helper to get events_cleared to 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-5-yukuai1@huaweicloud.comSigned-off-by: default avatarSong Liu <song@kernel.org>
parent 96815381
...@@ -2104,6 +2104,8 @@ int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats) ...@@ -2104,6 +2104,8 @@ int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
counts = &bitmap->counts; counts = &bitmap->counts;
stats->missing_pages = counts->missing_pages; stats->missing_pages = counts->missing_pages;
stats->pages = counts->pages; stats->pages = counts->pages;
stats->events_cleared = bitmap->events_cleared;
stats->file = bitmap->storage.file; stats->file = bitmap->storage.file;
return 0; return 0;
......
...@@ -235,6 +235,7 @@ struct bitmap { ...@@ -235,6 +235,7 @@ struct bitmap {
}; };
struct md_bitmap_stats { struct md_bitmap_stats {
u64 events_cleared;
unsigned long missing_pages; unsigned long missing_pages;
unsigned long pages; unsigned long pages;
struct file *file; struct file *file;
......
...@@ -1372,6 +1372,18 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor ...@@ -1372,6 +1372,18 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
return ret; return ret;
} }
static u64 md_bitmap_events_cleared(struct mddev *mddev)
{
struct md_bitmap_stats stats;
int err;
err = md_bitmap_get_stats(mddev->bitmap, &stats);
if (err)
return 0;
return stats.events_cleared;
}
/* /*
* validate_super for 0.90.0 * validate_super for 0.90.0
* note: we are not using "freshest" for 0.9 superblock * note: we are not using "freshest" for 0.9 superblock
...@@ -1464,7 +1476,7 @@ static int super_90_validate(struct mddev *mddev, struct md_rdev *freshest, stru ...@@ -1464,7 +1476,7 @@ static int super_90_validate(struct mddev *mddev, struct md_rdev *freshest, stru
/* if adding to array with a bitmap, then we can accept an /* if adding to array with a bitmap, then we can accept an
* older device ... but not too old. * older device ... but not too old.
*/ */
if (ev1 < mddev->bitmap->events_cleared) if (ev1 < md_bitmap_events_cleared(mddev))
return 0; return 0;
if (ev1 < mddev->events) if (ev1 < mddev->events)
set_bit(Bitmap_sync, &rdev->flags); set_bit(Bitmap_sync, &rdev->flags);
...@@ -1991,7 +2003,7 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *freshest, struc ...@@ -1991,7 +2003,7 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *freshest, struc
/* If adding to array with a bitmap, then we can accept an /* If adding to array with a bitmap, then we can accept an
* older device, but not too old. * older device, but not too old.
*/ */
if (ev1 < mddev->bitmap->events_cleared) if (ev1 < md_bitmap_events_cleared(mddev))
return 0; return 0;
if (ev1 < mddev->events) if (ev1 < mddev->events)
set_bit(Bitmap_sync, &rdev->flags); set_bit(Bitmap_sync, &rdev->flags);
......
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