From: hare@suse.de (Hannes Reinecke)
Subject: [PATCHv2 03/11] nvmet: refactor AER handling
Date: Tue, 22 May 2018 11:09:56 +0200 [thread overview]
Message-ID: <20180522091004.39620-4-hare@suse.de> (raw)
In-Reply-To: <20180522091004.39620-1-hare@suse.de>
From: Christoph Hellwig <hch@lst.de>
Create a helper to iterate all controlles in a subsystem instead of open
coding the loop. Also use the NVME_AER_NOTICE_NS_CHANGED definition instead
of plain 0.
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
drivers/nvme/target/core.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index e95424f172fd..505d4267b8f1 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -137,6 +137,19 @@ static void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type,
schedule_work(&ctrl->async_event_work);
}
+static void nvmet_send_ns_changed_event(struct nvmet_subsys *subsys)
+{
+ /*
+ * XXX: should also include the log id, but the changed namespace list
+ * log needs to be implemented first..
+ */
+ struct nvmet_ctrl *ctrl;
+
+ list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry)
+ nvmet_add_async_event(ctrl, NVME_AER_TYPE_NOTICE,
+ NVME_AER_NOTICE_NS_CHANGED, 0);
+}
+
int nvmet_register_transport(const struct nvmet_fabrics_ops *ops)
{
int ret = 0;
@@ -274,7 +287,6 @@ void nvmet_put_namespace(struct nvmet_ns *ns)
int nvmet_ns_enable(struct nvmet_ns *ns)
{
struct nvmet_subsys *subsys = ns->subsys;
- struct nvmet_ctrl *ctrl;
int ret = 0;
mutex_lock(&subsys->lock);
@@ -320,9 +332,7 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
list_add_tail_rcu(&ns->dev_link, &old->dev_link);
}
- list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry)
- nvmet_add_async_event(ctrl, NVME_AER_TYPE_NOTICE, 0, 0);
-
+ nvmet_send_ns_changed_event(subsys);
ns->enabled = true;
ret = 0;
out_unlock:
@@ -337,7 +347,6 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
void nvmet_ns_disable(struct nvmet_ns *ns)
{
struct nvmet_subsys *subsys = ns->subsys;
- struct nvmet_ctrl *ctrl;
mutex_lock(&subsys->lock);
if (!ns->enabled)
@@ -363,9 +372,7 @@ void nvmet_ns_disable(struct nvmet_ns *ns)
percpu_ref_exit(&ns->ref);
mutex_lock(&subsys->lock);
- list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry)
- nvmet_add_async_event(ctrl, NVME_AER_TYPE_NOTICE, 0, 0);
-
+ nvmet_send_ns_changed_event(subsys);
if (ns->bdev)
blkdev_put(ns->bdev, FMODE_WRITE|FMODE_READ);
out_unlock:
--
2.12.3
next prev parent reply other threads:[~2018-05-22 9:09 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-22 9:09 [PATCHv2 00/11] nvme: ANA support Hannes Reinecke
2018-05-22 9:09 ` [PATCHv2 01/11] nvme.h: untangle AEN notice definitions Hannes Reinecke
2018-05-22 9:09 ` [PATCHv2 02/11] nvme: submit AEN event configuration on startup Hannes Reinecke
2018-05-22 10:00 ` Christoph Hellwig
2018-05-22 10:55 ` Hannes Reinecke
2018-05-22 9:09 ` Hannes Reinecke [this message]
2018-05-22 9:09 ` [PATCHv2 04/11] nvmet: Add AEN configuration support Hannes Reinecke
2018-05-22 10:01 ` Christoph Hellwig
2018-05-22 10:56 ` Hannes Reinecke
2018-05-22 9:09 ` [PATCHv2 05/11] nvme.h: add ANA definitions Hannes Reinecke
2018-05-22 9:09 ` [PATCHv2 06/11] nvme: add support for the log specific field Hannes Reinecke
2018-05-22 9:10 ` [PATCHv2 07/11] nvme: always failover on path or transport errors Hannes Reinecke
2018-05-25 13:24 ` Christoph Hellwig
2018-05-22 9:10 ` [PATCHv2 08/11] nvme: add ANA support Hannes Reinecke
2018-05-23 11:52 ` Popuri, Sriram
2018-05-23 13:19 ` Hannes Reinecke
2018-05-25 13:31 ` Christoph Hellwig
2018-05-25 13:28 ` Christoph Hellwig
2018-05-25 14:32 ` Hannes Reinecke
2018-05-31 10:21 ` Sagi Grimberg
2018-05-22 9:10 ` [PATCHv2 09/11] nvmet: add a new nvmet_zero_sgl helper Hannes Reinecke
2018-05-22 9:10 ` [PATCHv2 10/11] nvmet: split log page implementation Hannes Reinecke
2018-05-22 9:10 ` [PATCHv2 11/11] nvmet: ANA support Hannes Reinecke
2018-05-22 10:05 ` Christoph Hellwig
2018-05-22 11:05 ` Hannes Reinecke
2018-05-25 13:34 ` Christoph Hellwig
2018-05-31 10:27 ` 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=20180522091004.39620-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 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.