Skip to contentSkip to conversation

nvmet-file: clamp-down file namespace lba_shift

PATCH Superseded Sagi Grimberg 2 participants 2 messages Mar 9, 2019 – Mar 11, 2019

Subsystems (2)
lore
Share & tools
lore

Sagi Grimberg

author maintainer
#0 lore raw

PATCH v2 1/1 nvmet-file: clamp-down file namespace lba_shift

When the backing file is a tempfile for example, the inode i_blkbits can be 1M in size which causes problems for hosts to support as the disk block size.

Signed-off-by Sagi Grimberg <sagi at grimberg.me>

---
Changes from v1:
- don't cross 80 char limit

 drivers/nvme/target/io-cmd-file.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/target/io-cmd-file.c +2 -1
index 517522305e5c..9876751fed05 100644
@@ -49,7 +49,8 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns)
 		goto err;
 
 	ns->size = stat.size;
-	ns->blksize_shift = file_inode(ns->file)->i_blkbits;
+	ns->blksize_shift = min_t(u8,
+			file_inode(ns->file)->i_blkbits, PAGE_SHIFT);
 
 	ns->bvec_cache = kmem_cache_create("nvmet-bvec",
 			NVMET_MAX_MPOOL_BVEC * sizeof(struct bio_vec),
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 nvmet-file: clamp-down file namespace lba_shift

Quoted 3 lines · Sagi Grimberg

When the backing file is a tempfile for example, the inode i_blkbits can be 1M in size which causes problems for hosts to support as the disk block size.

Can you please look into the other review comments as well?

Also this will need a code comment describing why we do this clamping.