From nobody Sat Jul 25 00:16:38 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 8EA6E403AFB for ; Tue, 21 Jul 2026 17:46:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655966; cv=none; b=FocXsThfNt5Qkm6dWgAiVSdy9mqGbtstsiV3tN7kfTPPA2yC+e1PJoBsVUqMjsf5KvbrFyNGXPk0uKUwuet4yr3oQoJlPjU1zzigWUiDKqn/WeOxdIYFGv0X9P5YS1DELkyGTmwTwaRfJg3gP3aL6qkzIIqMOZNE365FtH16vuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655966; c=relaxed/simple; bh=QTEEwhMU6/s8xKt2ATytvlDpVE5PLdhRSGF9tXAdxU8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r9Ys2ie7H9rXDMhud+HSrVAPr88kSH/OczVnVVnvbEb2Aq34ptSbSpsjqHKmwzkcFO2kDiVdvNl4PPeHm1pAfsn0PDNIRB5PTxZqyz8Yisr2Pt3sOOlgFYye0VRJuYkeJKT8ErveLB58CdUhz/fnhb1hl3N/zlbE0R5iN3pHoHE= 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=MLkjMsOh; arc=none smtp.client-ip=209.85.128.54 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="MLkjMsOh" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-493f6de72faso36435485e9.0 for ; Tue, 21 Jul 2026 10:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meshstor.io; s=google; t=1784655962; x=1785260762; 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=lWWll8LWGk4bgXbjsNFMGQ+aIu0e9z5vmcW+zxQ0akc=; b=MLkjMsOhQH7N0szfn2gTOcCyGLg12//O35Ej/epe1NTKRgdPQCXcPBUJY69Ey+iVqJ LITQzakR5POxUVVOM/EIJ8JzoK6upAcVKclrjC70JpJDI5wl5x71RlaENfLxNWfnqcJ2 6S0toSdX6VJzk65MI2zrUIoVZZAmQBo1LayPJrQPmpqVRVOwDnahQgv9sr3UURzY4Ob+ Oy6c3kUd7s4C5Kqxr6MnH3Ji2nc7a0fCodmkEYPx/KLVElqkPkpoif1WEfKeYvx+bc0X Sb53mCPYK/JLLvo/cdYm2HgyxGrHgf7vkVO1nx6DMuKi0c6DBLvprqbqhk2n7tefAeg0 7y4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784655962; x=1785260762; 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=lWWll8LWGk4bgXbjsNFMGQ+aIu0e9z5vmcW+zxQ0akc=; b=ZVVHizp6fwdFkWXC5EMski4imJ2KOIb4GKoG7oZhDYQ04e8bmx2HmMCyOAxXi8y7zz Ay0eo1dcJt1up7Absl4aEG8rBocyA4y+6Yn9DU3Q96RdNRVJnyIg1miHD/eBr2aLwKc2 0tiin+Tp9c7frwWdjnxWAVih7V1DredoUPto0Q/M63KNpB3iQlpjxgF+pE/PJAmEFBU8 Cerk6A9BPpT5RmwFAPyvSs8XlweNghw/eA8q2VQLnLayqR8o3T72WA0rS5lUFTZQWGsW d4I6o5Z093k7fcIVYRa0XOZzdhiEy54VcchXmAKXg4vdhkJneWXwdF4aZzRILMgksSGd FhXw== X-Forwarded-Encrypted: i=1; AHgh+RrNSJIejYKruN6JRB5O7WjMJEAIYiqiUY2+Lonydx0dVzoWu+PCvsERQ28U50xC5G397YfcWczfPZ9fgjo=@vger.kernel.org X-Gm-Message-State: AOJu0YxZav6L/HNDj1FqGYamyWdfZ0hjuBdj8sbBYrZJjQavqVuQjqDP iDD52rxBIbxiWxAK/107UO6yaApW+qA74ZNNO+bdX/uBkZQ5XXyUQ/2lknQ9WsGJEg== X-Gm-Gg: AfdE7clODsEhwEWDk2kadR9yqKnksK/8OjCPxiI5NvnufBipywpbUAHIggcCeG4OVjK uk7X6Yqu//A8w9Lo/pxbx/bqkelpcfNZyzfCPyyM5Zw1u4P4k8kaz9Noxz4JkNj8QuHXCrU6IUD A+NT5zt9r/VQMAHKVSYbgqqV5Vaqkpn8wV/rbdY35T1MSE8hgiJ/1SxnlUTYLh17uCrT7P0O91I kAmUuiruFruYiutgXnX6OABOcOdwD7uS7SAUBOdWVgODyfpHZkCGDKLHdIJ/I2jKqBuSKb+d0Jj c7g947YrSgV69cmBgOCtWGczZTRty0yPn/qHbgEf7KP8SPia8eDQVBQNXH399KIu6eAeFlk1sRR ojDzDOsg8C2hajMgKmjaDr5QdL3GXPfGBUD7Ejf9sSWJzKdNK8y5fjGDbdRfovy9QcV7Vd0Y2wb ww1qWJhjy4JfMz+9Irrpa9G2UhvrBy14xcRKu/FwhSLefxvxAHk0GyBNOc0Q== X-Received: by 2002:a05:600c:4747:b0:495:5d6d:9cc1 with SMTP id 5b1f17b1804b1-4956a4a14ecmr8642615e9.0.1784655961748; Tue, 21 Jul 2026 10:46:01 -0700 (PDT) Received: from ai-pc ([46.172.241.174]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63eddd27sm40860513f8f.28.2026.07.21.10.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 10:46:01 -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 v3 1/8] blk-mq-dma: restore BLK_STS_TARGET for unsupported P2P transfers Date: Tue, 21 Jul 2026 19:44:55 +0200 Message-ID: <20260721174502.111503-2-mykola@meshstor.io> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260721174502.111503-1-mykola@meshstor.io> References: <20260721174502.111503-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: quoted-printable Content-Type: text/plain; charset="utf-8" Unsupported P2P transfers used to fail with BLK_STS_TARGET, chosen by commit 91fb2b6052f7 ("nvme-pci: convert to using dma_map_sgtable()") for dma_map_sgtable()'s -EREMOTEIO: an I/O that can never succeed on this device must not be retried. The blk_rq_dma_map conversion changed it to BLK_STS_INVAL, which blk_path_error() treats as retryable and md deliberately ignores for member failures -- a P2P write to a member the peer cannot reach is counted as written and the mirrors silently diverge. Restore BLK_STS_TARGET. Hit e.g. with CMB memory of one NVMe device used as the data buffer for I/O to a second one behind a different host bridge. Fixes: 858299dc6160 ("block: add scatterlist-less DMA mapping helpers") Fixes: 7ce3c1dd78fc ("nvme-pci: convert the data mapping to blk_rq_dma_map") Cc: stable@vger.kernel.org # v6.17 Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Mykola Marzhan Reviewed-by: Logan Gunthorpe --- block/blk-mq-dma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/blk-mq-dma.c b/block/blk-mq-dma.c index bfdb9ed70741..c17e4c49900c 100644 --- a/block/blk-mq-dma.c +++ b/block/blk-mq-dma.c @@ -190,7 +190,11 @@ static bool blk_dma_map_iter_start(struct request *req= , struct device *dma_dev, case PCI_P2PDMA_MAP_NONE: break; default: - iter->status =3D BLK_STS_INVAL; + /* + * Match dma_map_sgtable()'s -EREMOTEIO: this transfer + * can never succeed, so don't let it be retried. + */ + iter->status =3D BLK_STS_TARGET; return false; } =20 --=20 2.52.0 From nobody Sat Jul 25 00:16:38 2026 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 D897C46D0B1 for ; Tue, 21 Jul 2026 17:46:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655967; cv=none; b=Bt227A8Ixc1zPMej5osALNiqbd/HtMzQFA3lT1fFZjQTuXDMq3uxI1CxEXtk9Bisv8IuPT3furOWiCg5Rd0rioUfCqyQK1L/kh2G9kcKWwKaio1UoBuYthdk0gtdQTJ3h4MT/ptquV54qbrMs0iM5ZwmtDqZBtKRwK6cQ0S3cl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655967; c=relaxed/simple; bh=UmHDQ8Avh88213YFsBTKp7WY9yAPzXpx6PsDprJSvWw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ucPgxCUuPtm54Lm3WH9jDi0GKvtkzmmVaximgeHyq63EWcqqZWeNTcVOvQtr6h+ptWfZ+nr2ojY2QpfRvisgUT74e5CObdcOtM0T5WHSbSs82k/f2xrti9X7pQGGApH8KdKvhRzHATqcVZx1XT1c2tOkFOIRpwDBLcr1WaDqwB0= 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=esOZG+U9; arc=none smtp.client-ip=209.85.221.46 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="esOZG+U9" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-4799b3f7c83so8407671f8f.2 for ; Tue, 21 Jul 2026 10:46:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meshstor.io; s=google; t=1784655964; x=1785260764; 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=esOZG+U9ERajKjNOIUJfkXtFGMzt/lQo4ehj3YxLvK+PNIAUhM7ActdNwCxLyeCZZR fo8n1ZCxo77xJ/0fmo3T27PEPNtvlFMWCMIytrQrNfy6cz4Wu7h+FiM/MnVjRwF7PqPg ODELkrDbKQ2y56PlRAj7z7m9M5HHVFPzWaeM4WL2r8PJL2/xuHM5CAcUoPtkPVZvvva3 op1DUS2ZwqUPzoVYjqtuS6dO96nkenFmbuCO+mGO0wtK/L7hGzNDdyeYieBD6Z/cZvOK cJb1VwcS5gJcJSDDyCAe8nIaUdm/URy+IWkj0RMlVbN85z4CpmTXbPe1AlxSJqSS/S1I qf+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784655964; x=1785260764; 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=eVdFYNytKw0wNbvJY4HcHp0fpEIseQSaNi2ZudqKxbF5JYYLo/x2M/8vxF+DhVThzk htvSt4QKlJXO91l75iM7XWp88DorOPnVfZPRb0SVj6FzFgNo8PC7wFACdxUcTJR4pa4i NBkTzxpW9l0ZfcCuxHL68Y2KXp4YOZfgC2NqB0tILpGW0RHwwajKjlD7JfGZyR6g9NhR Wz4eVuMufquNzRkUHYWOPiWB7hCHEdSX9t7xMLzuRhX/DKkxUdqrF7qPhOISVlFQgcSf SngfQ+4Mu8MNJ8P+EX2o1a4GNemeSsbHDoTP65jzwUyg9YyMQj4C+xbQutj/Nr/RkdDk +40g== X-Forwarded-Encrypted: i=1; AHgh+RpSc7tTkhIOBSknxrLv7BWTeFiQdCLEpNIU0DHgGW6p8W7ynXDHdhFR89hzelt0NdMs53baHAJ3eA0VSZI=@vger.kernel.org X-Gm-Message-State: AOJu0YzZ94CyhKn2jAiaqJd109zve6oiWvGLjGFvPxFlHR0PNTJQz7tj cfSrq8wKdJY7f+5pSiTND249cDUXc19F41vFB7i7AENIRB/+vdoyLeSwJUc8GkZlPA== X-Gm-Gg: AR+sD13Lxp2ejhRcqCOdQOwIzAs6AIgcchRxOzVMKiaCNHfIG75jNE+bhJCjWOfOKFX 1xQF/ueH1479027CT3FaPdSZtV84M1YDH2NWZ24ynvbS2ox/0ENSC47MmCVGb7T4CdW/62U5DcT oTZmOwbbWT/+Ae2CJZ0CjyH6dxvovP6i3uglAkYYLnhfPMDw4ZJCGA/kE1Ux7NyTDBXnIQM7hJL iWAnmALlVX8Qe6TXcBixyFGDX4y/L3INm9PC2jTvgHHVYH+loeqmRqhleQGYoKxvtRHbOZyin56 93jKlRkie1yL3uaBjht7iKlQhkNT4YbIbQXDm/CCMgHmqAjioiydSzjCajWPM3BIp4T90Cx9jv1 TWyUYNumjXNZGxyMwFg4wte53vhc5ewQDqo+VodBlat/7k3ngMMN7qR/ZGFnr2vONH0tbgrRLfF LyZc0s+CqHbsKe4ECwKOBsAak6zYsWIoxS5vGcHer8nlwru/w= X-Received: by 2002:a05:6000:2084:b0:470:6dc:848a with SMTP id ffacd0b85a97d-47f622fcea6mr22185571f8f.2.1784655963771; Tue, 21 Jul 2026 10:46:03 -0700 (PDT) Received: from ai-pc ([46.172.241.174]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63eddd27sm40860513f8f.28.2026.07.21.10.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 10:46:03 -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 v3 2/8] md: ensure REQ_NOMERGE is set on P2PDMA bios Date: Tue, 21 Jul 2026 19:44:56 +0200 Message-ID: <20260721174502.111503-3-mykola@meshstor.io> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260721174502.111503-1-mykola@meshstor.io> References: <20260721174502.111503-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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; } =20 - /* bio could be mergeable after passing to underlayer */ - bio->bi_opf &=3D ~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 |=3D REQ_NOMERGE; + else + bio->bi_opf &=3D ~REQ_NOMERGE; =20 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 =20 #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: */ --=20 2.52.0 From nobody Sat Jul 25 00:16:38 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 AD68146D557 for ; Tue, 21 Jul 2026 17:46:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655969; cv=none; b=D2NUzZ5gqDJL/8ROj4Tozqg+2YMGzmTh5+MJmE+H2kkeTsfYmOWtTVry8i+0iGAexJG/Y/BXY0VoNZyUHGpqxAEXXvoXg72d42kBOR9tqoxfC3KpdbITyw52jn8ArtUagwcA2DdjMjL7rk9p/hr8iuLINhgOz8/kFL0uSqv9Wyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655969; c=relaxed/simple; bh=hrTCMMr70YntHE8rHfpC3UJfjfd1U5mS3A9u7ATI3Z0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VpyPvp238s+rSnGWNTO+RLJaztFoGhh3pdCAtE+NFXSuBcBsyfC74MiLvPsrglVel+zZduvkxgAAEazJzhDjVDeHEc1qxKl48VfYfY42K4EKm/4H5Pci0GFUQFTExGnzTSV7OgSVSNf8ZWnZE1/D4P+qWqqZudOXfSpdCkISgLQ= 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=MnhgK+D0; arc=none smtp.client-ip=209.85.221.51 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="MnhgK+D0" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-47ddf7b09aaso7667187f8f.3 for ; Tue, 21 Jul 2026 10:46:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meshstor.io; s=google; t=1784655966; x=1785260766; 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=GLcS/ETJPdW48ntvSy2VqAomcBgiATmYTCUKJMNlgIw=; b=MnhgK+D0jVt3+ATaByMqGtxcYbe71WAklsLkYbQhxrMZaCwgzYNT3aHKFTRkoVNwii fgMwGPTb6jPT5SBWRC4CmDhweLrQ+ncGrx27LpP8vn/ROytTD5noUlKp/4F8olifBqD9 2Pl1nWmvOyjv96G8ddkLN1sumDxP06ApYiHy5alMfrN/hF/SdcsFRLxsN+qPNqB+5/mS 6ffSR3qx2XZefTKfoLDbwgATTTPTeYZl/gP4rDxmc7vF/6QOdo6WcwutfQA637576wt0 /z5DGIbaOVuFqSZMx9teep6Z363p8TYoW8xpugvIWBhRGFDCZARezjr2kSRc5vlKzMNH NldA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784655966; x=1785260766; 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=GLcS/ETJPdW48ntvSy2VqAomcBgiATmYTCUKJMNlgIw=; b=mE/v1wFgDS4GWzbZwkgmxMcvmyllhQ8YC2L8dnml16VWewKe9FYjT5UssW4MWRc9CZ SwxjF3GjayaKbLqcvwyswBxI4YNggwTMyrjxvgHu8WA8Nv4Q6C1ZXOonmjHQl3Zb1jdX 1Hkk5RpHpN4yxAC9NUQz9QAu4OoYa2xnN8muwYwZoh+f0U5s9vuRamV1Z34+vUOWXxDg TdtflqKGZW6uTuMa/1i7Vb2jgyGV3HnMwmlru5xDzmO5hA+XGb1H8NDdsA3cMqw1T9Rs C6nWmQt51VxvxKmUvY1RjqqChLarfHaa9yRf+neVQIy0Jfg6csKFzs3AteZxRMlZwiVz Qzaw== X-Forwarded-Encrypted: i=1; AHgh+RruSUNr/iVqQAuDS9dHgHiFFvfxgo52SkmACM5QKgkwBRLppTW7CfJ2XBbn0+sDiLZbFzI7RIq1lvy9Zdk=@vger.kernel.org X-Gm-Message-State: AOJu0YztMf7+5dvjmz8PrSe/5Wu+xyTmqvdhzl3+UWGXLS1nfuqmHJ7D YV4g07+YH+5vKgtD14ZY5pcJe24lGysKZIsqCqjKzEUJp0viTaYHcmBSjrn0lDuEaQ== X-Gm-Gg: AR+sD12wwvngyYa5K8v5AN3UVK3q0aVJv/9lNoRSyB7VrkGrYbfVcU0w4XqIBz3mnsf v9RAKWdKhFaKM3wQ1n5BMbBELGTHwSfZtlLS9IXAgfK7boCZywId/zg2pdigs1syAenBwtVtNgY GN5hTGR72hdB2sISqiK4FGfKWjppqHXjKFIht11q7Xb1DPTIdoxVg1dz0ULcQKwEtcQdWUpBaob KDeq5Hohmjitht8SCGjd1DhdAfBpgx1OR9vs8xNv/wWi8m9ABc+vT8pm+WEldJsiAVhPH20JAZl 8e5zSXWeb1qJXCF/MfzaBOkD6Q6VyJ6ITw4hLqngOdZoTeVnjYRZPxH5V+22BvjSmjcriw5q0Tk dZC+dBU/2fRdIJOAS+NOfpD2E4+H9kvPkv1BDSaJd8/bLzDhwcxjlBE8DzlrhKNoKLuIyzWl835 juaS2rDBYRACRvryp5yxFx9NZAVHsvJHF+8RKeIR2bUznto3U= X-Received: by 2002:a05:6000:27db:20b0:47f:4602:66e9 with SMTP id ffacd0b85a97d-47f6232e29dmr17004239f8f.40.1784655965889; Tue, 21 Jul 2026 10:46:05 -0700 (PDT) Received: from ai-pc ([46.172.241.174]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63eddd27sm40860513f8f.28.2026.07.21.10.46.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 10:46:05 -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 v3 3/8] md/raid1: serialize non-write-behind writes on CollisionCheck rdevs Date: Tue, 21 Jul 2026 19:44:57 +0200 Message-ID: <20260721174502.111503-4-mykola@meshstor.io> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260721174502.111503-1-mykola@meshstor.io> References: <20260721174502.111503-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: quoted-printable Content-Type: text/plain; charset="utf-8" A write that skips write-behind (full behind queue, a waiting reader, failed behind-bio allocation) races the in-flight behind write it overlaps: nothing orders the two on the write-mostly member, and if the older behind data lands last the member keeps stale data for sectors already acknowledged as rewritten. Serialize on CollisionCheck, which marks exactly the rdevs owning a serial tree: serialize_policy rdevs plus write-mostly members when write-behind arms serialization -- the case the MD_SERIALIZE_POLICY test misses. remove_serial() under the same condition. This also avoids the old gate's latent NULL deref for rdevs hot-added under serialize_policy (they never get a serial tree). Fixes: d0d2d8ba0494 ("md/raid1: introduce wait_for_serialization") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-fable-5 Signed-off-by: Mykola Marzhan --- drivers/md/raid1.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index afe2ca96ad8c..997f79c05db7 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -564,7 +564,7 @@ static void raid1_end_write_request(struct bio *bio) call_bio_endio(r1_bio); } } - } else if (test_bit(MD_SERIALIZE_POLICY, &rdev->mddev->flags)) + } else if (test_bit(CollisionCheck, &rdev->flags)) remove_serial(rdev, lo, hi); if (r1_bio->bios[mirror] =3D=3D NULL) rdev_dec_pending(rdev, conf->mddev); @@ -1677,7 +1677,11 @@ static bool raid1_write_request(struct mddev *mddev,= struct bio *bio, mbio =3D bio_alloc_clone(rdev->bdev, bio, GFP_NOIO, &mddev->bio_set); =20 - if (test_bit(MD_SERIALIZE_POLICY, &mddev->flags)) + /* + * CollisionCheck marks every rdev with a serial + * tree; order against in-flight write-behind I/O. + */ + if (test_bit(CollisionCheck, &rdev->flags)) wait_for_serialization(rdev, r1_bio); } =20 --=20 2.52.0 From nobody Sat Jul 25 00:16:38 2026 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 C70C446E01B for ; Tue, 21 Jul 2026 17:46:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655971; cv=none; b=nRO7JAg9Kd8xucIBcADQOnzKbrB4si/fkFVsy+cyUiGTVriA2GeLZWjqSHOTznt5Rizr1LBtqZOzC+Kvo0aYmLKeEEW4sBX9AqkQjPeGVTLypT3JkNpixa6oudYdIMj/Sc7EwiGSZSC65kpd1XS7bEdO09m41SflVtf+ufr/LiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655971; c=relaxed/simple; bh=cD3SxDgYRV4P07YCyZ3D6dpRoOb3a5AG7H6z997kprs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N8F4knCl/n+/486pGJk6ozqIqgmicVcePqc2zQH/ETmM7yLdV7sqnTvGMaTu3+5RkbnZ+lgrFx7HyBGNEyUAAKQgacmX8X5V0nh7sUt76ZRlpcmM6DnsmXwqjTj73bOR9CDxb/CTlwD+cBg0W2lTBjYiz0eqnE29yYh6Hc5l/58= 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=oUIFIvsB; arc=none smtp.client-ip=209.85.221.46 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="oUIFIvsB" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-47de008b020so3951240f8f.1 for ; Tue, 21 Jul 2026 10:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meshstor.io; s=google; t=1784655968; x=1785260768; 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=dWf575YMSf1W7NtVvbE0zlmvwqtjFzi0s/WGa1kQOeI=; b=oUIFIvsBg3mo3dDAlk47n4w5O0Cc3AJoV0IGlW9f+z1B/kGJvyG4I1Hw/QZ/nXXX+J q2aKBdDgrtO83PofGhUhWOvDjbW4R+YOwoBc2m6Q00HU/SpzdYEhI6YXSFmhDUhJZq1R M81sjSglpEZAb0JgqlOhxVFbuUIBXFxLijbvsebJG064/AFroA80Beuzcf/IUzYYPywr RBE88+0gxMagu80LRIepOWdR9XNFVLs4RFEQmmTg2sOo+hZNkOnqpDrqCnvIzFsw/1OH Srns4yMDUT20apg9S8/QtMhSr2hXVCtkT6p07X62clOjHgznrh0X8w6x3bCc5unicf4w zwuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784655968; x=1785260768; 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=dWf575YMSf1W7NtVvbE0zlmvwqtjFzi0s/WGa1kQOeI=; b=dEiyFhIfLaldSvslQWm8LOhQtdBE2b3iH+CjwD5nGQ9GwAaX4CQI0vI7AVxHa+En4+ CJ/H42lvx70CWqw55dVuTEopUps+IhQ7tOIE2o1ed732QZ+0u1CpZZtKS6K5oKT+1Vee pIrtoEiSKzoXZ5xKXRXu2XArc5AknwwabImNiiPNzx817bzxGVmgnWF1Q4Qy7iYP4Hpz WZDRYKEn+3A5Giyyqb1Qa18q9zwQ5ryjpgACMrTUkQODbvf6f3iDFgILOUUxkwjLswud EbksTCvtMS5hubzw9xzs1RO36qoAF4QrfNUw5EkHJUzbMWTMtpTQJq3gaLlUviwz74sk dW5Q== X-Forwarded-Encrypted: i=1; AHgh+RqAsTZ1CVgswZTbGb58u76TV7sMoVNSWG/Qnx+nZ+2aUGzmXpNKPZK0g/iIPvUzUbN8KzW2se2EjfBIDJU=@vger.kernel.org X-Gm-Message-State: AOJu0Yw0NYQvX9H89aqHVnN7Uk6edJG7b3u3VQljDlCIpGcB+DIxIizt EWvQq4vLsyhQy3fY/D/b+2tFJ6bPHo5ZDTtO1WbGZZeIBdpC+RpulG4Lpcme5Mr26w== X-Gm-Gg: AR+sD13L+E1rqk5hOYI47+e2ctg8y9PZg9BSP4E9jLBgZ5kg5IDZF5fdecvGxj08Ppt H7JyDOIc+fmASaKoUae0O79HGHAIVYVajp5NQgPy0UfpZBQjklyaEnm9s1nFuJ4231ndTcD0HAg Ri9QtTMiiO6pJAZZ9GKCCLOtzaYnqjrIAP8UpRgUX35Un7UpL7tfnuiz4zE5xsI/KTNgL83BCgO 1f8PR8IJGNbVLIJL6K4E0/KEYVkxbHxoPQp1Gle7j4TEoaEv9TbdGlQVOkcmAHQfL7fZFC1FX6o vDOLlJuWy28t9d8VdhWEkTV+M8BXq3DVAEgAr3b+mCvx/cwdS8nJ4hCMpzY31J0lK2hu7xI1AV4 pLd0DQ4itYPExXnmWKMAjiYoJh1xbkmsmXZ2E+0ffz7uf77L9YWv6uqw6q+ATSvfGB4JLSvD85k T1IEYtYTA0HQwT2yrX0IA51FeT0d92lIR9RuuT2RzRSUJGOkU= X-Received: by 2002:a05:6000:2903:b0:47f:7864:1b7b with SMTP id ffacd0b85a97d-47f840c596amr727053f8f.24.1784655967970; Tue, 21 Jul 2026 10:46:07 -0700 (PDT) Received: from ai-pc ([46.172.241.174]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63eddd27sm40860513f8f.28.2026.07.21.10.46.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 10:46:07 -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 v3 4/8] md/raid1: don't use write-behind for P2PDMA bios Date: Tue, 21 Jul 2026 19:44:58 +0200 Message-ID: <20260721174502.111503-5-mykola@meshstor.io> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260721174502.111503-1-mykola@meshstor.io> References: <20260721174502.111503-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: quoted-printable Content-Type: text/plain; charset="utf-8" alloc_behind_master_bio() copies the bio's data with bio_copy_data(), a CPU copy. P2PDMA pages are peer device (BAR) memory; generic code must not assume CPU load/store access to them is safe or fast on every architecture, and bouncing peer memory through the CPU defeats the point of a peer-to-peer transfer. Skip write-behind for P2PDMA bios: they are written directly to all members, including write-mostly ones. Ordering against write-behind I/O in flight to overlapping sectors is preserved: the non-behind clone path serializes on CollisionCheck rdevs (see the preceding fix), which covers these bios like any other write that bypasses write-behind. 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/raid1.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 997f79c05db7..7d769b6460ca 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1523,6 +1523,7 @@ static bool raid1_write_request(struct mddev *mddev, = struct bio *bio, bool write_behind =3D false; bool nowait =3D bio->bi_opf & REQ_NOWAIT; bool is_discard =3D op_is_discard(bio->bi_opf); + bool is_p2pdma =3D md_bio_is_p2pdma(bio); sector_t sector =3D bio->bi_iter.bi_sector; =20 if (mddev_is_clustered(mddev) && @@ -1575,9 +1576,12 @@ static bool raid1_write_request(struct mddev *mddev,= struct bio *bio, /* * The write-behind io is only attempted on drives marked as * write-mostly, which means we could allocate write behind - * bio later. + * bio later. P2PDMA bios are excluded: write-behind copies + * the data with bio_copy_data(), a CPU copy that cannot be + * assumed safe or fast on P2PDMA (device BAR) pages. */ - if (!is_discard && rdev && test_bit(WriteMostly, &rdev->flags)) + if (!is_discard && !is_p2pdma && rdev && + test_bit(WriteMostly, &rdev->flags)) write_behind =3D true; =20 r1_bio->bios[i] =3D NULL; --=20 2.52.0 From nobody Sat Jul 25 00:16:38 2026 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 0ADD246F4A6 for ; Tue, 21 Jul 2026 17:46:11 +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=1784655973; cv=none; b=YRfXKCqhh1c7F/pp5VCXEayefa9GS4JnCS5Xgr1X/sqQwUDQhZwE5AtpjA6NimEGZ1kqlGbhkORu0qoO+OC/FTIiw8IVOCInI75d7x+poPNYxZdgzFOMm7CPIANa5KsKp3IyZ7rJeArgSvwpOSRvIkrKWAhr8SY8CulSUEKlYn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655973; c=relaxed/simple; bh=2hXrMq9EcVe8qu/MqiwSrwMrpbLS1aTcErxtzRiVgss=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eiVaKiE7bXAUGkmn66QtJrinre7S5g5LAngN7mEaVyEyjN8S77SHW01cCDtKfJbD1G2fSOJhCgvpL+mUMwnbmbyze8FxV6se73FpoF1fCdi5WGZaqqnIGADlVEgq3FOe/Bchf/1Q+lAi0lFVH1M58huCsh9T2yfdmwa4y+pHW/0= 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=KhRbw6Mw; 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="KhRbw6Mw" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-49548e01d02so21343105e9.0 for ; Tue, 21 Jul 2026 10:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meshstor.io; s=google; t=1784655970; x=1785260770; 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=yn3hWNKXTlSTf/hzkreGnovc9sItcGhl/RSESOOgGvw=; b=KhRbw6MwzUd7bmMo0hV4z9+afj8sqjGTYv73xy6EeRCBt96GRnE1E6SzHul1x+s1O0 9DqH8N1S30ibm9hDorMJgvv2sLDeIR4YCrcAGgFkOqCKdyLp43eSt1hsTWKuN4aqMEL+ 0DQ91igtVJipG2Ykkq5dppdt87wMOMHOEirEl6NljGbSqx4HmhMM3cfHbYxDiDgapclo RFHXQdxP/QrMCc5itBCIA2wE3yJoFbTs2n6096hPv/4W6BWJVMJM8D8mpaAWelTwqB5B 8HxCA6PfnK3y+ZCnwSFUGWb/3PpAeIlHDLiiiaer1vtOe2QiYKWPd+bbGp356lvGTjcW f+AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784655970; x=1785260770; 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=yn3hWNKXTlSTf/hzkreGnovc9sItcGhl/RSESOOgGvw=; b=cxl5CjTYDXFb2rp6Ruj2MVT85pphX/cheNkhzKfzN7Oi+bVkAnkPbRM/8fd4jl93mE rt+6e/5ErXnIWxRdOYCExAl5JHFfW9mv8Mv8ZJDlXq0Kx3lp7jndC9En58kFExKNSlYy M+Mm0WSJtk58vJrX3xjbAmO1+dOJVPwHQmyLaMFOkKrzLFYhDqbV+gw1QY0PAMu7ZBYi Uo7xHMhi8IAJR5rUQAqpmqBW+abiSG1mpqJAwepOdKVS/uGHHBvX1lP0PJrE88OHvoZO OYpDukIwgpzS1MqFGLqBo5vrs+HBNlZ9g1d0EPG5Z2WUy3bSH7dNE44aiFa/jfZZmHFj pVEg== X-Forwarded-Encrypted: i=1; AHgh+RoQsv6IQpBePNuB23P0Ow/xNWucuEsx4ROiHj7MYkChJYJPDU2hKZoTa34lCalApzqNIltxEVzrkQLw6c8=@vger.kernel.org X-Gm-Message-State: AOJu0YxEyJGp8kYM61bWV5Te10UXXFNm9VI/4tAVj1Uy0OlYtwuqSdGy wPxWEdSNGjJlTJpKNej6keNc33PmPIawUZ4vKslibs4V9b1K8z505gpEdj+kxU5zEQ== X-Gm-Gg: AfdE7ck4rO6nLzxbKaNg3d6oH2iAIKlLVi1nzDgtdA5SOMbY0j0Ht0mdtSMXKSJHonJ MMg3l0BMvp7k/7vJ4DnvAAyU67lksZ5oMyUuP/uNmfNHbizEdhuYX3Rlg36SNV2T7MpFXcAcszz ZKWiurLVzA98LnS6cYkOvaScix3stM0JPjMnipo28jaRSisn/Hj11H3Cfd+hPNx0Tbfo90P2gkj LD8Xiy1h/Ae8Xu2Ll559PAtx5CoE032dF4oJP+M/iBsrshzd+8Kz4/VLc62svaOBvURKkXZ2Uvg pgdPAOfE/uHsgyQdpHV0TAId0mvH8Eq/GcpFO6mueOIrYv+I93vMm/XO85dG5UTLckavBcW1ju5 mJCy3uJUE/6Frq+KxVfZfLQXV57S5ZsHzvriGnUI6CL2b1YYcyi738mDYwnX7QLEPEBS4SvioYP LTQIGNzi2/qrASaRP8ndbvdxlwebL7F0SIlJWPQw+dc5j4SBQQItbCBa/Cbg== X-Received: by 2002:a05:600c:2908:b0:493:bb6b:5bb5 with SMTP id 5b1f17b1804b1-4954a3dcc67mr172161575e9.13.1784655970189; Tue, 21 Jul 2026 10:46:10 -0700 (PDT) Received: from ai-pc ([46.172.241.174]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63eddd27sm40860513f8f.28.2026.07.21.10.46.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 10:46:09 -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 v3 5/8] md/raid1,raid10: keep REQ_NOMERGE on narrow_write_error() retry clones Date: Tue, 21 Jul 2026 19:44:59 +0200 Message-ID: <20260721174502.111503-6-mykola@meshstor.io> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260721174502.111503-1-mykola@meshstor.io> References: <20260721174502.111503-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Logan Gunthorpe --- 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 7d769b6460ca..16b7465c233a 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2570,6 +2570,9 @@ static void narrow_write_error(struct r1bio *r1_bio, = int i) } =20 wbio->bi_opf =3D REQ_OP_WRITE; + /* Keep P2PDMA retry bios unmergeable, like the original */ + if (md_bio_is_p2pdma(wbio)) + wbio->bi_opf |=3D REQ_NOMERGE; wbio->bi_iter.bi_sector =3D r1_bio->sector; wbio->bi_iter.bi_size =3D r1_bio->sectors << 9; =20 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 =3D wsector + choose_data_offset(r10_bio, rdev); wbio->bi_opf =3D REQ_OP_WRITE; + /* Keep P2PDMA retry bios unmergeable, like the original */ + if (md_bio_is_p2pdma(wbio)) + wbio->bi_opf |=3D REQ_NOMERGE; =20 if (submit_bio_wait(wbio) && !rdev_set_badblocks(rdev, wsector, sectors, 0)) { --=20 2.52.0 From nobody Sat Jul 25 00:16:38 2026 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 25F1C47042A for ; Tue, 21 Jul 2026 17:46:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655976; cv=none; b=alqa/erzPSeXz42HVKP+4zCXipFpr49Ha9EtFsYwS1G/q6uvAQjyyum84/eOMTpVE4tPFu33puVa33Du7ck27eK0l7oVr53qwMHwnrhfRbpOGSExUIFpqyypcdkVm+AtdlPBt6uVmcuyxyHDwa4ns4jdQhRsJnfuetiYkREaeUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655976; c=relaxed/simple; bh=7tCnvUVxAg7gfBg1vhZ0oYTg4SOqF5x+kKhvNqafOrA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VP37Of3QtHxupP42Y0lmXMVfSE4CjMmRn6oksFU8ksU7C9n7HBMM9xHjkuCepsgjy5WYNeJkYixircjvcKfqsLUWV7yN99dlx1OvcujF3j/Xo5ketU7eHxv+wJiwb7VpzN6zlWX29e+7RSVcFquL7Tlh6i3eJ7UHgbJpQIS4vLg= 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=D62pSTFs; arc=none smtp.client-ip=209.85.221.49 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="D62pSTFs" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-47f3b39f2a1so5945199f8f.2 for ; Tue, 21 Jul 2026 10:46:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meshstor.io; s=google; t=1784655972; x=1785260772; 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=RI/ofRS9U+6ig5kLdN1LCndM4I9pFM5i9E2zRYc1mtk=; b=D62pSTFs7Im3Odtzxs7tM+9rPr5cT1fZr9f6DzFAlgVIGNAA1VY6CIW1WeJCKs7rMs NRwaLOyeE5y1uO5MeCgDfEjgJzQ+xCNDOc5fjvfn/6tYYtdZ2CWN49/+EvWKC5w8YY4D M0gfTF8GZ/kv7P1yOY+P3PT0olPJ9gjCCBXylV4k4TPeD0aP/zQYj46UYasw5FT1yJfg NKTxgungizusLj/huwqURpAa6qE2fyWLOu75vgKF9Mk9v5559vbDg8sLpj81ARz4oc0h o8xTpLg4zCjtAw7hW2SqpPMxtUNr9X1Lc8nxdjM6qcm/Uq0kYSvDpSutoUO1nJZ2iwY3 EnQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784655972; x=1785260772; 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=RI/ofRS9U+6ig5kLdN1LCndM4I9pFM5i9E2zRYc1mtk=; b=ZGrp6tqFdyfTIUEj6RwvDWs8HgUPz2L5Tp+v5J4miPEC6dGPkvVRToiQzj3JehnIO6 YK2OxEMeDIwHkzxBDwtI9O234M0KyVjcFreJCg26MNH83mTrkp2xjZtZCjHorpGvvf45 27YtvwEAmc2e0gv9WZYXX31es/RG/yTNztJ6/1Sl91Nq1ilWokelThZVvt9uOA2o3BYM yzXLIlkIGqtc5V5YCqvxru2vgtkv+Gmw0RXK7Tf9MyyJIaw/F7L6UdlDjrjjJG1K8Yk3 Vp9VLNhE3lhzg7uiuQiNP1SXeUMTsB2wXScoq4vLE1MK2pFnN6pU3TNlEVzfErNeLmLl vltQ== X-Forwarded-Encrypted: i=1; AHgh+RpXaTsZwdyLsVf4cZQGHplhLB0CKP+Hw4xClxtD7o7iM8FnjPFIxQ41ZMJhbLcDUTC2X4TrrhMCJlXdnqc=@vger.kernel.org X-Gm-Message-State: AOJu0YzLisxX0XUy23LG2mx5/a2bcZAJOl3wOnRlJIyK+uY7Pynu5yyK au58AaddjkRm8Pb9OvwPIeKBTkV7WACA/GxMahZEOZMYsx/tfPZm4fxGNu7UOIUEZg== X-Gm-Gg: AR+sD11Cte2IQQcu/IkltxtElbDWXqAK8T9y5XTQDUDYPHSQG3KonCWtsdCNHo/dh9p 1+im9MiZ1BWVAh402TdBrX8BwUrq3AoQDRurcO+Yn0l8Nkzb251D2iGMbX1PUSMZMo+63E4zJQK /BUUSjlGRopEqZvZsroXT4xZl/Q5lfcw61hkQ4l5Hma+lYcrCCqwqiFR4XA6bu9Eh1aTMoLM+6f 0EuNcIKgtYkBEj2LPotyS7qVpbXdFZrCzr1HbdCp3xUm9NRrEujvNyfF1h+XhzYikVGgOUhBhd8 R6E3TwRT8kxnHPI8eaXcwql+lEUmGliiBREleD7VMSwal7NvW3WEjoYNuu0w0JoVwcwhVjqDAeJ iX9lLwlMuBWf/VusZHFEr6L1ilUWee4TzlNNuFfgIzZPqrK05wdhZjZFrXjokzHl6Mt4wM/mIlW zYg6zAs92imKfMYIH/ecri+vUcIDnxpA76E7zUCA2Jq3yyVuE= X-Received: by 2002:a05:6000:41e1:b0:47f:6d9a:d7a6 with SMTP id ffacd0b85a97d-47f6d9ad948mr17562857f8f.25.1784655972302; Tue, 21 Jul 2026 10:46:12 -0700 (PDT) Received: from ai-pc ([46.172.241.174]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63eddd27sm40860513f8f.28.2026.07.21.10.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 10:46:11 -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 v3 6/8] md/raid1: skip futile retries on P2PDMA mapping failures Date: Tue, 21 Jul 2026 19:45:00 +0200 Message-ID: <20260721174502.111503-7-mykola@meshstor.io> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260721174502.111503-1-mykola@meshstor.io> References: <20260721174502.111503-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: quoted-printable Content-Type: text/plain; charset="utf-8" A member that cannot DMA-map peer memory fails the leg bio with BLK_STS_TARGET. The failure is a property of the peer/member pairing -- retrying the same pages against the same member cannot succeed, and there is nothing on the medium to repair -- but the error machinery treats it as a medium error: narrow_write_error() grinds through hundreds of doomed chunk retries per write, WantReplacement burns a spare and evicts the healthy member, fix_read_error()'s host-page probe "succeeds" so mixed host/P2P reads charge the read-error budget until a healthy member is kicked (~1s in testing), and FailFast evicts on the first unroutable I/O. Flag P2PDMA master bios with a new R1BIO_P2PDMA state bit at submission. On a BLK_STS_TARGET leg failure for a flagged bio: retry writes once as a single whole range, recording one bad range if that also fails (TARGET can be a transient device condition, e.g. NVME_SC_NS_NOT_READY, so the retry is not skipped outright); don't set WantReplacement; mark failed read legs IO_BLOCKED without charging the read-error budget; and don't treat the failure as FailFast evidence -- the request never reached the wire -- as commit f7b24c7b41f2 ("md/raid1,raid10: don't fail devices for invalid IO errors") did for BLK_STS_INVAL. 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 | 54 ++++++++++++++++++++++++++++++++++------------ drivers/md/raid1.h | 2 ++ 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 16b7465c233a..6334032c4bb8 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -483,16 +483,22 @@ static void raid1_end_write_request(struct bio *bio) * 'one mirror IO has finished' event handler: */ if (bio->bi_status && !ignore_error) { - set_bit(WriteErrorSeen, &rdev->flags); - if (!test_and_set_bit(WantReplacement, &rdev->flags)) - set_bit(MD_RECOVERY_NEEDED, & - conf->mddev->recovery); + /* Peer/member pairing failure, not member health. */ + bool p2pdma_unmappable =3D bio->bi_status =3D=3D BLK_STS_TARGET && + test_bit(R1BIO_P2PDMA, &r1_bio->state); =20 - if (test_bit(FailFast, &rdev->flags) && - (bio->bi_opf & MD_FAILFAST) && - /* We never try FailFast to WriteMostly devices */ - !test_bit(WriteMostly, &rdev->flags)) { - md_error(r1_bio->mddev, rdev); + set_bit(WriteErrorSeen, &rdev->flags); + if (!p2pdma_unmappable) { + if (!test_and_set_bit(WantReplacement, &rdev->flags)) + set_bit(MD_RECOVERY_NEEDED, + &conf->mddev->recovery); + + if (test_bit(FailFast, &rdev->flags) && + (bio->bi_opf & MD_FAILFAST) && + /* We never try FailFast to WriteMostly devices */ + !test_bit(WriteMostly, &rdev->flags)) { + md_error(r1_bio->mddev, rdev); + } } =20 /* @@ -1378,6 +1384,8 @@ static void raid1_read_request(struct mddev *mddev, s= truct bio *bio, else init_r1bio(r1_bio, mddev, bio); r1_bio->sectors =3D max_read_sectors; + if (md_bio_is_p2pdma(bio)) + set_bit(R1BIO_P2PDMA, &r1_bio->state); =20 /* * make_request() can abort the operation when read-ahead is being @@ -1557,6 +1565,8 @@ static bool raid1_write_request(struct mddev *mddev, = struct bio *bio, =20 r1_bio =3D alloc_r1bio(mddev, bio); r1_bio->sectors =3D max_sectors; + if (md_bio_is_p2pdma(bio)) + set_bit(R1BIO_P2PDMA, &r1_bio->state); =20 /* first select target devices under rcu_lock and * inc refcount on their rdev. Record them by setting @@ -2522,7 +2532,7 @@ static void fix_read_error(struct r1conf *conf, struc= t r1bio *r1_bio) } } =20 -static void narrow_write_error(struct r1bio *r1_bio, int i) +static void narrow_write_error(struct r1bio *r1_bio, int i, bool coarse) { struct mddev *mddev =3D r1_bio->mddev; struct r1conf *conf =3D mddev->private; @@ -2536,6 +2546,9 @@ static void narrow_write_error(struct r1bio *r1_bio, = int i) * It is conceivable that the bio doesn't exactly align with * blocks. We must handle this somehow. * + * With 'coarse', retry the whole range as one bio: P2PDMA + * mapping failures fail every block identically. + * * We currently own a reference on the rdev. */ =20 @@ -2550,9 +2563,12 @@ static void narrow_write_error(struct r1bio *r1_bio,= int i) block_sectors =3D roundup(1 << rdev->badblocks.shift, lbs); =20 sector =3D r1_bio->sector; - sectors =3D ((sector + block_sectors) - & ~(sector_t)(block_sectors - 1)) - - sector; + if (coarse) + sectors =3D sect_to_write; + else + sectors =3D ((sector + block_sectors) + & ~(sector_t)(block_sectors - 1)) + - sector; =20 while (sect_to_write) { struct bio *wbio; @@ -2633,8 +2649,12 @@ static void handle_write_finished(struct r1conf *con= f, struct r1bio *r1_bio) * narrow down and record precise write * errors. */ + bool coarse =3D r1_bio->bios[m]->bi_status =3D=3D + BLK_STS_TARGET && + test_bit(R1BIO_P2PDMA, &r1_bio->state); + fail =3D true; - narrow_write_error(r1_bio, m); + narrow_write_error(r1_bio, m, coarse); rdev_dec_pending(conf->mirrors[m].rdev, conf->mddev); } @@ -2661,6 +2681,9 @@ static void handle_read_error(struct r1conf *conf, st= ruct r1bio *r1_bio) { struct md_rdev *rdev =3D conf->mirrors[r1_bio->read_disk].rdev; struct bio *bio =3D r1_bio->bios[r1_bio->read_disk]; + /* evaluate before the bio_put() below */ + bool p2pdma_error =3D bio->bi_status =3D=3D BLK_STS_TARGET && + test_bit(R1BIO_P2PDMA, &r1_bio->state); struct mddev *mddev =3D conf->mddev; sector_t sector; =20 @@ -2680,6 +2703,9 @@ static void handle_read_error(struct r1conf *conf, st= ruct r1bio *r1_bio) */ if (mddev->ro) { r1_bio->bios[r1_bio->read_disk] =3D IO_BLOCKED; + } else if (p2pdma_error) { + /* Peer can't reach this member: just redirect the read. */ + r1_bio->bios[r1_bio->read_disk] =3D IO_BLOCKED; } else if (test_bit(FailFast, &rdev->flags)) { md_error(mddev, rdev); } else { diff --git a/drivers/md/raid1.h b/drivers/md/raid1.h index c98d43a7ae99..61b788a99d14 100644 --- a/drivers/md/raid1.h +++ b/drivers/md/raid1.h @@ -184,6 +184,8 @@ enum r1bio_state { R1BIO_MadeGood, R1BIO_WriteError, R1BIO_FailFast, +/* the master bio carries PCI P2PDMA (peer device memory) pages */ + R1BIO_P2PDMA, }; =20 static inline int sector_to_idx(sector_t sector) --=20 2.52.0 From nobody Sat Jul 25 00:16:38 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 312CC470449 for ; Tue, 21 Jul 2026 17:46:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655980; cv=none; b=QUwuQDHBtfqY6YakpoGE1H8PFdmnMENt3LbAWY2MqJgJe7TqiKKD7EUMFVztoggD1i9UnzQ3soNLNDvITSYqOCqnPY26BEnZbY7XKU7XzEri66qzzZzWjwkRfGMwe3kOiOZJ46JiXXiUXZUZRAgZkonDF+rpv6HS1gw4P2+jCJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655980; c=relaxed/simple; bh=8lwKlp75z1YvnrOncarPX7oWeDqy+5JbGTS5C7xvC9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZQkwwHWdeN9hZjSbUASJjNJvWhXbeIliP0zLt6P36Pgj3l2g0u44RaDJQc+lPKhS0r+DGFLlxviCmMoZy45ntW4VXf4iX//4513FaGEFJBwusOSajoxSqW+OCTZOyWCT1i/FQaNGdcLOWDwX0+yEdINAJDY/Z8AlQiF3oCunhug= 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=rOLePR4m; arc=none smtp.client-ip=209.85.128.45 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="rOLePR4m" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4956242332dso18874955e9.2 for ; Tue, 21 Jul 2026 10:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meshstor.io; s=google; t=1784655974; x=1785260774; 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=8dj3uaA5KIKi+y4TtBPBIa/9LhAWdxcRprl1F1cYW18=; b=rOLePR4mOWPSi7QcH7lsd3oNwTyAWc05lQ0Y9ypNMaFsobQvfJ9SrHf+mCx+i4V1T4 sslu0EyK1Qlljo45Y9aSF/N6PUPDkth/yTCz4ZAMPeXi7d+6EukfkgaJlSRuE48S452y mrlqd6qWBaH2gd6yn1BEyB1XffYKRkW1lCoSIpj7QOK3WhpwaTuv9y21S7q3/yob3o88 qNmpdGl9eQ2iGA1NDQscmbP67+ZcSdoy8MIa4fbcN8Ry10fWXB7qNp9PgKoORQsqM8b+ tAjlNbOd7/z3OMAHC9RfFCdjUzGP6T13fE0ZYMq0udf3QH528apkXkQ5FIRUZ+ebjPX3 tqjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784655974; x=1785260774; 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=8dj3uaA5KIKi+y4TtBPBIa/9LhAWdxcRprl1F1cYW18=; b=lmBvyuLRSVTkqrSwvb0a/w7K14nva7U1q7RxgHNd536/16OpLiOB/c7Vj7mRf60OM8 5/t0idPrhPRTkx7oeuOOq3BsbfNQp9zA5FfRBEHuJGzLHqySPmKxuyDkazB7fX+m+RwR uLdNTKJWK77JL8mNjTQUZXFB6eodDUuznCv9ehM7zmMTACOpJvYMERQFP9g1xEP8Hy2P QQWQHRYSBmYIDRGASTIfn1Z7aOnK7XY6Uo6rZ8/6lbOChFs0fA/yuFeTa2tSY1s1e5HY 7cs0UK7ym0GO3U7vRDqTfvCDn71C1S77+LzAtKyFnPlSxlqGINMbkZ0/f2VUCsRF6hjZ nlIg== X-Forwarded-Encrypted: i=1; AHgh+RoMQ5cnxUnvLjNXjZQ6Y3Io/nE7UdH/mNLUO/yQ8k4Qu9LVhhyZW5FWpESot2B+6GNh04GgwhoOBChqvm0=@vger.kernel.org X-Gm-Message-State: AOJu0YzNDlYQW/CykAUqVOKg6AoLTMQIm7W2SZqluSOjV9HBRYXuRE6T z6a4ljoT+XULIpQeaq0wFoJXBNy8UV7/a2zZ/EFm+PsrZUTjRMOE8FfaIGoswfud5w== X-Gm-Gg: AfdE7clS+zhLljcc/SdQ0eqt9eXDYZMKp0TS+QtGnbQcUVDNeSqmi4RjqiayB47hr/D l98BJ9rDGyE/s3a7jrQG89srly2iE4WmcW/lD5uGCF8ymrCVpTFTefIqBCMxZdPOoSwE3yekdOP zsBmpKFVjveBLZALKtsBa00ssKa1SOckH7DMwGCsLHF2gW8K0ir+QlpSA0v4i9NFVgnDF8FoOXV Ti9FAmm1rLRPnj38PY6jH6bj1Wx8rFt1lJC12dYJ6wfOkt50LTi1EAE8UemfzHejT3saCIW84ew jfdHARBK+QDcsGU+/hJOieIPQbJUaKCDMHVrCi5jsMYiJp4Ngas+aKn+vy5wRFENOoSwXBXJuOn 1DfANXQ4KExYfPrI8SwVThiCS7KvsLUbqWjSec2RkV/9Xi8pjih5QhVqY6bbr4WzwPGL3dDbzDR DcGRDH8oGjNg5BhxWG7wZpEAfgwIewvw9dk946ZTF8b1val4A= X-Received: by 2002:a05:600c:1914:b0:495:4598:6e13 with SMTP id 5b1f17b1804b1-4954a3f5271mr199481405e9.17.1784655974444; Tue, 21 Jul 2026 10:46:14 -0700 (PDT) Received: from ai-pc ([46.172.241.174]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63eddd27sm40860513f8f.28.2026.07.21.10.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 10:46:13 -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 v3 7/8] md/raid10: skip futile retries on P2PDMA mapping failures Date: Tue, 21 Jul 2026 19:45:01 +0200 Message-ID: <20260721174502.111503-8-mykola@meshstor.io> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260721174502.111503-1-mykola@meshstor.io> References: <20260721174502.111503-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: quoted-printable Content-Type: text/plain; charset="utf-8" Same handling as the preceding raid1 commit: flag P2PDMA master bios with R10BIO_P2PDMA at submission; on a BLK_STS_TARGET leg failure retry writes once as a whole range, don't set WantReplacement, block the leg for reads without charging the read-error budget, don't trip FailFast. Replacement legs keep the stock fail-on-write-error policy: badblocks are never recorded on a replacement, so failing it is the only outcome that cannot leave a silent hole in a rebuild. 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/raid10.c | 63 ++++++++++++++++++++++++++++++++++----------- drivers/md/raid10.h | 2 ++ 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index f7ef903a3d4e..4c3da50250a5 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -482,15 +482,23 @@ static void raid10_end_write_request(struct bio *bio) */ md_error(rdev->mddev, rdev); else { - set_bit(WriteErrorSeen, &rdev->flags); - if (!test_and_set_bit(WantReplacement, &rdev->flags)) - set_bit(MD_RECOVERY_NEEDED, - &rdev->mddev->recovery); + /* Peer/member pairing failure, not member health. */ + bool p2pdma_unmappable =3D + bio->bi_status =3D=3D BLK_STS_TARGET && + test_bit(R10BIO_P2PDMA, &r10_bio->state); =20 + set_bit(WriteErrorSeen, &rdev->flags); dec_rdev =3D 0; - if (test_bit(FailFast, &rdev->flags) && - (bio->bi_opf & MD_FAILFAST)) { - md_error(rdev->mddev, rdev); + if (!p2pdma_unmappable) { + if (!test_and_set_bit(WantReplacement, + &rdev->flags)) + set_bit(MD_RECOVERY_NEEDED, + &rdev->mddev->recovery); + + if (test_bit(FailFast, &rdev->flags) && + (bio->bi_opf & MD_FAILFAST)) { + md_error(rdev->mddev, rdev); + } } =20 /* @@ -1170,6 +1178,9 @@ static void raid10_read_request(struct mddev *mddev, = struct bio *bio, */ gfp_t gfp =3D err_path ? (GFP_NOIO | __GFP_HIGH) : GFP_NOIO; =20 + if (md_bio_is_p2pdma(bio)) + set_bit(R10BIO_P2PDMA, &r10_bio->state); + if (slot >=3D 0 && r10_bio->devs[slot].rdev) { /* * This is an error retry, but we cannot @@ -1357,6 +1368,9 @@ static bool raid10_write_request(struct mddev *mddev,= struct bio *bio, sector_t sectors; int max_sectors; =20 + if (md_bio_is_p2pdma(bio)) + set_bit(R10BIO_P2PDMA, &r10_bio->state); + if ((mddev_is_clustered(mddev) && mddev->cluster_ops->area_resyncing(mddev, WRITE, bio->bi_iter.bi_sector, @@ -2786,7 +2800,7 @@ static void fix_read_error(struct r10conf *conf, stru= ct mddev *mddev, struct r10 } } =20 -static void narrow_write_error(struct r10bio *r10_bio, int i) +static void narrow_write_error(struct r10bio *r10_bio, int i, bool coarse) { struct bio *bio =3D r10_bio->master_bio; struct mddev *mddev =3D r10_bio->mddev; @@ -2800,6 +2814,9 @@ static void narrow_write_error(struct r10bio *r10_bio= , int i) * It is conceivable that the bio doesn't exactly align with * blocks. We must handle this. * + * With 'coarse', retry the whole range as one bio: P2PDMA + * mapping failures fail every block identically. + * * We currently own a reference to the rdev. */ =20 @@ -2814,9 +2831,12 @@ static void narrow_write_error(struct r10bio *r10_bi= o, int i) block_sectors =3D roundup(1 << rdev->badblocks.shift, lbs); =20 sector =3D r10_bio->sector; - sectors =3D ((r10_bio->sector + block_sectors) - & ~(sector_t)(block_sectors - 1)) - - sector; + if (coarse) + sectors =3D sect_to_write; + else + sectors =3D ((r10_bio->sector + block_sectors) + & ~(sector_t)(block_sectors - 1)) + - sector; =20 while (sect_to_write) { struct bio *wbio; @@ -2856,6 +2876,7 @@ static void handle_read_error(struct mddev *mddev, st= ruct r10bio *r10_bio) { int slot =3D r10_bio->read_slot; struct bio *bio; + bool p2pdma_error; struct r10conf *conf =3D mddev->private; struct md_rdev *rdev =3D r10_bio->devs[slot].rdev; =20 @@ -2868,17 +2889,24 @@ static void handle_read_error(struct mddev *mddev, = struct r10bio *r10_bio) * frozen. */ bio =3D r10_bio->devs[slot].bio; + /* evaluate before the bio_put() below */ + p2pdma_error =3D bio->bi_status =3D=3D BLK_STS_TARGET && + test_bit(R10BIO_P2PDMA, &r10_bio->state); bio_put(bio); r10_bio->devs[slot].bio =3D NULL; =20 if (mddev->ro) r10_bio->devs[slot].bio =3D IO_BLOCKED; - else if (!test_bit(FailFast, &rdev->flags)) { + else if (p2pdma_error) { + /* Peer can't reach this member: just redirect the read. */ + r10_bio->devs[slot].bio =3D IO_BLOCKED; + } else if (test_bit(FailFast, &rdev->flags)) { + md_error(mddev, rdev); + } else { freeze_array(conf, 1); fix_read_error(conf, mddev, r10_bio); unfreeze_array(conf); - } else - md_error(mddev, rdev); + } =20 rdev_dec_pending(rdev, mddev); r10_bio->state =3D 0; @@ -2947,8 +2975,13 @@ static void handle_write_completed(struct r10conf *c= onf, struct r10bio *r10_bio) r10_bio->sectors, 0); rdev_dec_pending(rdev, conf->mddev); } else if (bio !=3D NULL && bio->bi_status) { + bool coarse =3D bio->bi_status =3D=3D + BLK_STS_TARGET && + test_bit(R10BIO_P2PDMA, + &r10_bio->state); + fail =3D true; - narrow_write_error(r10_bio, m); + narrow_write_error(r10_bio, m, coarse); rdev_dec_pending(rdev, conf->mddev); } bio =3D r10_bio->devs[m].repl_bio; diff --git a/drivers/md/raid10.h b/drivers/md/raid10.h index ec79d87fb92f..a2e1554f77db 100644 --- a/drivers/md/raid10.h +++ b/drivers/md/raid10.h @@ -174,6 +174,8 @@ enum r10bio_state { R10BIO_Previous, /* failfast devices did receive failfast requests. */ R10BIO_FailFast, +/* the master bio carries PCI P2PDMA (peer device memory) pages */ + R10BIO_P2PDMA, R10BIO_Discard, }; #endif --=20 2.52.0 From nobody Sat Jul 25 00:16:38 2026 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 75B4746F4AA for ; Tue, 21 Jul 2026 17:46:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655980; cv=none; b=c4hHDG+fKRu+TW1iRWpHUYc7t9Au5MgCrklFwFyiKAR8N257ifCac16Lpydgo8l9ZMtzbHTpWOqeEMhx4x/51rhPdTbLQwWv2ktExnXwEdtuPStr0l7J6AvBdkcXfyP8rhJFBPh3kIuFjuwheKILzX6WLvz6JfMfcTe7PCdzUnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655980; c=relaxed/simple; bh=gyTrkaup4Ks5bfaG/FoabYF4rN440J0V60i2qS5Yijs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bzoL7JYltfFw27HeavGwxZFUjUvbi71guwkI4zON/G6PzN/cgfOSiJuzscbId7RslFqKtoT298cNmAubgH2VXfm+3Og6SXRGEa/heHVLYKuUaEo5GI5k0iwi6uSuYSqVhnbUIgSta/mEpyXgdwITksqr59AAoAEbpV6GDQ6LxUA= 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=NjrQ99bM; arc=none smtp.client-ip=209.85.221.41 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="NjrQ99bM" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-47f6609c657so1747974f8f.2 for ; Tue, 21 Jul 2026 10:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meshstor.io; s=google; t=1784655977; x=1785260777; 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=AadYXUkLInAYH0JaK/HqdbVk2juyzp5yk+Dx6h3Mv+o=; b=NjrQ99bMf3IJfIqwLL+iZ4YUDFQ9yYv1rfZV+XAbFeUCMZ0Dj+3xjWKK/s4gkXyf8K WTHUNJ9WHftTSjNO/b98ZD11mOoHTLTBjrqjYzsHdoDjKM3qPTDWrdTU0NwowVa/n7J7 s7QyXB/PaTTftO8jJM5CMRsIJ2gXZ05oUIYuGfkhyk2xc/TMKoUDw6vpPguIhLLrV6te z1h8Yg7MzK3HXxN/ixLzMyUq1SSH/0zxwoZ2hLjoUZUnFda6NZI6U5fRYt6tnA/AuyyJ R1IBNjyePCxdbZerUX8r+QpnfuorkoPJY82FOlOvi53qRrdY6Ac3qo59c68QijhUugqD 2ouA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784655977; x=1785260777; 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=AadYXUkLInAYH0JaK/HqdbVk2juyzp5yk+Dx6h3Mv+o=; b=MHX/mwNifZ686YS0od5DdaQS+lpDlEk4pQG7VbNd/t/ajEqZH4q0qzNjQs6pqWWwWf FCnV/DIUE0MqPoxGpE1jCUieVr1sgEwObsulgZF0akUM1bWE0fTq+FMGy/MTJcEI/con 26sHSrVwarI4fm/0y/9gFRwAey7WFWe+2G1DsITkYtiMkVfY3ggayn64FEWr8Wna7gkL 5kTMtTld750q4VV6gg4B6cXNtwJIg4OUXkRCoOYjqkL3/JwGzWpJYBdxKEsQXN0TtuoB XFV34eeZNesxxlOr1NftD+XsOfUaNQd24/Xdfgb0jsoZcbIqHnK1nKs4Yc2q13PbGdTP 44uQ== X-Forwarded-Encrypted: i=1; AHgh+Rpo5KnSp6dMjptHGBGZ2K7FcyXVNJHYDZeWfFvohIb2oc/4hg2md2GiiW7ROx/UwWxloSZeuPkhHi8ANVw=@vger.kernel.org X-Gm-Message-State: AOJu0YybFYvAPra8zjCiLeEzKLiY2JZIOKEC11gbWX89gV38famEUe5r QzPfnw5XL9++ssrwkjbYcsVYiVIceVwRtP8IU15j/PIY813CrmO3NMvTa0TigAbCqA== X-Gm-Gg: AR+sD12r41C5pMh/n+FuztJlx6PpibGIoBFSC8qmKEEA3dqap8Vg6dYYGq7Qiay1n6i V4SiXjoQzd0ufPcPIxXyGNfkoFElqhO/VoypPQIyrApG4CHfgkDPt429sVCkR8F+tuALBKNRYl9 yCGzVYCB16KfnxrmcdPFc1f+F/66bUSe/ioKyCctzAgtBNkIoimD/No4QYz5Ok+WHazAPkcR+T5 4NSAizJwZ+jVvQWLrucQ5/8NTaGMiENQHzyGVQeHuSC/draM69Q6BVcXcRrbiSEYSDFWLcdBY11 8MgGLmKZ3WIQALVhnPiLtM+Hstg+LTUTus5ILCsf5dXfl+WmPgTSwPyt33k7U661+tPF55oMcKJ tXLRpThIOr47TvtxOrO2AzBncgfKkPRwbdMSt2ETkLiax94sANlkh/6FpAzabIWJYbEhNjgUXcz 6kHUMydIB8iiph8mDQ0nIVTb4eqWh0OVbCfj1biZUk9ueXdUI= X-Received: by 2002:a05:6000:1ace:b0:477:71ef:5d81 with SMTP id ffacd0b85a97d-47f62305373mr23603687f8f.6.1784655976544; Tue, 21 Jul 2026 10:46:16 -0700 (PDT) Received: from ai-pc ([46.172.241.174]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63eddd27sm40860513f8f.28.2026.07.21.10.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 10:46:16 -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 v3 8/8] nvme-rdma: return BLK_STS_TARGET for unsupported P2P transfers Date: Tue, 21 Jul 2026 19:45:02 +0200 Message-ID: <20260721174502.111503-9-mykola@meshstor.io> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260721174502.111503-1-mykola@meshstor.io> References: <20260721174502.111503-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: quoted-printable Content-Type: text/plain; charset="utf-8" ib_dma_map_sg() returns 0 on a P2P mapping failure, losing the DMA layer's -EREMOTEIO, so nvme-rdma reports a path error. Default multipath requeues the I/O forever, and without multipath it burns nvme_max_retries requeues, then completes as retryable BLK_STS_TRANSPORT. Map the data and metadata scatterlists with ib_dma_map_sgtable_attrs() and return BLK_STS_TARGET for -EREMOTEIO, matching nvme-pci (commit 91fb2b6052f7 ("nvme-pci: convert to using dma_map_sgtable()")). Scatterlists stay: ib_map_mr_sg() consumes them, so blk_rq_dma_map does not apply. Start the request only after mapping succeeds so multipath accounting is never taken for an unmapped request, and ratelimit the map-failure message. Fixes: 23528aa3320a ("nvme: enable PCI P2PDMA support for RDMA transport") Cc: stable@vger.kernel.org # v7.1 Assisted-by: Claude:claude-fable-5 Signed-off-by: Mykola Marzhan --- drivers/nvme/host/rdma.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 6909e3542794..f8edb23552ad 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1469,6 +1469,7 @@ static int nvme_rdma_dma_map_req(struct ib_device *ib= dev, struct request *rq, int *count, int *pi_count) { struct nvme_rdma_request *req =3D blk_mq_rq_to_pdu(rq); + struct sg_table sgt; int ret; =20 req->data_sgl.sg_table.sgl =3D (struct scatterlist *)(req + 1); @@ -1480,12 +1481,14 @@ static int nvme_rdma_dma_map_req(struct ib_device *= ibdev, struct request *rq, =20 req->data_sgl.nents =3D blk_rq_map_sg(rq, req->data_sgl.sg_table.sgl); =20 - *count =3D ib_dma_map_sg(ibdev, req->data_sgl.sg_table.sgl, - req->data_sgl.nents, rq_dma_dir(rq)); - if (unlikely(*count <=3D 0)) { - ret =3D -EIO; + sgt =3D (struct sg_table) { + .sgl =3D req->data_sgl.sg_table.sgl, + .orig_nents =3D req->data_sgl.nents, + }; + ret =3D ib_dma_map_sgtable_attrs(ibdev, &sgt, rq_dma_dir(rq), 0); + if (unlikely(ret)) goto out_free_table; - } + *count =3D sgt.nents; =20 if (blk_integrity_rq(rq)) { req->metadata_sgl->sg_table.sgl =3D @@ -1501,14 +1504,14 @@ static int nvme_rdma_dma_map_req(struct ib_device *= ibdev, struct request *rq, =20 req->metadata_sgl->nents =3D blk_rq_map_integrity_sg(rq, req->metadata_sgl->sg_table.sgl); - *pi_count =3D ib_dma_map_sg(ibdev, - req->metadata_sgl->sg_table.sgl, - req->metadata_sgl->nents, - rq_dma_dir(rq)); - if (unlikely(*pi_count <=3D 0)) { - ret =3D -EIO; + sgt =3D (struct sg_table) { + .sgl =3D req->metadata_sgl->sg_table.sgl, + .orig_nents =3D req->metadata_sgl->nents, + }; + ret =3D ib_dma_map_sgtable_attrs(ibdev, &sgt, rq_dma_dir(rq), 0); + if (unlikely(ret)) goto out_free_pi_table; - } + *pi_count =3D sgt.nents; } =20 return 0; @@ -2026,8 +2029,6 @@ static blk_status_t nvme_rdma_queue_rq(struct blk_mq_= hw_ctx *hctx, if (ret) goto unmap_qe; =20 - nvme_start_request(rq); - if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) && queue->pi_support && (c->common.opcode =3D=3D nvme_cmd_write || @@ -2039,11 +2040,13 @@ static blk_status_t nvme_rdma_queue_rq(struct blk_m= q_hw_ctx *hctx, =20 err =3D nvme_rdma_map_data(queue, rq, c); if (unlikely(err < 0)) { - dev_err(queue->ctrl->ctrl.device, - "Failed to map data (%d)\n", err); + dev_err_ratelimited(queue->ctrl->ctrl.device, + "Failed to map data (%d)\n", err); goto err; } =20 + nvme_start_request(rq); + sqe->cqe.done =3D nvme_rdma_send_done; =20 ib_dma_sync_single_for_device(dev, sqe->dma, @@ -2063,6 +2066,9 @@ static blk_status_t nvme_rdma_queue_rq(struct blk_mq_= hw_ctx *hctx, ret =3D nvme_host_path_error(rq); else if (err =3D=3D -ENOMEM || err =3D=3D -EAGAIN) ret =3D BLK_STS_RESOURCE; + /* Peer memory unreachable from this device: don't retry. */ + else if (err =3D=3D -EREMOTEIO) + ret =3D BLK_STS_TARGET; else ret =3D BLK_STS_IOERR; nvme_cleanup_cmd(rq); --=20 2.52.0