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+LIzCtJLcpLzFFi42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fgGvyleGBbMsH1nnWMrxSPx0+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;