From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-nvme@lists.infradead.org, Sagi Grimberg <sagi@grimberg.me>,
Keith Busch <keith.busch@wdc.com>, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 2/3] nvme: add 'queue_if_no_path' semantics
Date: Mon, 5 Oct 2020 11:42:55 +0200 [thread overview]
Message-ID: <20201005094256.49358-3-hare@suse.de> (raw)
In-Reply-To: <20201005094256.49358-1-hare@suse.de>
Instead of reverting the handling of the 'last' path for all
setups we should be restricting it to the non-fabrics case.
So add a 'queue_if_no_path' flag which will switch to the
current behaviour; disabling this flag will revert to the
original (pre-fabrics) behaviour.
And set this flag per default for fabrics.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/nvme/host/core.c | 7 ++++++-
drivers/nvme/host/multipath.c | 4 ++++
drivers/nvme/host/nvme.h | 1 +
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index af950d58c562..79b88b4c448f 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -474,8 +474,11 @@ static void nvme_free_ns_head(struct kref *ref)
struct nvme_ns_head *head =
container_of(ref, struct nvme_ns_head, ref);
- if (head->disk)
+ if (head->disk) {
+ if (test_bit(NVME_NSHEAD_QUEUE_IF_NO_PATH, &head->flags))
+ nvme_mpath_remove_disk(head);
put_disk(head->disk);
+ }
ida_simple_remove(&head->subsys->ns_ida, head->instance);
cleanup_srcu_struct(&head->srcu);
nvme_put_subsystem(head->subsys);
@@ -3686,6 +3689,8 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
head->subsys = ctrl->subsys;
head->ns_id = nsid;
head->ids = *ids;
+ if (ctrl->ops->flags & NVME_F_FABRICS)
+ set_bit(NVME_NSHEAD_QUEUE_IF_NO_PATH, &head->flags);
kref_init(&head->ref);
ret = __nvme_check_ids(ctrl->subsys, head);
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 55045291b4de..05c4fbc35bb2 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -682,6 +682,10 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head)
{
if (!head->disk)
return;
+ if (test_bit(NVME_NSHEAD_QUEUE_IF_NO_PATH, &head->flags)) {
+ kblockd_schedule_work(&head->requeue_work);
+ return;
+ }
if (head->disk->flags & GENHD_FL_UP)
del_gendisk(head->disk);
blk_set_queue_dying(head->disk->queue);
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index b6180bb3361d..baf4a84918d8 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -411,6 +411,7 @@ struct nvme_ns_head {
struct mutex lock;
unsigned long flags;
#define NVME_NSHEAD_DISK_LIVE 0
+#define NVME_NSHEAD_QUEUE_IF_NO_PATH 1
struct nvme_ns __rcu *current_path[];
#endif
};
--
2.16.4
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2020-10-05 9:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-05 9:42 [RFC PATCHv2 0/3] nvme: queue_if_no_path functionality Hannes Reinecke
2020-10-05 9:42 ` [PATCH 1/3] nvme-mpath: delete disk after last connection Hannes Reinecke
2020-10-05 11:27 ` Christoph Hellwig
2020-10-05 9:42 ` Hannes Reinecke [this message]
2020-10-05 11:29 ` [PATCH 2/3] nvme: add 'queue_if_no_path' semantics Christoph Hellwig
2020-10-05 9:42 ` [PATCH 3/3] nvme: add 'queue_if_no_path' sysfs attribute Hannes Reinecke
2020-10-05 11:31 ` Christoph Hellwig
2020-10-05 11:38 ` Christoph Hellwig
2020-10-05 11:56 ` Hannes Reinecke
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=20201005094256.49358-3-hare@suse.de \
--to=hare@suse.de \
--cc=hch@lst.de \
--cc=keith.busch@wdc.com \
--cc=linux-nvme@lists.infradead.org \
--cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.