@@ -2105,6 +2105,7 @@ int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
stats->pages = counts->pages;
stats->missing_pages = counts->missing_pages;
stats->file = bitmap->storage.file;
+ stats->events_cleared = bitmap->events_cleared;
return 0;
}
@@ -238,6 +238,7 @@ struct md_bitmap_stats {
unsigned long pages;
unsigned long missing_pages;
struct file *file;
+ u64 events_cleared;
};
/* the bitmap API */
@@ -282,6 +283,17 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
void md_bitmap_free(struct bitmap *bitmap);
void md_bitmap_wait_behind_writes(struct mddev *mddev);
+static inline u64 md_bitmap_events_cleared(struct mddev *mddev)
+{
+ struct md_bitmap_stats stats;
+ int err = md_bitmap_get_stats(mddev->bitmap, &stats);
+
+ if (err)
+ return 0;
+
+ return stats.events_cleared;
+}
+
static inline bool md_bitmap_enabled(struct bitmap *bitmap)
{
return bitmap && bitmap->storage.filemap &&
@@ -1464,7 +1464,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
* older device ... but not too old.
*/
- if (ev1 < mddev->bitmap->events_cleared)
+ if (ev1 < md_bitmap_events_cleared(mddev))
return 0;
if (ev1 < mddev->events)
set_bit(Bitmap_sync, &rdev->flags);
@@ -1991,7 +1991,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
* older device, but not too old.
*/
- if (ev1 < mddev->bitmap->events_cleared)
+ if (ev1 < md_bitmap_events_cleared(mddev))
return 0;
if (ev1 < mddev->events)
set_bit(Bitmap_sync, &rdev->flags);