Hi,

在 2025/05/19 18:09, Mikulas Patocka 写道:
The commit e879a0d9cb08 ("md/raid1,raid10: don't ignore IO flags") breaks
the lvm2 test shell/lvcreate-large-raid.sh. The commit changes raid1 and
raid10 to pass down all the flags from the incoming bio. The problem is
when we pass down the REQ_RAHEAD flag - bios with this flag may fail
anytime and md-raid is not prepared to handle this failure.

Can dm-raid handle this falg? At least from md-raid array, for read
ahead IO, it doesn't make sense to kill that flag.

If we want to fall back to old behavior, can we kill that flag from
dm-raid?

diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 127138c61be5..ca7fb1713117 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -3353,6 +3353,11 @@ static int raid_map(struct dm_target *ti, struct bio *bio) if (unlikely(bio_has_data(bio) && bio_end_sector(bio) > mddev->array_sectors))
                return DM_MAPIO_REQUEUE;

+       /*
+        * bios with this flag may fail anytime, dm-raid is not prepared to
+        * handle failure.
+        */
+       bio->bi_opf &= ~REQ_RAHEAD;
        if (unlikely(!md_handle_request(mddev, bio)))
                return DM_MAPIO_REQUEUE;

Thanks,
Kuai


This commit fixes the code, so that the REQ_RAHEAD flag is not passed
down.

Signed-off-by: Mikulas Patocka <mpato...@redhat.com>
Fixes: e879a0d9cb08 ("md/raid1,raid10: don't ignore IO flags")

---
  drivers/md/raid1.c  |    1 +
  drivers/md/raid10.c |    1 +
  2 files changed, 2 insertions(+)

Index: linux-2.6/drivers/md/raid1.c
===================================================================
--- linux-2.6.orig/drivers/md/raid1.c
+++ linux-2.6/drivers/md/raid1.c
@@ -1404,6 +1404,7 @@ static void raid1_read_request(struct md
        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 &= ~REQ_RAHEAD;
        if (test_bit(FailFast, &mirror->rdev->flags) &&
            test_bit(R1BIO_FailFast, &r1_bio->state))
                read_bio->bi_opf |= MD_FAILFAST;
Index: linux-2.6/drivers/md/raid10.c
===================================================================
--- linux-2.6.orig/drivers/md/raid10.c
+++ linux-2.6/drivers/md/raid10.c
@@ -1263,6 +1263,7 @@ static void raid10_write_one_disk(struct
        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 &= ~REQ_RAHEAD;
        if (!replacement && test_bit(FailFast,
                                     &conf->mirrors[devnum].rdev->flags)
                         && enough(conf, devnum))


.



Reply via email to