nvmet-file: clamp-down file namespace lba_shift
Subsystems (2)
Sagi Grimberg
maintainerPATCH 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.
---
This issue was observed in I/O errors in the log running test nvme/009.
drivers/nvme/target/io-cmd-file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/io-cmd-file.c +1 -1
@@ -49,7 +49,7 @@ 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
PATCH 1/1 nvmet-file: clamp-down file namespace lba_shift
Quoted 8 lines · Sagi Grimberg
When the backing file is a tempfile for example, the inode
i_blkbitscan 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>---
This issue was observed in I/O errors in the log running test nvme/009.
We are not doing any I/O in nvme/009 explicitly using dd/fio, is this due to internal commands we send as a part of connect and disconnect ? Or test number is different ?
Quoted 17 lines
drivers/nvme/target/io-cmd-file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/target/io-cmd-file.c +1
-1@@ -49,7 +49,7 @@ 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),
Sagi Grimberg
maintainerPATCH 1/1 nvmet-file: clamp-down file namespace lba_shift
Quoted 5 lines
Quoted 5 lines
When the backing file is a tempfile for example, the inode
i_blkbitscan be 1M in size which causes problems for hosts to support as the disk block size.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Sagi Grimberg <sagi at grimberg.me>---
This issue was observed in I/O errors in the log running test nvme/009.We are not doing any I/O in nvme/009 explicitly using dd/fio, is this due to internal commands we send as a part of connect and disconnect ? Or test number is different ?
The former.
Also, I just now hit a divide by zero BUG when running test 009 with multipath enabled.
Quick look shows that this is coming from blk_queue_stack_limits for the ns_head.
Looks like nvme_update_disk_info() is reading a bs=0:
--
unsigned short bs = 1 << ns->lba_shift;
--
bs is 16 bits and lba_shift is 20
(coming directly from the tempfile file_inode(ns->file)->i_blkbits)
So this fixes that one as well. Regardless, I think bs should be unsigned int?
PATCH 1/1 nvmet-file: clamp-down file namespace lba_shift
Quoted 23 lines · Sagi Grimberg
Quoted 5 lines
Quoted 5 lines
When the backing file is a tempfile for example, the inode
i_blkbitscan be 1M in size which causes problems for hosts to support as the disk block size.Quoted 7 lines
Quoted 4 lines
Signed-off-by Sagi Grimberg <sagi at grimberg.me>---
This issue was observed in I/O errors in the log running test nvme/009.We are not doing any I/O in nvme/009 explicitly using dd/fio, is this due to internal commands we send as a part of connect and disconnect ? Or test number is different ?
The former.
Also, I just now hit a divide by zero BUG when running test 009 with multipath enabled.
Quick look shows that this is coming from
blk_queue_stack_limitsfor thens_head.Looks like
nvme_update_disk_info()is reading a bs=0:
--
Quoted 8 lines
unsigned short bs = 1 << ns->lba_shift;--
bs is 16 bits and
lba_shiftis 20
(coming directly from the tempfile file_inode(ns->file)->i_blkbits)So this fixes that one as well. Regardless, I think bs should be unsigned int?
Yes.
Quoted 6 lines
_______________________________________________
Linux-nvme mailing list
Linux-nvme at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerPATCH 1/1 nvmet-file: clamp-down file namespace lba_shift
Quoted 9 lines · Chaitanya Kulkarni
Quoted 8 lines · Sagi Grimberg
Quick look shows that this is coming from
blk_queue_stack_limitsfor thens_head.Looks like
nvme_update_disk_info()is reading a bs=0:
--unsigned short bs = 1 << ns->lba_shift;--
Quoted 7 lines
Quoted 5 lines
bs is 16 bits and
lba_shiftis 20
(coming directly from the tempfile file_inode(ns->file)->i_blkbits)So this fixes that one as well. Regardless, I think bs should be unsigned int?
Yes.
blk_queue_logical_block_size() takes an 'unsigned short', so be sure to check 'bs' is less than USHRT_MAX.
Sagi Grimberg
maintainerPATCH 1/1 nvmet-file: clamp-down file namespace lba_shift
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quick look shows that this is coming from
blk_queue_stack_limitsfor thens_head.Looks like
nvme_update_disk_info()is reading a bs=0:
--unsigned short bs = 1 << ns->lba_shift;--
bs is 16 bits and
lba_shiftis 20
(coming directly from the tempfile file_inode(ns->file)->i_blkbits)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
So this fixes that one as well. Regardless, I think bs should be unsigned int?
Yes.
blk_queue_logical_block_size()takes an 'unsigned short', so be sure to check 'bs' is less thanUSHRT_MAX.
So this means that we should fail ns allocation if lba_shift is more than fits in a short.
Christoph Hellwig
maintainerPATCH 1/1 nvmet-file: clamp-down file namespace lba_shift
In reply to Sagi Grimbergdrivers/nvme/target/io-cmd-file.c int nvmet_file_ns_enable(struct nvmet_ns *ns) · line 52
Quoted 2 lines
drivers/nvme/target/io-cmd-file.c +1
-1- ns->blksize_shift =file_inode (ns->file)->i_blkbits; + ns->blksize_shift =min_t (u8,file_inode (ns->file)->i_blkbits,PAGE_SHIFT );
I think we want to limit to 4k as the universally acceptable upper bound. Also this should not use u8 for the case but probably an unsigned int.
Last but not least this introduced a > 80 char line.