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 3/3] nvme: add 'queue_if_no_path' sysfs attribute
Date: Mon, 5 Oct 2020 11:42:56 +0200 [thread overview]
Message-ID: <20201005094256.49358-4-hare@suse.de> (raw)
In-Reply-To: <20201005094256.49358-1-hare@suse.de>
Add a sysfs attribute 'queue_if_no_path' to allow the admin to
view and modify the 'queue_if_no_path' flag.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/nvme/host/core.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 79b88b4c448f..87589f0adea3 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3349,12 +3349,42 @@ static ssize_t nsid_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(nsid);
+static ssize_t queue_if_no_path_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct nvme_ns_head *head = dev_to_ns_head(dev);
+
+ return sprintf(buf, "%s\n",
+ test_bit(NVME_NSHEAD_QUEUE_IF_NO_PATH, &head->flags) ?
+ "on" : "off");
+}
+
+static ssize_t queue_if_no_path_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ struct nvme_ns_head *head = dev_to_ns_head(dev);
+ int queue_if_no_path, err;
+
+ err = kstrtoint(buf, 10, &queue_if_no_path);
+ if (err)
+ return -EINVAL;
+
+ else if (queue_if_no_path <= 0)
+ clear_bit(NVME_NSHEAD_QUEUE_IF_NO_PATH, &head->flags);
+ else
+ set_bit(NVME_NSHEAD_QUEUE_IF_NO_PATH, &head->flags);
+ return count;
+}
+static DEVICE_ATTR(queue_if_no_path, S_IRUGO | S_IWUSR,
+ queue_if_no_path_show, queue_if_no_path_store);
+
static struct attribute *nvme_ns_id_attrs[] = {
&dev_attr_wwid.attr,
&dev_attr_uuid.attr,
&dev_attr_nguid.attr,
&dev_attr_eui.attr,
&dev_attr_nsid.attr,
+ &dev_attr_queue_if_no_path.attr,
#ifdef CONFIG_NVME_MULTIPATH
&dev_attr_ana_grpid.attr,
&dev_attr_ana_state.attr,
@@ -3381,6 +3411,10 @@ static umode_t nvme_ns_id_attrs_are_visible(struct kobject *kobj,
if (!memchr_inv(ids->eui64, 0, sizeof(ids->eui64)))
return 0;
}
+ if (a == &dev_attr_queue_if_no_path.attr) {
+ if (dev_to_disk(dev)->fops == &nvme_fops)
+ return 0;
+ }
#ifdef CONFIG_NVME_MULTIPATH
if (a == &dev_attr_ana_grpid.attr || a == &dev_attr_ana_state.attr) {
if (dev_to_disk(dev)->fops != &nvme_fops) /* per-path attr */
--
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 ` [PATCH 2/3] nvme: add 'queue_if_no_path' semantics Hannes Reinecke
2020-10-05 11:29 ` Christoph Hellwig
2020-10-05 9:42 ` Hannes Reinecke [this message]
2020-10-05 11:31 ` [PATCH 3/3] nvme: add 'queue_if_no_path' sysfs attribute 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-4-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.