Message ID | 20210806040023.5355-2-martin.petersen@oracle.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [v2,1/5] scsi: core: Add helper to return number of logical blocks in a request | expand |
On 8/5/21 9:00 PM, Martin K. Petersen wrote: > Cc: Bart Van Assche <bvanassche@acm.org> > Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> > --- > include/scsi/scsi_cmnd.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h > index 90da9617d28a..804b2b33da4a 100644 > --- a/include/scsi/scsi_cmnd.h > +++ b/include/scsi/scsi_cmnd.h > @@ -232,6 +232,13 @@ static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd) > return blk_rq_pos(scmd->request) >> 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(scmd->request) >> shift; > +} Reviewed-by: Bart Van Assche <bvanassche@acm.org>
On Fri, 6 Aug 2021 00:00:19 -0400, Martin K. Petersen wrote:
>
Applied to 5.15/scsi-queue, thanks!
[1/5] scsi: core: Add helper to return number of logical blocks in a request
https://git.kernel.org/mkp/scsi/c/6a20e21ae1e2
[2/5] scsi: isci: Use the proper SCSI midlayer interfaces for PI
https://git.kernel.org/mkp/scsi/c/4cc0096e2d54
[3/5] scsi: mpi3mr: Use the proper SCSI midlayer interfaces for PI
https://git.kernel.org/mkp/scsi/c/92cc94adfce4
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 90da9617d28a..804b2b33da4a 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -232,6 +232,13 @@ static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd) return blk_rq_pos(scmd->request) >> 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(scmd->request) >> shift; +} + /* * The operations below are hints that tell the controller driver how * to handle I/Os with DIF or similar types of protection information.
Cc: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> --- include/scsi/scsi_cmnd.h | 7 +++++++ 1 file changed, 7 insertions(+)