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

Yu Kuai
2024-08-14T07:15:44Z

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@huawei.com>
---
drivers/md/md-bitmap.c | 6 +++---
drivers/md/md-bitmap.h | 4 +---
drivers/md/md.c | 2 +-
drivers/md/raid1.c | 2 +-
4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index eb7c5e552acf..c6826cb28ed2 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1863,7 +1863,7 @@ static void md_bitmap_free(struct bitmap *bitmap)
kfree(bitmap);
}

-void md_bitmap_wait_behind_writes(struct mddev *mddev)
+static void bitmap_wait_behind_writes(struct mddev *mddev)
{
struct bitmap *bitmap = mddev->bitmap;

@@ -1876,7 +1876,6 @@ void md_bitmap_wait_behind_writes(struct mddev *mddev)
atomic_read(&bitmap->behind_writes) == 0);
}
}
-EXPORT_SYMBOL_GPL(md_bitmap_wait_behind_writes);

static void bitmap_destroy(struct mddev *mddev)
{
@@ -1885,7 +1884,7 @@ static void bitmap_destroy(struct mddev *mddev)
if (!bitmap) /* there was no bitmap */
return;

- md_bitmap_wait_behind_writes(mddev);
+ bitmap_wait_behind_writes(mddev);
if (!mddev->serialize_policy)
mddev_destroy_serial_pool(mddev, NULL);

@@ -2752,6 +2751,7 @@ static struct bitmap_operations bitmap_ops = {
.dirty_bits = bitmap_dirty_bits,
.unplug = bitmap_unplug,
.daemon_work = bitmap_daemon_work,
+ .wait_behind_writes = bitmap_wait_behind_writes,

.startwrite = bitmap_startwrite,
.endwrite = bitmap_endwrite,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index d0037665a4dc..b232ac57c0dc 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -258,6 +258,7 @@ struct bitmap_operations {
unsigned long e);
void (*unplug)(struct mddev *mddev, bool sync);
void (*daemon_work)(struct mddev *mddev);
+ void (*wait_behind_writes)(struct mddev *mddev);

int (*startwrite)(struct mddev *mddev, sector_t offset,
unsigned long sectors, bool behind);
@@ -285,9 +286,6 @@ struct bitmap_operations {
/* the bitmap API */
void mddev_set_bitmap_ops(struct mddev *mddev);

-/* these are exported */
-void md_bitmap_wait_behind_writes(struct mddev *mddev);
-
static inline u64 md_bitmap_events_cleared(struct mddev *mddev)
{
struct md_bitmap_stats stats;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 4bdfe23a565d..6800888152d0 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6484,7 +6484,7 @@ EXPORT_SYMBOL_GPL(md_stop_writes);

static void mddev_detach(struct mddev *mddev)
{
- md_bitmap_wait_behind_writes(mddev);
+ mddev->bitmap_ops->wait_behind_writes(mddev);
if (mddev->pers && mddev->pers->quiesce && !is_md_suspended(mddev)) {
mddev->pers->quiesce(mddev, 1);
mddev->pers->quiesce(mddev, 0);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index e285f01e3ef6..17b1965fec56 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1384,7 +1384,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
* over-take any writes that are 'behind'
*/
mddev_add_trace_msg(mddev, "raid1 wait behind writes");
- md_bitmap_wait_behind_writes(mddev);
+ mddev->bitmap_ops->wait_behind_writes(mddev);
}

if (max_sectors < bio_sectors(bio)) {
--
2.39.2