From patchwork Thu Aug 3 02:48:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13339180 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6BDBC001DE for ; Thu, 3 Aug 2023 02:48:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231405AbjHCCse (ORCPT ); Wed, 2 Aug 2023 22:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232883AbjHCCsd (ORCPT ); Wed, 2 Aug 2023 22:48:33 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDD47103 for ; Wed, 2 Aug 2023 19:48:31 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230803024829epoutp028a5e6c104eab3e182b313a5391f85ac6~3v6cwowyJ2226522265epoutp023 for ; Thu, 3 Aug 2023 02:48:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230803024829epoutp028a5e6c104eab3e182b313a5391f85ac6~3v6cwowyJ2226522265epoutp023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1691030909; bh=CwBsuvROgaXCJ8AMDL4SdXVgyJ0v6aiqhJAaPpU3dPk=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=G7CQKH3gIpIIWY7zdwYmI1MuoQOnskpH802WAnQjJsZK1J4fOJ30Y5vhe9p5T8bTm E1+xrwTZUH2BtKsG222bBjbEuivyO7I7MSDII5dgAP+qVr3/8VUu5WiW1zdCKTZGMg ggxKvriatT+jiwVutJ3GnUu95AnLCXRA5kxK4oxo= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230803024829epcas2p34e6b1542e6e1e5849517c7ca28ab2287~3v6cOK3eI2760627606epcas2p36; Thu, 3 Aug 2023 02:48:29 +0000 (GMT) Received: from epsmgec2p1.samsung.com (unknown [182.195.36.97]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4RGYF85ZKbz4x9Pv; Thu, 3 Aug 2023 02:48:28 +0000 (GMT) X-AuditID: b6c32a43-84dfa7000000c342-61-64cb157c45d9 Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmgec2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 9D.23.49986.C751BC46; Thu, 3 Aug 2023 11:48:28 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH v3 1/4] block: make bvec_try_merge_hw_page() non-static Reply-To: j-young.choi@samsung.com Sender: Jinyoung Choi From: Jinyoung Choi To: Christoph Hellwig , "axboe@kernel.dk" , "kbusch@kernel.org" , "chaitanya.kulkarni@wdc.com" , "sagi@grimberg.me" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "martin.petersen@oracle.com" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230803024656epcms2p4da6defb8e1e9b050fe2fbd52cb2e9524@epcms2p4> X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20230803024827epcms2p838d9e9131492c86a159fff25d195658f@epcms2p8> Date: Thu, 03 Aug 2023 11:48:27 +0900 X-CMS-MailID: 20230803024827epcms2p838d9e9131492c86a159fff25d195658f X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H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Zflvaz XSnHty9tuuyVNmdhyfTVdVkrDJr3trevqLbW/13ye2/cxtvNAskdM3u5tefz+VySTPrL4HLy fcTJb63F9+s+TfksdqOMx9ZVZvuu+yVVN7hXfl9e1s0w/VmiYqNp+/uolniFotLFtX5fmxUC uGwPH2pZuaysO0hOiaU4I9FQi7moOBEA51Mc+yoEAAA= DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230803024656epcms2p4da6defb8e1e9b050fe2fbd52cb2e9524 References: <20230803024656epcms2p4da6defb8e1e9b050fe2fbd52cb2e9524@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This will be used for multi-page configuration for integrity payload. Cc: Christoph Hellwig Cc: Martin K. Petersen Reviewed-by: Christoph Hellwig Signed-off-by: Jinyoung Choi --- block/bio.c | 2 +- block/blk.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index c92dda962449..8d1533af7c60 100644 --- a/block/bio.c +++ b/block/bio.c @@ -934,7 +934,7 @@ static bool bvec_try_merge_page(struct bio_vec *bv, struct page *page, * size limit. This is not for normal read/write bios, but for passthrough * or Zone Append operations that we can't split. */ -static bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, +bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, struct page *page, unsigned len, unsigned offset, bool *same_page) { diff --git a/block/blk.h b/block/blk.h index 686712e13835..9d22ec3a53bc 100644 --- a/block/blk.h +++ b/block/blk.h @@ -75,6 +75,10 @@ struct bio_vec *bvec_alloc(mempool_t *pool, unsigned short *nr_vecs, gfp_t gfp_mask); void bvec_free(mempool_t *pool, struct bio_vec *bv, unsigned short nr_vecs); +bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, + struct page *page, unsigned len, unsigned offset, + bool *same_page); + static inline bool biovec_phys_mergeable(struct request_queue *q, struct bio_vec *vec1, struct bio_vec *vec2) { From patchwork Thu Aug 3 02:49:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13339181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75235C001DE for ; Thu, 3 Aug 2023 02:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233758AbjHCCuI (ORCPT ); Wed, 2 Aug 2023 22:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231577AbjHCCuE (ORCPT ); Wed, 2 Aug 2023 22:50:04 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2644FE7D for ; Wed, 2 Aug 2023 19:50:00 -0700 (PDT) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230803024958epoutp02b7124310411c38b26b76dfad9c06db1c~3v7vQh0J62532425324epoutp02M for ; Thu, 3 Aug 2023 02:49:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230803024958epoutp02b7124310411c38b26b76dfad9c06db1c~3v7vQh0J62532425324epoutp02M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1691030998; bh=lONrHNsEkCBmY0gtyPzxjck/4+ABThiyZREGBOSdSJI=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=V+eK/hB4X46Gop1awZNZec0RgAqITRz+SZs6DQildHdoA0sSwHyvmhOuAaMeEGYk0 YIe46OyoK7RdHYEcL9IVFXrjAYTPgtaQwFueDy8agdChIjdY4sz+zUcoO3OIchIX1W h9m3k/g+bzumNw77oNOKLgRFa3FbDatOV5vFoIAc= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230803024957epcas2p31983d25d59b29e60b32e8101169c09af~3v7usJOwG2133421334epcas2p3I; Thu, 3 Aug 2023 02:49:57 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.102]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4RGYGs2487z4x9Pt; Thu, 3 Aug 2023 02:49:57 +0000 (GMT) X-AuditID: b6c32a45-83dfd7000000c2f9-9c-64cb15d5f7f2 Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id F0.AA.49913.5D51BC46; Thu, 3 Aug 2023 11:49:57 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH v3 2/4] bio-integrity: update the payload size in bio_integrity_add_page() Reply-To: j-young.choi@samsung.com Sender: Jinyoung Choi From: Jinyoung Choi To: Christoph Hellwig , "axboe@kernel.dk" , "kbusch@kernel.org" , "chaitanya.kulkarni@wdc.com" , "sagi@grimberg.me" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "martin.petersen@oracle.com" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230803024827epcms2p838d9e9131492c86a159fff25d195658f@epcms2p8> X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20230803024956epcms2p38186a17392706650c582d38ef3dbcd32@epcms2p3> Date: Thu, 03 Aug 2023 11:49:56 +0900 X-CMS-MailID: 20230803024956epcms2p38186a17392706650c582d38ef3dbcd32 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBJsWRmVeSWpSXmKPExsW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bZxcHXOgamC93qXbF3ZM2f3RyVm f8GUh3u/RH36mdM1q23W9Mlcew5/eC0mNeWva3rZW0lzfb8//qvuxjGwzd565Edn4uTHFpvb rp78fmvj0QcN/zh0XlbEfDi4RYmlOCPRUIu5qDgRACILMk4rBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230803024656epcms2p4da6defb8e1e9b050fe2fbd52cb2e9524 References: <20230803024827epcms2p838d9e9131492c86a159fff25d195658f@epcms2p8> <20230803024656epcms2p4da6defb8e1e9b050fe2fbd52cb2e9524@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Previously, the bip's bi_size has been set before an integrity pages were added. If a problem occurs in the process of adding pages for bip, the bi_size mismatch problem must be dealt with. When the page is successfully added to bvec, the bi_size is updated. The parts affected by the change were also contained in this commit. Cc: Christoph Hellwig Cc: Martin K. Petersen Reviewed-by: Christoph Hellwig Signed-off-by: Jinyoung Choi --- block/bio-integrity.c | 2 +- drivers/md/dm-crypt.c | 1 - drivers/nvme/host/ioctl.c | 1 - drivers/nvme/target/io-cmd-bdev.c | 3 +-- drivers/target/target_core_iblock.c | 3 +-- 5 files changed, 3 insertions(+), 7 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 045553a164e0..6220a99977a4 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -137,6 +137,7 @@ int bio_integrity_add_page(struct bio *bio, struct page *page, bvec_set_page(&bip->bip_vec[bip->bip_vcnt], page, len, offset); bip->bip_vcnt++; + bip->bip_iter.bi_size += len; return len; } @@ -244,7 +245,6 @@ bool bio_integrity_prep(struct bio *bio) } bip->bip_flags |= BIP_BLOCK_INTEGRITY; - bip->bip_iter.bi_size = len; bip_set_seed(bip, bio->bi_iter.bi_sector); if (bi->flags & BLK_INTEGRITY_IP_CHECKSUM) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 1dc6227d353e..f2662c21a6df 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1160,7 +1160,6 @@ static int dm_crypt_integrity_io_alloc(struct dm_crypt_io *io, struct bio *bio) tag_len = io->cc->on_disk_tag_size * (bio_sectors(bio) >> io->cc->sector_shift); - bip->bip_iter.bi_size = tag_len; bip->bip_iter.bi_sector = io->cc->start + io->sector; ret = bio_integrity_add_page(bio, virt_to_page(io->integrity_metadata), diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 5c3250f36ce7..19a5177bc360 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -118,7 +118,6 @@ static void *nvme_add_user_metadata(struct request *req, void __user *ubuf, goto out_free_meta; } - bip->bip_iter.bi_size = len; bip->bip_iter.bi_sector = seed; ret = bio_integrity_add_page(bio, virt_to_page(buf), len, offset_in_page(buf)); diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c index 2733e0158585..468833675cc9 100644 --- a/drivers/nvme/target/io-cmd-bdev.c +++ b/drivers/nvme/target/io-cmd-bdev.c @@ -206,12 +206,11 @@ static int nvmet_bdev_alloc_bip(struct nvmet_req *req, struct bio *bio, return PTR_ERR(bip); } - bip->bip_iter.bi_size = bio_integrity_bytes(bi, bio_sectors(bio)); /* virtual start sector must be in integrity interval units */ bip_set_seed(bip, bio->bi_iter.bi_sector >> (bi->interval_exp - SECTOR_SHIFT)); - resid = bip->bip_iter.bi_size; + resid = bio_integrity_bytes(bi, bio_sectors(bio)); while (resid > 0 && sg_miter_next(miter)) { len = min_t(size_t, miter->length, resid); rc = bio_integrity_add_page(bio, miter->page, len, diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 3d1b511ea284..a7050f63b7cc 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -689,7 +689,6 @@ iblock_alloc_bip(struct se_cmd *cmd, struct bio *bio, return PTR_ERR(bip); } - bip->bip_iter.bi_size = bio_integrity_bytes(bi, bio_sectors(bio)); /* virtual start sector must be in integrity interval units */ bip_set_seed(bip, bio->bi_iter.bi_sector >> (bi->interval_exp - SECTOR_SHIFT)); @@ -697,7 +696,7 @@ iblock_alloc_bip(struct se_cmd *cmd, struct bio *bio, pr_debug("IBLOCK BIP Size: %u Sector: %llu\n", bip->bip_iter.bi_size, (unsigned long long)bip->bip_iter.bi_sector); - resid = bip->bip_iter.bi_size; + resid = bio_integrity_bytes(bi, bio_sectors(bio)); while (resid > 0 && sg_miter_next(miter)) { len = min_t(size_t, miter->length, resid); From patchwork Thu Aug 3 02:50:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13339182 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E975DC001DE for ; Thu, 3 Aug 2023 02:51:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231462AbjHCCvG (ORCPT ); Wed, 2 Aug 2023 22:51:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231484AbjHCCvF (ORCPT ); Wed, 2 Aug 2023 22:51:05 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D1E810A for ; Wed, 2 Aug 2023 19:51:03 -0700 (PDT) Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20230803025101epoutp0393e0a701a8aa2ee8a607ae2f5a14aa6d~3v8qWoIqS3201732017epoutp034 for ; Thu, 3 Aug 2023 02:51:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20230803025101epoutp0393e0a701a8aa2ee8a607ae2f5a14aa6d~3v8qWoIqS3201732017epoutp034 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1691031061; bh=GgZEpQKj5vGYyF34El8cqciXDkasij1/6nECeUJEU8w=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=lG6g6KM0H5iTchjUnUVs4vAwUs7AdYdVHA6MXcQIoLxuL0M0ohLrDzbfWaQDPDG24 kcWdRIcNUD6+QPWMP1vdobBe6DeqFLhQpZcuiANsjJoJOAIFZ07RnXI/rzR6+g+tfB EvGFEcJzUsepMh0i280gVPDV8qUUTm91ugpl7kvs= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20230803025100epcas2p19ca34ccc42f2fccb928a183efe4589de~3v8opgKQX1952119521epcas2p1D; Thu, 3 Aug 2023 02:51:00 +0000 (GMT) Received: from epsmgec2p1-new.samsung.com (unknown [182.195.36.91]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4RGYJ33WbNz4x9Ps; Thu, 3 Aug 2023 02:50:59 +0000 (GMT) X-AuditID: b6c32a4d-637c170000047356-e5-64cb1613582c Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmgec2p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id E4.EA.29526.3161BC46; Thu, 3 Aug 2023 11:50:59 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH v3 3/4] bio-integrity: cleanup adding integrity pages to bip's bvec. Reply-To: j-young.choi@samsung.com Sender: Jinyoung Choi From: Jinyoung Choi To: Christoph Hellwig , "axboe@kernel.dk" , "kbusch@kernel.org" , "chaitanya.kulkarni@wdc.com" , "sagi@grimberg.me" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "martin.petersen@oracle.com" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230803024656epcms2p4da6defb8e1e9b050fe2fbd52cb2e9524@epcms2p4> X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20230803025058epcms2p5a4d0db5da2ad967668932d463661c633@epcms2p5> Date: Thu, 03 Aug 2023 11:50:58 +0900 X-CMS-MailID: 20230803025058epcms2p5a4d0db5da2ad967668932d463661c633 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNJsWRmVeSWpSXmKPExsWy7bCmha6w2OkUg/dPxS1W3+1ns5h1+zWL xctDmhanJyxisph06Bqjxd5b2haXd81hs1h+/B+TxbrX71kcOD3O39vI4rF5hZbH5bOlHptW dbJ5fHx6i8Wjb8sqRo/Pm+Q82g90MwVwRGXbZKQmpqQWKaTmJeenZOal2yp5B8c7x5uaGRjq GlpamCsp5CXmptoqufgE6Lpl5gDdpqRQlphTChQKSCwuVtK3synKLy1JVcjILy6xVUotSMkp MC/QK07MLS7NS9fLSy2xMjQwMDIFKkzIzpi0/w1TwSKeiqmzjzI3MB7m7GLk5JAQMJHYvGsK O4gtJLCHUeLfX7MuRg4OXgFBib87hEHCwgJhEov//2GGKFGSOLdmFiNE3ECi5XYbC4jNJqAn seP5bqAxXBwiAnOYJS6tWcYKMZ9XYkb7UxYIW1pi+/KtYM2cAn4Sl6bNhoprSPxY1ssMYYtK 3Fz9lh3Gfn9sPiOELSLReu8sVI2gxIOfu6HikhKHDn1lA7lZQiBfYsOBQIhwjUTbr/dQ5foS 1zo2gq3iFfCVmLZ7OxuIzSKgKrFw5kQWiFYXiaer80HCzALyEtvfzmEGCTMLaEqs36UPUaEs ceQWC0QFn0TH4b/sMP81bPyNlb1j3hMmiFY1iUVNRhBhGYmvh+ezT2BUmoUI5VlI1s5CWLuA kXkVo1RqQXFuemqyUYGhbl5qOTxuk/NzNzGCU6mW7w7G1+v/6h1iZOJgPMQowcGsJMIr/ft4 ihBvSmJlVWpRfnxRaU5q8SFGU6CfJzJLiSbnA5N5Xkm8oYmlgYmZmaG5kamBuZI4773WuSlC AumJJanZqakFqUUwfUwcnFINTDrXX2/ZyO3zTGPD+8Ygaa5gp+5TyrIzf0t8mNduffp8gcjf 6UFium1za/w1Hl7Iedz4d8M21sIG02tP7nls7b1141jFS5mp788fZhDYt45VqT3s155HjEb9 5/kWSvovNRFZdCHk4+apwT/CXjJZmcRM3VlvWReRvpiHa7ZvjrNviGOBc73HSzXNph7fnqcd dUa7GjRM76/Zt/ZVtM8J7vtP/IUOfNKNnLQihS+E5/G8vSuWXWLYcGeqYHeY4hnhfQya5pMa Nmz4vmHaHc/LQo0uSxlebFv0X8J53b75HJ56blqWgSyVke+Fd5yzeD6Jt+Y/n5DUj/Cny454 8YTxKPqeun/XTe5evFjzbCZXCyWW4oxEQy3mouJEAD1waQUuBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230803024656epcms2p4da6defb8e1e9b050fe2fbd52cb2e9524 References: <20230803024656epcms2p4da6defb8e1e9b050fe2fbd52cb2e9524@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org bio_integrity_add_page() returns the add length if successful, else 0, just as bio_add_page. Simply check return value checking in bio_integrity_prep to not deal with a > 0 but < len case that can't happen. Cc: Christoph Hellwig Cc: Martin K. Petersen Reviewed-by: Christoph Hellwig Signed-off-by: Jinyoung Choi --- block/bio-integrity.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 6220a99977a4..c6b3bc86e1f9 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -252,27 +252,18 @@ bool bio_integrity_prep(struct bio *bio) /* Map it */ offset = offset_in_page(buf); - for (i = 0 ; i < nr_pages ; i++) { - int ret; + for (i = 0; i < nr_pages && len > 0; i++) { bytes = PAGE_SIZE - offset; - if (len <= 0) - break; - if (bytes > len) bytes = len; - ret = bio_integrity_add_page(bio, virt_to_page(buf), - bytes, offset); - - if (ret == 0) { + if (bio_integrity_add_page(bio, virt_to_page(buf), + bytes, offset) < bytes) { printk(KERN_ERR "could not attach integrity payload\n"); goto err_end_io; } - if (ret < bytes) - break; - buf += bytes; len -= bytes; offset = 0; @@ -291,7 +282,6 @@ bool bio_integrity_prep(struct bio *bio) bio->bi_status = BLK_STS_RESOURCE; bio_endio(bio); return false; - } EXPORT_SYMBOL(bio_integrity_prep); From patchwork Thu Aug 3 02:52:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13339190 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDA25C04A6A for ; Thu, 3 Aug 2023 02:52:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232400AbjHCCwI (ORCPT ); Wed, 2 Aug 2023 22:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231354AbjHCCwH (ORCPT ); Wed, 2 Aug 2023 22:52:07 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA9AC1AA for ; Wed, 2 Aug 2023 19:52:05 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20230803025203epoutp03edbaf2108ea5bb9f61f09bc2d0325cf2~3v9kEe-fi3117531175epoutp03a for ; Thu, 3 Aug 2023 02:52:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20230803025203epoutp03edbaf2108ea5bb9f61f09bc2d0325cf2~3v9kEe-fi3117531175epoutp03a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1691031123; bh=PoQdjC9lBed1xqyEfsVkXd2x90gYvZd/Stb7lCXTnc0=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=TDbnLOJFuQJogZjHquL6qwrCnLtTWOshSi29pJ52cz/Rw2yzAEw6/Wde1phkzo81P 8w+NenQZdPi3IVTcRsFbqfOFPQcMJmTv+hB3FZwKjmE0OwT4gwz+N5WwV5ekXh3fRr 7MYqNVGj2R33kdaBGlcql0lIiboZkfsphhFH5zDM= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20230803025203epcas2p22fd826ad8ebfbc1bc720885cc81be973~3v9jtijML0956209562epcas2p2A; Thu, 3 Aug 2023 02:52:03 +0000 (GMT) Received: from epsmgec2p1.samsung.com (unknown [182.195.36.99]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4RGYKG6b9sz4x9Py; Thu, 3 Aug 2023 02:52:02 +0000 (GMT) X-AuditID: b6c32a43-84dfa7000000c342-bd-64cb1652b575 Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmgec2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 2C.44.49986.2561BC46; Thu, 3 Aug 2023 11:52:02 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH v3 4/4] bio-integrity: create multi-page bvecs in bio_integrity_add_page() Reply-To: j-young.choi@samsung.com Sender: Jinyoung Choi From: Jinyoung Choi To: Christoph Hellwig , "axboe@kernel.dk" , "kbusch@kernel.org" , "chaitanya.kulkarni@wdc.com" , "sagi@grimberg.me" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "martin.petersen@oracle.com" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230803024656epcms2p4da6defb8e1e9b050fe2fbd52cb2e9524@epcms2p4> X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20230803025202epcms2p82f57cbfe32195da38c776377b55aed59@epcms2p8> Date: Thu, 03 Aug 2023 11:52:02 +0900 X-CMS-MailID: 20230803025202epcms2p82f57cbfe32195da38c776377b55aed59 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJJsWRmVeSWpSXmKPExsWy7bCmqW6Q2OkUg7dPDSxW3+1ns5h1+zWL xctDmhanJyxisph06Bqjxd5b2haXd81hs1h+/B+TxbrX71kcOD3O39vI4rF5hZbH5bOlHptW dbJ5fHx6i8Wjb8sqRo/Pm+Q82g90MwVwRGXbZKQmpqQWKaTmJeenZOal2yp5B8c7x5uaGRjq GlpamCsp5CXmptoqufgE6Lpl5gDdpqRQlphTChQKSCwuVtK3synKLy1JVcjILy6xVUotSMkp MC/QK07MLS7NS9fLSy2xMjQwMDIFKkzIzpjTsJyloEeoYs32lYwNjA/5uhg5OSQETCTu3G9m 7GLk4hAS2MEoseLTMiCHg4NXQFDi7w5hkBphgRiJSfuXsILYQgJKEufWzGKEiBtItNxuYwGx 2QT0JHY8380OMkdEYA6zxKU1y1ghFvBKzGh/ygJhS0tsX74VrJlTwE/i0rTZUHENiR/Lepkh bFGJm6vfssPY74/NZ4SwRSRa752FqhGUePBzN1RcUuLQoa9sIDdLCORLbDgQCBGukWj79R6q XF/iWsdGsFW8Ar4Sf5efArNZBFQlTm75BDXGReJVXwcbiM0sIC+x/e0cZpCRzAKaEut36UNM V5Y4cosFooJPouPwX3aYBxs2/sbK3jHvCRNEq5rEoiYjiLCMxNfD89knMCrNQgTzLCRrZyGs XcDIvIpRLLWgODc9NdmowBAes8n5uZsYwWlUy3kH45X5//QOMTJxMB5ilOBgVhLhlf59PEWI NyWxsiq1KD++qDQntfgQoynQwxOZpUST84GJPK8k3tDE0sDEzMzQ3MjUwFxJnPde69wUIYH0 xJLU7NTUgtQimD4mDk6pBiZv1tMrtFavaVJ3X6vF4+qnfH6JwcZvSdO2f4/79HzB9npGn6x/ m2zcVGoOtq+745XxcqfAhgj2BQ8fFCQnBMad0p46fep77umxt2WOn+h2nhjyZM6v1TXzkr1T 13xnKz0rbrYx4qmhTYVDJvuLpKYyVXmxiqOTNjKdtdd+yH4o1vfRvpwzfyKTr786lsl04puA 4CmFeVOFdza3rj67U1orWCvh4Z1OkSPsv857VSnI2va1q6qb/yw6vbz6S8Hr6xy/121xEpSU m5DN94XV6JtRP++nlkPVa9t/5sSzL/p2auvP6XXr/GwSr97f9SSt6LzcBp5jiUZRLpdvPnCY +e5y/OZnq5LPrJ21vLDGavkUJZbijERDLeai4kQA7+eTQCwEAAA= DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230803024656epcms2p4da6defb8e1e9b050fe2fbd52cb2e9524 References: <20230803024656epcms2p4da6defb8e1e9b050fe2fbd52cb2e9524@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org In general, the bvec data structure consists of one for physically continuous pages. But, in the bvec configuration for bip, physically continuous integrity pages are composed of each bvec. Allow bio_integrity_add_page() to create multi-page bvecs, just like the bio payloads. This simplifies adding larger payloads, and fixes support for non-tiny workloads with nvme, which stopped using scatterlist for metadata a while ago. Cc: Christoph Hellwig Cc: Martin K. Petersen Fixes: 783b94bd9250 ("nvme-pci: do not build a scatterlist to map metadata") Reviewed-by: Christoph Hellwig Signed-off-by: Jinyoung Choi --- block/bio-integrity.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index c6b3bc86e1f9..ec8ac8cf6e1b 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -123,17 +123,34 @@ void bio_integrity_free(struct bio *bio) int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset) { + struct request_queue *q = bdev_get_queue(bio->bi_bdev); struct bio_integrity_payload *bip = bio_integrity(bio); - if (bip->bip_vcnt >= bip->bip_max_vcnt) { - printk(KERN_ERR "%s: bip_vec full\n", __func__); + if (((bip->bip_iter.bi_size + len) >> SECTOR_SHIFT) > + queue_max_hw_sectors(q)) return 0; - } - if (bip->bip_vcnt && - bvec_gap_to_prev(&bdev_get_queue(bio->bi_bdev)->limits, - &bip->bip_vec[bip->bip_vcnt - 1], offset)) - return 0; + if (bip->bip_vcnt > 0) { + struct bio_vec *bv = &bip->bip_vec[bip->bip_vcnt - 1]; + bool same_page = false; + + if (bvec_try_merge_hw_page(q, bv, page, len, offset, + &same_page)) { + bip->bip_iter.bi_size += len; + return len; + } + + if (bip->bip_vcnt >= + min(bip->bip_max_vcnt, queue_max_integrity_segments(q))) + return 0; + + /* + * If the queue doesn't support SG gaps and adding this segment + * would create a gap, disallow it. + */ + if (bvec_gap_to_prev(&q->limits, bv, offset)) + return 0; + } bvec_set_page(&bip->bip_vec[bip->bip_vcnt], page, len, offset); bip->bip_vcnt++;