From: Yu Kuai <yukuai3@xxxxxxxxxx> Add a new paramater "bool sync" for md_bitmap_unplug(), and remove the exported md_bitmap_unplug_async(). Hence bitmap_operations only need one op to cover them. Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx> --- drivers/md/md-bitmap.c | 23 +++++++++++++++-------- drivers/md/md-bitmap.h | 3 +-- drivers/md/md.c | 2 +- drivers/md/raid1-10.c | 5 +---- drivers/md/raid5.c | 2 +- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 4f3ea6e51572..b08476746350 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1030,7 +1030,7 @@ static int md_bitmap_file_test_bit(struct bitmap *bitmap, sector_t block) /* this gets called when the md device is ready to unplug its underlying * (slave) device queues -- before we let any writes go down, we need to * sync the dirty pages of the bitmap file to disk */ -void md_bitmap_unplug(struct bitmap *bitmap) +static void bitmap_unplug(struct bitmap *bitmap) { unsigned long i; int dirty, need_write; @@ -1062,7 +1062,6 @@ void md_bitmap_unplug(struct bitmap *bitmap) if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags)) md_bitmap_file_kick(bitmap); } -EXPORT_SYMBOL(md_bitmap_unplug); struct bitmap_unplug_work { struct work_struct work; @@ -1075,11 +1074,11 @@ static void md_bitmap_unplug_fn(struct work_struct *work) struct bitmap_unplug_work *unplug_work = container_of(work, struct bitmap_unplug_work, work); - md_bitmap_unplug(unplug_work->bitmap); + bitmap_unplug(unplug_work->bitmap); complete(unplug_work->done); } -void md_bitmap_unplug_async(struct bitmap *bitmap) +static void bitmap_unplug_async(struct bitmap *bitmap) { DECLARE_COMPLETION_ONSTACK(done); struct bitmap_unplug_work unplug_work; @@ -1091,7 +1090,15 @@ void md_bitmap_unplug_async(struct bitmap *bitmap) queue_work(md_bitmap_wq, &unplug_work.work); wait_for_completion(&done); } -EXPORT_SYMBOL(md_bitmap_unplug_async); + +void md_bitmap_unplug(struct bitmap *bitmap, bool sync) +{ + if (sync) + bitmap_unplug(bitmap); + else + bitmap_unplug_async(bitmap); +} +EXPORT_SYMBOL(md_bitmap_unplug); static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed); @@ -2060,9 +2067,9 @@ static int bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *low, for (i = 0; i < bitmap->storage.file_pages; i++) if (test_page_attr(bitmap, i, BITMAP_PAGE_PENDING)) set_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE); - md_bitmap_unplug(bitmap); + bitmap_unplug(bitmap); } - md_bitmap_unplug(mddev->bitmap); + bitmap_unplug(mddev->bitmap); *low = lo; *high = hi; __bitmap_free(bitmap); @@ -2296,7 +2303,7 @@ static int bitmap_resize(struct bitmap *bitmap, sector_t blocks, spin_unlock_irq(&bitmap->counts.lock); if (!init) { - md_bitmap_unplug(bitmap); + bitmap_unplug(bitmap); bitmap->mddev->pers->quiesce(bitmap->mddev, 0); } ret = 0; diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index f67e030139cd..054e85c4a704 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -460,8 +460,7 @@ static inline void md_bitmap_free(struct mddev *mddev, struct bitmap *bitmap) return mddev->bitmap_ops->free(bitmap); } -void md_bitmap_unplug(struct bitmap *bitmap); -void md_bitmap_unplug_async(struct bitmap *bitmap); +void md_bitmap_unplug(struct bitmap *bitmap, bool sync); static inline bool md_bitmap_enabled(struct bitmap *bitmap) { diff --git a/drivers/md/md.c b/drivers/md/md.c index 841539a0be1b..2e6270c47317 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -4691,7 +4691,7 @@ bitmap_store(struct mddev *mddev, const char *buf, size_t len) md_bitmap_dirty_bits(mddev, chunk, end_chunk); buf = skip_spaces(end); } - md_bitmap_unplug(mddev->bitmap); /* flush the bits to disk */ + md_bitmap_unplug(mddev->bitmap, true); /* flush the bits to disk */ out: mddev_unlock(mddev); return len; diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c index 2ea1710a3b70..e8410d0cc96f 100644 --- a/drivers/md/raid1-10.c +++ b/drivers/md/raid1-10.c @@ -168,10 +168,7 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio, */ static inline void raid1_prepare_flush_writes(struct bitmap *bitmap) { - if (current->bio_list) - md_bitmap_unplug_async(bitmap); - else - md_bitmap_unplug(bitmap); + md_bitmap_unplug(bitmap, current->bio_list == NULL); } /* diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 8b1e2157a798..99332649bac3 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -6766,7 +6766,7 @@ static void raid5d(struct md_thread *thread) /* Now is a good time to flush some bitmap updates */ conf->seq_flush++; spin_unlock_irq(&conf->device_lock); - md_bitmap_unplug(mddev->bitmap); + md_bitmap_unplug(mddev->bitmap, true); spin_lock_irq(&conf->device_lock); conf->seq_write = conf->seq_flush; activate_bit_delay(conf, conf->temp_inactive_list); -- 2.39.2