From patchwork Tue Oct 29 16:23:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13855247 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF02E1DA305 for ; Tue, 29 Oct 2024 17:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222620; cv=none; b=HmTyaAT6zKbXoQ3DfgqqBAbTr9zxLNQed1mH4CkYHHgKtVfIYnFjHRlI42EltQ0Am6sQnB8hek3AFTCHrQ+iinYxPQgkjFTh6FriqrZ7rrEDkkcId1daryAIAY+Uwoq5p+OgFGgPkvj0aVf9P/PNACKcL4x6+AUKbhD9KfB0/eQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222620; c=relaxed/simple; bh=u4sUcEX/k+wez75P184+zcG/4LIpxzsuKCd9h01C0oc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=I6q/DEvtwEJGtfMD/B0ZlWlgjvsNKKhhLKYJInb1qa+wZebq9LU9kxbYkIedDBD0KZAF+kgGPMaETbn0RJ2HWQwv4zQjazDdaUcE9An42yWGnZseQr1bBbYCznZn2QzG8O69WizWlRuJL5tQsC8fMTMQXFzeY3WBYIB9cd6LPgI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=GLduJASx; arc=none smtp.client-ip=203.254.224.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="GLduJASx" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241029172335epoutp014dec8053c643aff7d01b5320fa2433c8~C-E1WgWzc2983329833epoutp01D for ; Tue, 29 Oct 2024 17:23:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241029172335epoutp014dec8053c643aff7d01b5320fa2433c8~C-E1WgWzc2983329833epoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730222615; bh=1yEesIXP8hqj3mWCayZYKotAS9KxK7WmVJifezfxMwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GLduJASx6XouFM0VMY4gFhHacTRWDJqN2yJGc/zFyBliGOMe69jzjxiwsy5w7qRmC q0Tu/Didt6YsvYUu9gaI5mx71fLbzkQ75H69mc3LdwnVhO8uFhSNS99PAY2Nn3xgrh UjTv1UnRCV3R4PYlQcVFENj6X+BwVB/8u+ZEaG+A= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20241029172335epcas5p4b9aeaf624b86420921a9231cc1551bee~C-E0vVZsB1636716367epcas5p4B; Tue, 29 Oct 2024 17:23:35 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.174]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XdHCn3w11z4x9Pv; Tue, 29 Oct 2024 17:23:33 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 02.F9.09420.51A11276; Wed, 30 Oct 2024 02:23:33 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20241029163214epcas5p1069ca93a2a9d8840e4f142cc4b713775~C_X-v4_OV2340523405epcas5p1A; Tue, 29 Oct 2024 16:32:14 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241029163214epsmtrp1c51dc3fc90333bdd1c5a8dcc372ba54f~C_X-vDYut0708307083epsmtrp1K; Tue, 29 Oct 2024 16:32:14 +0000 (GMT) X-AuditID: b6c32a49-0d5ff700000024cc-52-67211a15b45d Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id D4.07.08227.E0E01276; Wed, 30 Oct 2024 01:32:14 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241029163212epsmtip2c07a03b121b4c271c42f7bd3adf8681f~C_X9alVN10998409984epsmtip2W; Tue, 29 Oct 2024 16:32:12 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta Subject: [PATCH v5 02/10] block: copy back bounce buffer to user-space correctly in case of split Date: Tue, 29 Oct 2024 21:53:54 +0530 Message-Id: <20241029162402.21400-3-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241029162402.21400-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+Ng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 srw7XGpdZw/esX0if+ffHFNpaXf7E7+rjn3wtmaokCxMNZ86Vyhkfgab78H9+1517LK8YGmc f52Pf4fQnG47o7ZNybZXzu1U2i4m9nD/rSibGS0z27T+/JE2EnsW/59B45xKNuvz/87ZH2fZ Zr1fu/pGpY/1OcPKF01+q42kJsoqrNoQddDh6P5//qsj5FIKzq548HChhQ+vZu753U/nZdxy vvVUUYmlOCPRUIu5qDgRAL6ZvHUhAwAA X-CMS-MailID: 20241029163214epcas5p1069ca93a2a9d8840e4f142cc4b713775 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241029163214epcas5p1069ca93a2a9d8840e4f142cc4b713775 References: <20241029162402.21400-1-anuj20.g@samsung.com> From: Christoph Hellwig Copy back the bounce buffer to user-space in entirety when the parent bio completes. The existing code uses bip_iter.bi_size for sizing the copy, which can be modified. So move away from that and fetch it from the vector passed to the block layer. While at it, switch to using better variable names. Fixes: 492c5d455969f ("block: bio-integrity: directly map user buffers") Signed-off-by: Anuj Gupta [hch: better names for variables] Signed-off-by: Christoph Hellwig Reviewed-by: Keith Busch --- block/bio-integrity.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index a448a25d13de..4341b0d4efa1 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -118,17 +118,18 @@ static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs, static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip) { - unsigned short nr_vecs = bip->bip_max_vcnt - 1; - struct bio_vec *copy = &bip->bip_vec[1]; - size_t bytes = bip->bip_iter.bi_size; - struct iov_iter iter; + unsigned short orig_nr_vecs = bip->bip_max_vcnt - 1; + struct bio_vec *orig_bvecs = &bip->bip_vec[1]; + struct bio_vec *bounce_bvec = &bip->bip_vec[0]; + size_t bytes = bounce_bvec->bv_len; + struct iov_iter orig_iter; int ret; - iov_iter_bvec(&iter, ITER_DEST, copy, nr_vecs, bytes); - ret = copy_to_iter(bvec_virt(bip->bip_vec), bytes, &iter); + iov_iter_bvec(&orig_iter, ITER_DEST, orig_bvecs, orig_nr_vecs, bytes); + ret = copy_to_iter(bvec_virt(bounce_bvec), bytes, &orig_iter); WARN_ON_ONCE(ret != bytes); - bio_integrity_unpin_bvec(copy, nr_vecs, true); + bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs, true); } /**