From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-nvme@lists.infradead.org
Cc: sagi@grimberg.me, Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
hch@lst.de
Subject: [PATCH V3 3/7] nvmet: export resize thread enable-disable attr
Date: Sun, 19 Apr 2020 16:48:52 -0700 [thread overview]
Message-ID: <20200419234856.59901-4-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20200419234856.59901-1-chaitanya.kulkarni@wdc.com>
We implement ns-revalidation feature as a mechanism and not as a policy
and allow user to set the policies. This also allows more flexibility to
user.
This patch adds a new configfs attributes so that user can enable/
disable resize monitor thread as and when needed by allowing user to
decide on the policy.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
drivers/nvme/target/configfs.c | 34 ++++++++++++++++++++++++++++++++++
drivers/nvme/target/nvmet.h | 13 +++++++++++++
2 files changed, 47 insertions(+)
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index b0e84027b3bc..f6fbe59fc60c 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -1050,8 +1050,42 @@ static struct configfs_group_operations nvmet_subsystems_group_ops = {
.make_group = nvmet_subsys_make,
};
+static ssize_t nvmet_control_group_control_resize_refresh_show(
+ struct config_item *item, char *page)
+{
+ return snprintf(page, PAGE_SIZE, "%u\n",
+ to_nvmet_control(item)->enable);
+}
+
+static ssize_t nvmet_control_group_control_resize_refresh_store(
+ struct config_item *item, const char *page, size_t count)
+{
+ struct nvmet_control_configfs *control = to_nvmet_control(item);
+ bool enable;
+
+ if (kstrtobool(page, &enable))
+ return -EINVAL;
+
+ mutex_lock(&monitor->control_lock);
+ control->enable = enable;
+ if (control->enable)
+ nvmet_enable_ns_resize_monitor();
+ else
+ nvmet_disable_ns_resize_monitor();
+ mutex_unlock(&monitor->control_lock);
+ return count;
+}
+
+CONFIGFS_ATTR(nvmet_control_group_, control_resize_refresh);
+
+static struct configfs_attribute *nvmet_control_group_attrs[] = {
+ &nvmet_control_group_attr_control_resize_refresh,
+ NULL,
+};
+
static const struct config_item_type nvmet_subsystems_type = {
.ct_group_ops = &nvmet_subsystems_group_ops,
+ .ct_attrs = nvmet_control_group_attrs,
.ct_owner = THIS_MODULE,
};
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 7fe6d705cbf1..796acd4226a1 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -62,6 +62,19 @@ struct nvmet_resize_monitor {
extern struct nvmet_resize_monitor *monitor;
+struct nvmet_control_configfs {
+ bool enable;
+ struct config_group group;
+};
+
+static inline struct nvmet_control_configfs *to_nvmet_control(
+ struct config_item *item)
+{
+ struct config_group *group = to_config_group(item);
+
+ return container_of(group, struct nvmet_control_configfs, group);
+}
+
struct nvmet_ns {
struct list_head dev_link;
struct percpu_ref ref;
--
2.22.1
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2020-04-19 23:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-19 23:48 [PATCH V3 0/7] nvmet: add target ns revalidate support Chaitanya Kulkarni
2020-04-19 23:48 ` [PATCH V3 1/7] nvmet: add ns revalidation support Chaitanya Kulkarni
2020-04-19 23:48 ` [PATCH V3 2/7] nvmet: add global thread for ns-resize AEN Chaitanya Kulkarni
2020-04-27 14:19 ` Hannes Reinecke
2020-04-19 23:48 ` Chaitanya Kulkarni [this message]
2020-04-19 23:48 ` [PATCH V3 4/7] nvmet: export resize thread scan interval Chaitanya Kulkarni
2020-04-19 23:48 ` [PATCH V3 5/7] nvmet: export resize thread sched attributes Chaitanya Kulkarni
2020-04-19 23:48 ` [PATCH V3 6/7] nvmet: export ns resize monitor attribute Chaitanya Kulkarni
2020-04-19 23:48 ` [PATCH V3 7/7] nvmet: add async event tracing support Chaitanya Kulkarni
2020-04-22 8:19 ` [PATCH V3 0/7] nvmet: add target ns revalidate support Christoph Hellwig
2020-04-23 6:03 ` Chaitanya Kulkarni
2020-04-23 8:20 ` Sagi Grimberg
2020-04-24 7:05 ` Christoph Hellwig
2020-04-24 8:34 ` Chaitanya Kulkarni
2020-04-24 19:08 ` Sagi Grimberg
2020-04-24 21:02 ` 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=20200419234856.59901-4-chaitanya.kulkarni@wdc.com \
--to=chaitanya.kulkarni@wdc.com \
--cc=hch@lst.de \
--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 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).