diff options
author | Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> | 2021-01-12 07:26:16 +0300 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2021-02-02 12:26:11 +0300 |
commit | 193fcf371f9e3705c14a0bf1d4bfc44af0f7c124 (patch) | |
tree | e03131156e5412e1ac1db076e861fe2606d86083 /drivers/nvme/target/nvmet.h | |
parent | 3c7b224f1956ed232b24ed2eb2c54e4476c6acb2 (diff) | |
download | linux-193fcf371f9e3705c14a0bf1d4bfc44af0f7c124.tar.xz |
nvmet: add lba to sect conversion helpers
In this preparation patch, we add helpers to convert lbas to sectors &
sectors to lba. This is needed to eliminate code duplication in the ZBD
backend.
Use these helpers in the block device backend.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/nvme/target/nvmet.h')
-rw-r--r-- | drivers/nvme/target/nvmet.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index 592763732065..8776dd1a0490 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -603,4 +603,14 @@ static inline bool nvmet_ns_has_pi(struct nvmet_ns *ns) return ns->pi_type && ns->metadata_size == sizeof(struct t10_pi_tuple); } +static inline __le64 nvmet_sect_to_lba(struct nvmet_ns *ns, sector_t sect) +{ + return cpu_to_le64(sect >> (ns->blksize_shift - SECTOR_SHIFT)); +} + +static inline sector_t nvmet_lba_to_sect(struct nvmet_ns *ns, __le64 lba) +{ + return le64_to_cpu(lba) << (ns->blksize_shift - SECTOR_SHIFT); +} + #endif /* _NVMET_H */ |