From patchwork Thu Nov 14 10:45:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13875013 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (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 8C4031F8935 for ; Thu, 14 Nov 2024 11:20:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583248; cv=none; b=GFA2ytNJtLebQy7wBkI58HkRAuprA+dn8g0bwKNDcALKQGLy+fR0XIBrGx7DX/0JSF7kocQRGzmfCb2enRxhH4SouluLcmS0gOADZ5qzAABfOJAT+4nXAIA/G3WJfkTG7AyUvIIQm6dIhxEbWwS2Z7pYjDsDQFBswFmnsUsy9TY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731583248; c=relaxed/simple; bh=g2fp64Elfp9R80cl3zu6i89Ehrxw1OCNHe/eXuK93qM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=EzftFklJYoc+7RaRP9v70iGvoIdkzmekxSNbGXfgFDfX8pUHXgCNFXtGALXF6h5rKupMcGPjQxl7JLOsxkMEU5i6VDQuOA87aaiu2241+qRa31XyI3RInhNktV6G7c7wt3322nbvIJhtZXZ4N1TAwhNscetIxu8qAFwaNawddZM= 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=gxHkNspw; arc=none smtp.client-ip=203.254.224.25 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="gxHkNspw" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241114112044epoutp02a87a4d6f06fb0465c04b5c9ca76a5d71~H0clzKQxv0586405864epoutp02h for ; Thu, 14 Nov 2024 11:20:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241114112044epoutp02a87a4d6f06fb0465c04b5c9ca76a5d71~H0clzKQxv0586405864epoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731583244; bh=FQM1oME+yjLcszh/NNdlGeevLgEVh+e4WfItNIpaOVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gxHkNspwD3MvmqnzD+uT4PZfdSb3n0sUqgMfIMJJvQ3Y8h7FhCridryGEoCt9qV35 c3XIHfwlX+EWXFgGO03HIrcIQc/TYHxLotFRi7Wvw1CR0eNltzjZOm9xsMcGjGZUvz iX5QRnoXvOieoS7H3TOnyydbHHRhFv/87LCZ6o7Q= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241114112044epcas5p201405b0548d1fcb4fafdee083cdf0e3c~H0clL8nuO2483624836epcas5p2v; Thu, 14 Nov 2024 11:20:44 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.175]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XpyPj5wmNz4x9QP; Thu, 14 Nov 2024 11:20:41 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 28.4F.37975.C3CD5376; Thu, 14 Nov 2024 20:17:16 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241114105354epcas5p49a73947c3d37be4189023f66fb7ba413~H0FKDmn8J3038330383epcas5p4N; Thu, 14 Nov 2024 10:53:54 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241114105354epsmtrp15b28b4f295e4fa2d17925eab21257562~H0FKB5O4R1625716257epsmtrp1v; Thu, 14 Nov 2024 10:53:54 +0000 (GMT) X-AuditID: b6c32a50-085ff70000049457-97-6735dc3caa88 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F8.5A.07371.2C6D5376; Thu, 14 Nov 2024 19:53:54 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241114105352epsmtip2e2b0eed35b9ebb8f60e972629024a793~H0FHuq9Fv1405814058epsmtip2H; Thu, 14 Nov 2024 10:53:51 +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 v9 02/11] block: copy back bounce buffer to user-space correctly in case of split Date: Thu, 14 Nov 2024 16:15:08 +0530 Message-Id: <20241114104517.51726-3-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241114104517.51726-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAA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voipW GHRvaNs4f0vv70kTb2dN8IrzKPr/9v5shusTVjzv6H3Ta/XfI3je7n0Cmq/r9nTNv1fNeFph z447yZtjwtZdMNjUJXNB+/mFE0zr4ve/fLjDYYHaM9tuDd5lfldt2l0vvsx7WJTSt+Ro2vHL 5nvnSaxcXiQdYG7FVD9p3r9sFRM5S64zLrPtePuM3OMOJZmLeAXvaOR8PG2BX/nZ6A2860uX 3Pd/LrlfiaU4I9FQi7moOBEAaCGCdiIDAAA= X-CMS-MailID: 20241114105354epcas5p49a73947c3d37be4189023f66fb7ba413 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241114105354epcas5p49a73947c3d37be4189023f66fb7ba413 References: <20241114104517.51726-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: Christoph Hellwig Signed-off-by: Anuj Gupta 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); } /**