From: Yu Kuai <yukuai3@xxxxxxxxxx> So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx> --- drivers/md/md-bitmap.c | 3 ++- drivers/md/md-bitmap.h | 11 +++++++++-- drivers/md/md.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index b34f13aa2697..9a21123a3b8b 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -2092,7 +2092,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot); -void md_bitmap_status(struct seq_file *seq, struct bitmap *bitmap) +static void bitmap_status(struct seq_file *seq, struct bitmap *bitmap) { unsigned long chunk_kb; struct bitmap_counts *counts; @@ -2711,6 +2711,7 @@ static struct bitmap_operations bitmap_ops = { .load = bitmap_load, .destroy = bitmap_destroy, .flush = bitmap_flush, + .status = bitmap_status, .update_sb = bitmap_update_sb, }; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 29c217630ae5..c60b6a9f6163 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -239,6 +239,7 @@ struct bitmap_operations { int (*load)(struct mddev *mddev); void (*destroy)(struct mddev *mddev); void (*flush)(struct mddev *mddev); + void (*status)(struct seq_file *seq, struct bitmap *bitmap); void (*update_sb)(struct bitmap *bitmap); }; @@ -279,6 +280,14 @@ static inline void md_bitmap_flush(struct mddev *mddev) mddev->bitmap_ops->flush(mddev); } +static inline void md_bitmap_status(struct seq_file *seq, struct mddev *mddev) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->status) + return; + + mddev->bitmap_ops->status(seq, mddev->bitmap); +} + static inline void md_bitmap_update_sb(struct mddev *mddev) { if (!mddev->bitmap || !mddev->bitmap_ops->update_sb) @@ -287,8 +296,6 @@ static inline void md_bitmap_update_sb(struct mddev *mddev) mddev->bitmap_ops->update_sb(mddev->bitmap); } -void md_bitmap_status(struct seq_file *seq, struct bitmap *bitmap); - int md_bitmap_setallbits(struct bitmap *bitmap); void md_bitmap_write_all(struct bitmap *bitmap); diff --git a/drivers/md/md.c b/drivers/md/md.c index e749e24e12de..033ea06f6abe 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8454,7 +8454,7 @@ static int md_seq_show(struct seq_file *seq, void *v) } else seq_printf(seq, "\n "); - md_bitmap_status(seq, mddev->bitmap); + md_bitmap_status(seq, mddev); seq_printf(seq, "\n"); } -- 2.39.2