[PATCH RFC -next v2 15/41] md/md-bitmap: merge md_bitmap_flush() into bitmap_operations

From: Yu Kuai
Date: Wed Aug 14 2024 - 03:18:44 EST


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 | 6 ++----
drivers/md/md-bitmap.h | 2 +-
drivers/md/md.c | 3 ++-
3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 94cf3c6e96e3..d1b43bce5953 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1773,10 +1773,7 @@ void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long
}
}

-/*
- * flush out any pending updates
- */
-void md_bitmap_flush(struct mddev *mddev)
+static void bitmap_flush(struct mddev *mddev)
{
struct bitmap *bitmap = mddev->bitmap;
long sleep;
@@ -2722,6 +2719,7 @@ static struct bitmap_operations bitmap_ops = {
.create = bitmap_create,
.load = bitmap_load,
.destroy = bitmap_destroy,
+ .flush = bitmap_flush,
};

void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 9376bbeb4698..0212284c2b29 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -249,13 +249,13 @@ struct bitmap_operations {
int (*create)(struct mddev *mddev, int slot);
int (*load)(struct mddev *mddev);
void (*destroy)(struct mddev *mddev);
+ void (*flush)(struct mddev *mddev);
};

/* the bitmap API */
void mddev_set_bitmap_ops(struct mddev *mddev);

/* these are used only by md/bitmap */
-void md_bitmap_flush(struct mddev *mddev);

void md_bitmap_print_sb(struct bitmap *bitmap);
void md_bitmap_update_sb(struct bitmap *bitmap);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7aecd99d50e2..69d4b21c441e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6450,7 +6450,8 @@ static void __md_stop_writes(struct mddev *mddev)
mddev->pers->quiesce(mddev, 1);
mddev->pers->quiesce(mddev, 0);
}
- md_bitmap_flush(mddev);
+
+ mddev->bitmap_ops->flush(mddev);

if (md_is_rdwr(mddev) &&
((!mddev->in_sync && !mddev_is_clustered(mddev)) ||
--
2.39.2