From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH 3/4] nvme: ANA transition timeout handling
Date: Thu, 7 Jun 2018 16:16:09 +0300 [thread overview]
Message-ID: <ffb79ccc-3259-ca9a-dc71-309baca1e10d@grimberg.me> (raw)
In-Reply-To: <20180607073556.39050-4-hare@suse.de>
On 06/07/2018 10:35 AM, Hannes Reinecke wrote:
> Add a timer for tracking ANA transition timeout, and reset the
> controller once the timeout expires.
>
> Signed-off-by: Hannes Reinecke <hare at suse.com>
> ---
> drivers/nvme/host/core.c | 3 +++
> drivers/nvme/host/multipath.c | 34 ++++++++++++++++++++++++++++------
> drivers/nvme/host/nvme.h | 6 ++++++
> 3 files changed, 37 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index e62de51209b2..3b578ae62cb5 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2378,6 +2378,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
> ctrl->kas = le16_to_cpu(id->kas);
> ctrl->max_namespaces = le32_to_cpu(id->mnan);
> ctrl->anacap = id->anacap;
> + ctrl->anatt = id->anatt;
> ctrl->nanagrpid = le32_to_cpu(id->nanagrpid);
> ctrl->anagrpmax = le32_to_cpu(id->anagrpmax);
>
> @@ -3025,6 +3026,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
> blk_queue_flag_set(QUEUE_FLAG_NONROT, ns->queue);
> ns->queue->queuedata = ns;
> ns->ctrl = ctrl;
> + timer_setup(&ns->anatt_timer, nvme_anatt_timedout, 0);
>
> kref_init(&ns->kref);
> ns->lba_shift = 9; /* set to a default value for 512 until disk is validated */
> @@ -3113,6 +3115,7 @@ static void nvme_ns_remove(struct nvme_ns *ns)
> blk_integrity_unregister(ns->disk);
> }
>
> + del_timer_sync(&ns->anatt_timer);
> mutex_lock(&ns->ctrl->subsys->lock);
> nvme_mpath_clear_current_path(ns);
> list_del_rcu(&ns->siblings);
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index d30229a21c97..7a37f5959ad4 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -62,13 +62,12 @@ void nvme_failover_req(struct request *req)
> */
> switch (nvme_req(req)->status & 0x7ff) {
> case NVME_SC_ANA_TRANSITION:
> - /*
> - * XXX: We should verify the controller doesn't die on during
> - * the transition. But that means we per-group timeout from
> - * when we first hit the change state, so this won't be
> - * entirely trivial..
> - */
> nvme_update_ana_state(ns, NVME_ANA_CHANGE);
> + if (!timer_pending(&ns->anatt_timer)) {
> + ns->anatt_timer.expires =
> + ns->ctrl->anatt * HZ + jiffies;
> + add_timer(&ns->anatt_timer);
> + }
Shouldn't this del and re-add the timer if its pending?
> break;
> case NVME_SC_ANA_PERSISTENT_LOSS:
> nvme_update_ana_state(ns, NVME_ANA_PERSISTENT_LOSS);
> @@ -390,11 +389,34 @@ static int nvme_process_ana_log(struct nvme_ctrl *ctrl, bool groups_only)
> static void nvme_ana_work(struct work_struct *work)
> {
> struct nvme_ctrl *ctrl = container_of(work, struct nvme_ctrl, ana_work);
> + struct nvme_ns *ns;
>
> nvme_process_ana_log(ctrl, false);
> + down_write(&ctrl->namespaces_rwsem);
> + list_for_each_entry(ns, &ctrl->namespaces, list) {
> + enum nvme_ana_state state = nvme_ns_ana_state(ns);
> +
> + if (timer_pending(&ns->anatt_timer) &&
> + state != NVME_ANA_CHANGE)
> + del_timer_sync(&ns->anatt_timer);
> + if (!timer_pending(&ns->anatt_timer) &&
> + state == NVME_ANA_CHANGE) {
> + ns->anatt_timer.expires =
> + ns->ctrl->anatt * HZ + jiffies;
> + add_timer(&ns->anatt_timer);
> + }
Called from couple of sites, can move to helper?
next prev parent reply other threads:[~2018-06-07 13:16 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-07 7:35 [PATCH 0/4] nvme: ANATT handling Hannes Reinecke
2018-06-07 7:35 ` [PATCH 1/4] nvmet: make ANATT configurable Hannes Reinecke
2018-06-07 12:06 ` Christoph Hellwig
2018-06-07 12:42 ` Hannes Reinecke
2018-06-07 13:03 ` Sagi Grimberg
2018-06-07 7:35 ` [PATCH 2/4] nvmet: ANA transition timeout handling Hannes Reinecke
2018-06-07 12:07 ` Christoph Hellwig
2018-06-07 13:31 ` Hannes Reinecke
2018-06-07 13:41 ` Christoph Hellwig
2018-06-07 13:12 ` Sagi Grimberg
2018-06-07 7:35 ` [PATCH 3/4] nvme: " Hannes Reinecke
2018-06-07 12:09 ` Christoph Hellwig
2018-06-07 12:52 ` Hannes Reinecke
2018-06-07 13:11 ` Christoph Hellwig
2018-06-07 13:16 ` Sagi Grimberg [this message]
2018-06-07 13:26 ` Christoph Hellwig
2018-06-07 7:35 ` [PATCH 4/4] nvme: start ANATT timer on out-of-order state changes Hannes Reinecke
2018-06-07 12:11 ` Christoph Hellwig
2018-06-07 12:37 ` Hannes Reinecke
2018-06-07 13:10 ` Christoph Hellwig
2018-06-07 13:20 ` Hannes Reinecke
2018-06-07 13:46 ` Christoph Hellwig
2018-06-07 14:01 ` Hannes Reinecke
2018-06-07 14:22 ` Christoph Hellwig
2018-06-07 15:20 ` Sagi Grimberg
2018-06-07 13:20 ` Sagi Grimberg
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=ffb79ccc-3259-ca9a-dc71-309baca1e10d@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