From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E2DC35C685 for ; Wed, 22 Jul 2026 18:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784746749; cv=none; b=I8+krZDeFa2usokKNEP1NAGEuBdaKfWt5ZFwP4dYtYxMrLfdsgpiphW9I8jZKweI/s7/84dSlJy9EQdQXWyy+gUNtuBiGrDWDAtaVyfqesDoNRQpRN0x0JuH6r6cRtjtCeAWL8PekYAYKUW6mOrthvqVI0IOLcizGJMDU/1UWoo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784746749; c=relaxed/simple; bh=UmHDQ8Avh88213YFsBTKp7WY9yAPzXpx6PsDprJSvWw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P+BhImr9dG1mKm5sufS6gLtWEPNEw6tZHTR6dCaVx9UNXRq08h42HzxlcuM8C4pgLM1EluFA9ZA1a58gBjrRcAVVDA8K9w+Mj7dBX808p8YblNMH68Ui7TgwMJcG8gWZn+dpFi951g/QoITk0q4dQQtgmeB04J6b+2y1rO4mxAk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meshstor.io; spf=pass smtp.mailfrom=meshstor.io; dkim=pass (2048-bit key) header.d=meshstor.io header.i=@meshstor.io header.b=pO2ctPAC; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meshstor.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meshstor.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meshstor.io header.i=@meshstor.io header.b="pO2ctPAC" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-49571fea44eso2338565e9.2 for ; Wed, 22 Jul 2026 11:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meshstor.io; s=google; t=1784746743; x=1785351543; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=V5hliKyCAPWFZqHS5mW2T1dJRPt4J/vTka7mcNCHq10=; b=pO2ctPAC573zzwGSfqULFeBA/5OYTJ9IkLMmUQ1RrtLSK3KfQS67DoOTO1kXRMVcya ACKo1PTnFejVlqK1mJ2B7lvLgQjhUUIz10hXfa3KGkvobunjwH6ccIGlqZtzITEUKLGo K9jTdr8MlsILiYfBr76Tfr4iOEOOXEXRgam3mpvmRrDutTw87yV0VAeAtxL7pA+B7WCZ mWoqdrMEA0gIJbX29W85S8v/qNcw3urPkU1GbNFi2T+jfYpMwqWoyuEBsCAdAh5SR3I9 OeVFWeaX4uwA6M0Nd+EQszydv0AU6zpsVxdwRx49or6g1yrsqNGgpKFlu1ORIke9WuSX GLpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784746743; x=1785351543; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=V5hliKyCAPWFZqHS5mW2T1dJRPt4J/vTka7mcNCHq10=; b=NLHwsWuGskSYkuz7kqEKG5BFNUSkLv2kkz9EufIIFHG8J8hKDeIGGMNNOWh8TwN6pU 66MeCtI23Crop7il9WxvRvCEXstZFRICkhwxeEvC5h8NLp6TxhJFw386PA0UqhGkwOvq NGS0Yl5RGhWB516KsBLkD3f2mdBLREy+87Hu1AM3hlpmoNpY46v39xp9elsdjJQfvpAZ Nmwb3onZv0s8vogbLpW4lXeUKzVSvkvtwflZ0Fm/4F3BlbZvh/F3DsEyNLov9at90H3y /kORaYeraU76Bqy28VwsJqgcV/hHh8ePiiM9OeTi0fJ7jwn6PY2Fu+URALqGd+QZG1uH Wbhg== X-Forwarded-Encrypted: i=1; AHgh+Rq0XEEZikpP7f7dit8vYwl3dlvgDXr+3jO+l24R6nsTzOkQSdX+W/nEB5dYP4YBopmp6UiCXTyv3+qp14Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yyn8/AgfIYQhWApN65K03sZIKPWffq2kOYzZ8VfWwMN6dQmd8dN 1X8K8/OlOWuL/vpfmCHDuiGuRC9Iaz/burwf6HLBbQneVTH4lYtYBvU3kj8wEag4hA== X-Gm-Gg: AR+sD111Psh0G1Wgwu4fZt4H8WMIqebUy9JflZQVo47QfOgHNj+rFMar0vQ5ssP5+Qm e6ou27fRMzgSaT1xlHn9y2WRs5V1nivgI1gF2MC89lfpu/OPe1kK1MaUrSQR/Nx0rKRfAfs35x2 xrpL6qzEFN99YQU+7olTkAkBQ+OYSSPVQWcMMidyRQuPF5dfFAi4VdplvlFdi81F6ada3gV3unZ VHO9pcQzNIaMUicM3cRm8/Om0GVoKlmiAc8hqWKwPAVNEplPe+tjo6ZhVrZVPVIeYSv7rTK3d1P tMLuiMM4nm9T+JTlRfMhzFk5EEyq9qHtpoHp625XAE9iK8F2gplkIvoxeW/ceiPmseEdC/ofG7y OZklSUiS6f2ZJ6irQfxs9CXac/6B0qXRderNm3nOHYQJ0O1sgucA8n98UxLpHvCy3qmvEHRYMct g8LEiqqWzGuZ2Sk3ldWSeTevuNGt4gBBr7WqIo65R9gKi25K0= X-Received: by 2002:a05:600c:c174:b0:495:63e4:7f78 with SMTP id 5b1f17b1804b1-49563e47fa7mr133877135e9.10.1784746742455; Wed, 22 Jul 2026 11:59:02 -0700 (PDT) Received: from ai-pc ([46.172.241.174]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-495730353d9sm13740055e9.12.2026.07.22.11.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2026 11:59:02 -0700 (PDT) From: Mykola Marzhan To: Jens Axboe , Song Liu , Yu Kuai , Keith Busch , Christoph Hellwig , Sagi Grimberg , linux-block@vger.kernel.org, linux-raid@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Li Nan , Xiao Ni , Guoqing Jiang , Leon Romanovsky , Jason Gunthorpe , Kiran Kumar Modukuri , Chaitanya Kulkarni , Logan Gunthorpe , Bjorn Helgaas , Shivaji Kant , Pranjal Shrivastava , Henrique Carvalho , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v4 2/9] md: ensure REQ_NOMERGE is set on P2PDMA bios Date: Wed, 22 Jul 2026 20:58:34 +0200 Message-ID: <20260722185841.449934-3-mykola@meshstor.io> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260722185841.449934-1-mykola@meshstor.io> References: <20260722185841.449934-1-mykola@meshstor.io> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit md_submit_bio() strips REQ_NOMERGE from every bio. For P2PDMA bios the flag is what keeps requests single-provider (see __bio_add_page()): merging a P2PDMA bio with one over a different pgmap, or over host memory, maps the merged request with the wrong bus address. Set the flag on P2PDMA bios -- bios built via bio_iov_bvec_set() arrive without it -- and keep stripping it otherwise. 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 Reviewed-by: Logan Gunthorpe --- drivers/md/md.c | 10 ++++++++-- drivers/md/md.h | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index d1465bcd86c8..3770bdb4d4b2 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -451,8 +451,14 @@ static void md_submit_bio(struct bio *bio) return; } - /* bio could be mergeable after passing to underlayer */ - bio->bi_opf &= ~REQ_NOMERGE; + /* + * A bio md split may merge again below md -- except P2PDMA bios, + * which must stay single-provider (see __bio_add_page()). + */ + if (md_bio_is_p2pdma(bio)) + bio->bi_opf |= REQ_NOMERGE; + else + bio->bi_opf &= ~REQ_NOMERGE; md_handle_request(mddev, bio); } diff --git a/drivers/md/md.h b/drivers/md/md.h index d8daf0f75cbb..73df1a6eccd8 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -11,8 +11,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -22,6 +24,19 @@ #include #define MaxSector (~(sector_t)0) + +/* + * P2P and host pages never mix within a bio, so the first bvec is + * representative. Read bi_io_vec directly: bio_first_bvec_all() + * WARNs on the split clones md handles, and data-less bios have no + * bi_io_vec. Not valid after the bio's iterator is consumed. + */ +static inline bool md_bio_is_p2pdma(struct bio *bio) +{ + return bio_has_data(bio) && bio->bi_io_vec && + is_pci_p2pdma_page(bio->bi_io_vec->bv_page); +} + /* * Number of guaranteed raid bios in case of extreme VM load: */ -- 2.52.0