Skip to content

Commit f03e94f

Browse files
ChaotianJingmartinkpetersen
authored andcommitted
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: [email protected] Fixes: 6a20e21 ("scsi: core: Add helper to return number of logical blocks in a request") Signed-off-by: Chaotian Jing <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 2fa62ce commit f03e94f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/scsi/scsi_cmnd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
234234

235235
static inline unsigned int scsi_logical_block_count(struct scsi_cmnd *scmd)
236236
{
237-
unsigned int shift = ilog2(scmd->device->sector_size) - SECTOR_SHIFT;
237+
unsigned int shift = ilog2(scmd->device->sector_size);
238238

239239
return blk_rq_bytes(scsi_cmd_to_rq(scmd)) >> shift;
240240
}

0 commit comments

Comments
 (0)