diff options
author | Yu Kuai <yukuai3@huawei.com> | 2023-05-29 16:11:02 +0300 |
---|---|---|
committer | Song Liu <song@kernel.org> | 2023-06-14 01:25:43 +0300 |
commit | 8295efbe68c080047e98d9c0eb5cb933b238a8cb (patch) | |
tree | 7442096e03bf560b894e7373e8cd04cd8136d98f /drivers/md/raid1-10.c | |
parent | 5ec6ca140a034682e421e2e808ef5ddfdfd65242 (diff) | |
download | linux-8295efbe68c080047e98d9c0eb5cb933b238a8cb.tar.xz |
md/raid1-10: factor out a helper to submit normal write
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
Diffstat (limited to 'drivers/md/raid1-10.c')
-rw-r--r-- | drivers/md/raid1-10.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c index 76cff924b70b..21b0ff3ca4f0 100644 --- a/drivers/md/raid1-10.c +++ b/drivers/md/raid1-10.c @@ -111,6 +111,23 @@ static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp, } 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, blk_plug_cb_fn unplug) { |