From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH v3 3/3] nvmet-file: clamp-down file namespace lba_shift
Date: Mon, 11 Mar 2019 14:16:08 -0700 [thread overview]
Message-ID: <20190311211608.16628-4-sagi@grimberg.me> (raw)
In-Reply-To: <20190311211608.16628-1-sagi@grimberg.me>
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>
---
drivers/nvme/target/io-cmd-file.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c
index 517522305e5c..d52fe965a5d5 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;
+ /*
+ * inode i_blkbits can be greater than the universally accepted upper
+ * bound so make sure we export we export a sane namespace lba_shift.
+ */
+ 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),
--
2.17.1
prev parent reply other threads:[~2019-03-11 21:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-11 21:16 [PATCH v3 0/3] Couple of fixes detected with blktests Sagi Grimberg
2019-03-11 21:16 ` [PATCH v3 1/3] nvme: fail namespace revalidate if block size exceeds PAGE_SIZE Sagi Grimberg
2019-03-11 21:21 ` Keith Busch
2019-03-11 22:02 ` Sagi Grimberg
2019-03-11 22:05 ` Keith Busch
2019-03-11 21:16 ` [PATCH v3 2/3] nvme: put ns_head ref if namespace fails allocation Sagi Grimberg
2019-03-11 21:16 ` Sagi Grimberg [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190311211608.16628-4-sagi@grimberg.me \
--to=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox