From patchwork Thu Apr 25 18:39:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13643655 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 4FAC26EB4E for ; Thu, 25 Apr 2024 18:47:03 +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=1714070825; cv=none; b=tNEm/PIMJe6h3+Ejof0B8IjU+zt99fczQfRAYcKalGXrrzrJLjO4RSjlnc/NLK3g4SRvA/2bOKcucPObJcqAKeoIUdoRzDngHgsAnSwUbZ4QjMR+0PR0llp4tuyU97brLa1Yy2ga/XX4YRZQZJPPNls+ta40h7YUWBfnixnY+aM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070825; c=relaxed/simple; bh=0zuD9gszrxLOfK8HJKkiv8NVBsKlq8lupJk3KzBU8ok=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=RcfDC/vEoFI0nJc6O7wiZohwddcJ1zXEA+YquTRlIgCp1y/1SCzQkMkuM/B6kriih2gJOUUNzzm1Mt4AC5TPzL25zvE7jj1+q1D9uuMqBBcuBH3ntO1WLG8C41ndQZZCqeoBTopqUPy60RsWICrEvVe0Ju6wvRpe097w/V0BAqw= 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=bYhiEqIM; 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="bYhiEqIM" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240425184655epoutp021b2a5bb37ae322ff3e53dc289be524f4~JmlM5YnLY2801828018epoutp02q for ; Thu, 25 Apr 2024 18:46:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240425184655epoutp021b2a5bb37ae322ff3e53dc289be524f4~JmlM5YnLY2801828018epoutp02q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1714070815; bh=aRbU1XKPvEeuwgaCiIvDBDmtfNhGzLeEHTExPWAIynM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bYhiEqIMOYIsKPXeih/PLo3m+M127zA+bL3KHmuFsV5BhkIi1kNU0KCCdIWqJzp+9 sy6VfdnpHMh/JT/4WEFJ6Vr12xjQUAUqwUBslTNO1rZn/TG9BWxWaatTDgyxCrJMQn rTUrACELQDNZo9/qN7n0tt5VidqTtQbbpFwcvCmw= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240425184654epcas5p26f282413236cf15e1c992c985ea04949~JmlLwLGk_2738327383epcas5p2j; Thu, 25 Apr 2024 18:46:54 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.183]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4VQPwD390Rz4x9Pp; Thu, 25 Apr 2024 18:46:52 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id C9.E6.19431.C15AA266; Fri, 26 Apr 2024 03:46:52 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240425184651epcas5p3404f2390d6cf05148eb96e1af093e7bc~JmlJoQfkR0824808248epcas5p3f; Thu, 25 Apr 2024 18:46:51 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240425184651epsmtrp245499ce6745e46d2ab1d88b3388c1748~JmlJnUZsw0238902389epsmtrp2b; Thu, 25 Apr 2024 18:46:51 +0000 (GMT) X-AuditID: b6c32a50-ccbff70000004be7-c0-662aa51c7ff8 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 8C.C2.19234.B15AA266; Fri, 26 Apr 2024 03:46:51 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240425184650epsmtip143df1e6819cfa539ae1ae7996e97cad2~JmlH25CSx3053530535epsmtip1s; Thu, 25 Apr 2024 18:46:49 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, martin.petersen@oracle.com, kbusch@kernel.org, hch@lst.de, brauner@kernel.org Cc: asml.silence@gmail.com, dw@davidwei.uk, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH 01/10] block: set bip_vcnt correctly Date: Fri, 26 Apr 2024 00:09:34 +0530 Message-Id: <20240425183943.6319-2-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425183943.6319-1-joshi.k@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: H4sIAAAAAAAAA02Sf0wTZxjH896d1ytbyVnYeNMswk6XIBvQjlKuC4hGQi7OLYDbPywGanvS hvZa+8PhTEaDA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jp3UeOkJYpsWqwLTzMKGa+ZE/zadNPc4naHw/sLchcVf1ooaDCncYX1p+JF ocIN3wsPeP53yPrsfLLSeNbD49uj9momhbz49V2JpTgj0VCLuag4EQD+boJzBAMAAA== X-CMS-MailID: 20240425184651epcas5p3404f2390d6cf05148eb96e1af093e7bc X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240425184651epcas5p3404f2390d6cf05148eb96e1af093e7bc References: <20240425183943.6319-1-joshi.k@samsung.com> From: Anuj Gupta Set the bip_vcnt correctly in bio_integrity_init_user and bio_integrity_copy_user. If the bio gets split at a later point, this value is required to set the right bip_vcnt in the cloned bio. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig --- block/bio-integrity.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 2e3e8e04961e..e3390424e6b5 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -254,6 +254,7 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec, bip->bip_flags |= BIP_INTEGRITY_USER | BIP_COPY_USER; bip->bip_iter.bi_sector = seed; + bip->bip_vcnt = nr_vecs; return 0; free_bip: bio_integrity_free(bio); @@ -275,6 +276,7 @@ static int bio_integrity_init_user(struct bio *bio, struct bio_vec *bvec, bip->bip_flags |= BIP_INTEGRITY_USER; bip->bip_iter.bi_sector = seed; bip->bip_iter.bi_size = len; + bip->bip_vcnt = nr_vecs; return 0; } From patchwork Thu Apr 25 18:39:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13643657 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 26FE914D2AE for ; Thu, 25 Apr 2024 18:47:04 +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=1714070827; cv=none; b=SgoGRKSAqWs9yTKYqYE776lCLMr+Q6fPNGwsDVVnjdPbBpecKaPBNNi8L8EAUAo487K0lrpWsCjVsyS6oJ3H/q5cAS03uDiGLgto36jmSwHD0A1/K2kWGEgwvrNBEMwOfGuYHPN9sIe6S5qB7l4B3LSJMjuG9AM8rqPF1EP+KTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070827; c=relaxed/simple; bh=kOhpakvYf08EPjB71ahhoVsLQyFkjn3TrcLEzDp72jc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=e7qPwP6XxOPqrWYfhIwD1VtckTh0HoVKtiHjOY+8H6ZNaK6ZFLci6oP80HoLFgyvEtYCBCYHdCw6Ls8ngtv9dbXO7HVb7k5gpFehUTWc5vGOb/jTDqYEpgv4LNvBoGpxUzw6hf2FwIJ3gpFUIW3HUntv4YS/pVmc/raQosw2Y2w= 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=EkWk0nZF; 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="EkWk0nZF" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240425184657epoutp016deeedfab20c4076afe91c8223b90cfd~JmlOb7Fwc0066600666epoutp01u for ; Thu, 25 Apr 2024 18:46:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240425184657epoutp016deeedfab20c4076afe91c8223b90cfd~JmlOb7Fwc0066600666epoutp01u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1714070817; bh=8UjWzASLbE281aLekYBWGcVUrDYfR/50j9EjsKMziS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EkWk0nZFFZR+UZPyMT3GvkvBnqBu8Ir0x2eKAXzvLVPGuZ/zaYZ+XLZ7vPDMFrndK 6CdiDg98Eole7XqWegqjEo7GV6nC2/+lY+bGx1B+3vcv1aJyLaabEr11jwQbyHz0gl p5rjRcNhC0GFBvJAB2wyJTeFCvDRtSEHAH+HkE3g= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240425184656epcas5p35ee096051f0bbb21f8542a38aabb4ea6~JmlNhW5YC0824808248epcas5p3h; Thu, 25 Apr 2024 18:46:56 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.177]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4VQPwG354Fz4x9Pp; Thu, 25 Apr 2024 18:46:54 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id A7.20.09665.E15AA266; Fri, 26 Apr 2024 03:46:54 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240425184653epcas5p28de1473090e0141ae74f8b0a6eb921a7~JmlLj1-nc2219922199epcas5p2p; Thu, 25 Apr 2024 18:46:53 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240425184653epsmtrp15999b231b11a167202adf9a316909721~JmlLjFbN_0085200852epsmtrp1N; Thu, 25 Apr 2024 18:46:53 +0000 (GMT) X-AuditID: b6c32a4b-829fa700000025c1-13-662aa51ea6f3 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F8.F0.07541.D15AA266; Fri, 26 Apr 2024 03:46:53 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240425184652epsmtip15304991c802986bd2c08f53595bdaacf~JmlJv392M3082730827epsmtip1Y; Thu, 25 Apr 2024 18:46:51 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, martin.petersen@oracle.com, kbusch@kernel.org, hch@lst.de, brauner@kernel.org Cc: asml.silence@gmail.com, dw@davidwei.uk, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH 02/10] block: copy bip_max_vcnt vecs instead of bip_vcnt during clone Date: Fri, 26 Apr 2024 00:09:35 +0530 Message-Id: <20240425183943.6319-3-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425183943.6319-1-joshi.k@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+NgFlrHJsWRmVeSWpSXmKPExsWy7bCmhq7cUq00g1k3BC2aJvxltpizahuj xeq7/WwWrw9/YrR4NWMtm8XNAzuZLFauPspk8a71HIvF0f9v2SwmHbrGaLH3lrbF/GVP2S2W H//H5MDrcW3GRBaPnbPusntcPlvqsWlVJ5vH5iX1HrtvNrB5fHx6i8Wjb8sqRo/Pm+QCOKOy bTJSE1NSixRS85LzUzLz0m2VvIPjneNNzQwMdQ0tLcyVFPISc1NtlVx8AnTdMnOArlZSKEvM KQUKBSQ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pSXmKPExsWy7bCSnK7sUq00g03NZhZNE/4yW8xZtY3R YvXdfjaL14c/MVq8mrGWzeLmgZ1MFitXH2WyeNd6jsXi6P+3bBaTDl1jtNh7S9ti/rKn7BbL j/9jcuD1uDZjIovHzll32T0uny312LSqk81j85J6j903G9g8Pj69xeLRt2UVo8fnTXIBnFFc NimpOZllqUX6dglcGTuvvWAtuM9RcezZTZYGxsXsXYycHBICJhK31m9k7WLk4hAS2M0oMXPS BGaIhLhE87UfUEXCEiv/PWeHKPrIKHF43mSWLkYODjYBTYkLk0tBakQEsiT29l8Bq2EWeMso Mf/vHrBBwgKhEn+mv2AGqWcRUJW49NsIJMwrYC4xbWUvK8R8eYmZl76D7eIUsJCYfPE0mC0E VDN1zSJGiHpBiZMzn7CA2MxA9c1bZzNPYBSYhSQ1C0lqASPTKkbJ1ILi3PTcZMMCw7zUcr3i xNzi0rx0veT83E2M4JjR0tjBeG/+P71DjEwcjIcYJTiYlUR4b37USBPiTUmsrEotyo8vKs1J LT7EKM3BoiTOazhjdoqQQHpiSWp2ampBahFMlomDU6qB6cipWw3Fkw+dXl0YKXFwZ+fyhIDT m7Y/O//9g5+4uNbFxddDJ8clLyh+Vt4x36vRVfmo/WXzBUVSbeeZ7/K67/Ce81HnopRDaMxt lozC+isvl8vPyXhawL10YsH85b6HSjw+vHjVNFM12DPHR+Nc66atGdsUmAKTxX8+j5p66Okf 0Ul/RaIr2D+bsB79wb6sqpzf1T+F713Lz3s2KxsFrgTysvoe8/fr7b1WfSzNfHFf9bvnnNKX b1icuch3J/lK1eHr6cL976J9583TvDD357omcb7FTRKiu/7snXTd5JRTJtf81Uldmbs1/m/K 9TG0X6PmWWW4fErwtszZgXtvCYX46O9TXeA7+1/apefdfkosxRmJhlrMRcWJAG8TR5QIAwAA X-CMS-MailID: 20240425184653epcas5p28de1473090e0141ae74f8b0a6eb921a7 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240425184653epcas5p28de1473090e0141ae74f8b0a6eb921a7 References: <20240425183943.6319-1-joshi.k@samsung.com> From: Anuj Gupta If bio_integrity_copy_user is used to process the meta buffer, bip_max_vcnt is one greater than bip_vcnt. In this case bip_max_vcnt vecs needs to be copied to cloned bip. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- block/bio-integrity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index e3390424e6b5..c1955f01412e 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -622,12 +622,12 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, BUG_ON(bip_src == NULL); - bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_vcnt); + bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_max_vcnt); if (IS_ERR(bip)) return PTR_ERR(bip); memcpy(bip->bip_vec, bip_src->bip_vec, - bip_src->bip_vcnt * sizeof(struct bio_vec)); + bip_src->bip_max_vcnt * sizeof(struct bio_vec)); bip->bip_vcnt = bip_src->bip_vcnt; bip->bip_iter = bip_src->bip_iter; From patchwork Thu Apr 25 18:39:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13643658 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 7869F149DFD for ; Thu, 25 Apr 2024 18:47:06 +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=1714070828; cv=none; b=uBtEoX7ZYJBjLqfj0EPNdiIXLiQgTL1T5Edo6fQ44b3pUckiODIv//5dEIzpeQrCrTEIV7THxJd3DRQUhEMegd381IplDOK5ZmcCh7D/xICDTgV58TX/Q0zZQY/Vs/1g6Ll9EF3fbSlZRLM+sWey+5Eu4C0rsePqaBO6yPbfugY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070828; c=relaxed/simple; bh=tu3vNQfF5iF/HqabzcCL7d4l4ldyHCclld5bafxBYoA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=cL5luxRoUJ//AA34D+H+rHSjFO+2JsJVGmtYuZDc8AQcOzihf1RKRILlPLen+1eaVQhCSlgcEpIerBvNM4p8Hbo4/av+EL0Hcmf/+oZz7gYvKCsXTtmQfJ1msktyHSMZ3HM1P5Cn234/+1lPhRjuXz3/blp6mAwgJisHz9fvsOs= 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=cRiQ9fqm; 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="cRiQ9fqm" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240425184659epoutp01e84c1d79ea59a30146361ec91ebd9336~JmlQcdtTf3260632606epoutp017 for ; Thu, 25 Apr 2024 18:46:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240425184659epoutp01e84c1d79ea59a30146361ec91ebd9336~JmlQcdtTf3260632606epoutp017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1714070819; bh=ZsVoWy3S7pVMyWodKivCv3lhvh2UtU0BIm04ZdY7CeI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRiQ9fqmaXDJzx/v1DMgoMw173NrD46B3YWhMM6uj7UT7w0C+K+zS00qN87QhH5xd gI5qdQ6vvOg+L5Bp53+SOktO/hFWYFsrMGX/ay0Ek6z3a68W+PIhi+vStZN9W8iBUF dsgSCg5oc4JQRhhrP6mcSZgxRsTP6jQJGAip4tHw= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240425184658epcas5p24e2579ceaa12477ac46bf02ece097130~JmlQBXrcS1533515335epcas5p2B; Thu, 25 Apr 2024 18:46:58 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.177]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4VQPwK0sMWz4x9Pp; Thu, 25 Apr 2024 18:46:57 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 15.72.08600.025AA266; Fri, 26 Apr 2024 03:46:57 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240425184656epcas5p42228cdef753cf20a266d12de5bc130f0~JmlNcxsdr1482414824epcas5p4e; Thu, 25 Apr 2024 18:46:56 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240425184656epsmtrp1f83ebcb4478fd493e8ff02931983235b~JmlNcEobB0085000850epsmtrp1U; Thu, 25 Apr 2024 18:46:56 +0000 (GMT) X-AuditID: b6c32a44-6c3ff70000002198-ca-662aa5204f69 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 6D.C2.19234.F15AA266; Fri, 26 Apr 2024 03:46:55 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240425184654epsmtip16e320a8c4939754f33ddec3ede5df744~JmlLpX8mS3266832668epsmtip13; Thu, 25 Apr 2024 18:46:53 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, martin.petersen@oracle.com, kbusch@kernel.org, hch@lst.de, brauner@kernel.org Cc: asml.silence@gmail.com, dw@davidwei.uk, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH 03/10] block: copy result back to user meta buffer correctly in case of split Date: Fri, 26 Apr 2024 00:09:36 +0530 Message-Id: <20240425183943.6319-4-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425183943.6319-1-joshi.k@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+NgFtrIJsWRmVeSWpSXmKPExsWy7bCmuq7iUq00g5PdzBZNE/4yW8xZtY3R YvXdfjaL14c/MVq8mrGWzeLmgZ1MFitXH2WyeNd6jsXi6P+3bBaTDl1jtNh7S9ti/rKn7BbL j/9jcuD1uDZjIovHzll32T0uny312LSqk81j85J6j903G9g8Pj69xeLRt2UVo8fnTXIBnFHZ NhmpiSmpRQqpecn5KZl56bZK3sHxzvGmZgaGuoaWFuZKCnmJuam2Si4+AbpumTlAVysplCXm lAKFAhKLi5X07WyK8ktLUhUy8otLbJVSC1JyCkwK9IoTc4tL89L18lJLrAwNDIxMgQoTsjM+ ru1nL1jCVfFx5nfGBsYbHF2MnBwSAiYSh9Y8Z+9i5OIQEtjNKHH2w0VWCOcTo8SKI6sRnNsf d7HCtDS33oJq2ckosebMW0YI5zOjxLuOuSxdjBwcbAKaEhcml4I0iAikSLxa95oRxGYWeMoo 8aOTCaREWCBeonFnJEiYRUBV4suubSwgNq+AucSW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KXDp+ mw0iIS7RfO0HO4QtLLHy33Oooo+MEl9nTmTuYuTgYBPQlLgwuRSkRkQgS2Jv/xWwGmaBt4wS 8//uYQZJCAvESpyd38YKYrMIqEp82bWNBcTmFTCX2NLcxgixQF5i5qXvYMs4BSwkJl88DWYL AdVMXbOIEaJeUOLkzCdgvcxA9c1bZzNPYBSYhSQ1C0lqASPTKkbR1ILi3PTc5AJDveLE3OLS vHS95PzcTYzgaNEK2sG4bP1fvUOMTByMhxglOJiVRHhvftRIE+JNSaysSi3Kjy8qzUktPsQo zcGiJM6rnNOZIiSQnliSmp2aWpBaBJNl4uCUamDaesnwkYb5UYbCHS39+VUbp17emD11nVmJ yZuHbaJO9ikSaYvvN/VGtuy1j6t+c6rIIMRqmeDci1EGHrYd5Vt7Z79xiTeb5RZ5IaFxd2+5 5EK+4PPzZTZMd9hdcW3yGysv/9eXbsbWx3HOmr987/tknVTNJ3v/ip/829szfb3gtd9nTa12 Lfmc6XrzkUyZz8cAUZu3Hg6FM6ctuyTRs3dxktDn5bNZIg67HP198c3e7kc/31nff7TX1Wma /MVTxx/fyVHmVN9srjk7qTn/ZrDIosmeXdVVVqFKdqKeEmEsfgFLVFLY8h2u9Jioxv49tcuu 12vpa8fyiypPD9VWb7241+e005eLZ1oMz+hPZTykxFKckWioxVxUnAgATUJq2wUDAAA= X-CMS-MailID: 20240425184656epcas5p42228cdef753cf20a266d12de5bc130f0 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240425184656epcas5p42228cdef753cf20a266d12de5bc130f0 References: <20240425183943.6319-1-joshi.k@samsung.com> From: Anuj Gupta In case of split, the len and offset of bvec gets updated in the iter. Use it to fetch the right bvec, and copy it back to user meta buffer. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- block/bio-integrity.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index c1955f01412e..b4042414a08f 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -108,11 +108,15 @@ 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 bio_vec copy_bvec, src_bvec; struct iov_iter iter; int ret; - iov_iter_bvec(&iter, ITER_DEST, copy, nr_vecs, bytes); - ret = copy_to_iter(bvec_virt(bip->bip_vec), bytes, &iter); + copy_bvec = mp_bvec_iter_bvec(copy, bip->bip_iter); + src_bvec = mp_bvec_iter_bvec(bip->bip_vec, bip->bip_iter); + + iov_iter_bvec(&iter, ITER_DEST, ©_bvec, nr_vecs, bytes); + ret = copy_to_iter(bvec_virt(&src_bvec), bytes, &iter); WARN_ON_ONCE(ret != bytes); bio_integrity_unpin_bvec(copy, nr_vecs, true); From patchwork Thu Apr 25 18:39:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13643661 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (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 5B7931514DD for ; Thu, 25 Apr 2024 18:47:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070831; cv=none; b=MfVjVqEuAZ1DPsiS/lrs0O53PPLDXHZhHv87dFIY/Jky26HljCWaOiK4n28rqT/LsiWs2KA+w4pMAunGx0dFzhiP/im6NELCHJlgwDxZ7t5gGFqXLnc350p3qYgHa/s3qR51hJFJ3mHDSYg9KNzRHa245vZZuO2qkJb6NITf+GU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070831; c=relaxed/simple; bh=LJSHEEALYuYlUhgwGg0LriiebY8Ob71WhJkAcd/6hao=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=RFCC7Rh1q7HCEyjcoML6S3tJQ+zQ0ncpqMyJ215oCxzaLEhZI5sVuuoOQEz7rKKZquOXJcC6trI+C0Rr07i/s29E23yqbkL6bR+QNFbQMo2EG/5HZ+oTqdi2EQIQgfOi3a45u+Gkzayh7TgFTBombwxfBgp1vWhF64Rchem6myM= 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=hrfIkLM5; arc=none smtp.client-ip=203.254.224.34 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="hrfIkLM5" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240425184701epoutp04f3f9b45d0e36f97b879276a10a3c972a~JmlS5GAP80315103151epoutp046 for ; Thu, 25 Apr 2024 18:47:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240425184701epoutp04f3f9b45d0e36f97b879276a10a3c972a~JmlS5GAP80315103151epoutp046 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1714070821; bh=y7q5DBA+dQSHzSzTE+I2A8FpCK4wGEC6e38FcbiE8dM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hrfIkLM5Ko722p/A170VQ9L01uKGMvw2rTG02DnA1u9x0WamMgT/HalDHS0rMvP56 hI8AZCeoWvEkZLf3AJGf9zM7W4tLPz16PCRObAHPO0tGSwLc8qQ5Tvxb2KBPP4o3io Wdzj6M9q3efpD7K1wwlw75uPoZ7RUNe9HPosSrbE= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240425184700epcas5p16182b7694f4eb5278108585ab6122d47~JmlRs8YMB1431014310epcas5p1D; Thu, 25 Apr 2024 18:47:00 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.183]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4VQPwL5sKzz4x9Pt; Thu, 25 Apr 2024 18:46:58 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F5.72.08600.225AA266; Fri, 26 Apr 2024 03:46:58 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240425184658epcas5p2adb6bf01a5c56ffaac3a55ab57afaf8e~JmlPT_CW42219922199epcas5p2t; Thu, 25 Apr 2024 18:46:58 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240425184658epsmtrp28f3c47bbf444e46e51d01a1353aca379~JmlPTSy700239002390epsmtrp2Z; Thu, 25 Apr 2024 18:46:58 +0000 (GMT) X-AuditID: b6c32a44-921fa70000002198-cd-662aa522290c Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 8E.C2.19234.125AA266; Fri, 26 Apr 2024 03:46:57 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240425184656epsmtip15159a669c0532a2ebf6c4175721ddf12~JmlNibyJU3082730827epsmtip1Z; Thu, 25 Apr 2024 18:46:55 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, martin.petersen@oracle.com, kbusch@kernel.org, hch@lst.de, brauner@kernel.org Cc: asml.silence@gmail.com, dw@davidwei.uk, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH 04/10] block: avoid unpinning/freeing the bio_vec incase of cloned bio Date: Fri, 26 Apr 2024 00:09:37 +0530 Message-Id: <20240425183943.6319-5-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425183943.6319-1-joshi.k@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+NgFtrEJsWRmVeSWpSXmKPExsWy7bCmlq7SUq00g6NNuhZNE/4yW8xZtY3R YvXdfjaL14c/MVq8mrGWzeLmgZ1MFitXH2WyeNd6jsXi6P+3bBaTDl1jtNh7S9ti/rKn7BbL j/9jcuD1uDZjIovHzll32T0uny312LSqk81j85J6j903G9g8Pj69xeLRt2UVo8fnTXIBnFHZ NhmpiSmpRQqpecn5KZl56bZK3sHxzvGmZgaGuoaWFuZKCnmJuam2Si4+AbpumTlAVysplCXm lAKFAhKLi5X07WyK8ktLUhUy8otLbJVSC1JyCkwK9IoTc4tL89L18lJLrAwNDIxMgQoTsjMO fXrLUjCBu6J94QfGBsadnF2MnBwSAiYSX25cYe9i5OIQEtjNKNFz/zYThPOJUeLrpQZWOGfG oilMMC1TN29ghkjsZJSYtfAWVNVnRonFrzuAqjg42AQ0JS5MLgVpEBFIkXi17jUjiM0s8JRR 4kcn2CBhgQiJ3Yuus4PYLAKqEt3zv4HFeQXMJY4dXcgIsUxeYual72A1nAIWEpMvnmaHqBGU ODnzCQvETHmJ5q2zwQ6SEFjLIfFr0j52iGYXiUc3f0INEpZ4dXwLVFxK4vO7vWwQdrLEpZnn oD4rkXi85yCUbS/ReqqfGeQX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CzJeXmHnpO9guTgELickXT4PZ QkA1U9csYoSoF5Q4OfMJC4jNDFTfvHU28wRGgVlIUrOQpBYwMq1iFE0tKM5Nz00uMNQrTswt Ls1L10vOz93ECI4VraAdjMvW/9U7xMjEwXiIUYKDWUmE9+ZHjTQh3pTEyqrUovz4otKc1OJD jNIcLErivMo5nSlCAumJJanZqakFqUUwWSYOTqkGpnrps0r+m4XDYqbXKeh83RDPv2LzqhUN GS8EM6Q/9MhNmvM/c8aH7hOVLX6TT2ypjpQ4JLjx74Qum6k/5/WKzVjzak5zz4SZnG9nf582 b1OBT1TJZ60ThxarqH2POTUzqeVyQNPPewuVeL2C12TYFrl8MpuYonPjM6vJpzbR+SnsjIpK 9XsXzufauain8/OZli2b2bTjvCa3rFvt9P6Alt+5P40ng1Xf1G2+sd3lldGbLVtnnX/47Y5z csm0O1aKm58+/HG5xmmBxJLXpvvUftnd0O6VTfoQ0nmISzru0cEe0e2bV5zTqW5+bZpwd4XU yb1HlvqtXG3+eFOQ26bGq59+lP9ZmSc0zcV5q8GDwskTlViKMxINtZiLihMBC75WrQQDAAA= X-CMS-MailID: 20240425184658epcas5p2adb6bf01a5c56ffaac3a55ab57afaf8e X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240425184658epcas5p2adb6bf01a5c56ffaac3a55ab57afaf8e References: <20240425183943.6319-1-joshi.k@samsung.com> From: Anuj Gupta Do it only once when the parent bio completes. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- block/bio-integrity.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index b4042414a08f..b698eb77515d 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -119,7 +119,8 @@ static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip) ret = copy_to_iter(bvec_virt(&src_bvec), bytes, &iter); WARN_ON_ONCE(ret != bytes); - bio_integrity_unpin_bvec(copy, nr_vecs, true); + if (!bio_flagged((bip->bip_bio), BIO_CLONED)) + bio_integrity_unpin_bvec(copy, nr_vecs, true); } static void bio_integrity_unmap_user(struct bio_integrity_payload *bip) @@ -129,11 +130,14 @@ static void bio_integrity_unmap_user(struct bio_integrity_payload *bip) if (bip->bip_flags & BIP_COPY_USER) { if (dirty) bio_integrity_uncopy_user(bip); - kfree(bvec_virt(bip->bip_vec)); + if (!bio_flagged((bip->bip_bio), BIO_CLONED)) + kfree(bvec_virt(bip->bip_vec)); return; } - bio_integrity_unpin_bvec(bip->bip_vec, bip->bip_max_vcnt, dirty); + if (!bio_flagged((bip->bip_bio), BIO_CLONED)) + bio_integrity_unpin_bvec(bip->bip_vec, bip->bip_max_vcnt, + dirty); } /** From patchwork Thu Apr 25 18:39:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13643656 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 3FA1214D444 for ; Thu, 25 Apr 2024 18:47:04 +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=1714070827; cv=none; b=L+bTwUeolJg0joMkvxJDvtu+P+SWu4R/78P2ymxXIYT+zS43rT0lUbo6/OnQjVeyHrj8QqnVvrN/uz2bjbM4EvpQhab64g0lS6y3ZHQDZYeJrxn8ojay5wJttcNtbwmu2plMJ1oUQDQK9J8T0SfgfKsSWDBxUABm6BbcGWZut7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070827; c=relaxed/simple; bh=oZigtMmHFc2xU6q3JTmVHi100BSKVm2meDvtnKse2JI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=OLHC41AVgcQTMp7xAO+/Woy1DrVPAYrSjghnF4pH9HvIA2/d2Q0lpTBTiRtz1XqKB4P6YXMTGq464WvKvmARsBOqv9QDZGzC0hYNNMogExU8x0Pt1HPIfxn+zaIg3aRIRqSitH26anrpdXB/WkLY/Aa5sr2sBcuupHsr3K6Z9QU= 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=UIFbaquY; 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="UIFbaquY" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240425184703epoutp02ee42d650374338fdd9b257bf1179828f~JmlUJ1JVv2801828018epoutp02v for ; Thu, 25 Apr 2024 18:47:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240425184703epoutp02ee42d650374338fdd9b257bf1179828f~JmlUJ1JVv2801828018epoutp02v DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1714070823; bh=F00u05YI6eiHNm55/ntjfplIagvFXf11AolOIQtFnGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UIFbaquYzDBut4jLHtkt+SGi9Lb4+8I5RCLF6atf2TSnanltN0ZiO+1YHJRfCHoqh zmB5NKf8ekf7HqSNlm2K7THGN2eT2YS2V4InT8FyksvSSMKIZq0RnZBcUu0WWkIFdu CQimUtSx2qb0pM8C+IjoJdwZYbZQ2zvshgf4HhFE= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240425184702epcas5p2b41c1145228a485e2883078343720f64~JmlTWAB0j1620416204epcas5p2J; Thu, 25 Apr 2024 18:47:02 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.177]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4VQPwN4g50z4x9Pt; Thu, 25 Apr 2024 18:47:00 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 64.C1.09666.425AA266; Fri, 26 Apr 2024 03:47:00 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240425184700epcas5p1687590f7e4a3f3c3620ac27af514f0ca~JmlRRXjxl1328213282epcas5p1M; Thu, 25 Apr 2024 18:47:00 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240425184700epsmtrp260d58501356653291e5003ddd22fb1f8~JmlRQnl8X0238902389epsmtrp2d; Thu, 25 Apr 2024 18:47:00 +0000 (GMT) X-AuditID: b6c32a49-f53fa700000025c2-1f-662aa52491d9 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 6F.C2.19234.325AA266; Fri, 26 Apr 2024 03:47:00 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240425184658epsmtip1ffeb5676217af8158896c1660e49b425~JmlPcCPj-0041100411epsmtip1l; Thu, 25 Apr 2024 18:46:58 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, martin.petersen@oracle.com, kbusch@kernel.org, hch@lst.de, brauner@kernel.org Cc: asml.silence@gmail.com, dw@davidwei.uk, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Kanchan Joshi , Anuj Gupta Subject: [PATCH 05/10] block, nvme: modify rq_integrity_vec function Date: Fri, 26 Apr 2024 00:09:38 +0530 Message-Id: <20240425183943.6319-6-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425183943.6319-1-joshi.k@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+NgFtrIJsWRmVeSWpSXmKPExsWy7bCmhq7KUq00gz0v5C2aJvxltpizahuj xeq7/WwWrw9/YrR4NWMtm8XNAzuZLFauPspk8a71HIvF0f9v2SwmHbrGaLH3lrbF/GVP2S2W H//H5MDrcW3GRBaPnbPusntcPlvqsWlVJ5vH5iX1HrtvNrB5fHx6i8Wjb8sqRo/Pm+QCOKOy bTJSE1NSixRS85LzUzLz0m2VvIPjneNNzQwMdQ0tLcyVFPISc1NtlVx8AnTdMnOArlZSKEvM KQUKBSQWFyvp29kU5ZeWpCpk5BeX2CqlFqTkFJgU6BUn5haX5qXr5aWWWBkaGBiZAhUmZGfM XdvHVvBcvGLJKYkGxr/CXYycHBICJhJvjhxj7WLk4hAS2M0o8aZrEguE84lRYsvxQ2xwzuut N1hhWiZfeMEIYgsJ7GSU2H8uDqLoM6PEiXNvgIo4ONgENCUuTC4FqRERSJF4te41I0gNs8BT Rok9X28ygSSEBVwknrzoBhvKIqAqcetNG1icV8Bc4uTijSwQy+QlZl76zg5icwpYSEy+eJod okZQ4uTMJ2A1zEA1zVtnM4MskBBYySFx7dwaJohmF4lvc9dBXS0s8er4FnYIW0ri87u9bBB2 ssSlmeeg6kskHu85CGXbS7Se6mcGeYYZ6Jn1u/QhdvFJ9P5+wgQSlhDglehoE4KoVpS4N+kp 1CZxiYczlkDZHhKv205AQ7SbUeLR1JvsExjlZy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fm5mxjBkaIVtINx2fq/eocYmTgYDzFKcDArifDe/KiRJsSbklhZlVqUH19UmpNafIhR moNFSZxXOaczRUggPbEkNTs1tSC1CCbLxMEp1cC0njty4ovvLUxfxB1dir6yPzjz6MbC7bvu nBJcenNq8Yl4g9yJjYkW1Srv8mX5rk3ZMdHSx9mgpmKy2pxDVudMVrm6WDvvUJ/WHT9h/eeZ ByZm2WRu6N7++fvc1M0djaoK+8Kv5rHUiW7LWf6es/bS1ttymQf71qpMd98b+pEp6ozyPzZH r4CyzaHCip8jXS7f2PdlxfQPjz77sa9Yk3T/2Mun/27q6rVVcnZsPSbaGykqW9nc8nb5zvjz e5Pd3r//vGeKm39ngsMt7jPpE5Xtnpnkznrm9URn28m929VnxnwxzWf58XDW9Ct5m49zWr9N T1zw59jZo/LcHLtaAmRvyLskRr7MlpJvfL+GpSufSYmlOCPRUIu5qDgRAFle4/MDAwAA X-CMS-MailID: 20240425184700epcas5p1687590f7e4a3f3c3620ac27af514f0ca X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240425184700epcas5p1687590f7e4a3f3c3620ac27af514f0ca References: <20240425183943.6319-1-joshi.k@samsung.com> rq_integrity_vec always returns the first bio_vec, and does not take bip_iter into consideration. Modify it so that it does. This is similar to how req_bvec() works for data buffers. This is necessary for correct dma map/unmap of meta buffer when it was split in the block layer. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- drivers/nvme/host/pci.c | 9 +++++---- include/linux/blk-integrity.h | 13 +++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 8e0bb9692685..bc5177ea6330 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -825,9 +825,9 @@ static blk_status_t nvme_map_metadata(struct nvme_dev *dev, struct request *req, struct nvme_command *cmnd) { struct nvme_iod *iod = blk_mq_rq_to_pdu(req); + struct bio_vec bv = rq_integrity_vec(req); - iod->meta_dma = dma_map_bvec(dev->dev, rq_integrity_vec(req), - rq_dma_dir(req), 0); + iod->meta_dma = dma_map_bvec(dev->dev, &bv, rq_dma_dir(req), 0); if (dma_mapping_error(dev->dev, iod->meta_dma)) return BLK_STS_IOERR; cmnd->rw.metadata = cpu_to_le64(iod->meta_dma); @@ -964,9 +964,10 @@ static __always_inline void nvme_pci_unmap_rq(struct request *req) if (blk_integrity_rq(req)) { struct nvme_iod *iod = blk_mq_rq_to_pdu(req); + struct bio_vec bv = rq_integrity_vec(req); - dma_unmap_page(dev->dev, iod->meta_dma, - rq_integrity_vec(req)->bv_len, rq_dma_dir(req)); + dma_unmap_page(dev->dev, iod->meta_dma, bv.bv_len, + rq_dma_dir(req)); } if (blk_rq_nr_phys_segments(req)) diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h index e253e7bd0d17..9223050c0f75 100644 --- a/include/linux/blk-integrity.h +++ b/include/linux/blk-integrity.h @@ -109,11 +109,12 @@ static inline bool blk_integrity_rq(struct request *rq) * Return the first bvec that contains integrity data. Only drivers that are * limited to a single integrity segment should use this helper. */ -static inline struct bio_vec *rq_integrity_vec(struct request *rq) +static inline struct bio_vec rq_integrity_vec(struct request *rq) { - if (WARN_ON_ONCE(queue_max_integrity_segments(rq->q) > 1)) - return NULL; - return rq->bio->bi_integrity->bip_vec; + WARN_ON_ONCE(queue_max_integrity_segments(rq->q) > 1); + + return mp_bvec_iter_bvec(rq->bio->bi_integrity->bip_vec, + rq->bio->bi_integrity->bip_iter); } #else /* CONFIG_BLK_DEV_INTEGRITY */ static inline int blk_rq_count_integrity_sg(struct request_queue *q, @@ -177,9 +178,9 @@ static inline int blk_integrity_rq(struct request *rq) return 0; } -static inline struct bio_vec *rq_integrity_vec(struct request *rq) +static inline struct bio_vec rq_integrity_vec(struct request *rq) { - return NULL; + return (struct bio_vec){0}; } #endif /* CONFIG_BLK_DEV_INTEGRITY */ #endif /* _LINUX_BLK_INTEGRITY_H */ From patchwork Thu Apr 25 18:39:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13643659 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 1083F14F9F5 for ; Thu, 25 Apr 2024 18:47:06 +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=1714070828; cv=none; b=WAjxydHTb1uIDeZPKVTjJ1KJrPbJQX+5OhU3HOjMLxRTIktJqEWZV/hzi+pKlTCd3Dlm6aq8Utv5Vn9KJ6jOUdrbjW18mY60RPUYTDf7pHmnIiRuKAVPPrU6KK1T+y/fdlGf766UJc6mHZ2680YNpdJsrGV6nvDLK3aog1pOWhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070828; c=relaxed/simple; bh=EELVs2/K7r6/yt7yfKYJWd3E3c40DRgqJAJx6QNgmF8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=rkshvdIainrpiAJ1com30TOkVeo+RQ5mE5B5Qe/2wetAoq/S1BakkSLknF2HXlrZNgU9qsu+b5Zew5I70PP8meyCR6cMwHVtNxL/v9osvVQKTM5AaJp69wdrGRMqBFmW0kVad1B021+JftGV/AreV5B+/SxwwbjuDfXQDUjoZUE= 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=ieemyNF+; 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="ieemyNF+" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240425184705epoutp02f01d41cbbbf84340bac14f320a674dd5~JmlV41Ezg2855928559epoutp02g for ; Thu, 25 Apr 2024 18:47:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240425184705epoutp02f01d41cbbbf84340bac14f320a674dd5~JmlV41Ezg2855928559epoutp02g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1714070825; bh=OxaxYUv6kXArTeVw0WCBnIgHVnHyAM8bZTyh57XJclA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ieemyNF+qwNgiF5ZKTEJtJSDMhMEsCir90HlzFn8b6N/jX5iUBpUNWLFHS3TYQ6hI qVdmxSi2lYAWc2QgfWxT2xgeyaWtgViHtbSkTfO8hu4AIkTKP1vZLf5h4CU3GvTF2/ JBfcIw+hmTHteIVisvsB4/9tsdSrJNAXUqJQHKcE= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240425184704epcas5p449c454a93cee3cd90db570bdcd3525e4~JmlVUZQq11507515075epcas5p4f; Thu, 25 Apr 2024 18:47:04 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.175]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4VQPwQ5N6Fz4x9Pp; Thu, 25 Apr 2024 18:47:02 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 6B.E6.19431.625AA266; Fri, 26 Apr 2024 03:47:02 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240425184702epcas5p1ccb0df41b07845bc252d69007558e3fa~JmlTM_5Ai1330613306epcas5p1M; Thu, 25 Apr 2024 18:47:02 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240425184702epsmtrp18037949dd8671c2b47ec3374d07e8cf3~JmlTMODXx0085000850epsmtrp1f; Thu, 25 Apr 2024 18:47:02 +0000 (GMT) X-AuditID: b6c32a50-f57ff70000004be7-cd-662aa526028b Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 2B.F0.07541.625AA266; Fri, 26 Apr 2024 03:47:02 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240425184700epsmtip12c9a5239317da24686f8384443bb40e6~JmlRXCNYr0041000410epsmtip1N; Thu, 25 Apr 2024 18:47:00 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, martin.petersen@oracle.com, kbusch@kernel.org, hch@lst.de, brauner@kernel.org Cc: asml.silence@gmail.com, dw@davidwei.uk, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH 06/10] block: modify bio_integrity_map_user argument Date: Fri, 26 Apr 2024 00:09:39 +0530 Message-Id: <20240425183943.6319-7-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425183943.6319-1-joshi.k@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+NgFtrMJsWRmVeSWpSXmKPExsWy7bCmuq7aUq00g4bt6hZNE/4yW8xZtY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98tl5zSLzy0lDv58/sir/k7GJtbP7nWSqc+PnKQ9533i5thh5IdaidnSKrmJUb9 UXQxXtKhctDH0ICfTfJj0ZNGe5Opa68IPgmertu7oNmuUYmlOCPRUIu5qDgRAHhULSgJAwAA X-CMS-MailID: 20240425184702epcas5p1ccb0df41b07845bc252d69007558e3fa X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240425184702epcas5p1ccb0df41b07845bc252d69007558e3fa References: <20240425183943.6319-1-joshi.k@samsung.com> From: Anuj Gupta This patch refactors bio_integrity_map_user to accept iov_iter as argument. This is a prep patch. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- block/bio-integrity.c | 14 ++++++-------- drivers/nvme/host/ioctl.c | 11 +++++++++-- include/linux/bio.h | 7 ++++--- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index b698eb77515d..1085cf45f51e 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -318,17 +318,16 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages, return nr_bvecs; } -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, - u32 seed) +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, + u32 seed) { struct request_queue *q = bdev_get_queue(bio->bi_bdev); unsigned int align = q->dma_pad_mask | queue_dma_alignment(q); struct page *stack_pages[UIO_FASTIOV], **pages = stack_pages; struct bio_vec stack_vec[UIO_FASTIOV], *bvec = stack_vec; + size_t offset, bytes = iter->count; unsigned int direction, nr_bvecs; - struct iov_iter iter; int ret, nr_vecs; - size_t offset; bool copy; if (bio_integrity(bio)) @@ -341,8 +340,7 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, else direction = ITER_SOURCE; - iov_iter_ubuf(&iter, direction, ubuf, bytes); - nr_vecs = iov_iter_npages(&iter, BIO_MAX_VECS + 1); + nr_vecs = iov_iter_npages(iter, BIO_MAX_VECS + 1); if (nr_vecs > BIO_MAX_VECS) return -E2BIG; if (nr_vecs > UIO_FASTIOV) { @@ -352,8 +350,8 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, pages = NULL; } - copy = !iov_iter_is_aligned(&iter, align, align); - ret = iov_iter_extract_pages(&iter, &pages, bytes, nr_vecs, 0, &offset); + copy = !iov_iter_is_aligned(iter, align, align); + ret = iov_iter_extract_pages(iter, &pages, bytes, nr_vecs, 0, &offset); if (unlikely(ret < 0)) goto free_bvec; diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 499a8bb7cac7..4ed389edb3b6 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -145,8 +145,15 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer, if (bdev) { bio_set_dev(bio, bdev); if (meta_buffer && meta_len) { - ret = bio_integrity_map_user(bio, meta_buffer, meta_len, - meta_seed); + struct iov_iter iter; + unsigned int direction; + + if (bio_data_dir(bio) == READ) + direction = ITER_DEST; + else + direction = ITER_SOURCE; + iov_iter_ubuf(&iter, direction, meta_buffer, meta_len); + ret = bio_integrity_map_user(bio, &iter, meta_seed); if (ret) goto out_unmap; req->cmd_flags |= REQ_INTEGRITY; diff --git a/include/linux/bio.h b/include/linux/bio.h index 875d792bffff..20cf47fc851f 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -723,7 +723,7 @@ static inline bool bioset_initialized(struct bio_set *bs) for_each_bio(_bio) \ bip_for_each_vec(_bvl, _bio->bi_integrity, _iter) -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t len, u32 seed); +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed); extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); extern bool bio_integrity_prep(struct bio *); @@ -795,8 +795,9 @@ static inline int bio_integrity_add_page(struct bio *bio, struct page *page, return 0; } -static inline int bio_integrity_map_user(struct bio *bio, void __user *ubuf, - ssize_t len, u32 seed) +static inline int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, + u32 seed) + { return -EINVAL; } From patchwork Thu Apr 25 18:39:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13643660 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 651731514CE for ; Thu, 25 Apr 2024 18:47:08 +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=1714070829; cv=none; b=M/PkcJ1L0bZcMgmpktsCgHZHyqJKWiRTPiopGTLq4VaT3jBZvIguBoKZ6lqNXLMi96RPUpS2GXuAs9YEH+PyOslRatB9PxTYh0OKrdvO11AWNk7SqAfGDsfoM2cVrTToe5CqLBn6UGAXN5hf3Z2QiKykXVfkh4Eh5BotsruzoQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070829; c=relaxed/simple; bh=jlEo7mjTEa/d+J31Oce5T1eo2vI+1xW+upTvWFWz27o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=aMp632OPYFtBPkWbvXUzTy/36RAU01vs2A9pSaC/I7Gr8pZhUXv9H0P2zQnYz/Gk1JHTFpFo/N3Gg9RHeG0aWUWyM4rd1Z6RgFwtbUABt1eRvMuAJQ2kvnb4tpfzWv8Lk498u9BYhCW7vuQ/07pbGlFE0Sng2f2BD1KcIyDQAOM= 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=EBDheG8A; 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="EBDheG8A" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240425184706epoutp0200a03c8d347a0127fc3b881376433150~JmlXZa-st2801828018epoutp02x for ; Thu, 25 Apr 2024 18:47:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240425184706epoutp0200a03c8d347a0127fc3b881376433150~JmlXZa-st2801828018epoutp02x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1714070826; bh=Js/hSRW8kEp1k9VQrph3vgZ0lgiRTB0hNOFeT7LTDp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EBDheG8AIWMBRVL6ov9bmb4ExSb+NI+B8PVbci3C6OO/yOq4XvOKwkDzQ1E37ji/7 kviG1rA2ZMyjm3Quq422qoaoBfkC/m/r6hfEZLxiRn51bvqlP43uEZQIM42SyXaQO9 vbKfWQMYv0Uwm5gOElWJPiloOJcwEmfaL1MkhYtU= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240425184706epcas5p1029962312fa51b49df216c5a1ce74a64~JmlW9NoKZ1431014310epcas5p1N; Thu, 25 Apr 2024 18:47:06 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.177]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4VQPwS4Hr2z4x9Pr; Thu, 25 Apr 2024 18:47:04 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 8B.20.09665.825AA266; Fri, 26 Apr 2024 03:47:04 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240425184704epcas5p3b9eb6cce9c9658eb1d0d32937e778a5d~JmlVCx69z2385723857epcas5p3v; Thu, 25 Apr 2024 18:47:04 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240425184704epsmtrp18d551fa6e17310e3273e8197843ea9c7~JmlVCCY9O0085200852epsmtrp1W; Thu, 25 Apr 2024 18:47:04 +0000 (GMT) X-AuditID: b6c32a4b-5cdff700000025c1-22-662aa528bc6d Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id AE.B4.08390.725AA266; Fri, 26 Apr 2024 03:47:03 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240425184702epsmtip1e3c93d2f39f3720b3bbf1b4c9c180f46~JmlTSyjgm3266832668epsmtip16; Thu, 25 Apr 2024 18:47:02 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, martin.petersen@oracle.com, kbusch@kernel.org, hch@lst.de, brauner@kernel.org Cc: asml.silence@gmail.com, dw@davidwei.uk, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Kanchan Joshi Subject: [PATCH 07/10] block: define meta io descriptor Date: Fri, 26 Apr 2024 00:09:40 +0530 Message-Id: <20240425183943.6319-8-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425183943.6319-1-joshi.k@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+NgFlrNJsWRmVeSWpSXmKPExsWy7bCmhq7GUq00g1k98hZzVm1jtFh9t5/N 4vXhT4wWr2asZbO4eWAnk8XK1UeZLN61nmOxOPr/LZvFpEPXGC323tK2mL/sKbvF8uP/mBx4 PK7NmMjisXPWXXaPy2dLPTat6mTz2Lyk3mP3zQY2j49Pb7F49G1ZxejxeZNcAGdUtk1GamJK apFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5kkJeYm6qrZKLT4CuW2YO0MFKCmWJOaVAoYDE 4mIlfTubovzSklSFjPziElul1IKUnAKTAr3ixNzi0rx0vbzUEitDAwMjU6DChOyMtXsOsxZM Za1YfCq8gbGfpYuRk0NCwERi3RMQm4tDSGA3o8TCLa/AEkICnxglDjwvgkh8Y5TYdPgWG0zH k/3fWSGK9jJKzLwpDlH0mVHizLyZQN0cHGwCmhIXJpeC1IgIpEi8WveaEaSGWeAAo8Si50/A BgkLmEts2riTHcRmEVCVODdhDpjNCxS/u+oX1DJ5iZmXvoPFOQUsJCZfPA1VIyhxcuYTsEuZ gWqat85mBlkgITCXQ+LzjE9MEM0uEjvXzGaHsIUlXh3fAmVLSbzsb4OykyUuzTwHVV8i8XjP QSjbXqL1VD8zyDPMQM+s36UPsYtPovf3EyaQsIQAr0RHmxBEtaLEvUlPWSFscYmHM5ZA2R4S 7S+WM0HCp5tR4tGKlywTGOVnIXlhFpIXZiFsW8DIvIpRMrWgODc9tdi0wDgvtRwercn5uZsY walWy3sH46MHH/QOMTJxMB5ilOBgVhLhvflRI02INyWxsiq1KD++qDQntfgQoykwjCcyS4km 5wOTfV5JvKGJpYGJmZmZiaWxmaGSOO/r1rkpQgLpiSWp2ampBalFMH1MHJxSDUzLvCxqoqPn ObEt1ec+Kr1GSLJssYnFtzWxR/1L1y1POvEhr9tey46/yzEs32JdaGjcEUbWo3NUPi1f4rRo Sq/X21SBixe231p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j5jVnPggK7p37Umanx3Wnmiu827zVb8yd bB2Zy1ZqFKzXFxlgMOtYz1mBaf7brFOLd98L1jvVwnP0/9rZgYahUp1fw9cIndPQ9j60aSLT xIIExfVTjz5XDDlUwXlQO8Ly4LI5gTuvPS83T0isi9cz+VK+mjt+o5H0HZ/uPUnODuXLbyVm Lpj873dM7uuV316oaoiL/vxp1CM5SYmlOCPRUIu5qDgRABmbW38CAwAA X-CMS-MailID: 20240425184704epcas5p3b9eb6cce9c9658eb1d0d32937e778a5d X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240425184704epcas5p3b9eb6cce9c9658eb1d0d32937e778a5d References: <20240425183943.6319-1-joshi.k@samsung.com> Introduces a new 'uio_meta' structure that upper layer (io_uring) can use to pass the meta/integrity information. This is a prep patch. Signed-off-by: Kanchan Joshi --- include/linux/bio.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/bio.h b/include/linux/bio.h index 20cf47fc851f..0281b356935a 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -331,6 +331,12 @@ enum bip_flags { BIP_COPY_USER = 1 << 6, /* Kernel bounce buffer in use */ }; +struct uio_meta { + u16 flags; + u16 apptag; + struct iov_iter iter; +}; + /* * bio integrity payload */ From patchwork Thu Apr 25 18:39:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13643662 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 782821514E7 for ; Thu, 25 Apr 2024 18:47:10 +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=1714070832; cv=none; b=uoteWFxqtfuGt9tH7raTkG41WEWSJOuILuM0oEiUEcqcF17m/RT3uhoBDb3yue/Qny8nfxLwKMP4VXo2GHMwkeJLW03ht42IjBxf1gvtCanTXE/IJIYn3wSiJmoF6/NHQdFmDohUmXIxigzNw+4xDYFTgQr3idlCoTVTJIvx8lk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070832; c=relaxed/simple; bh=RVztbVFstklSGE2U7W62Tc3o7mmL0o3JLWHXHFVVaRY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=BMUPR8G7g5dy1BeVTlg5eGQWKXQJuFwN8LoaKdZWxS7JeGxQZSbmBRDdA0Uwh55DRLAv6l/sFI3c6QfNK+epRXDN/85zw69YjZJNppF8vDZEWfbONJYmckGl3TvIz9Ai3wfnZbd+ZBuy7xUmAlymN1bgukP26r+BG75F+OCZeCU= 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=C7FkOrSn; 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="C7FkOrSn" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240425184708epoutp025752afd34417171fb29df7721af64257~JmlZRdhUh2855928559epoutp02i for ; Thu, 25 Apr 2024 18:47:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240425184708epoutp025752afd34417171fb29df7721af64257~JmlZRdhUh2855928559epoutp02i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1714070828; bh=FdFq2FZdO8v/8D9b+1sjDkJ0PD17j8j/mUpt7Sw3h80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C7FkOrSnlqY3mL7x6q1Ge7jVQgT8G5R/2W+k2nwrZpVBYqr2aZD44IGGNMicXTy6E Ggonq3z/ME8LAlOrA74RU8lJn1jrqScbyv4+jiGMKNREqTAN1NFXEHMJ/Cre+epWK3 E01ddTEjLZ8GnFaOCVXXimDODPG1vNsUblYfZ+tY= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240425184708epcas5p4b2815f78f0a5b00b5a33b6eeaa520135~JmlY0K4761482414824epcas5p4r; Thu, 25 Apr 2024 18:47:08 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.174]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4VQPwW0R34z4x9Pq; Thu, 25 Apr 2024 18:47:07 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 8C.E6.19431.A25AA266; Fri, 26 Apr 2024 03:47:06 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240425184706epcas5p1d75c19d1d1458c52fc4009f150c7dc7d~JmlXGq_w_2685426854epcas5p1P; Thu, 25 Apr 2024 18:47:06 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240425184706epsmtrp14c11a1eedd113ed87970fdfb484fa2cb~JmlXF2xdh0085000850epsmtrp1g; Thu, 25 Apr 2024 18:47:06 +0000 (GMT) X-AuditID: b6c32a50-f57ff70000004be7-d3-662aa52a99e6 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 70.E7.08924.A25AA266; Fri, 26 Apr 2024 03:47:06 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240425184704epsmtip1f173edc993d14c8e8955b5c8f8ab8888~JmlVEU6nb3082730827epsmtip1c; Thu, 25 Apr 2024 18:47:04 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, martin.petersen@oracle.com, kbusch@kernel.org, hch@lst.de, brauner@kernel.org Cc: asml.silence@gmail.com, dw@davidwei.uk, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Anuj Gupta , Kanchan Joshi , Nitesh Shetty Subject: [PATCH 08/10] io_uring/rw: add support to send meta along with read/write Date: Fri, 26 Apr 2024 00:09:41 +0530 Message-Id: <20240425183943.6319-9-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425183943.6319-1-joshi.k@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+NgFtrOJsWRmVeSWpSXmKPExsWy7bCmhq7WUq00gzuHrS2aJvxltpizahuj xeq7/WwWrw9/YrR4NWMtm8XNAzuZLFauPspk8a71HIvF0f9v2SwmHbrGaLH3lrbF/GVP2S2W H//HZLHt93xmBz6PazMmsnjsnHWX3ePy2VKPTas62Tw2L6n32H2zgc3j49NbLB59W1Yxenze JBfAGZVtk5GamJJapJCal5yfkpmXbqvkHRzvHG9qZmCoa2hpYa6kkJeYm2qr5OIToOuWmQN0 upJCWWJOKVAoILG4WEnfzqYov7QkVSEjv7jEVim1ICWnwKRArzgxt7g0L10vL7XEytDAwMgU qDAhO+P5z/MsBXPCKnbfO8jYwHjKtYuRk0NCwETi3LP7zF2MXBxCAnsYJS5O3cAK4XxilDg2 7xxU5hujxPR/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Tx2zrrL7nH5bKnHplWdbB6bl9R77L7ZwObx8ektFo++LasYPT5v kgvgjOKySUnNySxLLdK3S+DKeP7zPEvBnLCK3fcOMjYwnnLtYuTgkBAwkej5otHFyMUhJLCb UWLlzi62LkZOoLi4RPO1H+wQtrDEyn/P2SGKPjJKfDhwnBmkmU1AU+LC5FKQGhGBLIm9/VfA apgFpjFJbP3/CWyQsECQxIWntxlB6lkEVCV6b0qDhHkFzCUOLzsDtUteYual72C7OAUsJCZf PA1mCwHVTF2ziBGiXlDi5MwnLCA2M1B989bZzBMYBWYhSc1CklrAyLSKUTK1oDg3PbfYsMAw L7Vcrzgxt7g0L10vOT93EyM4drQ0dzBuX/VB7xAjEwfjIUYJDmYlEd6bHzXShHhTEiurUovy 44tKc1KLDzFKc7AoifOKv+hNERJITyxJzU5NLUgtgskycXBKNTAdYDzod/zwB6fgVlP5BQpL 7ofd1gq72ihU8/dOiDBzzd3Uw2qMbcrXt/k/yvZe0rxOVaskskb3af/9U65xvW/q1xp2Npyf u0948xVr7ilKkxwuT1Ceyrd/5/NLH51X1Fim78n4mbnec8P1M21KzgXXf6fwXN1vOqXQ2LNU 79nh5xesd24q9PuS+O9Z6ZLnjZHxkeqzV+vpSKyOXuol8XW98Xe289Z3ZitmOZ7n2fk9w3rF ibuPvH9e/+1f9X/Pl8mGj+5/3XDjY+c/583Hfhz5OPf20+1FT5MVeT70Jvu+UvX6cPFX3uHe JpbGiqU3vQsZC727jEwZTe9v2N5n9+j8+o2vW9kMuthYdy3bp6TgrsRSnJFoqMVcVJwIAAQY /j8MAwAA X-CMS-MailID: 20240425184706epcas5p1d75c19d1d1458c52fc4009f150c7dc7d X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240425184706epcas5p1d75c19d1d1458c52fc4009f150c7dc7d References: <20240425183943.6319-1-joshi.k@samsung.com> From: Anuj Gupta This patch introduces IORING_OP_READ_META and IORING_OP_WRITE_META opcodes which allow sending a meta buffer along with read/write. The meta buffer, its length, apptag and integrity check flags can be specified by the application in the newly introduced meta_buf, meta_len, apptag and meta_flags fields of SQE. Use the user-passed information to prepare uio_meta descriptor, and pass it down using kiocb->private. Meta exchange is supported only for direct IO. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty --- include/linux/fs.h | 1 + include/uapi/linux/io_uring.h | 15 +++++++ io_uring/io_uring.c | 4 ++ io_uring/opdef.c | 30 ++++++++++++++ io_uring/rw.c | 76 +++++++++++++++++++++++++++++++++-- io_uring/rw.h | 11 ++++- 6 files changed, 132 insertions(+), 5 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 8dfd53b52744..8868d17ae8f9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -329,6 +329,7 @@ struct readahead_control; #define IOCB_NOIO (1 << 20) /* can use bio alloc cache */ #define IOCB_ALLOC_CACHE (1 << 21) +#define IOCB_USE_META (1 << 22) /* * IOCB_DIO_CALLER_COMP can be set by the iocb owner, to indicate that the * iocb completion can be passed back to the owner for execution from a safe diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index a7f847543a7f..d4653b52fdd6 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -97,6 +97,12 @@ struct io_uring_sqe { __u64 addr3; __u64 __pad2[1]; }; + struct { + __u64 meta_addr; + __u32 meta_len; + __u16 meta_flags; + __u16 apptag; + }; __u64 optval; /* * If the ring is initialized with IORING_SETUP_SQE128, then @@ -106,6 +112,13 @@ struct io_uring_sqe { }; }; +/* + * meta io flags + */ +#define META_CHK_GUARD (1U << 0) /* guard is valid */ +#define META_CHK_APPTAG (1U << 1) /* app tag is valid */ +#define META_CHK_REFTAG (1U << 2) /* ref tag is valid */ + /* * If sqe->file_index is set to this for opcodes that instantiate a new * direct descriptor (like openat/openat2/accept), then io_uring will allocate @@ -256,6 +269,8 @@ enum io_uring_op { IORING_OP_FUTEX_WAITV, IORING_OP_FIXED_FD_INSTALL, IORING_OP_FTRUNCATE, + IORING_OP_READ_META, + IORING_OP_WRITE_META, /* this goes last, obviously */ IORING_OP_LAST, diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 3c9087f37c43..af95fc8d988c 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3723,7 +3723,11 @@ static int __init io_uring_init(void) BUILD_BUG_SQE_ELEM(44, __u16, addr_len); BUILD_BUG_SQE_ELEM(46, __u16, __pad3[0]); BUILD_BUG_SQE_ELEM(48, __u64, addr3); + BUILD_BUG_SQE_ELEM(48, __u64, meta_addr); BUILD_BUG_SQE_ELEM_SIZE(48, 0, cmd); + BUILD_BUG_SQE_ELEM(56, __u32, meta_len); + BUILD_BUG_SQE_ELEM(60, __u16, meta_flags); + BUILD_BUG_SQE_ELEM(62, __u16, apptag); BUILD_BUG_SQE_ELEM(56, __u64, __pad2); BUILD_BUG_ON(sizeof(struct io_uring_files_update) != diff --git a/io_uring/opdef.c b/io_uring/opdef.c index a16f73938ebb..8b8fdcfb7f30 100644 --- a/io_uring/opdef.c +++ b/io_uring/opdef.c @@ -444,6 +444,28 @@ const struct io_issue_def io_issue_defs[] = { .prep = io_eopnotsupp_prep, #endif }, + [IORING_OP_READ_META] = { + .needs_file = 1, + .plug = 1, + .audit_skip = 1, + .ioprio = 1, + .iopoll = 1, + .iopoll_queue = 1, + .async_size = sizeof(struct io_async_rw), + .prep = io_prep_read_meta, + .issue = io_rw_meta, + }, + [IORING_OP_WRITE_META] = { + .needs_file = 1, + .plug = 1, + .audit_skip = 1, + .ioprio = 1, + .iopoll = 1, + .iopoll_queue = 1, + .async_size = sizeof(struct io_async_rw), + .prep = io_prep_write_meta, + .issue = io_rw_meta, + }, [IORING_OP_READ_MULTISHOT] = { .needs_file = 1, .unbound_nonreg_file = 1, @@ -510,6 +532,14 @@ const struct io_cold_def io_cold_defs[] = { .cleanup = io_readv_writev_cleanup, .fail = io_rw_fail, }, + [IORING_OP_READ_META] = { + .name = "READ_META", + .fail = io_rw_fail, + }, + [IORING_OP_WRITE_META] = { + .name = "WRITE_META", + .fail = io_rw_fail, + }, [IORING_OP_FSYNC] = { .name = "FSYNC", }, diff --git a/io_uring/rw.c b/io_uring/rw.c index 3134a6ece1be..b2c9ac91d5e5 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -269,6 +269,7 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, rw->kiocb.ki_ioprio = get_current_ioprio(); } rw->kiocb.dio_complete = NULL; + rw->kiocb.ki_flags = 0; rw->addr = READ_ONCE(sqe->addr); rw->len = READ_ONCE(sqe->len); @@ -286,6 +287,41 @@ int io_prep_write(struct io_kiocb *req, const struct io_uring_sqe *sqe) return io_prep_rw(req, sqe, ITER_SOURCE, true); } +static int io_prep_rw_meta(struct io_kiocb *req, const struct io_uring_sqe *sqe, + int ddir, bool import) +{ + struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); + struct io_async_rw *io; + struct kiocb *kiocb = &rw->kiocb; + int ret; + + ret = io_prep_rw(req, sqe, ddir, import); + if (unlikely(ret)) + return ret; + + io = req->async_data; + kiocb->ki_flags |= IOCB_USE_META; + io->meta.flags = READ_ONCE(sqe->meta_flags); + io->meta.apptag = READ_ONCE(sqe->apptag); + ret = import_ubuf(ddir, u64_to_user_ptr(READ_ONCE(sqe->meta_addr)), + READ_ONCE(sqe->meta_len), &io->meta.iter); + if (unlikely(ret < 0)) + return ret; + + iov_iter_save_state(&io->meta.iter, &io->iter_meta_state); + return 0; +} + +int io_prep_read_meta(struct io_kiocb *req, const struct io_uring_sqe *sqe) +{ + return io_prep_rw_meta(req, sqe, ITER_DEST, true); +} + +int io_prep_write_meta(struct io_kiocb *req, const struct io_uring_sqe *sqe) +{ + return io_prep_rw_meta(req, sqe, ITER_SOURCE, true); +} + static int io_prep_rwv(struct io_kiocb *req, const struct io_uring_sqe *sqe, int ddir) { @@ -587,6 +623,8 @@ static int kiocb_done(struct io_kiocb *req, ssize_t ret, req->flags &= ~REQ_F_REISSUE; iov_iter_restore(&io->iter, &io->iter_state); + if (unlikely(rw->kiocb.ki_flags & IOCB_USE_META)) + iov_iter_restore(&io->meta.iter, &io->iter_meta_state); return -EAGAIN; } return IOU_ISSUE_SKIP_COMPLETE; @@ -768,7 +806,7 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode) if (!(req->flags & REQ_F_FIXED_FILE)) req->flags |= io_file_get_flags(file); - kiocb->ki_flags = file->f_iocb_flags; + kiocb->ki_flags |= file->f_iocb_flags; ret = kiocb_set_rw_flags(kiocb, rw->flags); if (unlikely(ret)) return ret; @@ -787,7 +825,8 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode) if (!(kiocb->ki_flags & IOCB_DIRECT) || !file->f_op->iopoll) return -EOPNOTSUPP; - kiocb->private = NULL; + if (likely(!(kiocb->ki_flags & IOCB_USE_META))) + kiocb->private = NULL; kiocb->ki_flags |= IOCB_HIPRI; kiocb->ki_complete = io_complete_rw_iopoll; req->iopoll_completed = 0; @@ -853,7 +892,8 @@ static int __io_read(struct io_kiocb *req, unsigned int issue_flags) } else if (ret == -EIOCBQUEUED) { return IOU_ISSUE_SKIP_COMPLETE; } else if (ret == req->cqe.res || ret <= 0 || !force_nonblock || - (req->flags & REQ_F_NOWAIT) || !need_complete_io(req)) { + (req->flags & REQ_F_NOWAIT) || !need_complete_io(req) || + (kiocb->ki_flags & IOCB_USE_META)) { /* read all, failed, already did sync or don't want to retry */ goto done; } @@ -864,6 +904,12 @@ static int __io_read(struct io_kiocb *req, unsigned int issue_flags) * manually if we need to. */ iov_iter_restore(&io->iter, &io->iter_state); + if (unlikely(kiocb->ki_flags & IOCB_USE_META)) { + /* don't handle partial completion for read + meta */ + if (ret > 0) + goto done; + iov_iter_restore(&io->meta.iter, &io->iter_meta_state); + } do { /* @@ -1053,7 +1099,8 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags) if (ret2 == -EAGAIN && (req->ctx->flags & IORING_SETUP_IOPOLL)) goto ret_eagain; - if (ret2 != req->cqe.res && ret2 >= 0 && need_complete_io(req)) { + if (ret2 != req->cqe.res && ret2 >= 0 && need_complete_io(req) + && !(kiocb->ki_flags & IOCB_USE_META)) { trace_io_uring_short_write(req->ctx, kiocb->ki_pos - ret2, req->cqe.res, ret2); @@ -1074,12 +1121,33 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags) } else { ret_eagain: iov_iter_restore(&io->iter, &io->iter_state); + if (unlikely(kiocb->ki_flags & IOCB_USE_META)) + iov_iter_restore(&io->meta.iter, &io->iter_meta_state); if (kiocb->ki_flags & IOCB_WRITE) io_req_end_write(req); return -EAGAIN; } } +int io_rw_meta(struct io_kiocb *req, unsigned int issue_flags) +{ + struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); + struct io_async_rw *io = req->async_data; + struct kiocb *kiocb = &rw->kiocb; + int ret; + + if (!(req->file->f_flags & O_DIRECT)) + return -EOPNOTSUPP; + + kiocb->private = &io->meta; + if (req->opcode == IORING_OP_READ_META) + ret = io_read(req, issue_flags); + else + ret = io_write(req, issue_flags); + + return ret; +} + void io_rw_fail(struct io_kiocb *req) { int res; diff --git a/io_uring/rw.h b/io_uring/rw.h index 3f432dc75441..a640071064e3 100644 --- a/io_uring/rw.h +++ b/io_uring/rw.h @@ -9,7 +9,13 @@ struct io_async_rw { struct iovec fast_iov; struct iovec *free_iovec; int free_iov_nr; - struct wait_page_queue wpq; + union { + struct wait_page_queue wpq; + struct { + struct uio_meta meta; + struct iov_iter_state iter_meta_state; + }; + }; }; int io_prep_read_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe); @@ -17,9 +23,12 @@ int io_prep_write_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe); int io_prep_readv(struct io_kiocb *req, const struct io_uring_sqe *sqe); int io_prep_writev(struct io_kiocb *req, const struct io_uring_sqe *sqe); int io_prep_read(struct io_kiocb *req, const struct io_uring_sqe *sqe); +int io_prep_read_meta(struct io_kiocb *req, const struct io_uring_sqe *sqe); int io_prep_write(struct io_kiocb *req, const struct io_uring_sqe *sqe); +int io_prep_write_meta(struct io_kiocb *req, const struct io_uring_sqe *sqe); int io_read(struct io_kiocb *req, unsigned int issue_flags); int io_write(struct io_kiocb *req, unsigned int issue_flags); +int io_rw_meta(struct io_kiocb *req, unsigned int issue_flags); void io_readv_writev_cleanup(struct io_kiocb *req); void io_rw_fail(struct io_kiocb *req); void io_req_rw_complete(struct io_kiocb *req, struct io_tw_state *ts); From patchwork Thu Apr 25 18:39:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13643663 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (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 0B78D1514E7 for ; Thu, 25 Apr 2024 18:47:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070834; cv=none; b=dubheN1xpS6yU/z1bGq7YioCSVFzlQ3vUq+83yLT3q9mVbrHAo3W6P8Hh1ZY44BKG6fVwsc4cOtqDt++M6SY9636/DRyV7b8jEoh6m6ff/Qo76Qw8iR8KkYW5x+PpnLCtmIKgcMLpsw5BWrvsJYGT1Q05pqDxurNIYz71CKnsQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070834; c=relaxed/simple; bh=/DPGeX9I0ObwE3EP0v0TbLOEIokjWnkXRqaku++fBDE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=BpKxj4kpvEm0hpMd2FJaV2zOn9OJzSe9BnZit9dTNxjdjvpGz4npFDtW3Vvhimyx6UVWfr4RlUgdQ7vgbP7hiNCCHiRVcH4Xi8L8uOTyaHaWfyNJgPBMrWd4TGRBU17EHmDlIq1Ksj/jyQns4UXk5+ysChDWPe0567RrLYxOG7Y= 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=M5YNw6cC; arc=none smtp.client-ip=203.254.224.34 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="M5YNw6cC" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240425184711epoutp04bd66e9dc53140633f210c7b5272f5435~Jmlb2TQ2b0315103151epoutp04- for ; Thu, 25 Apr 2024 18:47:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240425184711epoutp04bd66e9dc53140633f210c7b5272f5435~Jmlb2TQ2b0315103151epoutp04- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1714070831; bh=ZpVI+2oz3hOIVHmIDa5Dfh1pTAGcWIpPyXMJ0UEsJ9M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M5YNw6cCtaRVoeV0CGnet7Pxi0N1Dazvg9sBsItugLbRgucyUrLhQA4Hcy5is/lrP D6h6Zkv/fghX4tsv5e2Kf+mhCbCKFkxuwwgV3qGU5SJEsJCKUVWlZj9xWZwlpZ74TP Y7CDJFFGVOq+FzvMjnjxVzAMIaAFOJifXqlsYulo= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240425184710epcas5p38c919ee7548dbf6d85e36427a50cb697~JmlbSzWtt0687706877epcas5p34; Thu, 25 Apr 2024 18:47:10 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.176]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4VQPwY12gVz4x9Pq; Thu, 25 Apr 2024 18:47:09 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 9E.20.09665.C25AA266; Fri, 26 Apr 2024 03:47:09 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240425184708epcas5p4f1d95cd8d285614f712868d205a23115~JmlZGm_No1482414824epcas5p4t; Thu, 25 Apr 2024 18:47:08 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240425184708epsmtrp12435c2216b41129151b5da961d30625b~JmlZF1L8o0085000850epsmtrp1i; Thu, 25 Apr 2024 18:47:08 +0000 (GMT) X-AuditID: b6c32a4b-829fa700000025c1-27-662aa52cd31b Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 2C.F0.07541.C25AA266; Fri, 26 Apr 2024 03:47:08 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240425184706epsmtip103cfb1eb0a27f8948c2292d55253d0a5~JmlXL-eNj0041100411epsmtip1r; Thu, 25 Apr 2024 18:47:06 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, martin.petersen@oracle.com, kbusch@kernel.org, hch@lst.de, brauner@kernel.org Cc: asml.silence@gmail.com, dw@davidwei.uk, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Kanchan Joshi , Anuj Gupta Subject: [PATCH 09/10] block: add support to send meta buffer Date: Fri, 26 Apr 2024 00:09:42 +0530 Message-Id: <20240425183943.6319-10-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425183943.6319-1-joshi.k@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+NgFtrAJsWRmVeSWpSXmKPExsWy7bCmlq7uUq00g1lLmC2aJvxltpizahuj xeq7/WwWrw9/YrR4NWMtm8XNAzuZLFauPspk8a71HIvF0f9v2SwmHbrGaLH3lrbF/GVP2S2W H//H5MDrcW3GRBaPnbPusntcPlvqsWlVJ5vH5iX1HrtvNrB5fHx6i8Wjb8sqRo/Pm+QCOKOy bTJSE1NSixRS85LzUzLz0m2VvIPjneNNzQwMdQ0tLcyVFPISc1NtlVx8AnTdMnOArlZSKEvM KQUKBSQWFyvp29kU5ZeWpCpk5BeX2CqlFqTkFJgU6BUn5haX5qXr5aWWWBkaGBiZAhUmZGe8 f3+eqeCNesWB81UNjIsVuhg5OSQETCQOH5rE2sXIxSEksJtR4uWOq0wQzidGiW1TGthAqoQE vjFKfLmbDNMxf/d3qKK9jBJNG0+xQDifGSV+n9zB3MXIwcEmoClxYXIpSIOIQIrEq3WvGUFq mAWeMkrs+XqTCaRGWMBWYuVrJ5AaFgFViUPXp7OD2LwCFhJXfn5nh1gmLzHzEoTNCRSffPE0 VI2gxMmZT1hAbGagmuats5lB5ksIrOSQaDl2kRmi2UViRftxVghbWOLV8S1QQ6UkXva3QdnJ EpdmnmOCsEskHu85CGXbS7Se6gf7hRnol/W79CF28Un0/n4Cdr6EAK9ER5sQRLWixL1JT6E2 iUs8nLEEyvaQmHr0GTskeLoZJVZcvss0gVF+FpIXZiF5YRbCtgWMzKsYJVMLinPTU4tNC4zz Usvh0Zqcn7uJEZx0tbx3MD568EHvECMTB+MhRgkOZiUR3psfNdKEeFMSK6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wxuwUIYH0xJLU7NTUgtQimCwTB6dUA5OPb//e2uPRDhPOq+rMN0pmKv1zka/3RVLn Pt/PHb+e/tvNuFJnQ++TZSLlDw4J5k3xSjTUDra/bTDp3EnXVvfV7SG6cff8ub9d2PPh64PA r6vMGphntZ2eZDRJ+IRiqKQa89xHyfWLkt3fnPzw8vrnRTN23/DlfxlcvvsDj9faipBzH/T/ /vnW4p3uyVH2VozlpBrDwSeRu/62lW9+oGBwzabl2K0pF6fMUC/W25pzZWZUYsbMpkypTs8Y 77k3piqdMoyyzGI/Weks3XxCbX7JKusVj6o2antHVpxbUxp4W07+OPe52tNsket2chk13Xp8 xd6m7xiHq8bbv9Z75u/4zcYWJR4XO3nzmcbLCa+UWIozEg21mIuKEwFRqecdBgMAAA== X-CMS-MailID: 20240425184708epcas5p4f1d95cd8d285614f712868d205a23115 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240425184708epcas5p4f1d95cd8d285614f712868d205a23115 References: <20240425183943.6319-1-joshi.k@samsung.com> If iocb contains the meta, extract that and prepare the bip. Extend bip so that can it can carry three new integrity-check flags and application tag. Make sure that ->prepare_fn and ->complete_fn are skipped for user-owned meta buffer. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi --- block/bio-integrity.c | 31 ++++++++++++++++++++++++++++++- block/fops.c | 9 +++++++++ block/t10-pi.c | 6 ++++++ include/linux/bio.h | 10 ++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 1085cf45f51e..dab76fd73813 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include "blk.h" static struct kmem_cache *bip_slab; @@ -318,6 +318,35 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages, return nr_bvecs; } +int bio_integrity_map_iter(struct bio *bio, struct uio_meta *meta) +{ + struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk); + u16 bip_flags = 0; + int ret; + + if (!bi) + return -EINVAL; + + if (meta->iter.count < bio_integrity_bytes(bi, bio_sectors(bio))) + return -EINVAL; + + ret = bio_integrity_map_user(bio, &meta->iter, 0); + if (!ret) { + struct bio_integrity_payload *bip = bio_integrity(bio); + + if (meta->flags & META_CHK_GUARD) + bip_flags |= BIP_USER_CHK_GUARD; + if (meta->flags & META_CHK_APPTAG) + bip_flags |= BIP_USER_CHK_APPTAG; + if (meta->flags & META_CHK_REFTAG) + bip_flags |= BIP_USER_CHK_REFTAG; + + bip->bip_flags |= bip_flags; + bip->apptag = meta->apptag; + } + return ret; +} + int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed) { diff --git a/block/fops.c b/block/fops.c index 679d9b752fe8..e488fa66dd60 100644 --- a/block/fops.c +++ b/block/fops.c @@ -353,6 +353,15 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, task_io_account_write(bio->bi_iter.bi_size); } + if (unlikely(iocb->ki_flags & IOCB_USE_META)) { + ret = bio_integrity_map_iter(bio, iocb->private); + WRITE_ONCE(iocb->private, NULL); + if (unlikely(ret)) { + bio_put(bio); + return ret; + } + } + if (iocb->ki_flags & IOCB_NOWAIT) bio->bi_opf |= REQ_NOWAIT; diff --git a/block/t10-pi.c b/block/t10-pi.c index d90892fd6f2a..72d1522417a1 100644 --- a/block/t10-pi.c +++ b/block/t10-pi.c @@ -156,6 +156,8 @@ static void t10_pi_type1_prepare(struct request *rq) /* Already remapped? */ if (bip->bip_flags & BIP_MAPPED_INTEGRITY) break; + if (bip->bip_flags & BIP_INTEGRITY_USER) + break; bip_for_each_vec(iv, bip, iter) { unsigned int j; @@ -205,6 +207,8 @@ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes) struct bio_vec iv; struct bvec_iter iter; + if (bip->bip_flags & BIP_INTEGRITY_USER) + break; bip_for_each_vec(iv, bip, iter) { unsigned int j; void *p; @@ -408,6 +412,8 @@ static void ext_pi_type1_prepare(struct request *rq) /* Already remapped? */ if (bip->bip_flags & BIP_MAPPED_INTEGRITY) break; + if (bip->bip_flags & BIP_INTEGRITY_USER) + break; bip_for_each_vec(iv, bip, iter) { unsigned int j; diff --git a/include/linux/bio.h b/include/linux/bio.h index 0281b356935a..8724305bce62 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -329,6 +329,9 @@ enum bip_flags { BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */ BIP_INTEGRITY_USER = 1 << 5, /* Integrity payload is user address */ BIP_COPY_USER = 1 << 6, /* Kernel bounce buffer in use */ + BIP_USER_CHK_GUARD = 1 << 7, + BIP_USER_CHK_APPTAG = 1 << 8, + BIP_USER_CHK_REFTAG = 1 << 9, }; struct uio_meta { @@ -348,6 +351,7 @@ struct bio_integrity_payload { unsigned short bip_vcnt; /* # of integrity bio_vecs */ unsigned short bip_max_vcnt; /* integrity bio_vec slots */ unsigned short bip_flags; /* control flags */ + u16 apptag; /* apptag */ struct bvec_iter bio_iter; /* for rewinding parent bio */ @@ -729,6 +733,7 @@ static inline bool bioset_initialized(struct bio_set *bs) for_each_bio(_bio) \ bip_for_each_vec(_bvl, _bio->bi_integrity, _iter) +int bio_integrity_map_iter(struct bio *bio, struct uio_meta *meta); int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed); extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); @@ -808,6 +813,11 @@ static inline int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, return -EINVAL; } +static inline int bio_integrity_map_iter(struct bio *bio, struct uio_meta *meta) +{ + return -EINVAL; +} + #endif /* CONFIG_BLK_DEV_INTEGRITY */ /* From patchwork Thu Apr 25 18:39:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13643664 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (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 6A8121514F3 for ; Thu, 25 Apr 2024 18:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070836; cv=none; b=HlW98T3nDBr4soKQ3/zZeyvp+/adYH0hVMW0SARJXFAMuBI858O1dlPiqez5aJcDUd/9x2ltn0fqLx7W9DdxMCBNbZTBIiB+VfxbMpq5yV7H0bOpCtz20BXYG6WuDZJWLfsCVO7IBOgcsblipkFhjU7g+EeT61lcC1/+i5RsKZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714070836; c=relaxed/simple; bh=yjhSZQBWHu+9ooXnHDKChNMvyIgMGhUXB9T+UWulfH0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=jK+WQzQVekfsQxyczgyctMrWj9QqmCp+jhcndk/1rpUgY16RcOMjeo9J2+t7uaPxMgUjauLMIOpZt4FrE3VCqwuwQHY0Fwr60BjE12dPSqYIvX2f7PwVQ7wLk0CwsWd9DkWeNA9K09gej/KYGKf2Cmz2zbkAeN1iF+dXbAKn99U= 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=VtYVIxFg; arc=none smtp.client-ip=203.254.224.34 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="VtYVIxFg" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240425184712epoutp04779f98c9b1069d39793b16ad53438756~Jmlc3iDbJ0105801058epoutp04j for ; Thu, 25 Apr 2024 18:47:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240425184712epoutp04779f98c9b1069d39793b16ad53438756~Jmlc3iDbJ0105801058epoutp04j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1714070832; bh=GpaNMWMqzUtQKOveThTCzAl0+LvJX9/CNL8Eg2zqipA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VtYVIxFgkXgDu7QRDS2Uc6QnTjsq3ywg+ckiPPZN5/cJtsXLA7yE3sJHBoECbQoXn xr/9CQyd84Ru2wgpLRm3A4ozyAkLQBeGGusV+oZTmFwdroR4l6ST2rJ3cB0ud0fdC0 ewGpLf9Xqj5Ut1Jho1Iq9JOa1QcO3jp9NsQiKNHw= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240425184711epcas5p2ff167da86ca6a3e26396a9b47387ce8b~JmlcTLqnC1621116211epcas5p2Y; Thu, 25 Apr 2024 18:47:11 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.177]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4VQPwZ5lFvz4x9Pv; Thu, 25 Apr 2024 18:47:10 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 7D.E6.19431.E25AA266; Fri, 26 Apr 2024 03:47:10 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240425184710epcas5p2968bbc40ed10d1f0184bb511af054fcb~Jmla3wUSC1896318963epcas5p2H; Thu, 25 Apr 2024 18:47:10 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240425184710epsmtrp2407dc1e395edbb139ed2fd6ca97458fa~Jmla3B_-P0377403774epsmtrp2G; Thu, 25 Apr 2024 18:47:10 +0000 (GMT) X-AuditID: b6c32a50-ccbff70000004be7-d8-662aa52ef286 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 0D.F0.07541.E25AA266; Fri, 26 Apr 2024 03:47:10 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240425184708epsmtip15a805bc42cf84a83e5c58dc63dbc8ef4~JmlZIg4mQ3266832668epsmtip17; Thu, 25 Apr 2024 18:47:08 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, martin.petersen@oracle.com, kbusch@kernel.org, hch@lst.de, brauner@kernel.org Cc: asml.silence@gmail.com, dw@davidwei.uk, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, Kanchan Joshi Subject: [PATCH 10/10] nvme: add separate handling for user integrity buffer Date: Fri, 26 Apr 2024 00:09:43 +0530 Message-Id: <20240425183943.6319-11-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425183943.6319-1-joshi.k@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+NgFlrLJsWRmVeSWpSXmKPExsWy7bCmpq7eUq00g/2ztSzmrNrGaLH6bj+b xevDnxgtXs1Yy2Zx88BOJouVq48yWbxrPcdicfT/WzaLSYeuMVrsvaVtMX/ZU3aL5cf/MTnw eFybMZHFY+esu+wel8+Wemxa1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b0jAwMAAA== X-CMS-MailID: 20240425184710epcas5p2968bbc40ed10d1f0184bb511af054fcb X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240425184710epcas5p2968bbc40ed10d1f0184bb511af054fcb References: <20240425183943.6319-1-joshi.k@samsung.com> For user provided integrity buffer, convert bip flags (guard/reftag/apptag checks) to protocol specific flags. Also pass apptag and reftag down. Signed-off-by: Kanchan Joshi --- drivers/nvme/host/core.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 27281a9a8951..3b719be4eedb 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -886,6 +886,13 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req, return BLK_STS_OK; } +static void nvme_set_app_tag(struct nvme_command *cmnd, u16 apptag) +{ + cmnd->rw.apptag = cpu_to_le16(apptag); + /* use 0xfff as mask so that apptag is used in entirety*/ + cmnd->rw.appmask = cpu_to_le16(0xffff); +} + static void nvme_set_ref_tag(struct nvme_ns *ns, struct nvme_command *cmnd, struct request *req) { @@ -943,6 +950,25 @@ static inline blk_status_t nvme_setup_write_zeroes(struct nvme_ns *ns, return BLK_STS_OK; } +static inline void nvme_setup_user_integrity(struct nvme_ns *ns, + struct request *req, struct nvme_command *cmnd, + u16 *control) +{ + struct bio_integrity_payload *bip = bio_integrity(req->bio); + unsigned short bip_flags = bip->bip_flags; + + if (bip_flags & BIP_USER_CHK_GUARD) + *control |= NVME_RW_PRINFO_PRCHK_GUARD; + if (bip_flags & BIP_USER_CHK_REFTAG) { + *control |= NVME_RW_PRINFO_PRCHK_REF; + nvme_set_ref_tag(ns, cmnd, req); + } + if (bip_flags & BIP_USER_CHK_APPTAG) { + *control |= NVME_RW_PRINFO_PRCHK_APP; + nvme_set_app_tag(cmnd, bip->apptag); + } +} + static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, struct request *req, struct nvme_command *cmnd, enum nvme_opcode op) @@ -983,6 +1009,14 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, if (WARN_ON_ONCE(!nvme_ns_has_pi(ns->head))) return BLK_STS_NOTSUPP; control |= NVME_RW_PRINFO_PRACT; + } else { + /* process user-created integrity */ + if (bio_integrity(req->bio)->bip_flags & + BIP_INTEGRITY_USER) { + nvme_setup_user_integrity(ns, req, cmnd, + &control); + goto out; + } } switch (ns->head->pi_type) { @@ -999,7 +1033,7 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, break; } } - +out: cmnd->rw.control = cpu_to_le16(control); cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt); return 0;