lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230510085648epcms2p8f7a9095b798cab8746c39ea25d7f3bec@epcms2p8>
Date:   Wed, 10 May 2023 17:56:48 +0900
From:   Jinyoung CHOI <j-young.choi@...sung.com>
To:     Jinyoung CHOI <j-young.choi@...sung.com>,
        "axboe@...nel.dk" <axboe@...nel.dk>,
        "kbusch@...nel.org" <kbusch@...nel.org>, "hch@....de" <hch@....de>,
        "sagi@...mberg.me" <sagi@...mberg.me>,
        "jejb@...ux.ibm.com" <jejb@...ux.ibm.com>,
        "martin.petersen@...cle.com" <martin.petersen@...cle.com>,
        "johannes.thumshirn@....com" <johannes.thumshirn@....com>,
        "kch@...dia.com" <kch@...dia.com>,
        "willy@...radead.org" <willy@...radead.org>,
        "linux-block@...r.kernel.org" <linux-block@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH v2 09/14] scsi: change to use blk_rq_nr_integrity_segments()
 instead of blk_rq_count_integrity_sg()

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 <hch@....de>
Cc: Martin K. Petersen <martin.petersen@...cle.com>

Signed-off-by: Jinyoung Choi <j-young.choi@...sung.com>
---
 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;
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ