diff options
author | NeilBrown <neilb@suse.com> | 2017-04-05 00:05:51 -0400 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2017-04-11 13:12:36 -0400 |
commit | 673ca68d93879b9ffbbed874c9e70ca6e37cab15 (patch) | |
tree | 4b4f8e3b81fef6b2baaf9ec5fcbcbd6872ad66b7 /drivers/md/raid1.c | |
parent | 689389a06ce79fdced85b5115717f71c71e623e0 (diff) |
md/raid1: factor out flush_bio_list()
flush_pending_writes() and raid1_unplug() each contain identical
copies of a fairly large slab of code. So factor that out into
new flush_bio_list() to simplify maintenance.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r-- | drivers/md/raid1.c | 66 |
1 files changed, 26 insertions, 40 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 29a9aa9254c3..57611f43ed6c 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -787,6 +787,30 @@ static int raid1_congested(struct mddev *mddev, int bits) | |||
787 | return ret; | 787 | return ret; |
788 | } | 788 | } |
789 | 789 | ||
790 | static void flush_bio_list(struct r1conf *conf, struct bio *bio) | ||
791 | { | ||
792 | /* flush any pending bitmap writes to disk before proceeding w/ I/O */ | ||
793 | bitmap_unplug(conf->mddev->bitmap); | ||
794 | wake_up(&conf->wait_barrier); | ||
795 | |||
796 | while (bio) { /* submit pending writes */ | ||
797 | struct bio *next = bio->bi_next; | ||
798 | struct md_rdev *rdev = (void*)bio->bi_bdev; | ||
799 | bio->bi_next = NULL; | ||
800 | bio->bi_bdev = rdev->bdev; | ||
801 | if (test_bit(Faulty, &rdev->flags)) { | ||
802 | bio->bi_error = -EIO; | ||
803 | bio_endio(bio); | ||
804 | } else if (unlikely((bio_op(bio) == REQ_OP_DISCARD) && | ||
805 | !blk_queue_discard(bdev_get_queue(bio->bi_bdev)))) | ||
806 | /* Just ignore it */ | ||
807 | bio_endio(bio); | ||
808 | else | ||
809 | generic_make_request(bio); | ||
810 | bio = next; | ||
811 | } | ||
812 | } | ||
813 | |||
790 | static void flush_pending_writes(struct r1conf *conf) | 814 | static void flush_pending_writes(struct r1conf *conf) |
791 | { | 815 | { |
792 | /* Any writes that have been queued but are awaiting | 816 | /* Any writes that have been queued but are awaiting |
@@ -799,27 +823,7 @@ static void flush_pending_writes(struct r1conf *conf) | |||
799 | bio = bio_list_get(&conf->pending_bio_list); | 823 | bio = bio_list_get(&conf->pending_bio_list); |
800 | conf->pending_count = 0; | 824 | conf->pending_count = 0; |
801 | spin_unlock_irq(&conf->device_lock); | 825 | spin_unlock_irq(&conf->device_lock); |
802 | /* flush any pending bitmap writes to | 826 | flush_bio_list(conf, bio); |
803 | * disk before proceeding w/ I/O */ | ||
804 | bitmap_unplug(conf->mddev->bitmap); | ||
805 | wake_up(&conf->wait_barrier); | ||
806 | |||
807 | while (bio) { /* submit pending writes */ | ||
808 | struct bio *next = bio->bi_next; | ||
809 | struct md_rdev *rdev = (void*)bio->bi_bdev; | ||
810 | bio->bi_next = NULL; | ||
811 | bio->bi_bdev = rdev->bdev; | ||
812 | if (test_bit(Faulty, &rdev->flags)) { | ||
813 | bio->bi_error = -EIO; | ||
814 | bio_endio(bio); | ||
815 | } else if (unlikely((bio_op(bio) == REQ_OP_DISCARD) && | ||
816 | !blk_queue_discard(bdev_get_queue(bio->bi_bdev)))) | ||
817 | /* Just ignore it */ | ||
818 | bio_endio(bio); | ||
819 | else | ||
820 | generic_make_request(bio); | ||
821 | bio = next; | ||
822 | } | ||
823 | } else | 827 | } else |
824 | spin_unlock_irq(&conf->device_lock); | 828 | spin_unlock_irq(&conf->device_lock); |
825 | } | 829 | } |
@@ -1152,25 +1156,7 @@ static void raid1_unplug(struct blk_plug_cb *cb, bool from_schedule) | |||
1152 | 1156 | ||
1153 | /* we aren't scheduling, so we can do the write-out directly. */ | 1157 | /* we aren't scheduling, so we can do the write-out directly. */ |
1154 | bio = bio_list_get(&plug->pending); | 1158 | bio = bio_list_get(&plug->pending); |
1155 | bitmap_unplug(mddev->bitmap); | 1159 | flush_bio_list(conf, bio); |
1156 | wake_up(&conf->wait_barrier); | ||
1157 | |||
1158 | while (bio) { /* submit pending writes */ | ||
1159 | struct bio *next = bio->bi_next; | ||
1160 | struct md_rdev *rdev = (void*)bio->bi_bdev; | ||
1161 | bio->bi_next = NULL; | ||
1162 | bio->bi_bdev = rdev->bdev; | ||
1163 | if (test_bit(Faulty, &rdev->flags)) { | ||
1164 | bio->bi_error = -EIO; | ||
1165 | bio_endio(bio); | ||
1166 | } else if (unlikely((bio_op(bio) == REQ_OP_DISCARD) && | ||
1167 | !blk_queue_discard(bdev_get_queue(bio->bi_bdev)))) | ||
1168 | /* Just ignore it */ | ||
1169 | bio_endio(bio); | ||
1170 | else | ||
1171 | generic_make_request(bio); | ||
1172 | bio = next; | ||
1173 | } | ||
1174 | kfree(plug); | 1160 | kfree(plug); |
1175 | } | 1161 | } |
1176 | 1162 | ||