From patchwork Thu Nov 28 11:22:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13887940 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 834DA19AD8B for ; Thu, 28 Nov 2024 11:45:57 +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=1732794359; cv=none; b=T1znoa0OwMeu/aPn5REvsZP4fO1ssWiAVhBgM+TW4lJFgim7u19xzj5WTINbrCplUE8HMc3D9r9KZbrICYqkbJVoQBf2qjxJVCiO3oHb+KpiDyQa76B9+21CZhH4ieVO0CvJrflW1+ODUPHVP21B06CvVPJFvI0TS3tRRyOkok0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732794359; c=relaxed/simple; bh=g2fp64Elfp9R80cl3zu6i89Ehrxw1OCNHe/eXuK93qM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=XUa20qcIeyTgZN2fcd2chzNtpyObkimgOdIIjs25sst7VNS2GYKVBJvn4SGbX+KgpQqq9Am94wC1/zFGbSCjzjF5PJyiTYe9YE0U9rQrBZBXtrj7iBuGg0BLMCaxAJieAnZQBZd7SPZX7kxXMA9jApC3DDcexs9R0ZlksRpKnm4= 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=r2RGuylJ; 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="r2RGuylJ" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241128114555epoutp026fcafc63c5a3e0b145b6036c5f2d2f83~MH0kRIQne1279812798epoutp02C for ; Thu, 28 Nov 2024 11:45:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241128114555epoutp026fcafc63c5a3e0b145b6036c5f2d2f83~MH0kRIQne1279812798epoutp02C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1732794355; bh=FQM1oME+yjLcszh/NNdlGeevLgEVh+e4WfItNIpaOVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r2RGuylJhHYpxtovtgeiOV8PXusomywuf6dxPTVuD7qsu6x25+7l7nupUO0uQQ9pS OHWViXD4dn1uwF+hGKT964g+3kF8H2ksy5TYSS56ykSi0C8e+yC4l4xHaoBiZVsoYf 8I0Is1T8TEBRReviGiuH7+NbR6lBo6nN4uTI3C+c= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241128114554epcas5p2c9df787ad8145e598d3817c5db00bcca~MH0jhfO8m1857618576epcas5p28; Thu, 28 Nov 2024 11:45:54 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.182]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4XzZJH2fn4z4x9Pr; Thu, 28 Nov 2024 11:45:51 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E6.B3.19710.FE758476; Thu, 28 Nov 2024 20:45:51 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20241128113058epcas5p1f544aa328a27b59f96b48b94dc0bdf94~MHnhJguS-1316913169epcas5p1r; Thu, 28 Nov 2024 11:30:58 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241128113058epsmtrp2b79823e07685711bd53938c807451bc2~MHnhIiCRN3231632316epsmtrp2k; Thu, 28 Nov 2024 11:30:58 +0000 (GMT) X-AuditID: b6c32a44-36bdd70000004cfe-81-674857efef9e Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 32.58.33707.27458476; Thu, 28 Nov 2024 20:30:58 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241128113056epsmtip211016eab1dc2a7836a08fd9d6c853c49~MHne1hoN12660826608epsmtip2H; Thu, 28 Nov 2024 11:30:56 +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 v11 02/10] block: copy back bounce buffer to user-space correctly in case of split Date: Thu, 28 Nov 2024 16:52:32 +0530 Message-Id: <20241128112240.8867-3-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241128112240.8867-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrNJsWRmVeSW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8+28+w/LQqbEa29bPcg97f7x+wZ5JLypdn701 1dXY8XiughXPK6fu9Nd3Cti/Xr8cnH176ez1h65rvH+imfFRo5TVVPbs5ML0zeJ+CxSNln/s OznzaLesdOPm+JrreessCuc5HNkmdJDxIH/Liqf5SWd+vShvCVp+LsDkSu8B/jTPeRt1TatF 5zQJHAi133D8Zoe05LslTUaHRMTOr3okrexjNv2yReZhH7NDAms7Q0onyXLu/1IpOv2ac4oS S3FGoqEWc1FxIgB2wfXMHwMAAA== X-CMS-MailID: 20241128113058epcas5p1f544aa328a27b59f96b48b94dc0bdf94 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241128113058epcas5p1f544aa328a27b59f96b48b94dc0bdf94 References: <20241128112240.8867-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); } /**