[PATCH 3/3] md/raid1-10: share flush_bio_list between raid1 and raid10
"Li Youhong" <[email protected]>
| Newsgroups | gmane.linux.raid |
|---|---|
| Message-ID | <[email protected]> |
From: Li Youhong <[email protected]> raid1 already had flush_bio_list(); raid10 open-coded the same prepare/wake/submit loop in flush_pending_writes() and raid10_unplug(). Move a shared helper into raid1-10.c. The shared helper uses wq_has_sleeper() before wake_up(), matching raid1's wake_up_barrier() and raid10_unplug(). No intentional functional change. Signed-off-by: Li Youhong <[email protected]> --- drivers/md/raid1-10.c | 17 +++++++++++++++++ drivers/md/raid1.c | 19 ++----------------- drivers/md/raid10.c | 22 ++-------------------- 3 files changed, 21 insertions(+), 37 deletions(-) diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c index c7ddf136771d..476682110ea3 100644 --- a/drivers/md/raid1-10.c +++ b/drivers/md/raid1-10.c @@ -176,6 +176,23 @@ static inline void raid1_prepare_flush_writes(struct mddev *mddev) mddev->bitmap_ops->unplug(mddev, current->bio_list == NULL); } +static inline void flush_bio_list(struct mddev *mddev, struct bio *bio, + wait_queue_head_t *wait) +{ + /* flush any pending bitmap writes to disk before proceeding w/ I/O */ + raid1_prepare_flush_writes(mddev); + if (wq_has_sleeper(wait)) + wake_up(wait); + + while (bio) { /* submit pending writes */ + struct bio *next = bio->bi_next; + + raid1_submit_write(bio); + bio = next; + cond_resched(); + } +} + /* * Used by fix_read_error() to decay the per rdev read_errors. * We halve the read error count for every hour that has elapsed diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 8a40c69d70a3..894efb50c6d5 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -919,21 +919,6 @@ static void wake_up_barrier(struct r1conf *conf) wake_up(&conf->wait_barrier); } -static void flush_bio_list(struct r1conf *conf, struct bio *bio) -{ - /* flush any pending bitmap writes to disk before proceeding w/ I/O */ - raid1_prepare_flush_writes(conf->mddev); - wake_up_barrier(conf); - - while (bio) { /* submit pending writes */ - struct bio *next = bio->bi_next; - - raid1_submit_write(bio); - bio = next; - cond_resched(); - } -} - static void flush_pending_writes(struct r1conf *conf) { /* Any writes that have been queued but are awaiting @@ -959,7 +944,7 @@ static void flush_pending_writes(struct r1conf *conf) */ __set_current_state(TASK_RUNNING); blk_start_plug(&plug); - flush_bio_list(conf, bio); + flush_bio_list(conf->mddev, bio, &conf->wait_barrier); blk_finish_plug(&plug); } else spin_unlock_irq(&conf->device_lock); @@ -1289,7 +1274,7 @@ static void raid1_unplug(struct blk_plug_cb *cb, bool from_schedule) /* we aren't scheduling, so we can do the write-out directly. */ bio = bio_list_get(&plug->pending); - flush_bio_list(conf, bio); + flush_bio_list(conf->mddev, bio, &conf->wait_barrier); kfree(plug); } diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 5b1dbb0b7f5a..85d2c9364565 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -895,16 +895,7 @@ static void flush_pending_writes(struct r10conf *conf) __set_current_state(TASK_RUNNING); blk_start_plug(&plug); - raid1_prepare_flush_writes(conf->mddev); - wake_up(&conf->wait_barrier); - - while (bio) { /* submit pending writes */ - struct bio *next = bio->bi_next; - - raid1_submit_write(bio); - bio = next; - cond_resched(); - } + flush_bio_list(conf->mddev, bio, &conf->wait_barrier); blk_finish_plug(&plug); } else spin_unlock_irq(&conf->device_lock); @@ -1101,16 +1092,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. */ bio = bio_list_get(&plug->pending); - raid1_prepare_flush_writes(mddev); - wake_up_barrier(conf); - - while (bio) { /* submit pending writes */ - struct bio *next = bio->bi_next; - - raid1_submit_write(bio); - bio = next; - cond_resched(); - } + flush_bio_list(mddev, bio, &conf->wait_barrier); kfree(plug); } -- 2.25.1