From: hare@suse.de (Hannes Reinecke)
Subject: [PATCH 03/10] nvme: Only update capacity for optimized or non-optimized paths
Date: Tue, 29 May 2018 12:14:24 +0200 [thread overview]
Message-ID: <20180529101431.62271-4-hare@suse.de> (raw)
In-Reply-To: <20180529101431.62271-1-hare@suse.de>
As per ANA spec paths in 'inaccessible' or 'persistent-loss' state
might return a capacity of '0'. So when an inaccessible path is
detected last it might overwrite the actual capacity with '0',
rendering the device unuseable.
Hence we should only be updating the capacity if we are sure that
we've read the correct one.
Signed-off-by: Hannes Reinecke <hare at suse.com>
---
drivers/nvme/host/core.c | 4 +++-
drivers/nvme/host/multipath.c | 9 ---------
drivers/nvme/host/nvme.h | 13 +++++++++++++
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 1be424053f47..cc43bb685e63 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1457,7 +1457,9 @@ static void nvme_update_disk_info(struct gendisk *disk,
if (ns->ms && !nvme_ns_has_pi(ns) && !blk_get_integrity(disk))
capacity = 0;
- set_capacity(disk, capacity);
+ if (nvme_ns_ana_state(ns) == NVME_ANA_OPTIMIZED ||
+ nvme_ns_ana_state(ns) == NVME_ANA_NONOPTIMIZED)
+ set_capacity(disk, capacity);
nvme_config_discard(ns);
blk_mq_unfreeze_queue(disk->queue);
}
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 2fcaf50d84e2..a5f43d164b19 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -108,15 +108,6 @@ void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl)
up_read(&ctrl->namespaces_rwsem);
}
-static inline enum nvme_ana_state nvme_ns_ana_state(struct nvme_ns *ns)
-{
- if (!nvme_ctrl_has_ana(ns->ctrl))
- return NVME_ANA_OPTIMIZED;
- if (WARN_ON_ONCE(ns->anagrpid > ns->ctrl->anagrpmax))
- return 0;
- return READ_ONCE(ns->ctrl->ana_state[ns->anagrpid]);
-}
-
static const char *nvme_ana_state_names[] = {
[0] = "invalid state",
[NVME_ANA_OPTIMIZED] = "optimized",
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 53cb7f8a6267..8572f106d6ac 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -485,6 +485,15 @@ static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
kblockd_schedule_work(&head->requeue_work);
}
+static inline enum nvme_ana_state nvme_ns_ana_state(struct nvme_ns *ns)
+{
+ if (!nvme_ctrl_has_ana(ns->ctrl))
+ return NVME_ANA_OPTIMIZED;
+ if (WARN_ON_ONCE(ns->anagrpid > ns->ctrl->anagrpmax))
+ return 0;
+ return READ_ONCE(ns->ctrl->ana_state[ns->anagrpid]);
+}
+
extern struct device_attribute dev_attr_ana_grpid;
extern struct device_attribute dev_attr_ana_state;
@@ -534,6 +543,10 @@ static inline int nvme_configure_ana(struct nvme_ctrl *ctrl)
static inline void nvme_deconfigure_ana(struct nvme_ctrl *ctrl)
{
}
+static inline enum nvme_ana_state nvme_ns_ana_state(struct nvme_ns *ns)
+{
+ return NVME_ANA_OPTIMIZED;
+}
#endif /* CONFIG_NVME_MULTIPATH */
#ifdef CONFIG_NVM
--
2.12.3
next prev parent reply other threads:[~2018-05-29 10:14 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-29 10:14 [PATCH 00/10] nvme: ANA fixups Hannes Reinecke
2018-05-29 10:14 ` [PATCH 01/10] nvme: add missing kfree() in nvme_configure_ana() Hannes Reinecke
2018-05-29 12:16 ` Johannes Thumshirn
2018-05-29 12:39 ` Christoph Hellwig
2018-05-29 10:14 ` [PATCH 02/10] nvme: ANA transition timeout handling Hannes Reinecke
2018-05-29 12:47 ` Christoph Hellwig
2018-05-29 13:34 ` Hannes Reinecke
2018-05-29 13:47 ` Christoph Hellwig
2018-05-29 10:14 ` Hannes Reinecke [this message]
2018-05-29 12:38 ` [PATCH 03/10] nvme: Only update capacity for optimized or non-optimized paths Christoph Hellwig
2018-05-29 10:14 ` [PATCH 04/10] nvme: clear current path on ANA state change Hannes Reinecke
2018-05-29 12:22 ` Johannes Thumshirn
2018-05-29 12:43 ` Hannes Reinecke
2018-05-29 12:48 ` Christoph Hellwig
2018-05-29 10:14 ` [PATCH 05/10] nvme: retry nvme_get_log_ext() when processing ANA log Hannes Reinecke
2018-05-29 12:48 ` Christoph Hellwig
2018-05-29 10:14 ` [PATCH 06/10] nvme: simplify check for ANA in nvme_ns_id_attrs_are_visible() Hannes Reinecke
2018-05-29 12:49 ` Christoph Hellwig
2018-05-29 10:14 ` [PATCH 07/10] nvmet: make ANATT configurable Hannes Reinecke
2018-05-29 12:50 ` Christoph Hellwig
2018-05-29 10:14 ` [PATCH 08/10] nvmet: Set nanagrpid correctly Hannes Reinecke
2018-05-29 12:51 ` Christoph Hellwig
2018-05-29 13:04 ` Hannes Reinecke
2018-05-29 13:38 ` Christoph Hellwig
2018-05-29 10:14 ` [PATCH 09/10] nvmet: Set mnan correctly Hannes Reinecke
2018-05-29 12:52 ` Christoph Hellwig
2018-05-29 13:06 ` Hannes Reinecke
2018-05-29 13:40 ` Christoph Hellwig
2018-05-29 10:14 ` [PATCH 10/10] nvmet: set 'nuse' and 'nsze' to zero for inaccessible paths Hannes Reinecke
2018-05-29 12:57 ` Christoph Hellwig
2018-05-31 10:30 ` [PATCH 00/10] nvme: ANA fixups Sagi Grimberg
2018-05-31 16:26 ` 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=20180529101431.62271-4-hare@suse.de \
--to=hare@suse.de \
/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;
as well as URLs for NNTP newsgroup(s).