[PATCH 04/26] nvme: honor namespace block size for I/O
Ahmad Fatoum <[email protected]> Fri, 26 Jun 2026 10:42:15 +0200
| Newsgroups | org.infradead.lists.barebox |
|---|---|
| Message-ID | <[email protected]> |
The translation inside nvme_block_nr() is a no-op for 512-byte sectors as it expands to a right shift by (9 - 9) == 0. For other sector sizes, it will mangle the block number, which is wrong: block_device_ops already have blocks as units and NVMe registers the block device with blockbits == ns->lba_shift, so the unit coming from the block layer is already correct. Assisted-by: Codex:gpt-5.5 Signed-off-by: Ahmad Fatoum <[email protected]> --- drivers/nvme/host/core.c | 2 +- drivers/nvme/host/nvme.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 21aeda78ebfb..345707ecfeaf 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -293,7 +293,7 @@ static void nvme_setup_rw(struct nvme_ns *ns, struct nvme_command *cmnd, sector_t block, blkcnt_t num_block) { cmnd->rw.nsid = cpu_to_le32(ns->head->ns_id); - cmnd->rw.slba = cpu_to_le64(nvme_block_nr(ns, block)); + cmnd->rw.slba = cpu_to_le64(block); cmnd->rw.length = cpu_to_le16(num_block - 1); cmnd->rw.control = 0; cmnd->rw.dsmgmt = 0; diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 11942140ce32..cb259b5216f1 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -89,11 +89,6 @@ static inline bool nvme_ctrl_ready(struct nvme_ctrl *ctrl) return val & NVME_CSTS_RDY; } -static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector) -{ - return (sector >> (ns->lba_shift - 9)); -} - static inline void nvme_end_request(struct nvme_request *rq, __le16 status, union nvme_result result) { -- 2.47.3