[PATCH 04/26] nvme: honor namespace block size for I/O
Ahmad Fatoum
a.fatoum at barebox.org
Fri Jun 26 01:42:15 PDT 2026
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 <a.fatoum at barebox.org>
---
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
More information about the barebox
mailing list