md/raid1-10: factor out a helper to submit normal write
[ Upstream commit8295efbe68
] There are multiple places to do the same thing, factor out a helper to prevent redundant code, and the helper will be used in following patch as well. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20230529131106.2123367-4-yukuai1@huaweicloud.com Stable-dep-of:7db922bae3
("md/raid1-10: submit write io directly if bitmap is not enabled") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
fa0f13a833
commit
f98b89fbf8
|
@ -110,6 +110,23 @@ static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp,
|
||||||
} while (idx++ < RESYNC_PAGES && size > 0);
|
} while (idx++ < RESYNC_PAGES && size > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline void raid1_submit_write(struct bio *bio)
|
||||||
|
{
|
||||||
|
struct md_rdev *rdev = (struct md_rdev *)bio->bi_bdev;
|
||||||
|
|
||||||
|
bio->bi_next = NULL;
|
||||||
|
bio_set_dev(bio, rdev->bdev);
|
||||||
|
if (test_bit(Faulty, &rdev->flags))
|
||||||
|
bio_io_error(bio);
|
||||||
|
else if (unlikely(bio_op(bio) == REQ_OP_DISCARD &&
|
||||||
|
!bdev_max_discard_sectors(bio->bi_bdev)))
|
||||||
|
/* Just ignore it */
|
||||||
|
bio_endio(bio);
|
||||||
|
else
|
||||||
|
submit_bio_noacct(bio);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio,
|
static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio,
|
||||||
blk_plug_cb_fn unplug)
|
blk_plug_cb_fn unplug)
|
||||||
{
|
{
|
||||||
|
|
|
@ -799,17 +799,8 @@ static void flush_bio_list(struct r1conf *conf, struct bio *bio)
|
||||||
|
|
||||||
while (bio) { /* submit pending writes */
|
while (bio) { /* submit pending writes */
|
||||||
struct bio *next = bio->bi_next;
|
struct bio *next = bio->bi_next;
|
||||||
struct md_rdev *rdev = (void *)bio->bi_bdev;
|
|
||||||
bio->bi_next = NULL;
|
raid1_submit_write(bio);
|
||||||
bio_set_dev(bio, rdev->bdev);
|
|
||||||
if (test_bit(Faulty, &rdev->flags)) {
|
|
||||||
bio_io_error(bio);
|
|
||||||
} else if (unlikely((bio_op(bio) == REQ_OP_DISCARD) &&
|
|
||||||
!bdev_max_discard_sectors(bio->bi_bdev)))
|
|
||||||
/* Just ignore it */
|
|
||||||
bio_endio(bio);
|
|
||||||
else
|
|
||||||
submit_bio_noacct(bio);
|
|
||||||
bio = next;
|
bio = next;
|
||||||
cond_resched();
|
cond_resched();
|
||||||
}
|
}
|
||||||
|
|
|
@ -917,17 +917,8 @@ static void flush_pending_writes(struct r10conf *conf)
|
||||||
|
|
||||||
while (bio) { /* submit pending writes */
|
while (bio) { /* submit pending writes */
|
||||||
struct bio *next = bio->bi_next;
|
struct bio *next = bio->bi_next;
|
||||||
struct md_rdev *rdev = (void*)bio->bi_bdev;
|
|
||||||
bio->bi_next = NULL;
|
raid1_submit_write(bio);
|
||||||
bio_set_dev(bio, rdev->bdev);
|
|
||||||
if (test_bit(Faulty, &rdev->flags)) {
|
|
||||||
bio_io_error(bio);
|
|
||||||
} else if (unlikely((bio_op(bio) == REQ_OP_DISCARD) &&
|
|
||||||
!bdev_max_discard_sectors(bio->bi_bdev)))
|
|
||||||
/* Just ignore it */
|
|
||||||
bio_endio(bio);
|
|
||||||
else
|
|
||||||
submit_bio_noacct(bio);
|
|
||||||
bio = next;
|
bio = next;
|
||||||
}
|
}
|
||||||
blk_finish_plug(&plug);
|
blk_finish_plug(&plug);
|
||||||
|
@ -1136,17 +1127,8 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)
|
||||||
|
|
||||||
while (bio) { /* submit pending writes */
|
while (bio) { /* submit pending writes */
|
||||||
struct bio *next = bio->bi_next;
|
struct bio *next = bio->bi_next;
|
||||||
struct md_rdev *rdev = (void*)bio->bi_bdev;
|
|
||||||
bio->bi_next = NULL;
|
raid1_submit_write(bio);
|
||||||
bio_set_dev(bio, rdev->bdev);
|
|
||||||
if (test_bit(Faulty, &rdev->flags)) {
|
|
||||||
bio_io_error(bio);
|
|
||||||
} else if (unlikely((bio_op(bio) == REQ_OP_DISCARD) &&
|
|
||||||
!bdev_max_discard_sectors(bio->bi_bdev)))
|
|
||||||
/* Just ignore it */
|
|
||||||
bio_endio(bio);
|
|
||||||
else
|
|
||||||
submit_bio_noacct(bio);
|
|
||||||
bio = next;
|
bio = next;
|
||||||
}
|
}
|
||||||
kfree(plug);
|
kfree(plug);
|
||||||
|
|
Loading…
Reference in New Issue