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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sl04puA 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++;