diff mbox series

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

Message ID 20240810020854.797814-22-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 |  7 +++----
 drivers/md/md-bitmap.h | 14 ++++++++++++--
 2 files changed, 15 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index f6c0334708ee..199bd6757543 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2037,8 +2037,8 @@  static struct bitmap *bitmap_get_from_slot(struct mddev *mddev, int slot)
 /* Loads the bitmap associated with slot and copies the resync information
  * to our bitmap
  */
-int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
-		sector_t *low, sector_t *high, bool clear_bits)
+static int bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *low,
+				 sector_t *high, bool clear_bits)
 {
 	int rv = 0, i, j;
 	sector_t block, lo = 0, hi = 0;
@@ -2080,8 +2080,6 @@  int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
 
 	return rv;
 }
-EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot);
-
 
 static void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
 {
@@ -2716,6 +2714,7 @@  static struct bitmap_operations bitmap_ops = {
 	.resize			= bitmap_resize,
 	.sync_with_cluster	= bitmap_sync_with_cluster,
 	.get_from_slot		= bitmap_get_from_slot,
+	.copy_from_slot		= bitmap_copy_from_slot,
 };
 
 void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 199fb961b11f..acd868e2ef5e 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -261,6 +261,8 @@  struct bitmap_operations {
 				  sector_t old_lo, sector_t old_hi,
 				  sector_t new_lo, sector_t new_hi);
 	struct bitmap* (*get_from_slot)(struct mddev *mddev, int slot);
+	int (*copy_from_slot)(struct mddev *mddev, int slot,
+			      sector_t *lo, sector_t *hi, bool clear_bits);
 };
 
 /* the bitmap API */
@@ -421,12 +423,20 @@  static inline struct bitmap *md_bitmap_get_from_slot(struct mddev *mddev,
 	return mddev->bitmap_ops->get_from_slot(mddev, slot);
 }
 
+static inline int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
+					   sector_t *lo, sector_t *hi,
+					   bool clear_bits)
+{
+	if (!mddev->bitmap_ops->copy_from_slot)
+		return -EOPNOTSUPP;
+
+	return mddev->bitmap_ops->copy_from_slot(mddev, slot, lo, hi, clear_bits);
+}
+
 void md_bitmap_unplug(struct bitmap *bitmap);
 void md_bitmap_unplug_async(struct bitmap *bitmap);
 void md_bitmap_daemon_work(struct mddev *mddev);
 
-int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
-			     sector_t *lo, sector_t *hi, bool clear_bits);
 void md_bitmap_free(struct bitmap *bitmap);
 void md_bitmap_wait_behind_writes(struct mddev *mddev);