From patchwork Wed May 3 10:00:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230006 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 4F09FC77B7F for ; Wed, 3 May 2023 10:01:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229686AbjECKA7 (ORCPT ); Wed, 3 May 2023 06:00:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbjECKA6 (ORCPT ); Wed, 3 May 2023 06:00:58 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2833E43 for ; Wed, 3 May 2023 03:00:53 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20230503100051epoutp035982bcb0b25098be22c18a74a484c9d7~bmdr5YAfq1309313093epoutp03t for ; Wed, 3 May 2023 10:00:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20230503100051epoutp035982bcb0b25098be22c18a74a484c9d7~bmdr5YAfq1309313093epoutp03t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683108051; bh=Lh/JoKhqwHvgqNqdwOhUU4xB3qjfNA9DOJp/qwOaGTM=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=SwzA/pbmu8lEKPrQtd05GBW8GO8WrxrE1PF4buYVMm7KDgsbq82mB1d+NZ0zy0QaA tilrDndq0ZDBZkD69z2qDxnWT38yJhyGoi/SO3o0F8MmZuEl3Lk+IyJ9q3nRK5Y9ly ZJSEzifAVj0JCoq4tjLqdZ1clswtOg743ZjWXtRQ= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230503100051epcas2p4226eb26512691c9a5b0fe5e8ab873761~bmdrfzeS-1761217612epcas2p4q; Wed, 3 May 2023 10:00:51 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.88]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4QBCBV3zyxz4x9Px; Wed, 3 May 2023 10:00:50 +0000 (GMT) X-AuditID: b6c32a47-e99fd70000002007-a4-645230d274be Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 70.89.08199.2D032546; Wed, 3 May 2023 19:00:50 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 01/15] block: bio: rename page_is_mergeable to bio_page_is_mergeable and make non-static Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "hch@lst.de" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503100049epcms2p2c830ebb7b50beaa2663abd0cd274293c@epcms2p2> Date: Wed, 03 May 2023 19:00:49 +0900 X-CMS-MailID: 20230503100049epcms2p2c830ebb7b50beaa2663abd0cd274293c X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPKsWRmVeSWpSXmKPExsWy7bCmhe4lg6AUg797ZC1W3+1ns3h5SNNi 5eqjTBa9/VvZLPbe0ra4vGsOm8Xy4/+YHNg9Lp8t9dh9s4HN4+PTWywefVtWMXp83iQXwBqV bZORmpiSWqSQmpecn5KZl26r5B0c7xxvamZgqGtoaWGupJCXmJtqq+TiE6DrlpkDdIOSQlli TilQKCCxuFhJ386mKL+0JFUhI7+4xFYptSAlp8C8QK84Mbe4NC9dLy+1xMrQwMDIFKgwITuj /fc55oKzAhXP775hbWDcx9vFyMkhIWAisXPNPZYuRi4OIYEdjBJXt/9n7WLk4OAVEJT4u0MY pEZYIEti69Kb7CC2kICSxLk1sxhBSoQFDCRu9ZqDhNkE9CR+LpnBBmKLCKxmkmh+XgMxnldi RvtTFghbWmL78q2MIDangJ/E4w23GCHiGhI/lvUyQ9iiEjdXv2WHsd8fmw9VIyLReu8sVI2g xIOfu6HikhKHDn1lAzlHQiBfYsOBQIhwjcTb5QegSvQlrnVsBDuBV8BXYtHxVrDxLAKqEvN7 ZkCtcpGY9+UxE4jNLCAvsf3tHGaQkcwCmhLrd+lDTFeWOHKLBaKCT6Lj8F92mAcbNv7Gyt4x 7wkTRKuaxKImI4iwjMTXw/PZJzAqzUIE8iwka2chrF3AyLyKUSy1oDg3PbXYqMAYHq/J+bmb GMEpUct9B+OMtx/0DjEycTAeYpTgYFYS4f1Q6JcixJuSWFmVWpQfX1Sak1p8iNEU6OGJzFKi yfnApJxXEm9oYmlgYmZmaG5kamCuJM4rbXsyWUggPbEkNTs1tSC1CKaPiYNTqoEp42zr9p+F E1Qud2pKKRwoCN/rYnhmf/unX2U5nx/wnFW/63jDv1Jgsd131ud5VevUfT06eXZPk/34f8uZ /03muycamLRLFTmobtv8I4xP+HfEhb1nHzbkKLOxntQ1i+TXUvjUbPNkntr28NqWS9oXH+3r EFZ8IdZSdCcx2yEw+cyc2Wv2tS3VfTzj6c4dRwzrq5auNFOad+xSkdPHFyuq6x7uD72qNfdd qDHbskU3rf/vZpp3duXqtK/yPnOTuTUsWr4Ymy6P7dWUl179qTTgnUmh2Nb1c9avmbBep/fM 1J38exxag2Kzo33LZb0+K6gknLf/GHWr6FV2Rfxka9GJ+fa1ZcY5py7rP562Ri9LiaU4I9FQ i7moOBEA7Q64whIEAAA= DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org page_is_meargeable() can be used to merge the page to the bio_vec of bio's integrity payload. For this, the static was removed. There is a page_is_mergeable() in F2FS filesystem, so the name was changed to bio_page_is_mergeable. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- block/bio.c | 8 ++++---- include/linux/bio.h | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/block/bio.c b/block/bio.c index fd11614bba4d..3e5ab59502e2 100644 --- a/block/bio.c +++ b/block/bio.c @@ -903,9 +903,9 @@ static inline bool bio_full(struct bio *bio, unsigned len) return false; } -static inline bool page_is_mergeable(const struct bio_vec *bv, - struct page *page, unsigned int len, unsigned int off, - bool *same_page) +bool bio_page_is_mergeable(const struct bio_vec *bv, struct page *page, + unsigned int len, unsigned int off, + bool *same_page) { size_t bv_end = bv->bv_offset + bv->bv_len; phys_addr_t vec_end_addr = page_to_phys(bv->bv_page) + bv_end - 1; @@ -951,7 +951,7 @@ static bool __bio_try_merge_page(struct bio *bio, struct page *page, if (bio->bi_vcnt > 0) { struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; - if (page_is_mergeable(bv, page, len, off, same_page)) { + if (bio_page_is_mergeable(bv, page, len, off, same_page)) { if (bio->bi_iter.bi_size > UINT_MAX - len) { *same_page = false; return false; diff --git a/include/linux/bio.h b/include/linux/bio.h index d766be7152e1..b53a595b519a 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -418,6 +418,9 @@ struct bio *bio_alloc_clone(struct block_device *bdev, struct bio *bio_src, gfp_t gfp, struct bio_set *bs); int bio_init_clone(struct block_device *bdev, struct bio *bio, struct bio *bio_src, gfp_t gfp); +bool bio_page_is_mergeable(const struct bio_vec *bv, struct page *page, + unsigned int len, unsigned int off, + bool *same_page); extern struct bio_set fs_bio_set; From patchwork Wed May 3 10:02:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230007 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 C0FD2C77B7F for ; Wed, 3 May 2023 10:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbjECKC1 (ORCPT ); Wed, 3 May 2023 06:02:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbjECKC0 (ORCPT ); Wed, 3 May 2023 06:02:26 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33EBC1B0 for ; Wed, 3 May 2023 03:02:24 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230503100222epoutp0487431c43ad29b0041b724710254fb27a~bmfAidJNM1123611236epoutp04R for ; Wed, 3 May 2023 10:02:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230503100222epoutp0487431c43ad29b0041b724710254fb27a~bmfAidJNM1123611236epoutp04R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683108142; bh=o/y7pqqreOOyNd3ZbjyVH5zrhKm5j2wzOS45niAlYE4=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=qXa2dMLgA5s9fizPdZRKXZ2zfZHhrjlKptjJ0gAa0Yarx+cauEYQ7uDBJCjNxOg9S 887PELrA/+Dc/BsnFO9x4sqBi5lAu+30b7U9Dk9tIPKByk2Q4The8pnDf4jChUIAwi vDT8IMPjkIy3nTTH/8yLOKdt0yxYyaXjZ/cbCsPg= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230503100222epcas2p3cc0da536fd36757f90a1f16245acd6a4~bmfAM6Xm80396103961epcas2p3w; Wed, 3 May 2023 10:02:22 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.68]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4QBCDF3Rl4z4x9Q3; Wed, 3 May 2023 10:02:21 +0000 (GMT) X-AuditID: b6c32a45-465ff70000020cc1-ca-6452312d7a18 Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id BE.A9.03265.D2132546; Wed, 3 May 2023 19:02:21 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 02/15] block: blk-integiry: add helper functions for bio_integrity_add_page Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "hch@lst.de" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503100220epcms2p33e69fd7d5f04b305c621799792e8155f@epcms2p3> Date: Wed, 03 May 2023 19:02:20 +0900 X-CMS-MailID: 20230503100220epcms2p33e69fd7d5f04b305c621799792e8155f X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHKsWRmVeSWpSXmKPExsWy7bCmua6uYVCKwZK/Ihar7/azWbw8pGmx cvVRJove/q1sFntvaVtc3jWHzWL58X9MDuwel8+Weuy+2cDm8fHpLRaPvi2rGD0+b5ILYI3K tslITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wBukFJoSwx pxQoFJBYXKykb2dTlF9akqqQkV9cYquUWpCSU2BeoFecmFtcmpeul5daYmVoYGBkClSYkJ3x pqebqWC9aMX+Bd/YGxi7BLsYOTgkBEwk7i5n72Lk4hAS2MEo8WTRN2aQOK+AoMTfHcJdjJwc wgKxEoeufmIGsYUElCTOrZnFCFIiLGAgcavXHCTMJqAn8XPJDDYQW0RgNZNE8/MaEFtCgFdi RvtTFghbWmL78q2MIDangJ/E4w23GCHiGhI/lvUyQ9iiEjdXv2WHsd8fmw9VIyLReu8sVI2g xIOfu6HikhKHDn1lg/gkX2LDgUCIcI3E2+UHoEr0Ja51bAQ7gVfAV+LjuRlg41kEVCVu3e1k g6hxkdjR0c8KYjMLyEtsfzsHHAjMApoS63fpQ0xXljhyiwWigk+i4/BfdpgHGzb+xsreMe8J E0SrmsSiJiOIsIzE18Pz2ScwKs1CBPIsJGtnIaxdwMi8ilEstaA4Nz212KjAEB6tyfm5mxjB CVHLdQfj5Lcf9A4xMnEwHmKU4GBWEuH9UOiXIsSbklhZlVqUH19UmpNafIjRFOjhicxSosn5 wJScVxJvaGJpYGJmZmhuZGpgriTOK217MllIID2xJDU7NbUgtQimj4mDU6qBqUC+lfVR5ZP/ 03h1GOM+pq052mrLcMDUyuTLsdUXd+tlnWE6oHF8AXPqZuYt/K3qcQLqU4rZXNfzbLCyLBBb eob7wClr9ZRZ3JKdOy+wPt/toTHXLfuM87/YG7O/nSydzv7q0d4S2bdPaoJmLfn5s2n76++H zh5++TRvT+JyLj8NOfb1wvd/73/em11wup3RPIohX+bn7a+7nTsqXlzdJiXFmZdtsvbuB8kD O2OmNfnvunVHd82Xw3e5jNdvDwi6phS7+uWDhHMWDJUnXntqJVnOmLujQHGvRmBywM6PlTPZ c9fWCj2eMoXfYqvZ+dN+z64/2CUVyrsyOPHk9TsXbct6TkWmzdvveTr36V2lcAklluKMREMt 5qLiRAABKXjuEQQAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add functions that use the hardware limit to merge the page with integrity's bio_vec. Using the added functions, the physically continuous pages are made of one bio_vec. Previously, physically continuous pages were not created as one bio_vec, but separately created. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- block/bio-integrity.c | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 4533eb491661..06b6a2c178d2 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -111,6 +111,64 @@ void bio_integrity_free(struct bio *bio) bio->bi_opf &= ~REQ_INTEGRITY; } +/** + * bip_full - check if the bip is full + * @bip: bip to check + * @len: length of one segment to be added + * + * Return true if @bip is full and one segment with @len bytes can't be + * added to the bip, otherwise return false + */ +static inline bool bip_full(struct bio_integrity_payload *bip, unsigned int len) +{ + if (bip->bip_vcnt >= bip->bip_max_vcnt) + return true; + if (bip->bip_iter.bi_size > UINT_MAX - len) + return true; + return false; +} + +/** + * bip_try_merge_hw_seg - try to merge a page into a segment, while + * obeying the hardware segment size limit + * @q: the target queue + * @bip: bip to check + * @page: page containing integrity metadata + * @len: number of bytes of integrity metadata in page + * @offset: start offset within page + * @same_page: return if the segment has been merged inside the same page + * + * Return true if @page is merged to @bip, otherwise return false + */ +static bool bip_try_merge_hw_seg(struct request_queue *q, + struct bio_integrity_payload *bip, + struct page *page, unsigned int len, + unsigned int offset, bool *same_page) +{ + struct bio_vec *bv = &bip->bip_vec[bip->bip_vcnt - 1]; + unsigned long mask = queue_segment_boundary(q); + phys_addr_t addr1 = page_to_phys(bv->bv_page) + bv->bv_offset; + phys_addr_t addr2 = page_to_phys(page) + offset + len - 1; + + if ((addr1 | mask) != (addr2 | mask)) + return false; + if (bv->bv_len + len > queue_max_segment_size(q)) + return false; + + if (bip->bip_vcnt > 0) { + if (bio_page_is_mergeable(bv, page, len, offset, same_page)) { + if (bip->bip_iter.bi_size > UINT_MAX - len) { + *same_page = false; + return false; + } + bv->bv_len += len; + bip->bip_iter.bi_size += len; + return true; + } + } + return false; +} + /** * bio_integrity_add_page - Attach integrity metadata * @bio: bio to update From patchwork Wed May 3 10:06:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230008 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 240CDC77B75 for ; Wed, 3 May 2023 10:06:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229587AbjECKGs (ORCPT ); Wed, 3 May 2023 06:06:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbjECKGq (ORCPT ); Wed, 3 May 2023 06:06:46 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EF311A5 for ; Wed, 3 May 2023 03:06:43 -0700 (PDT) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230503100641epoutp043fb5288211a65e8d58d5787d80e0fcac~bmiyBQbmY1521015210epoutp04h for ; Wed, 3 May 2023 10:06:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230503100641epoutp043fb5288211a65e8d58d5787d80e0fcac~bmiyBQbmY1521015210epoutp04h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683108401; bh=1WhTIW3VLo5qDfXJ/0YEchijZafqk1XB4OYfht1gpEI=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=DcUF9wb+SnzJEz0OCAcXzgBVuPqyetKe4JbMFY8vPe4dDVOcwtWFXmfvjWgTT0fD+ 0n0DnSrhmk1irqyipV8Cpy2JUMtQcg1kF8K4FjTH7hlJ3PjqOrZmj+mx0WY5HjyrY0 ZqP/BT9TUKFeYa6pOcJ8Z/bjUdJtAxb8oseVE8Ac= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230503100640epcas2p4a916461813c8ba6adefad44e524d4480~bmixIQo-G2064220642epcas2p4I; Wed, 3 May 2023 10:06:40 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.91]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4QBCKD1frvz4x9Py; Wed, 3 May 2023 10:06:40 +0000 (GMT) X-AuditID: b6c32a47-c29ff70000002007-a2-645232306dac Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 06.6D.08199.03232546; Wed, 3 May 2023 19:06:40 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 03/15] block: bio-integrity: modify bio_integrity_add_page() 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" , "martin.petersen@oracle.com" , "kch@nvidia.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503100639epcms2p5069df7346cfce6db9718b9adf7cc3718@epcms2p5> Date: Wed, 03 May 2023 19:06:39 +0900 X-CMS-MailID: 20230503100639epcms2p5069df7346cfce6db9718b9adf7cc3718 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHJsWRmVeSWpSXmKPExsWy7bCmha6BUVCKwc73nBar7/azWbw8pGmx cvVRJove/q1sFpMOXWO0eHp1FpPF3lvaFpd3zWGzWH78H5PFutfvWRy4PM7f28jicflsqcem VZ1sHrtvNrB59Da/Y/P4+PQWi0ffllWMHp83yQVwRGXbZKQmpqQWKaTmJeenZOal2yp5B8c7 x5uaGRjqGlpamCsp5CXmptoqufgE6Lpl5gBdqKRQlphTChQKSCwuVtK3synKLy1JVcjILy6x VUotSMkpMC/QK07MLS7NS9fLSy2xMjQwMDIFKkzIzng0/TJTQatUxe69M5kaGM+JdDFyckgI mEgcWrCMtYuRi0NIYAejxMZze4EcDg5eAUGJvzuEQWqEBXwkTj38xQpiCwkoSZxbM4sRpERY wEDiVq85SJhNQE/i55IZbCBjRAQWMUtsmjeZDWI+r8SM9qcsELa0xPblWxlBbE4BP4nHG24x QsQ1JH4s62WGsEUlbq5+yw5jvz82H6pGRKL13lmoGkGJBz93Q8UlJQ4d+soGco+EQL7EhgOB EOEaibfLD0CV6Etc69gIdgKvgK/ElwPtYKexCKhKfP8wCWqki8TWg+uYQGxmAXmJ7W/nMIOM ZBbQlFi/Sx9iurLEkVssEBV8Eh2H/7LDPNiw8TdW9o55T5ggWtUkFjUZQYRlJL4ens8+gVFp FiKUZyFZOwth7QJG5lWMYqkFxbnpqcVGBcbwiE3Oz93ECE6oWu47GGe8/aB3iJGJg/EQowQH s5II74dCvxQh3pTEyqrUovz4otKc1OJDjKZAD09klhJNzgem9LySeEMTSwMTMzNDcyNTA3Ml cV5p25PJQgLpiSWp2ampBalFMH1MHJxSDUybZz9IyQwWv3lm9qH0jnRNjpudp3n+J//rT5ky uTfCybn9bnio5V+1xj2Z3p/u/w+XjVl7P9VNMOJuz6Fc5lV7Zkz5GC14KDjvxcXKYp6vzSe5 M9tfu3IpLAjveb/Uqnhivs7R15LWRZPn9fnuXBi3Q2Vvv43/pZCI15ePJP7eJ8NvsOxnve67 TEO++HNxSpIGrvvDy3omz+C+EZP4qovjrZXAjohNYY17LtQtPB/0eIlJwMRf2atOcE+r2Wdv NvupfNzPg2EuF46ft1KesFLndGXbD2Gbf64/NE7xzC1NirliaheifyQhdIfsyq3vhHoCHJ9z XDnOrtKx1X5b/TeLjqAlj8rd85etex+zS02JpTgj0VCLuag4EQDrnXkoMQQAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Considering the constraints of hardware, the physically continuous pages were to be composed of one bio_vec. Previously, bio_vec was created separately for each page entering the parameter. Cc: Christoph Hellwig Cc: Martin K. Petersen Fixes: 783b94bd9250 ("nvme-pci: do not build a scatterlist to map metadata") Signed-off-by: Jinyoung Choi --- block/bio-integrity.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 06b6a2c178d2..74cf9933c285 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -176,25 +176,45 @@ static bool bip_try_merge_hw_seg(struct request_queue *q, * @len: number of bytes of integrity metadata in page * @offset: start offset within page * - * Description: Attach a page containing integrity metadata to bio. + * Add a page containing integrity metadata to a bio while respecting + * the hardware max_sectors, max_segment and gap limitations. */ 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) { + if (((bip->bip_iter.bi_size + len) >> 9) > queue_max_hw_sectors(q)) + return 0; + + if (bip->bip_vcnt > 0) { + struct bio_vec *bv; + bool same_page = false; + + if (bip_try_merge_hw_seg(q, bip, page, len, offset, &same_page)) + return len; + + /* + * If the queue doesn't support SG gaps and adding this segment + * would create a gap, disallow it. + */ + bv = &bip->bip_vec[bip->bip_vcnt - 1]; + if (bvec_gap_to_prev(&q->limits, bv, offset)) + return 0; + } + + if (bip_full(bip, len)) { printk(KERN_ERR "%s: bip_vec full\n", __func__); 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)) + if (bip->bip_vcnt >= queue_max_integrity_segments(q)) return 0; bvec_set_page(&bip->bip_vec[bip->bip_vcnt], page, len, offset); bip->bip_vcnt++; + bip->bip_iter.bi_size += len; return len; } @@ -307,7 +327,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) @@ -316,7 +335,6 @@ bool bio_integrity_prep(struct bio *bio) /* Map it */ offset = offset_in_page(buf); for (i = 0 ; i < nr_pages ; i++) { - int ret; bytes = PAGE_SIZE - offset; if (len <= 0) @@ -325,18 +343,13 @@ bool bio_integrity_prep(struct bio *bio) 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"); status = BLK_STS_RESOURCE; goto err_end_io; } - if (ret < bytes) - break; - buf += bytes; len -= bytes; offset = 0; From patchwork Wed May 3 10:09:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230009 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 71DF6C77B78 for ; Wed, 3 May 2023 10:09:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229678AbjECKJN (ORCPT ); Wed, 3 May 2023 06:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229554AbjECKJM (ORCPT ); Wed, 3 May 2023 06:09:12 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D068844A1 for ; Wed, 3 May 2023 03:09:09 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20230503100908epoutp03ac55905eeb668e910adf6229943446d0~bmk6epIIR1928519285epoutp03e for ; Wed, 3 May 2023 10:09:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20230503100908epoutp03ac55905eeb668e910adf6229943446d0~bmk6epIIR1928519285epoutp03e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683108548; bh=kra6K6+UrYLIE+JQHy/nrTmW6GTWNgEH+aD6dQYjQ8E=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=WsAfJpBqvVnJDYUH62PLtpP/C7VxG63VKV4tLsVXFUfWa0Fup+Ut6FVbmDxfsqHjT rVyWf08TUWJtHTYDtqp2k1LU4+wsRH4BaHqKES/nXkiseGUSMKVtJydBBJLjcebNN9 b1PH+MXzvU7uLN2zzb7Ewo9VW1UxWYe2TyhdPnpg= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230503100907epcas2p3449f6572ea0db3a9b054da777cfb6efc~bmk6Aaucn2526925269epcas2p33; Wed, 3 May 2023 10:09:07 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.88]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4QBCN3198vz4x9Pr; Wed, 3 May 2023 10:09:07 +0000 (GMT) X-AuditID: b6c32a45-c6fb9a8000020cc1-43-645232c276f4 Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 70.1D.03265.2C232546; Wed, 3 May 2023 19:09:07 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 04/15] block: bio-integiry: cleanup bio_integrity_prep Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "hch@lst.de" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503100906epcms2p35226430da085d7449840bb122a6b193c@epcms2p3> Date: Wed, 03 May 2023 19:09:06 +0900 X-CMS-MailID: 20230503100906epcms2p35226430da085d7449840bb122a6b193c X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPKsWRmVeSWpSXmKPExsWy7bCmhe5ho6AUg3e9TBar7/azWbw8pGmx cvVRJove/q1sFntvaVtc3jWHzWL58X9MDuwel8+Weuy+2cDm8fHpLRaPvi2rGD0+b5ILYI3K tslITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wBukFJoSwx pxQoFJBYXKykb2dTlF9akqqQkV9cYquUWpCSU2BeoFecmFtcmpeul5daYmVoYGBkClSYkJ2x a8lR9oI5fBWNW7cyNjDu4O5i5OSQEDCReLj1G3sXIxeHkMAORom+Z5+AHA4OXgFBib87hEFq hAXcJB4tucwMYgsJKEmcWzOLEaREWMBA4lavOUiYTUBP4ueSGWwgtojAaiaJ5uc1EON5JWa0 P2WBsKUlti/fyghicwr4STzecIsRIq4h8WNZLzOELSpxc/Vbdhj7/bH5UDUiEq33zkLVCEo8 +LkbKi4pcejQVzaQcyQE8iU2HAiECNdIvF1+AKpEX+Jax0awE3gFfCV29J8FO5NFQFVixdQ5 UKe5SPTPOA82nllAXmL72znMICOZBTQl1u/Sh5iuLHHkFgtEBZ9Ex+G/7DAPNmz8jZW9Y94T JohWNYlFTUYQYRmJr4fns09gVJqFCORZSNbOQli7gJF5FaNYakFxbnpqsVGBITxek/NzNzGC U6KW6w7GyW8/6B1iZOJgPMQowcGsJML7odAvRYg3JbGyKrUoP76oNCe1+BCjKdDDE5mlRJPz gUk5ryTe0MTSwMTMzNDcyNTAXEmcV9r2ZLKQQHpiSWp2ampBahFMHxMHp1QDU9/9+fNsfW+v 0f0hZrSx00uP13G3eOpkaUtd7vk/54cVfHD7ZsFXe3HS/rBHrlcZ0s+zLXP6eNLnXpznne19 0oUs89TScjs+TC5dafSZ9/ihldrP37f8kuH43+66eH/eg7NHg7qVii3XZOn4eNhozb5reF1/ yb5dDv5ssjIP7MJXdJ74v+3P35XvDt88W71U+W95amLoN6cby9NeK4vPjchMvv5Hr2rXo+4t l4OUpoSyphqd0lY76+Xo3WdnVxaqN6/35rvunYbt4mt1umrqAuMdH03L1zxlmaS4ZFX40wCd R/7LRGS6Lz/elPl/boxIkfbGfmuOR5fklsb7c9aaPLef9H1qqtCF/k6XmBhLJZbijERDLeai 4kQAQxDxARIEAAA= DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org If a problem occurs in the process of creating an integrity payload, the status of bio is always BLK_STS_RESOURCE. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi Reviewed-by: Christoph Hellwig --- block/bio-integrity.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 74cf9933c285..329c44eca83d 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -278,7 +278,6 @@ bool bio_integrity_prep(struct bio *bio) unsigned int len, nr_pages; unsigned int bytes, offset, i; unsigned int intervals; - blk_status_t status; if (!bi) return true; @@ -307,7 +306,6 @@ bool bio_integrity_prep(struct bio *bio) /* Allocate kernel buffer for protection data */ len = intervals * bi->tuple_size; buf = kmalloc(len, GFP_NOIO); - status = BLK_STS_RESOURCE; if (unlikely(buf == NULL)) { printk(KERN_ERR "could not allocate integrity buffer\n"); goto err_end_io; @@ -322,7 +320,6 @@ bool bio_integrity_prep(struct bio *bio) if (IS_ERR(bip)) { printk(KERN_ERR "could not allocate data integrity bioset\n"); kfree(buf); - status = BLK_STS_RESOURCE; goto err_end_io; } @@ -346,7 +343,6 @@ bool bio_integrity_prep(struct bio *bio) if (bio_integrity_add_page(bio, virt_to_page(buf), bytes, offset) < bytes) { printk(KERN_ERR "could not attach integrity payload\n"); - status = BLK_STS_RESOURCE; goto err_end_io; } @@ -365,10 +361,9 @@ bool bio_integrity_prep(struct bio *bio) return true; err_end_io: - bio->bi_status = status; + bio->bi_status = BLK_STS_RESOURCE; bio_endio(bio); return false; - } EXPORT_SYMBOL(bio_integrity_prep); From patchwork Wed May 3 10:10:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230011 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 BDFB6C77B75 for ; Wed, 3 May 2023 10:10:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbjECKKx (ORCPT ); Wed, 3 May 2023 06:10:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbjECKKx (ORCPT ); Wed, 3 May 2023 06:10:53 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8464E73 for ; Wed, 3 May 2023 03:10:51 -0700 (PDT) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230503101049epoutp026d724c4a80d91327676b45abad256e3f~bmmZLUq6q2403724037epoutp02H for ; Wed, 3 May 2023 10:10:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230503101049epoutp026d724c4a80d91327676b45abad256e3f~bmmZLUq6q2403724037epoutp02H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683108649; bh=ZtBNUgN0/grPa2YZpBQ/+703+N7AXHalnFNdUd9CK2g=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=UnPjeASTTFYc230ki1CKes37Bp3ntuFLpyMO/8uEk/BhWG88f5yqCVE4Raafe95VY QWr2IzHZ42/su6wTa6IUr15vn1tWu7r5B/7wluT/nxqUWMnv9ptlzyijMEvPJ9jOaT gVjKkUJOzX3YBZg992GYZPQ+NFDesK3IssYAcAqo= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230503101049epcas2p38f6d0fb534262f57214878ba4a6ae640~bmmY8uVtU2866128661epcas2p3e; Wed, 3 May 2023 10:10:49 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.88]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4QBCQ10n2Zz4x9Pw; Wed, 3 May 2023 10:10:49 +0000 (GMT) X-AuditID: b6c32a45-6d1fd70000020cc1-29-6452332814ef Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id B1.7D.03265.82332546; Wed, 3 May 2023 19:10:49 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 05/15] block: fix not to apply bip information in blk_rq_bio_prep() Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "hch@lst.de" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503101048epcms2p61d61df1431955d9517c9939999ee3478@epcms2p6> Date: Wed, 03 May 2023 19:10:48 +0900 X-CMS-MailID: 20230503101048epcms2p61d61df1431955d9517c9939999ee3478 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDKsWRmVeSWpSXmKPExsWy7bCmma6mcVCKwd1pjBar7/azWbw8pGmx cvVRJove/q1sFntvaVtc3jWHzWL58X9MDuwel8+Weuy+2cDm8fHpLRaPvi2rGD0+b5ILYI3K tslITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wBukFJoSwx pxQoFJBYXKykb2dTlF9akqqQkV9cYquUWpCSU2BeoFecmFtcmpeul5daYmVoYGBkClSYkJ3x secac8E09opfK7+xNjC2sXUxcnJICJhI/Ph3m6mLkYtDSGAHo8SPX99Zuxg5OHgFBCX+7hAG MYUFQiXmL9YHKRcSUJI4t2YWI0TYQOJWrzlImE1AT+LnkhlgE0UEVjNJND+vgZjOKzGj/SkL hC0tsX35VkYQm1PAT+LxhluMEHENiR/LepkhbFGJm6vfssPY74/Nh6oRkWi9dxaqRlDiwc/d UHFJiUOHvrKBnCMhkC+x4UAgRLhG4u3yA1Al+hLXOjayQPzkK7F/VRhImEVAVWL7vecsEJ0u EhOn+4CEmQXkJba/ncMMEmYW0JRYv0sfokJZ4sgtFogKPomOw3/ZYd5r2PgbK3vHvCdMEK1q EouajCDCMhJfD89nn8CoNAsRwrOQrJ2FsHYBI/MqRrHUguLc9NRiowJDeKQm5+duYgQnQy3X HYyT337QO8TIxMF4iFGCg1lJhPdDoV+KEG9KYmVValF+fFFpTmrxIUZToH8nMkuJJucD03Fe SbyhiaWBiZmZobmRqYG5kjivtO3JZCGB9MSS1OzU1ILUIpg+Jg5OqQYmg5DXb4uWaP5g+mFt uORVxePWBvufskpP+MInH/+87PC5G+uCjok72FS87eOc9PvmsX2mj/aVuh3jSHsdsvWs3bvP C031t7f9Ztj+82fLN6vGz5czDNlsti04ENbZ5K1w6qqTbNiK8LQ9H988vCmQ7eDt2PtjYtL2 1Lt/m5cEsT5xPXtbQNohIa8z+vnEVpumnNC2rY4+9tsfiigklHPIMrBszre7vSNn+amd2/xW xP9ZeVAg4NJiLn2ZVO4DnqkZsufEl0Q9CjW32f0x9dzOpdt3ZH72rlbqOVb8R2wef96hzlt+ y9j/OJtfkNJxfMPYnr3/odXOm0YbfS9M0n0xUe+uw43muqd5J+PObRDbosRSnJFoqMVcVJwI AOw3ppIPBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org When a request is initialized through the bio, bio's integrity information is not reflected in the request. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- include/linux/blk-mq.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 1dacb2c81fdd..cdb95e090919 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -961,6 +961,11 @@ static inline void blk_rq_bio_prep(struct request *rq, struct bio *bio, rq->__data_len = bio->bi_iter.bi_size; rq->bio = rq->biotail = bio; rq->ioprio = bio_prio(bio); + + if (bio_integrity(bio)) { + rq->nr_integrity_segments = bio_integrity(bio)->bip_vcnt; + rq->cmd_flags |= REQ_INTEGRITY; + } } void blk_mq_hctx_set_fq_lock_class(struct blk_mq_hw_ctx *hctx, From patchwork Wed May 3 10:12:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230012 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 423BDC77B75 for ; Wed, 3 May 2023 10:12:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229645AbjECKMQ (ORCPT ); Wed, 3 May 2023 06:12:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbjECKMO (ORCPT ); Wed, 3 May 2023 06:12:14 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 757D21A5 for ; Wed, 3 May 2023 03:12:12 -0700 (PDT) Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230503101210epoutp014fc37bae5b4010cc5a024ff4821bca06~bmnkqwT5N1675516755epoutp01e for ; Wed, 3 May 2023 10:12:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230503101210epoutp014fc37bae5b4010cc5a024ff4821bca06~bmnkqwT5N1675516755epoutp01e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683108730; bh=zvETEJpKps7CgoP+0aNXfFiUkdNh7m7B7nh+qhAE130=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=l99GavOVKtzSJS36rSIxmBZLsPm0t8/CzRW5Q3A8LL+wYMe5pOe1Rz17O7OzXSBTh DlWWKdPK8Zk/U/FdD+odqPrzeoGHZeCRpOBeDhlF+zkb9BArHl9ZJhnEsmd8CW7hUD DLsu6fiG6JKk8BJ4Piyt1pPUIN+ug7aYa9GVtvSI= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230503101210epcas2p348dac10e0ac642bdfafcb7aeac0625e5~bmnj-qOF71815318153epcas2p3S; Wed, 3 May 2023 10:12:10 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.36.89]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4QBCRY4phbz4x9Pr; Wed, 3 May 2023 10:12:09 +0000 (GMT) X-AuditID: b6c32a46-8b7ff7000001438d-04-64523379883f Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 1E.74.17293.97332546; Wed, 3 May 2023 19:12:09 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 06/15] block: blk-merge: fix to add the number of integrity segments to the request twice Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "hch@lst.de" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503101208epcms2p217be9d66b1e07c4e2ce3741e659e158f@epcms2p2> Date: Wed, 03 May 2023 19:12:08 +0900 X-CMS-MailID: 20230503101208epcms2p217be9d66b1e07c4e2ce3741e659e158f X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHKsWRmVeSWpSXmKPExsWy7bCmqW6lcVCKQdtNRYvVd/vZLF4e0rRY ufook0Vv/1Y2i723tC0u75rDZrH8+D8mB3aPy2dLPXbfbGDz+Pj0FotH35ZVjB6fN8kFsEZl 22SkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY6hpaWpgrKeQl5qbaKrn4BOi6ZeYA3aCkUJaY UwoUCkgsLlbSt7Mpyi8tSVXIyC8usVVKLUjJKTAv0CtOzC0uzUvXy0stsTI0MDAyBSpMyM54 sH0Ga8EJtYqP02ayNjBuke9i5OSQEDCRuPqol7GLkYtDSGAHo8TqJd0sXYwcHLwCghJ/dwiD 1AgLZEv87tjMDGILCShJnFszixGkRFjAQOJWrzlImE1AT+LnkhlsILaIwGomiebnNRDjeSVm tD9lgbClJbYv38oIYnMK+Ek83nCLESKuIfFjWS8zhC0qcXP1W3YY+/2x+VA1IhKt985C1QhK PPi5GyouKXHo0Fc2kHMkBPIlNhwIhAjXSLxdfgCqRF/iWsdGqKd8JR69jQQJswioSux9vYwV osRFov1HE5jNLCAvsf3tHGaQcmYBTYn1u/QhhitLHLnFAlHBJ9Fx+C87zH8NG39jZe+Y94QJ olVNYlGTEURYRuLr4fnsExiVZiHCeBaStbMQ1i5gZF7FKJZaUJybnlpsVGAEj9bk/NxNjOCE qOW2g3HK2w96hxiZOBgPMUpwMCuJ8H4o9EsR4k1JrKxKLcqPLyrNSS0+xGgK9PBEZinR5Hxg Ss4riTc0sTQwMTMzNDcyNTBXEueVtj2ZLCSQnliSmp2aWpBaBNPHxMEp1cCk5bYpeOEal4Tl R74UfOi7KRvwQFExZlPrrBgv/tur/6ycGFsVvGJ1o2Sa+9//U+f5emc8v3zWXOftzJVP0trv MF0qyz3/bkVTjMp555JbxwTWvlulK6pxq+OlwJSbIjWBt29p2pQcmM8+a8eVxxLiU6cWpsUo 9aycpbxP5bUw13r1968+vr7+benClU/1/Gef6Jl/4aLWhos5ImWNR1WffnR9uTumKUWy2SJi ZuQLxT9P/l2OUrlWVXgxyrIgNODDrciK3TnMk9NXPeb5sehFkvCTkzltFgpX4t9rv7f6IfWO N2nDywOzGczElXd7H8s4+KTHdabqhMz5Aor3O+ZwSelZmpf/ilFe+jRCc23yDSWW4oxEQy3m ouJEAF4Mg6YRBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org blk_integrity_merge_bio() not only performs conditional tests, but also updates the integrity segment information of request. It can be called twice when merging the bio into an existing request. bio_attempt_bio_merge() or blk_mq_sched_try_merge() blk_rq_merge_ok() blk_integrity_merge_bio() - 1 bio_attemp_{back|front}_merge() ll_{back|front}_merge_fn() ll_new_hw_segments() blk_integrity_merge_bio() - 2 The part of checking the conditions and the code to update the information of the actual request were separated. At this time, the ll_back_merge_fn was called by passth-path, so the condition check was called by all the separated functions. And after success in blk_integrity_merge_bio(), the information of the request may be wrong if it is impossible to merge due to other conditional tests. Thus, it was changed to be called immediately before merging the bio's segments. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- block/blk-integrity.c | 34 +++++++++++++++++++++++++++++----- block/blk-merge.c | 9 +++++---- block/blk.h | 7 +++++++ 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index d4e9b4556d14..03a85e1f6d2e 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -184,19 +184,43 @@ bool blk_integrity_merge_rq(struct request_queue *q, struct request *req, return true; } +static inline bool blk_integrity_bypass_check(struct request *req, + struct bio *bio) +{ + return blk_integrity_rq(req) == 0 && bio_integrity(bio) == NULL; +} + +static bool __blk_integrity_mergeable(struct request_queue *q, + struct request *req, struct bio *bio) +{ + if (blk_integrity_rq(req) == 0 || bio_integrity(bio) == NULL) + return false; + + if (bio_integrity(req->bio)->bip_flags != bio_integrity(bio)->bip_flags) + return false; + + return true; +} + +bool blk_integrity_mergeable(struct request_queue *q, struct request *req, + struct bio *bio) +{ + if (blk_integrity_bypass_check(req, bio)) + return true; + + return __blk_integrity_mergeable(q, req, bio); +} + bool blk_integrity_merge_bio(struct request_queue *q, struct request *req, struct bio *bio) { int nr_integrity_segs; struct bio *next = bio->bi_next; - if (blk_integrity_rq(req) == 0 && bio_integrity(bio) == NULL) + if (blk_integrity_bypass_check(req, bio)) return true; - if (blk_integrity_rq(req) == 0 || bio_integrity(bio) == NULL) - return false; - - if (bio_integrity(req->bio)->bip_flags != bio_integrity(bio)->bip_flags) + if (!__blk_integrity_mergeable(q, req, bio)) return false; bio->bi_next = NULL; diff --git a/block/blk-merge.c b/block/blk-merge.c index 65e75efa9bd3..8509f468d6d4 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -611,9 +611,6 @@ static inline int ll_new_hw_segment(struct request *req, struct bio *bio, if (!blk_cgroup_mergeable(req, bio)) goto no_merge; - if (blk_integrity_merge_bio(req->q, req, bio) == false) - goto no_merge; - /* discard request merge won't add new segment */ if (req_op(req) == REQ_OP_DISCARD) return 1; @@ -621,6 +618,10 @@ static inline int ll_new_hw_segment(struct request *req, struct bio *bio, if (req->nr_phys_segments + nr_phys_segs > blk_rq_get_max_segments(req)) goto no_merge; + /* This will merge integrity segments */ + if (!blk_integrity_merge_bio(req->q, req, bio)) + goto no_merge; + /* * This will form the start of a new hw segment. Bump both * counters. @@ -934,7 +935,7 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio) return false; /* only merge integrity protected bio into ditto rq */ - if (blk_integrity_merge_bio(rq->q, rq, bio) == false) + if (!blk_integrity_mergeable(rq->q, rq, bio)) return false; /* Only merge if the crypt contexts are compatible */ diff --git a/block/blk.h b/block/blk.h index 45547bcf1119..5923d2190d91 100644 --- a/block/blk.h +++ b/block/blk.h @@ -189,6 +189,8 @@ static inline bool bio_integrity_endio(struct bio *bio) bool blk_integrity_merge_rq(struct request_queue *, struct request *, struct request *); +bool blk_integrity_mergeable(struct request_queue *rq, struct request *r, + struct bio *b); bool blk_integrity_merge_bio(struct request_queue *, struct request *, struct bio *); @@ -221,6 +223,11 @@ static inline bool blk_integrity_merge_rq(struct request_queue *rq, { return true; } +static inline bool blk_integrity_mergeable(struct request_queue *rq, + struct request *r, struct bio *b) +{ + return true; +} static inline bool blk_integrity_merge_bio(struct request_queue *rq, struct request *r, struct bio *b) { From patchwork Wed May 3 10:13:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230013 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 94988C77B75 for ; Wed, 3 May 2023 10:13:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229665AbjECKN5 (ORCPT ); Wed, 3 May 2023 06:13:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229729AbjECKNz (ORCPT ); Wed, 3 May 2023 06:13:55 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0C8A49CF for ; Wed, 3 May 2023 03:13:53 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230503101352epoutp02ecc14d29c8a2984401835f572847b92c~bmpC3eoBu2593325933epoutp02Q for ; Wed, 3 May 2023 10:13:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230503101352epoutp02ecc14d29c8a2984401835f572847b92c~bmpC3eoBu2593325933epoutp02Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683108832; bh=5spsBQ/UOnjOahi0JzD6hmV/5aBQ7IGxHCQ9KefOjyE=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=T5sgQtkLpfPBVjNcR07b57q0MOgTYpZ55yuIkkUazLw+zQJm1hqvV36LeGkBgicdp 335d2dUOkbZ/WLFrFD1LI9FLzS8ULUjO0rm77wikVguHawEPzUYBWa40ucY8RDhb3h Dobr//mzyxWoLgZ0GwZG4qMF4Kgf/zisKe6++AI8= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230503101351epcas2p40434afb19b942994ca0612bb822eeeeb~bmpCOdERn3032830328epcas2p4s; Wed, 3 May 2023 10:13:51 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.91]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4QBCTV6GwDz4x9Pw; Wed, 3 May 2023 10:13:50 +0000 (GMT) X-AuditID: b6c32a47-c29ff70000002007-98-645233dec14f Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id DB.4F.08199.ED332546; Wed, 3 May 2023 19:13:50 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 07/15] block: blk-merge: fix merging two requests in ll_merge_requests_fn Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "hch@lst.de" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503101350epcms2p63c31a0642156d56853acdcd4754abb50@epcms2p6> Date: Wed, 03 May 2023 19:13:50 +0900 X-CMS-MailID: 20230503101350epcms2p63c31a0642156d56853acdcd4754abb50 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHKsWRmVeSWpSXmKPExsWy7bCmme4946AUg62X9C1W3+1ns3h5SNNi 5eqjTBa9/VvZLPbe0ra4vGsOm8Xy4/+YHNg9Lp8t9dh9s4HN4+PTWywefVtWMXp83iQXwBqV bZORmpiSWqSQmpecn5KZl26r5B0c7xxvamZgqGtoaWGupJCXmJtqq+TiE6DrlpkDdIOSQlli TilQKCCxuFhJ386mKL+0JFUhI7+4xFYptSAlp8C8QK84Mbe4NC9dLy+1xMrQwMDIFKgwITvj X+8cxoJNvBUb2/rYGxgncncxcnJICJhIvNyzkLWLkYtDSGAHo8S1ZXOAHA4OXgFBib87hEFM YYFoiXtb00HKhQSUJM6tmcUIETaQuNVrDhJmE9CT+LlkBhuILSKwmkmi+XkNxHReiRntT1kg bGmJ7cu3MoLYnAJ+Eo833GKEiGtI/FjWywxhi0rcXP2WHcZ+f2w+VI2IROu9s1A1ghIPfu6G iktKHDr0lQ3kHAmBfIkNBwIhwjUSb5cfgCrRl7jWsRHsBF4BX4kVL1aAjWcRUJVo+DgZ6jQX idPXFoGNZxaQl9j+dg4zyEhmAU2J9bv0IaYrSxy5xQJRwSfRcfgvO8yDDRt/Y2XvmPeECaJV TWJRkxFEWEbi6+H57BMYlWYhwngWkrWzENYuYGRexSiWWlCcm55abFRgDI/W5PzcTYzghKjl voNxxtsPeocYmTgYDzFKcDArifB+KPRLEeJNSaysSi3Kjy8qzUktPsRoCvTwRGYp0eR8YErO K4k3NLE0MDEzMzQ3MjUwVxLnlbY9mSwkkJ5YkpqdmlqQWgTTx8TBKdXA1L5mLzfj+qCkRM8Z +25lT9zvv7fAKvzd05q1625/87n/4XXroXOHX+6sO51n6yxbZhNbU/zwxS5BhSfaInG7nnXb Tuxd3vt9efm0Xqu2A/OF/S1t7nKvDOf7lXVz5b2F2/omFnaFrt/CtkxjenFT8q27Vnbnds+1 P8QQWs46NVmfcY93TclhpVm3lJ9HT1mibPfl7Inwh3uzIwPD24OK9rKv2xe4Z+Xiz/9nztiy 94KL8jv9GK7w9KCPMp5XSw7dj1/jI/88vXZXTNLrrNntKscXXb6sZW+dYulSzCjs7in1p+zI 0QPprmUh3tNCWjU4Fj284Hkzcf+sUJGgZMN/nvciLi9uji+doX2xZH/QMiWW4oxEQy3mouJE AMEW8/cRBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org blk_integrity_merge_rq() merges integrity segment information of two requests. However, it is only a condition check and does not perform the actual integrity information update. So this was modified. After it is called, the merge process of the requests may fail due to other conditions. At this time, there is an error in the integrity segment information of request. So the call location was also changed. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- block/blk-integrity.c | 2 ++ block/blk-merge.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 03a85e1f6d2e..f97b7e8a6d4d 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -181,6 +181,8 @@ bool blk_integrity_merge_rq(struct request_queue *q, struct request *req, if (integrity_req_gap_back_merge(req, next->bio)) return false; + req->nr_integrity_segments += next->nr_integrity_segments; + return true; } diff --git a/block/blk-merge.c b/block/blk-merge.c index 8509f468d6d4..c6a0958e8df1 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -711,10 +711,11 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req, if (!blk_cgroup_mergeable(req, next->bio)) return 0; - if (blk_integrity_merge_rq(q, req, next) == false) + if (!bio_crypt_ctx_merge_rq(req, next)) return 0; - if (!bio_crypt_ctx_merge_rq(req, next)) + /* this will merge integrity segments */ + if (!blk_integrity_merge_rq(q, req, next)) return 0; /* Merge is OK... */ From patchwork Wed May 3 10:16:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230015 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 DB8AEC7EE22 for ; Wed, 3 May 2023 10:16:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229873AbjECKQW (ORCPT ); Wed, 3 May 2023 06:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229729AbjECKQV (ORCPT ); Wed, 3 May 2023 06:16:21 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D14749E4 for ; Wed, 3 May 2023 03:16:15 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230503101612epoutp01f5891d0a6a16fd1844c95cab855b8930~bmrFx7Rb32321123211epoutp01F for ; Wed, 3 May 2023 10:16:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230503101612epoutp01f5891d0a6a16fd1844c95cab855b8930~bmrFx7Rb32321123211epoutp01F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683108972; bh=dsClYh4QK7KsYkk+2+MP7q9EBU8OpMqvWeVl/PtqLS8=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=YeGXTCaqh/tFo7vqlLQJjqwH3JvYRDv5alKJu+0jsrOP7xan87j/1IDxsGPjQzeKG 5u0VMJGChzEnE64xF/TNjaiBgQ81YiF/h6whbg+MT7usJddlPowvh5hEb5+a5DygfB tifqjP/h1eOQsjUHF9uvsUd1S5Df/cSpwnK5lZX8= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20230503101612epcas2p117ba29f6e7f6f3ec8f6119f8fa637983~bmrFh2yCv3199031990epcas2p1S; Wed, 3 May 2023 10:16:12 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.36.91]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4QBCXC4cVVz4x9Pv; Wed, 3 May 2023 10:16:11 +0000 (GMT) X-AuditID: b6c32a46-b23fd7000001438d-a7-6452346b8ec5 Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id DC.16.17293.B6432546; Wed, 3 May 2023 19:16:11 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 08/15] block: add helper function to get the number of integrity segments Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "hch@lst.de" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503101611epcms2p57098b1a64ba519b0e2d3cd132d96051a@epcms2p5> Date: Wed, 03 May 2023 19:16:11 +0900 X-CMS-MailID: 20230503101611epcms2p57098b1a64ba519b0e2d3cd132d96051a X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLKsWRmVeSWpSXmKPExsWy7bCmmW62SVCKwYJ+eYvVd/vZLF4e0rRY ufook0Vv/1Y2i723tC0u75rDZrH8+D8mB3aPy2dLPXbfbGDz+Pj0FotH35ZVjB6fN8kFsEZl 22SkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY6hpaWpgrKeQl5qbaKrn4BOi6ZeYA3aCkUJaY UwoUCkgsLlbSt7Mpyi8tSVXIyC8usVVKLUjJKTAv0CtOzC0uzUvXy0stsTI0MDAyBSpMyM6Y /OYSY8F7roop138xNzB2cXYxcnBICJhI3Dru08XIxSEksINR4sSscywgcV4BQYm/O4RBTGGB aInJ5327GDmBSpQkzq2ZxQgRNpC41WsOEmYT0JP4uWQGG4gtIrCaSaL5eQ2ILSHAKzGj/SkL hC0tsX35VkYQm1PAT+LxhluMEHENiR/LepkhbFGJm6vfssPY74/Nh6oRkWi9dxaqRlDiwc/d UHFJiUOHvrJBPJIvseFAIES4RuLt8gNQJfoS1zo2gp3AK+ArMXXfebAzWQRUJZpmbIVa5SKx 9sZ2JhCbWUBeYvvbOcwgI5kFNCXW79KHmK4sceQWC0QFn0TH4b/sMA82bPyNlb1j3hMmiFY1 iUVNRhBhGYmvh+ezT2BUmoUI41lI1s5CWLuAkXkVo1hqQXFuemqxUYERPFaT83M3MYLToZbb DsYpbz/oHWJk4mA8xCjBwawkwvuh0C9FiDclsbIqtSg/vqg0J7X4EKMp0MMTmaVEk/OBCTmv JN7QxNLAxMzM0NzI1MBcSZxX2vZkspBAemJJanZqakFqEUwfEwenVAOT0LSborkaqR+2yH8M kJzhKLNS+++ZGU3Vl1xWfCkO4mEvOXDysl/W3vkJL9p/fztTVLd82Qsr1ssiDJY3liwM+3qJ bUVxpIWBzrF/kw9PN19gqGJpudH2+nTNvo37Xvws1RJe7H7owYnvVn68ofeCHid3T7YX/+T4 yGbRUuEFQQXa7xc1CjAes1x29v+/iepXyv7E7P5nYZ96cY/87es5ZzUW7ZumKvnvmJNXSgnP f9PVTTtCD34x17X+0lAjzmi546Mh559L/Bwnzu18XLj6YohQ69kXOVc2ci3PalHm3iu4NGpJ XojS6rP+iyf69N1xOzfxUueGhubeiZrRUz79dUy/t2fCuznT10wsujahaqESS3FGoqEWc1Fx IgCslwboEAQAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Since request always has the number of integrity segments in the process of generating and merging, a function for simply obtained this has been added. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- include/linux/blk-integrity.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h index 378b2459efe2..45b9fde1fee1 100644 --- a/include/linux/blk-integrity.h +++ b/include/linux/blk-integrity.h @@ -43,6 +43,11 @@ int blk_rq_map_integrity_sg(struct request_queue *, struct bio *, struct scatterlist *); int blk_rq_count_integrity_sg(struct request_queue *, struct bio *); +static inline unsigned short blk_rq_nr_integrity_segments(struct request *rq) +{ + return rq->nr_integrity_segments; +} + static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk) { struct blk_integrity *bi = &disk->queue->integrity; @@ -120,6 +125,10 @@ static inline int blk_rq_count_integrity_sg(struct request_queue *q, { return 0; } +static inline unsigned short blk_rq_nr_integrity_segments(struct request *rq) +{ + return 0; +} static inline int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *b, struct scatterlist *s) From patchwork Wed May 3 10:18:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230016 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 B846DC77B75 for ; Wed, 3 May 2023 10:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbjECKS1 (ORCPT ); Wed, 3 May 2023 06:18:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbjECKS0 (ORCPT ); Wed, 3 May 2023 06:18:26 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8FFCE43 for ; Wed, 3 May 2023 03:18:24 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230503101823epoutp01ad90c2eb1176a63c24ab6e1e1e39ea0b~bms-dVZd82321223212epoutp01x for ; Wed, 3 May 2023 10:18:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230503101823epoutp01ad90c2eb1176a63c24ab6e1e1e39ea0b~bms-dVZd82321223212epoutp01x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683109103; bh=v5aifcuvT4v06m1yAYerf8h0h01yE8oqVL3cCIFGtC8=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=myswX6UxBKURqrjDtEP0GJhJBNd0eaji8TVOc/qyvb+cpSkZ0z6IIBzA55CTGpsmJ WoNZ/f4vUAIC/fLMsesY4yH3pDbthdqmOX+7shEHsY8u1Cfxqn1aTSAOb2Calo+noD kMX9bsxXDjPvnh1JiYMqnWOba95gTDxG8a1B1VKM= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230503101822epcas2p41907fc7be801aa47a35830041603d10e~bms-EZHM-1649716497epcas2p4q; Wed, 3 May 2023 10:18:22 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.36.98]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4QBCZk2lGCz4x9Q5; Wed, 3 May 2023 10:18:22 +0000 (GMT) X-AuditID: b6c32a46-b23fd7000001438d-ff-645234ee3fd6 Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 27.C6.17293.EE432546; Wed, 3 May 2023 19:18:22 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 09/15] scsi: add scsi_alloc_integrity_sgtables() for integrity process Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "hch@lst.de" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503101822epcms2p3ce469757778cee255368e213755d58d6@epcms2p3> Date: Wed, 03 May 2023 19:18:22 +0900 X-CMS-MailID: 20230503101822epcms2p3ce469757778cee255368e213755d58d6 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupik+LIzCtJLcpLzFFi42LZdljTXPedSVCKwcEdghar7/azWbw8pGmx cvVRJove/q1sFotubGOy2HtL2+LyrjlsFsuP/2Ny4PC4fLbUY8KiA4weu282sHl8fHqLxaNv yypGj8+b5ALYorJtMlITU1KLFFLzkvNTMvPSbZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwC dN0yc4CuUVIoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fYKqUWpOQUmBfoFSfmFpfmpevlpZZY GRoYGJkCFSZkZ/zsfcVW8FGyYtPJY4wNjJNEuxg5OSQETCRaF0xi72Lk4hAS2MEo0fhnN3MX IwcHr4CgxN8dwiA1wgIREr07VzCD2EICShLn1sxiBCkRFjCQuNVrDhJmE9CT+LlkBhvIGBGB G0wSez6/ZoaYzysxo/0pC4QtLbF9+VZGEJtTwE/i8YZbjBBxDYkfy3qh6kUlbq5+yw5jvz82 H6pGRKL13lmoGkGJBz93Q8UlJQ4d+soGco+EQL7EhgOBEOEaibfLD0CV6Etc69gIdgKvgK/E gf7nYDaLgKrEy4sgrSA1LhJ9z9ezgtjMAvIS29/OAYcCs4CmxPpd+hDTlSWO3GKBqOCT6Dj8 lx3mwYaNv7Gyd8x7wgTRqiaxqMkIIiwj8fXwfPYJjEqzEKE8C8naWQhrFzAyr2IUSy0ozk1P LTYqMIJHbHJ+7iZGcKLUctvBOOXtB71DjEwcjIcYJTiYlUR4PxT6pQjxpiRWVqUW5ccXleak Fh9iNAV6eCKzlGhyPjBV55XEG5pYGpiYmRmaG5kamCuJ80rbnkwWEkhPLEnNTk0tSC2C6WPi 4JRqYNpyr65/rgm7k9xiHl6XPzbfBfv2xVw+GlG5aOMzp+JP+5Q392/YVz7pUH9p8N3HnVu1 F2Zor7gZlvK66MfLK1dnz/XZvKJkzq+MjVHrfI+oMv0uE3h33+bg6/s7eG6yGnMJujzJK09r yPtR7KE9eaVhs/dv6+hHtUpyx+ebHHXa+UTPcn/wEYee1MCfsbzJJa2bTyevS9+0ZlI1x7cm /49+hcsi/623nz/t70GdriqxiSyXJmczse2q4e5inmERXiCpOsX526Qlk0SYTXLUgrbJnuqb 0FUlZCacomhx9xBT0xLXWh7mjrqdS+6fDFYpNBJdeoCr133r7hMT7H5NXfbCRKP3tFnAP/tp Evzi0kosxRmJhlrMRcWJAHg749UdBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Separate the integrity mapping process of scsi_alloc_sgtables() into a new function for readability. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- drivers/scsi/scsi_lib.c | 71 ++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index b7c569a42aa4..89cf21345e1a 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1003,6 +1003,40 @@ static inline bool scsi_cmd_needs_dma_drain(struct scsi_device *sdev, sdev->host->hostt->dma_need_drain(rq); } +static blk_status_t scsi_alloc_integrity_sgtables(struct scsi_cmnd *cmd) +{ + struct request *rq = scsi_cmd_to_rq(cmd); + struct scsi_data_buffer *prot_sdb = cmd->prot_sdb; + int count, ivecs; + + if (WARN_ON_ONCE(!prot_sdb)) { + /* + * This can happen if someone (e.g. multipath) + * queues a command to a device on an adapter + * that does not support DIX. + */ + return BLK_STS_IOERR; + } + + ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio); + + if (sg_alloc_table_chained(&prot_sdb->table, ivecs, + prot_sdb->table.sgl, + SCSI_INLINE_PROT_SG_CNT)) { + return BLK_STS_RESOURCE; + } + + count = blk_rq_map_integrity_sg(rq->q, rq->bio, prot_sdb->table.sgl); + + BUG_ON(count > ivecs); + BUG_ON(count > queue_max_integrity_segments(rq->q)); + + cmd->prot_sdb = prot_sdb; + cmd->prot_sdb->table.nents = count; + + return BLK_STS_OK; +} + /** * scsi_alloc_sgtables - Allocate and initialize data and integrity scatterlists * @cmd: SCSI command data structure to initialize. @@ -1021,7 +1055,7 @@ blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd) struct request *rq = scsi_cmd_to_rq(cmd); unsigned short nr_segs = blk_rq_nr_phys_segments(rq); struct scatterlist *last_sg = NULL; - blk_status_t ret; + blk_status_t ret = BLK_STS_OK; bool need_drain = scsi_cmd_needs_dma_drain(sdev, rq); int count; @@ -1071,40 +1105,11 @@ blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd) cmd->sdb.length = blk_rq_payload_bytes(rq); if (blk_integrity_rq(rq)) { - struct scsi_data_buffer *prot_sdb = cmd->prot_sdb; - int ivecs; - - if (WARN_ON_ONCE(!prot_sdb)) { - /* - * This can happen if someone (e.g. multipath) - * queues a command to a device on an adapter - * that does not support DIX. - */ - ret = BLK_STS_IOERR; - goto out_free_sgtables; - } - - ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio); - - if (sg_alloc_table_chained(&prot_sdb->table, ivecs, - prot_sdb->table.sgl, - SCSI_INLINE_PROT_SG_CNT)) { - ret = BLK_STS_RESOURCE; - goto out_free_sgtables; - } - - count = blk_rq_map_integrity_sg(rq->q, rq->bio, - prot_sdb->table.sgl); - BUG_ON(count > ivecs); - BUG_ON(count > queue_max_integrity_segments(rq->q)); - - cmd->prot_sdb = prot_sdb; - cmd->prot_sdb->table.nents = count; + ret = scsi_alloc_integrity_sgtables(cmd); + if (ret != BLK_STS_OK) + scsi_free_sgtables(cmd); } - return BLK_STS_OK; -out_free_sgtables: - scsi_free_sgtables(cmd); return ret; } EXPORT_SYMBOL(scsi_alloc_sgtables); From patchwork Wed May 3 10:20:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230020 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 A795EC77B75 for ; Wed, 3 May 2023 10:20:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbjECKUl (ORCPT ); Wed, 3 May 2023 06:20:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbjECKUj (ORCPT ); Wed, 3 May 2023 06:20:39 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66DDFE43 for ; Wed, 3 May 2023 03:20:36 -0700 (PDT) Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230503102034epoutp02018ee723af4df738aba75b18eca57e76~bmu55kHPZ2867928679epoutp02R for ; Wed, 3 May 2023 10:20:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230503102034epoutp02018ee723af4df738aba75b18eca57e76~bmu55kHPZ2867928679epoutp02R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683109234; bh=J1DOTjK8gn87giwmABoGcvRXxfDSssG6aRXYYY56duk=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=SYz7FF1KL6BdMYc160Ff2BtS1fSYTB0TvuSmDXSZ9jhcWA7zFLJ05/XoqOSxwq0dz ZHQkL4ufCrdiyjcenkYJU2TvFn4iXmiHOQoNudDXQpZqSVDuRbn8kkHK1kFFxBd6Vc FA/Jz595IT+vNeueLQc4D4PHN798KQ09dAmtfTfU= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230503102034epcas2p34b8034eb2deb907bbf5df2d4aa118ce5~bmu5juCS13143031430epcas2p3V; Wed, 3 May 2023 10:20:34 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.90]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4QBCdF6VV4z4x9Q5; Wed, 3 May 2023 10:20:33 +0000 (GMT) X-AuditID: b6c32a47-c29ff70000002007-03-6452357195ef Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 6F.61.08199.17532546; Wed, 3 May 2023 19:20:33 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 10/15] scsi: change to use blk_rq_nr_integrity_segments() instead of blk_rq_count_integrity_sg() Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "hch@lst.de" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503102033epcms2p5791708735197d3aac4fe546bcd7ac387@epcms2p5> Date: Wed, 03 May 2023 19:20:33 +0900 X-CMS-MailID: 20230503102033epcms2p5791708735197d3aac4fe546bcd7ac387 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkk+LIzCtJLcpLzFFi42LZdljTXLfQNCjF4PItY4vVd/vZLF4e0rRY ufook0Vv/1Y2i0U3tjFZ7L2lbXF51xw2i+XH/zE5cHhcPlvqMWHRAUaP3Tcb2Dw+Pr3F4tG3 ZRWjx+dNcgFsUdk2GamJKalFCql5yfkpmXnptkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4B um6ZOUDXKCmUJeaUAoUCEouLlfTtbIryS0tSFTLyi0tslVILUnIKzAv0ihNzi0vz0vXyUkus DA0MjEyBChOyM/Zums9UsImvYuKqbewNjBN5uhg5OSQETCTOnl7D0sXIxSEksINRYu2L/6xd jBwcvAKCEn93CIOYwgJFEpPXR4OUCwkoSZxbM4sRImwgcavXHCTMJqAn8XPJDDaQKSICN5gk 9nx+zQwxnldiRvtTFghbWmL78q2MIDangJ/E4w23GCHiGhI/lvVC1YtK3Fz9lh3Gfn9sPlSN iETrvbNQNYISD37uhopLShw69JUN5B4JgXyJDQcCIcI1Em+XH4Aq0Ze41rER7AReAV+Jhvsb wGwWAVWJb1f+MUHUuEj0/l8PNp5ZQF5i+9s5zCAjmQU0Jdbv0oeYrixx5BYLRAWfRMfhv+ww DzZs/I2VvWPeEyaIVjWJRU1GEGEZia+H57NPYFSahQjkWUjWzkJYu4CReRWjWGpBcW56arFR gTE8XpPzczcxgtOklvsOxhlvP+gdYmTiYDzEKMHBrCTC+6HQL0WINyWxsiq1KD++qDQntfgQ oynQwxOZpUST84GJOq8k3tDE0sDEzMzQ3MjUwFxJnFfa9mSykEB6YklqdmpqQWoRTB8TB6dU A1PA0xgh9puejDxS6XIqbl23ryutmTVBx/VG+WlNlRlMWom3592p8hbTv7iv9dPUhazpP5sl vnQkbeFNm99j1F8XJv1/YVmx4PsPPBprF4hf9M8OOX21bv2JipKt0iqNZ1imSK11as5Z8O+D xT+nPfG1Xw9F6VuVeCgsdni+qnPbPAeWSa4GYhpbmS9ablltxMSpdeXP24QIY93+V0fP8r5Y zvWNXaFc+bTF9SWGPtMT3ld86o0t42NYnmPCOpXXfgGvyleGBbMsH1nnWMrxSPx0+Jq/Vm/K pSw2zb7pBYFuVbNfa3s6Ob7nNbbP8NeI+ZqnlB8T39a6Y15Mzs6jXX8Ny1gXrBH1193ikPVc iaU4I9FQi7moOBEAdX0yCBwEAAA= DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org In the block layer, the number of segments is recorded in the request. It is already divided into separate segments based on hw information. Therefore, there is no need to count again. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- drivers/scsi/scsi_lib.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 89cf21345e1a..5d67b6f6854e 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1006,8 +1006,9 @@ static inline bool scsi_cmd_needs_dma_drain(struct scsi_device *sdev, static blk_status_t scsi_alloc_integrity_sgtables(struct scsi_cmnd *cmd) { struct request *rq = scsi_cmd_to_rq(cmd); + unsigned short nr_integrity_segs = blk_rq_nr_integrity_segments(rq); struct scsi_data_buffer *prot_sdb = cmd->prot_sdb; - int count, ivecs; + int count; if (WARN_ON_ONCE(!prot_sdb)) { /* @@ -1018,9 +1019,7 @@ static blk_status_t scsi_alloc_integrity_sgtables(struct scsi_cmnd *cmd) return BLK_STS_IOERR; } - ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio); - - if (sg_alloc_table_chained(&prot_sdb->table, ivecs, + if (sg_alloc_table_chained(&prot_sdb->table, nr_integrity_segs, prot_sdb->table.sgl, SCSI_INLINE_PROT_SG_CNT)) { return BLK_STS_RESOURCE; @@ -1028,10 +1027,7 @@ static blk_status_t scsi_alloc_integrity_sgtables(struct scsi_cmnd *cmd) count = blk_rq_map_integrity_sg(rq->q, rq->bio, prot_sdb->table.sgl); - BUG_ON(count > ivecs); - BUG_ON(count > queue_max_integrity_segments(rq->q)); - - cmd->prot_sdb = prot_sdb; + BUG_ON(count > prot_sdb->table.nents); cmd->prot_sdb->table.nents = count; return BLK_STS_OK; From patchwork Wed May 3 10:21:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230021 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 B790FC77B78 for ; Wed, 3 May 2023 10:21:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229745AbjECKVt (ORCPT ); Wed, 3 May 2023 06:21:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229554AbjECKVt (ORCPT ); Wed, 3 May 2023 06:21:49 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A85603C01 for ; Wed, 3 May 2023 03:21:47 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230503102145epoutp01f55295a502d909018950634a6604c888~bmv8GkrmA2578025780epoutp01s for ; Wed, 3 May 2023 10:21:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230503102145epoutp01f55295a502d909018950634a6604c888~bmv8GkrmA2578025780epoutp01s DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683109305; bh=ZfhC85BvKxKIuur1CoeZsaWeIlAnBRlkMNE/o0TIGEU=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=jyNXa3IL3Wf63GZMeW5DyDIFhXPN7xFgXXLQCFE7ziOOvvmXjUK0EeWobmCywJ+Pd C4UHvEhtFAgX5XWt4dzB7Ls22Z9RkSUyw04KdEKCHVpRyGLyGsJ4P5b2G4HD6+i4a8 emHRb2n4pvR1aFR/66ZpzfOEbYi2B1CN5B8MDsC4= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230503102145epcas2p3ebef196678b9f539e5eef8d92b0100c6~bmv7h2NWR1582715827epcas2p3Z; Wed, 3 May 2023 10:21:45 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.89]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4QBCfc525gz4x9Pw; Wed, 3 May 2023 10:21:44 +0000 (GMT) X-AuditID: b6c32a45-6d1fd70000020cc1-fb-645235b806a6 Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id B3.70.03265.8B532546; Wed, 3 May 2023 19:21:44 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 11/15] block: blk-integrity: change how to find the number of integrity of bio Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "hch@lst.de" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503102144epcms2p5ba957092cb811a6ed6cce92debe6e10c@epcms2p5> Date: Wed, 03 May 2023 19:21:44 +0900 X-CMS-MailID: 20230503102144epcms2p5ba957092cb811a6ed6cce92debe6e10c X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPKsWRmVeSWpSXmKPExsWy7bCmme4O06AUg9aVqhar7/azWbw8pGmx cvVRJove/q1sFntvaVtc3jWHzWL58X9MDuwel8+Weuy+2cDm8fHpLRaPvi2rGD0+b5ILYI3K tslITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wBukFJoSwx pxQoFJBYXKykb2dTlF9akqqQkV9cYquUWpCSU2BeoFecmFtcmpeul5daYmVoYGBkClSYkJ1x dc511oINnBWdq28xNzA+Y+9i5OSQEDCR+DNzClMXIxeHkMAORokjp3oYuxg5OHgFBCX+7hAG qREWSJB43fKIFcQWElCSOLdmFliJsICBxK1ec5Awm4CexM8lM9hAbBGB1UwSzc9rIMbzSsxo f8oCYUtLbF++lRHE5hTwk3i84RYjRFxD4seyXmYIW1Ti5uq37DD2+2PzoWpEJFrvnYWqEZR4 8HM3VFxS4tChr2wg50gI5EtsOBAIEa6ReLv8AFSJvsS1jo1gJ/AK+ErMaVoNNp5FQFWi5/lS VogaF4nJM1vBbGYBeYntb+cwg4xkFtCUWL9LH2K6ssSRWywQFXwSHYf/ssM82LDxN1b2jnlP mCBa1SQWNRlBhGUkvh6ezz6BUWkWIpBnIVk7C2HtAkbmVYxiqQXFuempxUYFhvB4Tc7P3cQI TolarjsYJ7/9oHeIkYmD8RCjBAezkgjvh0K/FCHelMTKqtSi/Pii0pzU4kOMpkAPT2SWEk3O ByblvJJ4QxNLAxMzM0NzI1MDcyVxXmnbk8lCAumJJanZqakFqUUwfUwcnFINTB5sOidzuEU/ 7mE7UurH28RrvXwz92TxttpkC+9/rq+1RP2u5/4K/i9g31y+l/t479v357K65DZOltDMvW53 b02PHotc/zWHrgW9DGd1uZo4Lyo1H2tbv++uz3nP7Ss+9PN6bO//p/Hni17SwiPNVaJe1hwX 3Ru1ysqKJrt9lV63nGfCJpYVotEHZjY6xc09zb1g8c8dVku2aq/f9Hdvd/YNx97qE9rXO4q8 P0h873Hi9Cr8vLROK7e42mGLbEXTFkZT/TVmmV6eXnOq5y5nargXy3t3SmTTjdNXzR6dTSn/ 9mjJjIU3FCafsl7T4PxyDtfmvIMXC5xWab1733524/Od/6eo6PjtcCmZ2fcgVYmlOCPRUIu5 qDgRAJUtFKESBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The method of constructing a bip has been changed, the number of segments can be obtained through bip_vcnt. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- block/blk-integrity.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index f97b7e8a6d4d..64407b412947 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -217,7 +217,6 @@ bool blk_integrity_merge_bio(struct request_queue *q, struct request *req, struct bio *bio) { int nr_integrity_segs; - struct bio *next = bio->bi_next; if (blk_integrity_bypass_check(req, bio)) return true; @@ -225,9 +224,7 @@ bool blk_integrity_merge_bio(struct request_queue *q, struct request *req, if (!__blk_integrity_mergeable(q, req, bio)) return false; - bio->bi_next = NULL; - nr_integrity_segs = blk_rq_count_integrity_sg(q, bio); - bio->bi_next = next; + nr_integrity_segs = bio_integrity(bio)->bip_vcnt; if (req->nr_integrity_segments + nr_integrity_segs > q->limits.max_integrity_segments) From patchwork Wed May 3 10:23:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230022 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 8F56CC77B78 for ; Wed, 3 May 2023 10:23:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229741AbjECKXS (ORCPT ); Wed, 3 May 2023 06:23:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjECKXR (ORCPT ); Wed, 3 May 2023 06:23:17 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7A62E43 for ; Wed, 3 May 2023 03:23:16 -0700 (PDT) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20230503102315epoutp03226d078cc8d6d7a737a3e6519536ad93~bmxPZ-FA-2815228152epoutp03C for ; Wed, 3 May 2023 10:23:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20230503102315epoutp03226d078cc8d6d7a737a3e6519536ad93~bmxPZ-FA-2815228152epoutp03C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683109395; bh=ZM+sCSOwfR6BMhP2ycEflPofWbLGNzFKU7U4qcknaW8=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=uMFqmCmiUEeBZWiL9Sb6hAb6ydvxZNtemId5ZGobtPPI38INS2yHBf7GouLIc64fs h6Drg74VaNZ+cxboIWBKtVNNWF4p8w1ibL5/51gB+zzJpnhvIhGu5g2S+IoWERpepA bh43MtBAgOcGu/i+QYkUtfJoBagWscsr7doiCb5w= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230503102314epcas2p47f783c917b77e312bf1314b109badd5d~bmxOoSSjZ1780817808epcas2p4J; Wed, 3 May 2023 10:23:14 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.36.88]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4QBChK6q5Lz4x9Px; Wed, 3 May 2023 10:23:13 +0000 (GMT) X-AuditID: b6c32a48-6d3fa70000005998-5b-645236115133 Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 73.DF.22936.11632546; Wed, 3 May 2023 19:23:13 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 12/15] nvme: rdma: change how to find the number of integrity of request 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" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503102313epcms2p52eb54df61b367ae233c4dfe7c6594918@epcms2p5> Date: Wed, 03 May 2023 19:23:13 +0900 X-CMS-MailID: 20230503102313epcms2p52eb54df61b367ae233c4dfe7c6594918 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMJsWRmVeSWpSXmKPExsWy7bCmha6gWVCKwft7Jhar7/azWbw8pGmx cvVRJove/q1sFpMOXWO02HtL2+LyrjlsFsuP/2OyWPf6PYsDp8f5extZPC6fLfXYtKqTzWP3 zQY2j49Pb7F49G1ZxejxeZNcAHtUtk1GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5 kkJeYm6qrZKLT4CuW2YO0F1KCmWJOaVAoYDE4mIlfTubovzSklSFjPziElul1IKUnALzAr3i xNzi0rx0vbzUEitDAwMjU6DChOyMXZ82MxbsYa/o3jmHsYFxFVsXIyeHhICJRMOX+exdjFwc QgI7GCUaemcDJTg4eAUEJf7uEAapERaIkphzYjUTiC0koCRxbs0sRpASYQEDiVu95iBhNgE9 iZ9LZoCNFBH4yySx80U+xHheiRntT1kgbGmJ7cu3MoLYnAJ+Eo833GKEiGtI/FjWywxhi0rc XP2WHcZ+f2w+VI2IROu9s1A1ghIPfu6GiktKHDr0FexiCYF8iQ0HAiHCNRJvlx+AKtGXuNax EewEXgFfiWcz/oLZLAKqEv/mX4aqcZHoXP8DbC2zgLzE9rdzmEFGMgtoSqzfpQ8xXVniyC0W iAo+iY7Df9lhHmzY+Bsre8e8J0wQrWoSi5qMIMIyEl8Pz2efwKg0CxHIs5CsnYWwdgEj8ypG sdSC4tz01GKjAhN4vCbn525iBKdOLY8djLPfftA7xMjEwXiIUYKDWUmE90OhX4oQb0piZVVq UX58UWlOavEhRlOghycyS4km5wOTd15JvKGJpYGJmZmhuZGpgbmSOO/HDuUUIYH0xJLU7NTU gtQimD4mDk6pBqY+qSD51z6didP3dxdsaNos//e/2NujIRdFq269/eXo0PLppqPvkhC7ze8P /+ANiev94eu6deFGlW3eyU+0U2uOsmf8b5W6t/+YffPLo/PW2Zzme7X6XVN1r9A81bWySv83 zTvPkfT48CFV3VIzCaHFjPe43icbm8+8UKf3sOS94r41hQVfl/BvMHYVZ66r8jbMrmd4u6JR Ovbo7UtFexItxdOyevguOJ/TPHzk5bZD7y6uC34x/yvnbTvH3vpWy9867IsfVYSL2ji0b9Se cWCjmtQ0XTbtDoGvzL0pE25kVyQJmrf0r2JQvvgj8kZnFVPD7iuT/3bfvpjcP+3Kko61YcFu 01M359vYNR3TF1NiKc5INNRiLipOBACEuYZEJgQAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Since the request has the number of integrity segments, change to use the relevant api. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- drivers/nvme/host/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 0eb79696fb73..237d81ad54af 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1507,7 +1507,7 @@ static int nvme_rdma_dma_map_req(struct ib_device *ibdev, struct request *rq, req->metadata_sgl->sg_table.sgl = (struct scatterlist *)(req->metadata_sgl + 1); ret = sg_alloc_table_chained(&req->metadata_sgl->sg_table, - blk_rq_count_integrity_sg(rq->q, rq->bio), + blk_rq_nr_integrity_segments(rq), req->metadata_sgl->sg_table.sgl, NVME_INLINE_METADATA_SG_CNT); if (unlikely(ret)) { From patchwork Wed May 3 10:25:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230023 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 6C190C77B75 for ; Wed, 3 May 2023 10:25:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229595AbjECKZs (ORCPT ); Wed, 3 May 2023 06:25:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjECKZs (ORCPT ); Wed, 3 May 2023 06:25:48 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF86F35A6 for ; Wed, 3 May 2023 03:25:45 -0700 (PDT) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230503102544epoutp01ef714706a49815b25f1d41575097e60a~bmzaHO_wR2995129951epoutp01P for ; Wed, 3 May 2023 10:25:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230503102544epoutp01ef714706a49815b25f1d41575097e60a~bmzaHO_wR2995129951epoutp01P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683109544; bh=Qu9Yx8AHfpqjx58Hv8uRZKjzvr/nHdB5F0/a51oGkO8=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=MsXLWRzSWTXLUHxXqBeStKoWzjkGL85pXYRwZ6bTcsezk1Lwlk04RJfZcSpj76Oa5 CoFZ4hrb8sVi/9cZHNo02L3lummecQv1Od8Shdnkxn2AhGV5JrYnwLn9cdxScmOFlg ljaG5uQukl8GbPks/Ug+CrtV5HhPxHAPhQZz27dU= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20230503102543epcas2p2ca5917ded82f913c41eaf6e72457d945~bmzZgxulP0035600356epcas2p2h; Wed, 3 May 2023 10:25:43 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.36.90]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4QBClB6HYFz4x9Q5; Wed, 3 May 2023 10:25:42 +0000 (GMT) X-AuditID: b6c32a46-8b7ff7000001438d-29-645236a6590e Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id D9.88.17293.6A632546; Wed, 3 May 2023 19:25:42 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 13/15] block: add helper function for iteration of bip's bvec Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "hch@lst.de" , "martin.petersen@oracle.com" , "kch@nvidia.com" , "johannes.thumshirn@wdc.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: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503102542epcms2p371143d5975c9fa4e4a081b96f6bfc2c0@epcms2p3> Date: Wed, 03 May 2023 19:25:42 +0900 X-CMS-MailID: 20230503102542epcms2p371143d5975c9fa4e4a081b96f6bfc2c0 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLJsWRmVeSWpSXmKPExsWy7bCmue4ys6AUg94OI4vVd/vZLF4e0rRY ufook0Vv/1Y2i79d95gsnl6dxWSx95a2xeVdc9gslh//x2Tx+8ccNgcuj80rtDwuny312H2z gc2jt/kdm8fHp7dYPPq2rGL0+LxJzqP9QDdTAEdUtk1GamJKapFCal5yfkpmXrqtkndwvHO8 qZmBoa6hpYW5kkJeYm6qrZKLT4CuW2YO0IFKCmWJOaVAoYDE4mIlfTubovzSklSFjPziElul 1IKUnALzAr3ixNzi0rx0vbzUEitDAwMjU6DChOyMBT+2sBU84q2Y1d7I3sC4mruLkZNDQsBE Yt2u6cxdjFwcQgI7GCVunNgM5HBw8AoISvzdIQxSIyzgL9G+9x87iC0koCRxbs0sRpASYQED iVu95iBhNgE9iZ9LZrCBjBER2MUs8fXcRiaI+bwSM9qfskDY0hLbl29lBLE5BfwkHm+4xQgR 15D4sayXGcIWlbi5+i07jP3+2HyoGhGJ1ntnoWoEJR783A0Vl5Q4dOgrG8g9EgL5EhsOBEKE ayTeLj8AVaIvca1jI9gJvAK+Ege+HmEFsVkEVCWuz2mBGukisWfFVLA4s4C8xPa3c8ChwCyg KbF+lz7EdGWJI7dYICr4JDoO/2WHebBh42+s7B3znjBBtKpJLGoyggjLSHw9PJ99AqPSLEQo z0KydhbC2gWMzKsYxVILinPTU4uNCozgEZucn7uJEZxOtdx2ME55+0HvECMTB+MhRgkOZiUR 3g+FfilCvCmJlVWpRfnxRaU5qcWHGE2BHp7ILCWanA9M6Hkl8YYmlgYmZmaG5kamBuZK4rzS tieThQTSE0tSs1NTC1KLYPqYODilGphij/3gmCJr/2jC07abSUw7XgnlXCt5FyzczPjqb7z/ +mLFWxxWU88fU9mmcZ/R5+e1wv6VqfETFp291h3nWrrs3PZF9kf1m2dxp6seWpwVmfp5qbvX +lKXp3uWFbSoJ8vt4azK5mab8v9492qzqRNLOCYyfGNkaY31Tdrz5Jt62qnOaMavnkzrIh0L I6rnnD+6bX0EY8WLgOZXG56+23Ts0ZIZC51T2IynL+atCI/T9zyllPv71I9+Xf/a1qXiPesi g/7fYXPZ8Di0Xo5b2P39j1ixp9cD/vUFy/RwmJZ90i/MXexVf2ujDd/D5u3JwptZfW/GRL4o W3K+J9YnQuhSflNFfG/WtWy+5v3dlkosxRmJhlrMRcWJAB06peUwBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org bip_for_each_vec() performs the iteration in a page unit. Since a bio_vec of bip is composed of multi-page in the block, a macro that can be carried out in multi-page units has been added. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- include/linux/bio.h | 4 ++++ include/linux/bvec.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/include/linux/bio.h b/include/linux/bio.h index b53a595b519a..e3e437ce694c 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -695,6 +695,10 @@ static inline bool bioset_initialized(struct bio_set *bs) #if defined(CONFIG_BLK_DEV_INTEGRITY) +/* iterate over multi-page bvec for integrity */ +#define bip_for_each_mp_bvec(bvl, bip, iter) \ + for_each_mp_bvec(bvl, (bip)->bip_vec, iter, (bip)->bip_iter) + #define bip_for_each_vec(bvl, bip, iter) \ for_each_bvec(bvl, (bip)->bip_vec, iter, (bip)->bip_iter) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 555aae5448ae..9364c258513e 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -184,6 +184,12 @@ static inline void bvec_iter_advance_single(const struct bio_vec *bv, ((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \ bvec_iter_advance_single((bio_vec), &(iter), (bvl).bv_len)) +#define for_each_mp_bvec(bvl, bio_vec, iter, start) \ + for (iter = (start); \ + (iter).bi_size && \ + ((bvl = mp_bvec_iter_bvec((bio_vec), (iter))), 1); \ + bvec_iter_advance_single((bio_vec), &(iter), (bvl).bv_len)) + /* for iterating one bio from start to end */ #define BVEC_ITER_ALL_INIT (struct bvec_iter) \ { \ From patchwork Wed May 3 10:27:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230024 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 0A56DC77B78 for ; Wed, 3 May 2023 10:27:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229959AbjECK1Z (ORCPT ); Wed, 3 May 2023 06:27:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbjECK1Y (ORCPT ); Wed, 3 May 2023 06:27:24 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3574EE43 for ; Wed, 3 May 2023 03:27:23 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230503102721epoutp040cb521c931731906a1e9a00bd6ca8e45~bm00QuVGa3161631616epoutp04O for ; Wed, 3 May 2023 10:27:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230503102721epoutp040cb521c931731906a1e9a00bd6ca8e45~bm00QuVGa3161631616epoutp04O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683109641; bh=2tjd0O0lZWt8c5dIoxfFDYaBGx6V9lKhttI7UOkE/aI=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=svugPknYSM4UTmlHhT7iqGAew3dqoA/scXQ+mDa88AbXhtZKESyDXlUxbZfljlZnr MeF3ER7Z9pXyaBCbhOPYy7KXJOFyoLEY8RfcxTqY+uUKF5LkoKGoEUuV2Ts3R+w+JI psxjXTZIpRBr19E0J1iSDxG6QhhHc9G3KDXZWs9Y= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20230503102720epcas2p15ada5b8e729e3e2e82e00e5bc0baba27~bm0zvRyUY0379803798epcas2p1Z; Wed, 3 May 2023 10:27:20 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.36.88]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4QBCn36psCz4x9Q1; Wed, 3 May 2023 10:27:19 +0000 (GMT) X-AuditID: b6c32a48-6d3fa70000005998-6c-6452370710a0 Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 6E.A0.22936.70732546; Wed, 3 May 2023 19:27:19 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 14/15] 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" , "hch@lst.de" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503102719epcms2p457434fefd535ee43d502eff854227919@epcms2p4> Date: Wed, 03 May 2023 19:27:19 +0900 X-CMS-MailID: 20230503102719epcms2p457434fefd535ee43d502eff854227919 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPKsWRmVeSWpSXmKPExsWy7bCmuS67eVCKwcXpxhar7/azWbw8pGmx cvVRJove/q1sFntvaVtc3jWHzWL58X9MDuwel8+Weuy+2cDm8fHpLRaPvi2rGD0+b5ILYI3K tslITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wBukFJoSwx pxQoFJBYXKykb2dTlF9akqqQkV9cYquUWpCSU2BeoFecmFtcmpeul5daYmVoYGBkClSYkJ2x 4/l/9oI9ChWbpt5ja2C8ItnFyMkhIWAicenOAvYuRi4OIYEdjBJPX95g62Lk4OAVEJT4u0MY pEZYIFHi7qleNhBbSEBJ4tyaWYwgJcICBhK3es1BwmwCehI/l8wAKxERWM0k0fy8BmI8r8SM 9qcsELa0xPblWxlBbE4BP4nHG24xQsQ1JH4s62WGsEUlbq5+yw5jvz82H6pGRKL13lmoGkGJ Bz93Q8UlJQ4d+gp2sYRAvsSGA4EQ4RqJt8sPQJXoS1zr2Ah2Aq+Ar8S1FX/BzmQRUJXY/+Ie VI2LxKWjr8HizALyEtvfzmEGGcksoCmxfpc+xHRliSO3WCAq+CQ6Dv9lh3mwYeNvrOwd854w QbSqSSxqMoIIy0h8PTyffQKj0ixEIM9CsnYWwtoFjMyrGMVSC4pz01OLjQpM4PGanJ+7iRGc ErU8djDOfvtB7xAjEwfjIUYJDmYlEd4PhX4pQrwpiZVVqUX58UWlOanFhxhNgR6eyCwlmpwP TMp5JfGGJpYGJmZmhuZGpgbmSuK8HzuUU4QE0hNLUrNTUwtSi2D6mDg4pRqYZp4IZ0uR/HDE YJcjy2Gve+/bOncUz9l2m8Vsmaua0YaXVy7om1Y62vkf4n5hdnGLpWDCBksbXnG3Goe1/U61 u9bE77dkY5+V36LktHTpc+YZXadzgi7H8jSvdkj4ovfixlcFBu3laU1zD54+0Pb3+lqFwkI/ x4z+bXecv+WcPsy/J8ApwSqp7vIZhiMPPPnenzEIzn06ZeGaR9UeWvnREW+edb/Ze35zhErJ O4FI38tFTuHJW9pu/7+7/VmMWVj3XseQk/HS3msY/q1LljgT6tWb3p21IG/BvyMrDKMVN5VL Gro7GW3duvlNSMjF77ErLr/vKDb/8mu3/Y7ZGekWfR7LeduDwrRFeKptLLSVWIozEg21mIuK EwFnQNY1EgQAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> 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 | 52 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 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..71539d88ffe6 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -524,6 +524,58 @@ __blk_segment_map_sg_merge(struct request_queue *q, struct bio_vec *bvec, return true; } +/** + * 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); + static int __blk_bios_map_sg(struct request_queue *q, struct bio *bio, struct scatterlist *sglist, struct scatterlist **sg) From patchwork Wed May 3 10:28:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13230025 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 037A1C77B75 for ; Wed, 3 May 2023 10:28:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229878AbjECK2Y (ORCPT ); Wed, 3 May 2023 06:28:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229824AbjECK2X (ORCPT ); Wed, 3 May 2023 06:28:23 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4BD9E43 for ; Wed, 3 May 2023 03:28:21 -0700 (PDT) Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230503102820epoutp04525877be1ae4c8ba927e881a5d0c500d~bm1rYiGMe2973929739epoutp04c for ; Wed, 3 May 2023 10:28:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230503102820epoutp04525877be1ae4c8ba927e881a5d0c500d~bm1rYiGMe2973929739epoutp04c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683109700; bh=z1Pr/BMubVK5gm0MNy0PUzgA5DYmQXK+i/O5omA92XA=; h=Subject:Reply-To:From:To:In-Reply-To:Date:References:From; b=DfghvSUUIX54ioWeOM+ZO960qSwEM4DlGHKy0OxHqVyGAfRbtPzHFx2J97sZpjl8t y64Ej5j55frDtqnQjXxWq/WoEluvVlbA9hWPsMgppBpGanyxMUWkEwQyMY6+gADH7N JpaiuNbKN6dFO1sbpQavJyJ3xNP8E5Mh4vlaCPoY= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230503102819epcas2p3d5d48480285c6355b70b4be904d57435~bm1q5sKgY2240622406epcas2p35; Wed, 3 May 2023 10:28:19 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.90]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4QBCpC1Sy5z4x9Px; Wed, 3 May 2023 10:28:19 +0000 (GMT) X-AuditID: b6c32a45-465ff70000020cc1-47-64523743bffa Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 0C.12.03265.34732546; Wed, 3 May 2023 19:28:19 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH 15/15] block: blk-integrity: remove blk_rq_count_integrity_sg() Reply-To: j-young.choi@samsung.com Sender: Jinyoung CHOI From: Jinyoung CHOI To: Jinyoung CHOI , "axboe@kernel.dk" , "hch@lst.de" , "martin.petersen@oracle.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@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: <20230503102818epcms2p8fe187efd29182c441c2670f890c8f9c1@epcms2p8> Date: Wed, 03 May 2023 19:28:18 +0900 X-CMS-MailID: 20230503102818epcms2p8fe187efd29182c441c2670f890c8f9c1 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPKsWRmVeSWpSXmKPExsWy7bCmha6zeVCKwY59HBar7/azWbw8pGmx cvVRJove/q1sFntvaVtc3jWHzWL58X9MDuwel8+Weuy+2cDm8fHpLRaPvi2rGD0+b5ILYI3K tslITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wBukFJoSwx pxQoFJBYXKykb2dTlF9akqqQkV9cYquUWpCSU2BeoFecmFtcmpeul5daYmVoYGBkClSYkJ1x dtEZxoJuoYqVC/vZGhhf8nUxcnJICJhI7P/zgLmLkYtDSGAHo8Tt7WeAHA4OXgFBib87hEFq hAUCJa68/cIKYgsJKEmcWzOLEaREWMBA4lavOUiYTUBP4ueSGWwgtojAaiaJ5uc1EON5JWa0 P2WBsKUlti/fyghicwr4STzecIsRIq4h8WNZLzOELSpxc/Vbdhj7/bH5UDUiEq33zkLVCEo8 +LkbKi4pcejQVzaQcyQE8iU2HAiECNdIvF1+AKpEX+Jax0awE3gFfCVm7HjABGKzCKhKnFxx Auo0F4m7e86CfcgsIC+x/e0ccCAwC2hKrN+lDzFdWeLILRaICj6JjsN/2WEebNj4Gyt7x7wn TBCtahKLmowgwjISXw/PZ5/AqDQLEcizkKydhbB2ASPzKkax1ILi3PTUYqMCQ3i8JufnbmIE p0Qt1x2Mk99+0DvEyMTBeIhRgoNZSYT3Q6FfihBvSmJlVWpRfnxRaU5q8SFGU6CHJzJLiSbn A5NyXkm8oYmlgYmZmaG5kamBuZI4r7TtyWQhgfTEktTs1NSC1CKYPiYOTqkGJmuVqChxF3Up 9/gp9lssKoJiL2bLKDXNNnonfX5Og8x9s1qzYi79DZkucTKaSl+Wn5/od2FWecyqhfHXGP9t i3rYcVj1S0xr3DzJdxyqPd0vVUr+v/RiC1DY0TAze9XJSx/06yUPJjk863k3cUJGyYN/e4vO J1zImeeXtFP5tbfPS/e5M797Vf0snpBje1eym19qrmN6j/z+P1vTfS0/3+eumf1siwf3lP21 G/b/PnPd7/rSVTNbF9btTTvnrlzr99Duhl0UwyNrKb782YdYt8cVx4u4vlu518nPZ2EfQ0z6 w8otzeHmFUGXpN0PdN0+Pd9n85MrYr9+8desCdxVvbCz91n+LKMfrixrFfT2KrEUZyQaajEX FScCANZ+dCoSBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323 References: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org blk_rq_nr_nr_integrity_segments() allows you to obtain the number of integrity. Therefore, blk_rq_count_integrity_sg() is no longer necessary. Cc: Christoph Hellwig Cc: Martin K. Petersen Signed-off-by: Jinyoung Choi --- block/blk-integrity.c | 39 ----------------------------------- include/linux/blk-integrity.h | 1 - 2 files changed, 40 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index c50954652177..9bac2836c3ff 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -16,45 +16,6 @@ #include "blk.h" -/** - * blk_rq_count_integrity_sg - Count number of integrity scatterlist elements - * @q: request queue - * @bio: bio with integrity metadata attached - * - * Description: Returns the number of elements required in a - * scatterlist corresponding to the integrity metadata in a bio. - */ -int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio) -{ - struct bio_vec iv, ivprv = { NULL }; - unsigned int segments = 0; - unsigned int seg_size = 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 (seg_size + iv.bv_len > queue_max_segment_size(q)) - goto new_segment; - - seg_size += iv.bv_len; - } else { -new_segment: - segments++; - seg_size = iv.bv_len; - } - - prev = 1; - ivprv = iv; - } - - return segments; -} -EXPORT_SYMBOL(blk_rq_count_integrity_sg); - /** * blk_integrity_compare - Compare integrity profile of two disks * @gd1: Disk to compare diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h index 45b9fde1fee1..a2a9d72e8fab 100644 --- a/include/linux/blk-integrity.h +++ b/include/linux/blk-integrity.h @@ -41,7 +41,6 @@ void blk_integrity_unregister(struct gendisk *); int blk_integrity_compare(struct gendisk *, struct gendisk *); int blk_rq_map_integrity_sg(struct request_queue *, struct bio *, struct scatterlist *); -int blk_rq_count_integrity_sg(struct request_queue *, struct bio *); static inline unsigned short blk_rq_nr_integrity_segments(struct request *rq) {