From patchwork Wed May 10 09:00:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13236668 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 85BA8C77B7C for ; Wed, 10 May 2023 09:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236484AbjEJJAi (ORCPT ); Wed, 10 May 2023 05:00:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236916AbjEJJAd (ORCPT ); Wed, 10 May 2023 05:00:33 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D87A62696 for ; Wed, 10 May 2023 02:00:31 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20230510090029epoutp030c36f49716aa928c1379cd9a394b4ca5~dvJ_zAJ_P2451624516epoutp03t for ; Wed, 10 May 2023 09:00:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20230510090029epoutp030c36f49716aa928c1379cd9a394b4ca5~dvJ_zAJ_P2451624516epoutp03t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683709229; bh=wje4+70dQGpdS69u2rE7bX4B832hSjQqhr75qyzguy4=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=kqhxbcPSaXcHOAsTgBGMGwm6YMedZCqxm6NhZsPtvidMrw0TQYSXo3t1TL3e3V4aZ s3XjZK5KaBGeCUInbvdLn6FJvNZzS/7Qwein6X4MVcSn56wH4Kt1c+Ynba6AtS6uqJ 1V/YEzJFik18+sROJmWlMXWngEiRRf69GgrjAuhc= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230510090029epcas2p4bf8726b14940f028d6ff4c6aedc737fb~dvJ_PgxYW3236532365epcas2p4S; Wed, 10 May 2023 09:00:29 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.89]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4QGTWc466Bz4x9Q0; Wed, 10 May 2023 09:00:28 +0000 (GMT) X-AuditID: b6c32a45-465ff70000020cc1-e1-645b5d2c08f0 Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 09.2F.03265.C2D5B546; Wed, 10 May 2023 18:00:28 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH v2 13/14] block: blk-integrity: change sg-table configuration method for integrity Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "kbusch@kernel.org" , "hch@lst.de" , "sagi@grimberg.me" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "johannes.thumshirn@wdc.com" , "kch@nvidia.com" , "willy@infradead.org" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230510084407epcms2p123f17696d3c30c749897eeaf2c4de684@epcms2p1> 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: <20230510090028epcms2p6bdffebacbdf4784bbf03a62b7101dd98@epcms2p6> Date: Wed, 10 May 2023 18:00:28 +0900 X-CMS-MailID: 20230510090028epcms2p6bdffebacbdf4784bbf03a62b7101dd98 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 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rwlnZzrKz+wxPfWmwq6FJv8v8x7PFaOZeoCS4ttUevs +c4VzemJ82LPWXz3lWC8Z5NBSIjspRar3PDGMo2LZ0Wnatn8/Hu2pX9BnnRsuSrLr4d71mX4 ls2Y0l3fdSJd98zmbXuV0g7xdJqwnRby6YuZaR4n99rR8dH0UDPF6fM+HUpketj2bYvGDK2w qyava6pNT8y1XH2SdfZjm/+8pVO/R2yX/+ojosDctPb84kezr/7uiV++zML5kMKud6avtiqx FGckGmoxFxUnAgBw8ne9TQQAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230510084407epcms2p123f17696d3c30c749897eeaf2c4de684 References: <20230510084407epcms2p123f17696d3c30c749897eeaf2c4de684@epcms2p1> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Previously, a bio_vec of bip was made of one page in the block layer, and sg_list was generated using hw information in lld. This is done in the block layer and the bio_vec has been changed to multi-page, so it is changed to configure the sg-table using the existing api, such as the sg-table setting for the bio. (e.g. multi-page map) Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- block/blk-integrity.c | 52 ----------------------------------------- block/blk-merge.c | 54 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 52 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 64407b412947..c50954652177 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -55,58 +55,6 @@ int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio) } EXPORT_SYMBOL(blk_rq_count_integrity_sg); -/** - * blk_rq_map_integrity_sg - Map integrity metadata into a scatterlist - * @q: request queue - * @bio: bio with integrity metadata attached - * @sglist: target scatterlist - * - * Description: Map the integrity vectors in request into a - * scatterlist. The scatterlist must be big enough to hold all - * elements. I.e. sized using blk_rq_count_integrity_sg(). - */ -int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio, - struct scatterlist *sglist) -{ - struct bio_vec iv, ivprv = { NULL }; - struct scatterlist *sg = NULL; - unsigned int segments = 0; - struct bvec_iter iter; - int prev = 0; - - bio_for_each_integrity_vec(iv, bio, iter) { - - if (prev) { - if (!biovec_phys_mergeable(q, &ivprv, &iv)) - goto new_segment; - if (sg->length + iv.bv_len > queue_max_segment_size(q)) - goto new_segment; - - sg->length += iv.bv_len; - } else { -new_segment: - if (!sg) - sg = sglist; - else { - sg_unmark_end(sg); - sg = sg_next(sg); - } - - sg_set_page(sg, iv.bv_page, iv.bv_len, iv.bv_offset); - segments++; - } - - prev = 1; - ivprv = iv; - } - - if (sg) - sg_mark_end(sg); - - return segments; -} -EXPORT_SYMBOL(blk_rq_map_integrity_sg); - /** * blk_integrity_compare - Compare integrity profile of two disks * @gd1: Disk to compare diff --git a/block/blk-merge.c b/block/blk-merge.c index c6a0958e8df1..f17e19ff3a11 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -524,6 +524,60 @@ __blk_segment_map_sg_merge(struct request_queue *q, struct bio_vec *bvec, return true; } +#if defined(CONFIG_BLK_DEV_INTEGRITY) +/** + * blk_rq_map_integrity_sg - Map integrity metadata into a scatterlist + * @q: request queue + * @bio: bio with integrity metadata attached + * @sglist: target scatterlist + * + * Description: Map the integrity vectors in request into a scatterlist. + * The scatterlist must be big enough to hold all elements. + */ +int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio, + struct scatterlist *sglist) +{ + struct bio_vec iv, ivprv = { NULL }; + struct scatterlist *sg = NULL; + unsigned int nsegs = 0; + struct bvec_iter iter; + bool new_bio = false; + + for_each_bio(bio) { + struct bio_integrity_payload *bip = bio->bi_integrity; + + bip_for_each_mp_bvec(iv, bip, iter) { + /* + * Only try to merge bvecs from two bios given we + * have done bio internal merge when adding pages + * to bio + */ + if (new_bio && + __blk_segment_map_sg_merge(q, &iv, &ivprv, &sg)) + goto next_iv; + + if (iv.bv_offset + iv.bv_len <= PAGE_SIZE) + nsegs += __blk_bvec_map_sg(iv, sglist, &sg); + else + nsegs += blk_bvec_map_sg(q, &iv, sglist, &sg); + next_iv: + new_bio = false; + } + + if (likely(bip->bip_iter.bi_size)) { + ivprv = iv; + new_bio = true; + } + } + + if (sg) + sg_mark_end(sg); + + return nsegs; +} +EXPORT_SYMBOL(blk_rq_map_integrity_sg); +#endif /* CONFIG_BLK_DEV_INTEGRITY */ + static int __blk_bios_map_sg(struct request_queue *q, struct bio *bio, struct scatterlist *sglist, struct scatterlist **sg)