summaryrefslogtreecommitdiff
path: root/include/scsi/scsi_cmnd.h
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2021-08-06 00:00:19 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2021-08-11 22:25:43 -0400
commit6a20e21ae1e25f73385cc248f53440e78dd3cb94 (patch)
tree1b05a2494ae2069df3e3d1f935688b4042767bcd /include/scsi/scsi_cmnd.h
parent2266a2def97ce11ec979b6c58a1b637a16eca7dd (diff)
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: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'include/scsi/scsi_cmnd.h')
-rw-r--r--include/scsi/scsi_cmnd.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index ddc9671b325b..6c5a1c1c6b1e 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -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;
}
+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
* to handle I/Os with DIF or similar types of protection information.