diff options
author | Sagi Grimberg <sagi@grimberg.me> | 2019-04-24 20:43:23 +0200 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2019-04-25 16:51:19 +0200 |
commit | 525ec495e021068aa8635a0e18ff60695f5b1f4f (patch) | |
tree | 3d18692f443f67dfe4aeef38f5d3608b2a28f92e /drivers/nvme | |
parent | nvmet: include <linux/scatterlist.h> (diff) | |
download | linux-525ec495e021068aa8635a0e18ff60695f5b1f4f.tar.xz linux-525ec495e021068aa8635a0e18ff60695f5b1f4f.zip |
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. Instead, expose the minimum between i_blkbits and
12 (4K sector size).
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by:- Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/target/io-cmd-file.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c index bc6ebb51b0bf..05453f5d1448 100644 --- a/drivers/nvme/target/io-cmd-file.c +++ b/drivers/nvme/target/io-cmd-file.c @@ -49,7 +49,12 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns) goto err; ns->size = stat.size; - ns->blksize_shift = file_inode(ns->file)->i_blkbits; + /* + * i_blkbits can be greater than the universally accepted upper bound, + * so make sure we export a sane namespace lba_shift. + */ + ns->blksize_shift = min_t(u8, + file_inode(ns->file)->i_blkbits, 12); ns->bvec_cache = kmem_cache_create("nvmet-bvec", NVMET_MAX_MPOOL_BVEC * sizeof(struct bio_vec), |