From: Yu Kuai <yukuai3@xxxxxxxxxx> 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@xxxxxxxxxx> --- drivers/md/md-bitmap.c | 9 ++++----- drivers/md/md-bitmap.h | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 3c09de471634..8828175ad442 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1697,11 +1697,10 @@ static void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, sysfs_notify_dirent_safe(bitmap->mddev->sysfs_completed); } -void md_bitmap_sync_with_cluster(struct mddev *mddev, - sector_t old_lo, sector_t old_hi, - sector_t new_lo, sector_t new_hi) +static void bitmap_sync_with_cluster(struct bitmap *bitmap, + sector_t old_lo, sector_t old_hi, + sector_t new_lo, sector_t new_hi) { - struct bitmap *bitmap = mddev->bitmap; sector_t sector, blocks = 0; for (sector = old_lo; sector < new_lo; ) { @@ -1716,7 +1715,6 @@ void md_bitmap_sync_with_cluster(struct mddev *mddev, } WARN((blocks > new_hi) && old_hi, "alignment is not correct for hi\n"); } -EXPORT_SYMBOL(md_bitmap_sync_with_cluster); static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed) { @@ -2714,6 +2712,7 @@ static struct bitmap_operations bitmap_ops = { .cond_end_sync = bitmap_cond_end_sync, .update_sb = bitmap_update_sb, + .sync_with_cluster = bitmap_sync_with_cluster, }; void mddev_set_bitmap_ops(struct mddev *mddev) diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 71c3610dca7b..5a77b6d8358b 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -255,6 +255,9 @@ struct bitmap_operations { void (*cond_end_sync)(struct bitmap *bitmap, sector_t sector, bool force); void (*update_sb)(struct bitmap *bitmap); + void (*sync_with_cluster)(struct bitmap *bitmap, + sector_t old_lo, sector_t old_hi, + sector_t new_lo, sector_t new_hi); }; /* the bitmap API */ @@ -386,9 +389,16 @@ static inline void md_bitmap_cond_end_sync(struct mddev *mddev, sector_t sector, mddev->bitmap_ops->cond_end_sync(mddev->bitmap, sector, force); } -void md_bitmap_sync_with_cluster(struct mddev *mddev, - sector_t old_lo, sector_t old_hi, - sector_t new_lo, sector_t new_hi); +static inline void md_bitmap_sync_with_cluster(struct mddev *mddev, + sector_t old_lo, sector_t old_hi, + sector_t new_lo, sector_t new_hi) +{ + if (!mddev->bitmap || !mddev->bitmap_ops->sync_with_cluster) + return; + + mddev->bitmap_ops->sync_with_cluster(mddev->bitmap, old_lo, old_hi, + new_lo, new_hi); +} void md_bitmap_unplug(struct bitmap *bitmap); void md_bitmap_unplug_async(struct bitmap *bitmap); -- 2.39.2