Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: core: Fix the return value of scsi_logical_block_count()

scsi_logical_block_count() should return the block count of a given SCSI
command. The original implementation ended up shifting twice, leading to an
incorrect count being returned. Fix the conversion between bytes and
logical blocks.

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>
Link: https://lore.kernel.org/r/20240813053534.7720-1-chaotian.jing@mediatek.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Chaotian Jing and committed by
Martin K. Petersen
f03e94f2 2fa62ce9

+1 -1
+1 -1
include/scsi/scsi_cmnd.h
··· 234 234 235 235 static inline unsigned int scsi_logical_block_count(struct scsi_cmnd *scmd) 236 236 { 237 - unsigned int shift = ilog2(scmd->device->sector_size) - SECTOR_SHIFT; 237 + unsigned int shift = ilog2(scmd->device->sector_size); 238 238 239 239 return blk_rq_bytes(scsi_cmd_to_rq(scmd)) >> shift; 240 240 }