[PATCH v2] scsi: fix the return value of scsi_logical_block_count

Chaotian Jing posted 1 patch 1 month, 1 week ago
include/scsi/scsi_cmnd.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] scsi: fix the return value of scsi_logical_block_count
Posted by Chaotian Jing 1 month, 1 week ago
scsi_logical_block_count() should return the block count of scsi device,
but the original code has a wrong implement.

Cc: stable@vger.kernel.org
Fixes: 6a20e21ae1e2 ("scsi: core: Add helper to return number of logical
blocks in a request")
Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
 include/scsi/scsi_cmnd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 45c40d200154..8ecfb94049db 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -234,7 +234,7 @@ static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
 
 static inline unsigned int scsi_logical_block_count(struct scsi_cmnd *scmd)
 {
-	unsigned int shift = ilog2(scmd->device->sector_size) - SECTOR_SHIFT;
+	unsigned int shift = ilog2(scmd->device->sector_size);
 
 	return blk_rq_bytes(scsi_cmd_to_rq(scmd)) >> shift;
 }
-- 
2.46.0
Re: [PATCH v2] scsi: fix the return value of scsi_logical_block_count
Posted by Martin K. Petersen 1 month ago
On Tue, 13 Aug 2024 13:34:10 +0800, Chaotian Jing wrote:

> scsi_logical_block_count() should return the block count of scsi device,
> but the original code has a wrong implement.
> 
> 

Applied to 6.11/scsi-fixes, thanks!

[1/1] scsi: fix the return value of scsi_logical_block_count
      https://git.kernel.org/mkp/scsi/c/f03e94f23b04

-- 
Martin K. Petersen	Oracle Linux Engineering