diff mbox series

[md-6.12,13/41] md/md-bitmap: merge md_bitmap_load() into bitmap_operations

Message ID 20240822024718.2158259-14-yukuai1@huaweicloud.com (mailing list archive)
State Superseded
Headers show
Series md/md-bitmap: introduce bitmap_operations and make structure internel | expand

Commit Message

Yu Kuai Aug. 22, 2024, 2:46 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/dm-raid.c   | 4 +++-
 drivers/md/md-bitmap.c | 6 +++---
 drivers/md/md-bitmap.h | 2 +-
 drivers/md/md.c        | 7 ++++---
 4 files changed, 11 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 0c3323e0adb2..c3e201fde4c5 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -3949,7 +3949,9 @@  static int __load_dirty_region_bitmap(struct raid_set *rs)
 	/* Try loading the bitmap unless "raid0", which does not have one */
 	if (!rs_is_raid0(rs) &&
 	    !test_and_set_bit(RT_FLAG_RS_BITMAP_LOADED, &rs->runtime_flags)) {
-		r = md_bitmap_load(&rs->md);
+		struct mddev *mddev = &rs->md;
+
+		r = mddev->bitmap_ops->load(mddev);
 		if (r)
 			DMERR("Failed to load bitmap");
 	}
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index c0089e787215..bac247df6f40 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1977,7 +1977,7 @@  static int bitmap_create(struct mddev *mddev, int slot)
 	return 0;
 }
 
-int md_bitmap_load(struct mddev *mddev)
+static int bitmap_load(struct mddev *mddev)
 {
 	int err = 0;
 	sector_t start = 0;
@@ -2033,7 +2033,6 @@  int md_bitmap_load(struct mddev *mddev)
 out:
 	return err;
 }
-EXPORT_SYMBOL_GPL(md_bitmap_load);
 
 /* caller need to free returned bitmap with md_bitmap_free() */
 struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot)
@@ -2425,7 +2424,7 @@  location_store(struct mddev *mddev, const char *buf, size_t len)
 			if (rv)
 				goto out;
 
-			rv = md_bitmap_load(mddev);
+			rv = bitmap_load(mddev);
 			if (rv) {
 				mddev->bitmap_info.offset = 0;
 				md_bitmap_destroy(mddev);
@@ -2724,6 +2723,7 @@  const struct attribute_group md_bitmap_group = {
 
 static struct bitmap_operations bitmap_ops = {
 	.create			= bitmap_create,
+	.load			= bitmap_load,
 };
 
 void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index f4c4925102b6..f5b04b61d9e9 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -248,13 +248,13 @@  struct md_bitmap_stats {
 
 struct bitmap_operations {
 	int (*create)(struct mddev *mddev, int slot);
+	int (*load)(struct mddev *mddev);
 };
 
 /* the bitmap API */
 void mddev_set_bitmap_ops(struct mddev *mddev);
 
 /* these are used only by md/bitmap */
-int md_bitmap_load(struct mddev *mddev);
 void md_bitmap_flush(struct mddev *mddev);
 void md_bitmap_destroy(struct mddev *mddev);
 
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f766f5b8d2d3..ff59826aa192 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6316,7 +6316,8 @@  int do_md_run(struct mddev *mddev)
 	err = md_run(mddev);
 	if (err)
 		goto out;
-	err = md_bitmap_load(mddev);
+
+	err = mddev->bitmap_ops->load(mddev);
 	if (err) {
 		md_bitmap_destroy(mddev);
 		goto out;
@@ -7284,7 +7285,7 @@  static int set_bitmap_file(struct mddev *mddev, int fd)
 		if (fd >= 0) {
 			err = mddev->bitmap_ops->create(mddev, -1);
 			if (!err)
-				err = md_bitmap_load(mddev);
+				err = mddev->bitmap_ops->load(mddev);
 
 			if (err) {
 				md_bitmap_destroy(mddev);
@@ -7578,7 +7579,7 @@  static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
 				mddev->bitmap_info.default_space;
 			rv = mddev->bitmap_ops->create(mddev, -1);
 			if (!rv)
-				rv = md_bitmap_load(mddev);
+				rv = mddev->bitmap_ops->load(mddev);
 
 			if (rv)
 				md_bitmap_destroy(mddev);