Commit 6a20e21a authored by Martin K. Petersen's avatar Martin K. Petersen

scsi: core: Add helper to return number of logical blocks in a request

Link: https://lore.kernel.org/r/20210806040023.5355-2-martin.petersen@oracle.com
Cc: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 2266a2de
...@@ -237,6 +237,13 @@ static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd) ...@@ -237,6 +237,13 @@ static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
return blk_rq_pos(scsi_cmd_to_rq(scmd)) >> shift; return blk_rq_pos(scsi_cmd_to_rq(scmd)) >> shift;
} }
static inline unsigned int scsi_logical_block_count(struct scsi_cmnd *scmd)
{
unsigned int shift = ilog2(scmd->device->sector_size) - SECTOR_SHIFT;
return blk_rq_bytes(scsi_cmd_to_rq(scmd)) >> shift;
}
/* /*
* The operations below are hints that tell the controller driver how * The operations below are hints that tell the controller driver how
* to handle I/Os with DIF or similar types of protection information. * to handle I/Os with DIF or similar types of protection information.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment