diff mbox series

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

Message ID 20240810020854.797814-17-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 |  9 ++++-----
 drivers/md/md-bitmap.h | 10 +++++++++-
 drivers/md/raid1.c     |  2 +-
 drivers/md/raid10.c    |  2 +-
 drivers/md/raid5.c     |  2 +-
 5 files changed, 16 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index d0163533da14..100551868484 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1654,7 +1654,7 @@  static void bitmap_end_sync(struct bitmap *bitmap, sector_t offset,
 	spin_unlock_irqrestore(&bitmap->counts.lock, flags);
 }
 
-void md_bitmap_close_sync(struct bitmap *bitmap)
+static void bitmap_close_sync(struct bitmap *bitmap)
 {
 	/* Sync has finished, and any bitmap chunks that weren't synced
 	 * properly have been aborted.  It remains to us to clear the
@@ -1662,14 +1662,12 @@  void md_bitmap_close_sync(struct bitmap *bitmap)
 	 */
 	sector_t sector = 0;
 	sector_t blocks;
-	if (!bitmap)
-		return;
+
 	while (sector < bitmap->mddev->resync_max_sectors) {
 		bitmap_end_sync(bitmap, sector, &blocks, 0);
 		sector += blocks;
 	}
 }
-EXPORT_SYMBOL(md_bitmap_close_sync);
 
 void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force)
 {
@@ -1986,7 +1984,7 @@  static int bitmap_load(struct mddev *mddev)
 		bitmap_start_sync(bitmap, sector, &blocks, 0);
 		sector += blocks;
 	}
-	md_bitmap_close_sync(bitmap);
+	bitmap_close_sync(bitmap);
 
 	if (mddev->degraded == 0
 	    || bitmap->events_cleared == mddev->events)
@@ -2714,6 +2712,7 @@  static struct bitmap_operations bitmap_ops = {
 	.endwrite		= bitmap_endwrite,
 	.start_sync		= bitmap_start_sync,
 	.end_sync		= bitmap_end_sync,
+	.close_sync		= bitmap_close_sync,
 
 	.update_sb		= bitmap_update_sb,
 };
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 58c114246a2d..56ede16ce5fe 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -251,6 +251,7 @@  struct bitmap_operations {
 			  sector_t *blocks, int degraded);
 	void (*end_sync)(struct bitmap *bitmap, sector_t offset,
 			 sector_t *blocks, int aborted);
+	void (*close_sync)(struct bitmap *bitmap);
 
 	void (*update_sb)(struct bitmap *bitmap);
 };
@@ -367,7 +368,14 @@  static inline void md_bitmap_end_sync(struct mddev *mddev, sector_t offset,
 	mddev->bitmap_ops->end_sync(mddev->bitmap, offset, blocks, aborted);
 }
 
-void md_bitmap_close_sync(struct bitmap *bitmap);
+static inline void md_bitmap_close_sync(struct mddev *mddev)
+{
+	if (!mddev->bitmap || !mddev->bitmap_ops->close_sync)
+		return;
+
+	mddev->bitmap_ops->close_sync(mddev->bitmap);
+}
+
 void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force);
 void md_bitmap_sync_with_cluster(struct mddev *mddev,
 				 sector_t old_lo, sector_t old_hi,
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index cf787ead3d0d..8f5beba4184c 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2787,7 +2787,7 @@  static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
 		else /* completed sync */
 			conf->fullsync = 0;
 
-		md_bitmap_close_sync(mddev->bitmap);
+		md_bitmap_close_sync(mddev);
 		close_sync(conf);
 
 		if (mddev_is_clustered(mddev)) {
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 3746692f5f1c..19035e9950f1 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3216,7 +3216,7 @@  static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 			}
 			conf->fullsync = 0;
 		}
-		md_bitmap_close_sync(mddev->bitmap);
+		md_bitmap_close_sync(mddev);
 		close_sync(conf);
 		*skipped = 1;
 		return sectors_skipped;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index c566fcc6fd46..06f8a4a55b2b 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6501,7 +6501,7 @@  static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
 					   &sync_blocks, 1);
 		else /* completed sync */
 			conf->fullsync = 0;
-		md_bitmap_close_sync(mddev->bitmap);
+		md_bitmap_close_sync(mddev);
 
 		return 0;
 	}