]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
md/raid1,raid10: don't ignore IO flags
authorYu Kuai <yukuai3@huawei.com>
Thu, 27 Feb 2025 12:16:57 +0000 (20:16 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Sep 2025 16:58:20 +0000 (18:58 +0200)
commit e879a0d9cb086c8e52ce6c04e5bfa63825a6213c upstream.

If blk-wbt is enabled by default, it's found that raid write performance
is quite bad because all IO are throttled by wbt of underlying disks,
due to flag REQ_IDLE is ignored. And turns out this behaviour exist since
blk-wbt is introduced.

Other than REQ_IDLE, other flags should not be ignored as well, for
example REQ_META can be set for filesystems, clearing it can cause priority
reverse problems; And REQ_NOWAIT should not be cleared as well, because
io will wait instead of failing directly in underlying disks.

Fix those problems by keep IO flags from master bio.

Fises: f51d46d0e7cb ("md: add support for REQ_NOWAIT")
Fixes: e34cbd307477 ("blk-wbt: add general throttling mechanism")
Fixes: 5404bc7a87b9 ("[PATCH] Allow file systems to differentiate between data and meta reads")
Link: https://lore.kernel.org/linux-raid/20250227121657.832356-1-yukuai1@huaweicloud.com
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
[ Harshit: Resolve conflicts due to missing commit: f2a38abf5f1c
  ("md/raid1: Atomic write support") and  commit: a1d9b4fd42d9
  ("md/raid10: Atomic write support") in 6.12.y, we don't have Atomic
  writes feature in 6.12.y ]
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/raid1.c
drivers/md/raid10.c

index fe1599db69c8487b2e0c757625b6e6afd8893631..6e93e3b6bd8c02237dacd150ecf282c397794d28 100644 (file)
@@ -1315,8 +1315,6 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
        struct r1conf *conf = mddev->private;
        struct raid1_info *mirror;
        struct bio *read_bio;
-       const enum req_op op = bio_op(bio);
-       const blk_opf_t do_sync = bio->bi_opf & REQ_SYNC;
        int max_sectors;
        int rdisk;
        bool r1bio_existed = !!r1_bio;
@@ -1399,7 +1397,6 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
        read_bio->bi_iter.bi_sector = r1_bio->sector +
                mirror->rdev->data_offset;
        read_bio->bi_end_io = raid1_end_read_request;
-       read_bio->bi_opf = op | do_sync;
        if (test_bit(FailFast, &mirror->rdev->flags) &&
            test_bit(R1BIO_FailFast, &r1_bio->state))
                read_bio->bi_opf |= MD_FAILFAST;
@@ -1619,7 +1616,6 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
 
                mbio->bi_iter.bi_sector = (r1_bio->sector + rdev->data_offset);
                mbio->bi_end_io = raid1_end_write_request;
-               mbio->bi_opf = bio_op(bio) | (bio->bi_opf & (REQ_SYNC | REQ_FUA));
                if (test_bit(FailFast, &rdev->flags) &&
                    !test_bit(WriteMostly, &rdev->flags) &&
                    conf->raid_disks - mddev->degraded > 1)
index 7515a98001ca7fbb7b68685c0dfdd8e61be6791e..8bb9ec39dc4ff3d3b7093f245fb2edb4cb1ebf73 100644 (file)
@@ -1146,8 +1146,6 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
 {
        struct r10conf *conf = mddev->private;
        struct bio *read_bio;
-       const enum req_op op = bio_op(bio);
-       const blk_opf_t do_sync = bio->bi_opf & REQ_SYNC;
        int max_sectors;
        struct md_rdev *rdev;
        char b[BDEVNAME_SIZE];
@@ -1226,7 +1224,6 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
        read_bio->bi_iter.bi_sector = r10_bio->devs[slot].addr +
                choose_data_offset(r10_bio, rdev);
        read_bio->bi_end_io = raid10_end_read_request;
-       read_bio->bi_opf = op | do_sync;
        if (test_bit(FailFast, &rdev->flags) &&
            test_bit(R10BIO_FailFast, &r10_bio->state))
                read_bio->bi_opf |= MD_FAILFAST;
@@ -1240,9 +1237,6 @@ static void raid10_write_one_disk(struct mddev *mddev, struct r10bio *r10_bio,
                                  struct bio *bio, bool replacement,
                                  int n_copy)
 {
-       const enum req_op op = bio_op(bio);
-       const blk_opf_t do_sync = bio->bi_opf & REQ_SYNC;
-       const blk_opf_t do_fua = bio->bi_opf & REQ_FUA;
        unsigned long flags;
        struct r10conf *conf = mddev->private;
        struct md_rdev *rdev;
@@ -1261,7 +1255,6 @@ static void raid10_write_one_disk(struct mddev *mddev, struct r10bio *r10_bio,
        mbio->bi_iter.bi_sector = (r10_bio->devs[n_copy].addr +
                                   choose_data_offset(r10_bio, rdev));
        mbio->bi_end_io = raid10_end_write_request;
-       mbio->bi_opf = op | do_sync | do_fua;
        if (!replacement && test_bit(FailFast,
                                     &conf->mirrors[devnum].rdev->flags)
                         && enough(conf, devnum))