From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH-4.7 3/3] NVMe: Set capacity to 0 on all unusable namespaces
Date: Mon, 2 May 2016 11:12:08 -0600 [thread overview]
Message-ID: <1462209128-12376-4-git-send-email-keith.busch@intel.com> (raw)
In-Reply-To: <1462209128-12376-1-git-send-email-keith.busch@intel.com>
Set the disk capacity to 0 if unable to identify a namespace for any
reason. This way revalidating detached namespaces will be deleted quicker
since dirty data can't be sync'ed.
Signed-off-by: Keith Busch <keith.busch at intel.com>
---
drivers/nvme/host/core.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 9f1f318..b9de770 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -771,31 +771,27 @@ static void nvme_config_discard(struct nvme_ns *ns)
static int nvme_revalidate_disk(struct gendisk *disk)
{
struct nvme_ns *ns = disk->private_data;
- struct nvme_id_ns *id;
+ struct nvme_id_ns *id = NULL;
u8 lbaf, pi_type;
u16 old_ms;
unsigned short bs;
- if (test_bit(NVME_NS_DEAD, &ns->flags)) {
- set_capacity(disk, 0);
- return -ENODEV;
- }
+ if (test_bit(NVME_NS_DEAD, &ns->flags))
+ goto no_dev;
+
if (nvme_identify_ns(ns->ctrl, ns->ns_id, &id)) {
dev_warn(disk_to_dev(ns->disk), "%s: Identify failure\n",
__func__);
- return -ENODEV;
- }
- if (id->ncap == 0) {
- kfree(id);
- return -ENODEV;
+ goto no_dev;
}
+ if (id->ncap == 0)
+ goto no_dev;
if (nvme_nvm_ns_supported(ns, id) && ns->type != NVME_NS_LIGHTNVM) {
if (nvme_nvm_register(ns->queue, disk->disk_name)) {
dev_warn(disk_to_dev(ns->disk),
"%s: LightNVM init failure\n", __func__);
- kfree(id);
- return -ENODEV;
+ goto no_dev;
}
ns->type = NVME_NS_LIGHTNVM;
}
@@ -845,6 +841,10 @@ static int nvme_revalidate_disk(struct gendisk *disk)
kfree(id);
return 0;
+ no_dev:
+ kfree(id);
+ set_capacity(disk, 0);
+ return -ENODEV;
}
static char nvme_pr_type(enum pr_type type)
--
2.7.2
next prev parent reply other threads:[~2016-05-02 17:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-02 17:12 Patches for 4.7 Keith Busch
2016-05-02 17:12 ` [PATCH-4.7 1/3] NVMe: Return ENODEV error on invalid namespace Keith Busch
2016-05-03 7:58 ` Christoph Hellwig
2016-05-03 14:19 ` Busch, Keith
2016-05-03 14:25 ` Christoph Hellwig
2016-05-02 17:12 ` [PATCH-4.7 2/3] NVMe: Short-cut removal on surprise hot-unplug Keith Busch
2016-05-03 8:01 ` Christoph Hellwig
2016-05-10 19:16 ` Keith Busch
2016-05-12 7:06 ` Christoph Hellwig
2016-05-02 17:12 ` Keith Busch [this message]
2016-05-03 8:03 ` [PATCH-4.7 3/3] NVMe: Set capacity to 0 on all unusable namespaces Christoph Hellwig
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=1462209128-12376-4-git-send-email-keith.busch@intel.com \
--to=keith.busch@intel.com \
/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