Commit 48eb9581 authored by Yu Kuai's avatar Yu Kuai Committed by Song Liu

md/md-bitmap: merge md_bitmap_unplug_async() into md_bitmap_unplug()

Add a parameter 'bool sync' to distinguish them, and
md_bitmap_unplug_async() won't be exported anymore, hence
bitmap_operations only need one op to cover them.
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20240826074452.1490072-32-yukuai1@huaweicloud.comSigned-off-by: default avatarSong Liu <song@kernel.org>
parent 4338b942
...@@ -1026,7 +1026,7 @@ static int md_bitmap_file_test_bit(struct bitmap *bitmap, sector_t block) ...@@ -1026,7 +1026,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 /* 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 * (slave) device queues -- before we let any writes go down, we need to
* sync the dirty pages of the bitmap file to disk */ * 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; unsigned long i;
int dirty, need_write; int dirty, need_write;
...@@ -1058,7 +1058,6 @@ void md_bitmap_unplug(struct bitmap *bitmap) ...@@ -1058,7 +1058,6 @@ void md_bitmap_unplug(struct bitmap *bitmap)
if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags)) if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags))
md_bitmap_file_kick(bitmap); md_bitmap_file_kick(bitmap);
} }
EXPORT_SYMBOL(md_bitmap_unplug);
struct bitmap_unplug_work { struct bitmap_unplug_work {
struct work_struct work; struct work_struct work;
...@@ -1071,11 +1070,11 @@ static void md_bitmap_unplug_fn(struct work_struct *work) ...@@ -1071,11 +1070,11 @@ static void md_bitmap_unplug_fn(struct work_struct *work)
struct bitmap_unplug_work *unplug_work = struct bitmap_unplug_work *unplug_work =
container_of(work, struct bitmap_unplug_work, work); container_of(work, struct bitmap_unplug_work, work);
md_bitmap_unplug(unplug_work->bitmap); __bitmap_unplug(unplug_work->bitmap);
complete(unplug_work->done); complete(unplug_work->done);
} }
void md_bitmap_unplug_async(struct bitmap *bitmap) static void bitmap_unplug_async(struct bitmap *bitmap)
{ {
DECLARE_COMPLETION_ONSTACK(done); DECLARE_COMPLETION_ONSTACK(done);
struct bitmap_unplug_work unplug_work; struct bitmap_unplug_work unplug_work;
...@@ -1087,7 +1086,20 @@ void md_bitmap_unplug_async(struct bitmap *bitmap) ...@@ -1087,7 +1086,20 @@ void md_bitmap_unplug_async(struct bitmap *bitmap)
queue_work(md_bitmap_wq, &unplug_work.work); queue_work(md_bitmap_wq, &unplug_work.work);
wait_for_completion(&done); wait_for_completion(&done);
} }
EXPORT_SYMBOL(md_bitmap_unplug_async);
void md_bitmap_unplug(struct mddev *mddev, bool sync)
{
struct bitmap *bitmap = mddev->bitmap;
if (!bitmap)
return;
if (sync)
__bitmap_unplug(bitmap);
else
bitmap_unplug_async(bitmap);
}
EXPORT_SYMBOL_GPL(md_bitmap_unplug);
static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed); static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed);
...@@ -2108,9 +2120,9 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, ...@@ -2108,9 +2120,9 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
for (i = 0; i < bitmap->storage.file_pages; i++) for (i = 0; i < bitmap->storage.file_pages; i++)
if (test_page_attr(bitmap, i, BITMAP_PAGE_PENDING)) if (test_page_attr(bitmap, i, BITMAP_PAGE_PENDING))
set_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE); 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; *low = lo;
*high = hi; *high = hi;
md_bitmap_free(bitmap); md_bitmap_free(bitmap);
...@@ -2351,7 +2363,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks, ...@@ -2351,7 +2363,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
spin_unlock_irq(&bitmap->counts.lock); spin_unlock_irq(&bitmap->counts.lock);
if (!init) { if (!init) {
md_bitmap_unplug(bitmap); __bitmap_unplug(bitmap);
bitmap->mddev->pers->quiesce(bitmap->mddev, 0); bitmap->mddev->pers->quiesce(bitmap->mddev, 0);
} }
ret = 0; ret = 0;
......
...@@ -277,8 +277,7 @@ struct bitmap_operations { ...@@ -277,8 +277,7 @@ struct bitmap_operations {
void mddev_set_bitmap_ops(struct mddev *mddev); void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */ /* these are exported */
void md_bitmap_unplug(struct bitmap *bitmap); void md_bitmap_unplug(struct mddev *mddev, bool sync);
void md_bitmap_unplug_async(struct bitmap *bitmap);
void md_bitmap_daemon_work(struct mddev *mddev); void md_bitmap_daemon_work(struct mddev *mddev);
int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks, int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
......
...@@ -4715,7 +4715,7 @@ bitmap_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -4715,7 +4715,7 @@ bitmap_store(struct mddev *mddev, const char *buf, size_t len)
mddev->bitmap_ops->dirty_bits(mddev, chunk, end_chunk); mddev->bitmap_ops->dirty_bits(mddev, chunk, end_chunk);
buf = skip_spaces(end); buf = skip_spaces(end);
} }
md_bitmap_unplug(mddev->bitmap); /* flush the bits to disk */ md_bitmap_unplug(mddev, true); /* flush the bits to disk */
out: out:
mddev_unlock(mddev); mddev_unlock(mddev);
return len; return len;
......
...@@ -166,12 +166,9 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio, ...@@ -166,12 +166,9 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio,
* while current io submission must wait for bitmap io to be done. In order to * while current io submission must wait for bitmap io to be done. In order to
* avoid such deadlock, submit bitmap io asynchronously. * avoid such deadlock, submit bitmap io asynchronously.
*/ */
static inline void raid1_prepare_flush_writes(struct bitmap *bitmap) static inline void raid1_prepare_flush_writes(struct mddev *mddev)
{ {
if (current->bio_list) md_bitmap_unplug(mddev, current->bio_list == NULL);
md_bitmap_unplug_async(bitmap);
else
md_bitmap_unplug(bitmap);
} }
/* /*
......
...@@ -896,7 +896,7 @@ static void wake_up_barrier(struct r1conf *conf) ...@@ -896,7 +896,7 @@ static void wake_up_barrier(struct r1conf *conf)
static void flush_bio_list(struct r1conf *conf, struct bio *bio) static void flush_bio_list(struct r1conf *conf, struct bio *bio)
{ {
/* flush any pending bitmap writes to disk before proceeding w/ I/O */ /* flush any pending bitmap writes to disk before proceeding w/ I/O */
raid1_prepare_flush_writes(conf->mddev->bitmap); raid1_prepare_flush_writes(conf->mddev);
wake_up_barrier(conf); wake_up_barrier(conf);
while (bio) { /* submit pending writes */ while (bio) { /* submit pending writes */
......
...@@ -885,7 +885,7 @@ static void flush_pending_writes(struct r10conf *conf) ...@@ -885,7 +885,7 @@ static void flush_pending_writes(struct r10conf *conf)
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
blk_start_plug(&plug); blk_start_plug(&plug);
raid1_prepare_flush_writes(conf->mddev->bitmap); raid1_prepare_flush_writes(conf->mddev);
wake_up(&conf->wait_barrier); wake_up(&conf->wait_barrier);
while (bio) { /* submit pending writes */ while (bio) { /* submit pending writes */
...@@ -1101,7 +1101,7 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule) ...@@ -1101,7 +1101,7 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)
/* we aren't scheduling, so we can do the write-out directly. */ /* we aren't scheduling, so we can do the write-out directly. */
bio = bio_list_get(&plug->pending); bio = bio_list_get(&plug->pending);
raid1_prepare_flush_writes(mddev->bitmap); raid1_prepare_flush_writes(mddev);
wake_up_barrier(conf); wake_up_barrier(conf);
while (bio) { /* submit pending writes */ while (bio) { /* submit pending writes */
......
...@@ -6768,7 +6768,7 @@ static void raid5d(struct md_thread *thread) ...@@ -6768,7 +6768,7 @@ static void raid5d(struct md_thread *thread)
/* Now is a good time to flush some bitmap updates */ /* Now is a good time to flush some bitmap updates */
conf->seq_flush++; conf->seq_flush++;
spin_unlock_irq(&conf->device_lock); spin_unlock_irq(&conf->device_lock);
md_bitmap_unplug(mddev->bitmap); md_bitmap_unplug(mddev, true);
spin_lock_irq(&conf->device_lock); spin_lock_irq(&conf->device_lock);
conf->seq_write = conf->seq_flush; conf->seq_write = conf->seq_flush;
activate_bit_delay(conf, conf->temp_inactive_list); activate_bit_delay(conf, conf->temp_inactive_list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment