Skip to content

Commit

Permalink
scsi: core: Make scsi_get_lba() return the LBA
Browse files Browse the repository at this point in the history
[ Upstream commit d2c945f ]

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.

Link: https://lore.kernel.org/r/20210609033929.3815-13-martin.petersen@oracle.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Message-Id: <20210609033929.3815-13-martin.petersen@oracle.com>
Stable-dep-of: 066c5b4 ("scsi: core: Always send batch on reset or error handling command")
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Martin K. Petersen authored and Greg Kroah-Hartman committed Jan 5, 2024
1 parent f230e6d commit d054858
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions include/scsi/scsi_cmnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,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.
Expand Down Expand Up @@ -291,11 +298,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);
Expand Down

0 comments on commit d054858

Please sign in to comment.