Message ID | 20210609033929.3815-13-martin.petersen@oracle.com (mailing list archive) |
---|---|
State | Deferred |
Headers | show |
Series | Subject: Protection information and block size cleanup | expand |
On 6/8/21 8:39 PM, Martin K. Petersen wrote: > scsi_get_lba() confusingly returned the block layer sector number > expressed in units of 512 bytes. Now that we have a more aptly named > scsi_get_sector() function, make scsi_get_lba() return the actual LBA. Reviewed-by: Bart Van Assche <bvanassche@acm.org>
On Tue, Jun 08, 2021 at 11:39:26PM -0400, Martin K. Petersen wrote: > scsi_get_lba() confusingly returned the block layer sector number > expressed in units of 512 bytes. Now that we have a more aptly named > scsi_get_sector() function, make scsi_get_lba() return the actual LBA. > > Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> > --- > include/scsi/scsi_cmnd.h | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h > index cba63377d46a..90da9617d28a 100644 > --- a/include/scsi/scsi_cmnd.h > +++ b/include/scsi/scsi_cmnd.h > @@ -225,6 +225,13 @@ static inline sector_t scsi_get_sector(struct scsi_cmnd *scmd) > return blk_rq_pos(scmd->request); > } > > +static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd) > +{ > + unsigned int shift = ilog2(scmd->device->sector_size) - SECTOR_SHIFT; > + > + return blk_rq_pos(scmd->request) >> shift; Hmm again, should it use `blk_mq_rq_from_pdu()`?
On Mon, Jun 14, 2021 at 04:50:12PM +0200, Benjamin Block wrote: > On Tue, Jun 08, 2021 at 11:39:26PM -0400, Martin K. Petersen wrote: > > scsi_get_lba() confusingly returned the block layer sector number > > expressed in units of 512 bytes. Now that we have a more aptly named > > scsi_get_sector() function, make scsi_get_lba() return the actual LBA. > > > > Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> > > --- > > include/scsi/scsi_cmnd.h | 12 +++++++----- > > 1 file changed, 7 insertions(+), 5 deletions(-) > > > > diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h > > index cba63377d46a..90da9617d28a 100644 > > --- a/include/scsi/scsi_cmnd.h > > +++ b/include/scsi/scsi_cmnd.h > > @@ -225,6 +225,13 @@ static inline sector_t scsi_get_sector(struct scsi_cmnd *scmd) > > return blk_rq_pos(scmd->request); > > } > > > > +static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd) > > +{ > > + unsigned int shift = ilog2(scmd->device->sector_size) - SECTOR_SHIFT; > > + > > + return blk_rq_pos(scmd->request) >> shift; > > Hmm again, should it use `blk_mq_rq_from_pdu()`? > I'm taking this is the same as with the other patch, Bart's series will replace that as well. Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index cba63377d46a..90da9617d28a 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -225,6 +225,13 @@ static inline sector_t scsi_get_sector(struct scsi_cmnd *scmd) return blk_rq_pos(scmd->request); } +static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd) +{ + unsigned int shift = ilog2(scmd->device->sector_size) - SECTOR_SHIFT; + + return blk_rq_pos(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. @@ -287,11 +294,6 @@ static inline unsigned char scsi_get_prot_type(struct scsi_cmnd *scmd) return scmd->prot_type; } -static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd) -{ - return blk_rq_pos(scmd->request); -} - static inline u32 scsi_prot_ref_tag(struct scsi_cmnd *scmd) { struct request *rq = blk_mq_rq_from_pdu(scmd);
scsi_get_lba() confusingly returned the block layer sector number expressed in units of 512 bytes. Now that we have a more aptly named scsi_get_sector() function, make scsi_get_lba() return the actual LBA. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> --- include/scsi/scsi_cmnd.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)