diff mbox series

[RFC,-next,11/26] md/md-bitmap: merge md_bitmap_dirty_bits() into bitmap_operations

Message ID 20240810020854.797814-12-yukuai1@huaweicloud.com (mailing list archive)
State Superseded
Headers show
Series md/md-bitmap: introduce bitmap_operations | expand

Commit Message

Yu Kuai Aug. 10, 2024, 2:08 a.m. UTC
From: Yu Kuai <yukuai3@huawei.com>

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 |  4 +++-
 drivers/md/md-bitmap.h | 10 +++++++++-
 drivers/md/md.c        |  2 +-
 3 files changed, 13 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index aab7bb5418f7..b85ae1bf2b7d 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1755,7 +1755,8 @@  static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, in
 }
 
 /* dirty the memory and file bits for bitmap chunks "s" to "e" */
-void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
+static void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s,
+			      unsigned long e)
 {
 	unsigned long chunk;
 
@@ -2713,6 +2714,7 @@  static struct bitmap_operations bitmap_ops = {
 	.flush			= bitmap_flush,
 	.status			= bitmap_status,
 	.write_all		= bitmap_write_all,
+	.dirty_bits		= bitmap_dirty_bits,
 
 	.update_sb		= bitmap_update_sb,
 };
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 9df0c1d5f7ee..b708a25bd6f4 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -241,6 +241,7 @@  struct bitmap_operations {
 	void (*flush)(struct mddev *mddev);
 	void (*status)(struct seq_file *seq, struct bitmap *bitmap);
 	void (*write_all)(struct bitmap *bitmap);
+	void (*dirty_bits)(struct bitmap *bitmap, unsigned long s, unsigned long e);
 
 	void (*update_sb)(struct bitmap *bitmap);
 };
@@ -305,7 +306,14 @@  static inline void md_bitmap_write_all(struct mddev *mddev)
 	mddev->bitmap_ops->write_all(mddev->bitmap);
 }
 
-void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e);
+static inline void md_bitmap_dirty_bits(struct mddev *mddev, unsigned long s,
+					unsigned long e)
+{
+	if (!mddev->bitmap || !mddev->bitmap_ops->dirty_bits)
+		return;
+
+	mddev->bitmap_ops->dirty_bits(mddev->bitmap, s, e);
+}
 
 /* these are exported */
 int md_bitmap_startwrite(struct bitmap *bitmap, sector_t offset,
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 2260540dd458..841539a0be1b 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4688,7 +4688,7 @@  bitmap_store(struct mddev *mddev, const char *buf, size_t len)
 			if (buf == end) break;
 		}
 		if (*end && !isspace(*end)) break;
-		md_bitmap_dirty_bits(mddev->bitmap, chunk, end_chunk);
+		md_bitmap_dirty_bits(mddev, chunk, end_chunk);
 		buf = skip_spaces(end);
 	}
 	md_bitmap_unplug(mddev->bitmap); /* flush the bits to disk */