narrow_write_error() re-issues a failed write in badblock-granularity chunks, cloning from the master bio and resetting bi_opf to a bare REQ_OP_WRITE. For a P2PDMA bio that reset drops REQ_NOMERGE, which is the only request-level protection against the member queue merging P2PDMA segments across pgmaps or with host memory (see the preceding md_submit_bio() fix): the retry path would quietly reopen the hole the submission path closes. Restore the flag on P2PDMA retry clones. Fixes: 02666132403a ("md: propagate BLK_FEAT_PCI_P2PDMA from member devices to RAID device") Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Mykola Marzhan --- drivers/md/raid1.c | 3 +++ drivers/md/raid10.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 914fb86452c0..f562b6bd438b 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2573,6 +2573,9 @@ static void narrow_write_error(struct r1bio *r1_bio, int i) } wbio->bi_opf = REQ_OP_WRITE; + /* Keep P2PDMA retry bios unmergeable, like the original */ + if (md_bio_is_p2pdma(wbio)) + wbio->bi_opf |= REQ_NOMERGE; wbio->bi_iter.bi_sector = r1_bio->sector; wbio->bi_iter.bi_size = r1_bio->sectors << 9; diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 0a3cfdd3f5df..f7ef903a3d4e 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -2831,6 +2831,9 @@ static void narrow_write_error(struct r10bio *r10_bio, int i) wbio->bi_iter.bi_sector = wsector + choose_data_offset(r10_bio, rdev); wbio->bi_opf = REQ_OP_WRITE; + /* Keep P2PDMA retry bios unmergeable, like the original */ + if (md_bio_is_p2pdma(wbio)) + wbio->bi_opf |= REQ_NOMERGE; if (submit_bio_wait(wbio) && !rdev_set_badblocks(rdev, wsector, sectors, 0)) { -- 2.43.0