From: Christoph Hellwig <hch@lst.de>
To: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org
Subject: [PATCH 3/5] nvme: factor out a nvme_ns_remove_by_nsid helper
Date: Mon, 6 Apr 2020 14:13:50 +0200 [thread overview]
Message-ID: <20200406121352.1151026-4-hch@lst.de> (raw)
In-Reply-To: <20200406121352.1151026-1-hch@lst.de>
Factor out a pice of deeply indented and logicaly separate piece of code
from nvme_scan_ns_list.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/core.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 5fcc35f74eac..ffa1d62eaeb1 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3697,6 +3697,16 @@ static void nvme_ns_remove(struct nvme_ns *ns)
nvme_put_ns(ns);
}
+static void nvme_ns_remove_by_nsid(struct nvme_ctrl *ctrl, u32 nsid)
+{
+ struct nvme_ns *ns = nvme_find_get_ns(ctrl, nsid);
+
+ if (ns) {
+ nvme_ns_remove(ns);
+ nvme_put_ns(ns);
+ }
+}
+
static void nvme_validate_ns(struct nvme_ctrl *ctrl, unsigned nsid)
{
struct nvme_ns *ns;
@@ -3730,7 +3740,6 @@ static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
static int nvme_scan_ns_list(struct nvme_ctrl *ctrl, unsigned nn)
{
- struct nvme_ns *ns;
__le32 *ns_list;
unsigned i, j, nsid, prev = 0;
unsigned num_lists = DIV_ROUND_UP_ULL((u64)nn, 1024);
@@ -3755,13 +3764,8 @@ static int nvme_scan_ns_list(struct nvme_ctrl *ctrl, unsigned nn)
nvme_validate_ns(ctrl, nsid);
- while (++prev < nsid) {
- ns = nvme_find_get_ns(ctrl, prev);
- if (ns) {
- nvme_ns_remove(ns);
- nvme_put_ns(ns);
- }
- }
+ while (++prev < nsid)
+ nvme_ns_remove_by_nsid(ctrl, prev);
}
nn -= j;
}
--
2.25.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-06 12:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-06 12:13 a few more namespace scanning cleanups Christoph Hellwig
2020-04-06 12:13 ` [PATCH 1/5] nvme: refine the Qemu Identify CNS quirk Christoph Hellwig
2020-04-06 17:03 ` Sagi Grimberg
2020-04-06 12:13 ` [PATCH 2/5] nvme: clean up nvme_scan_work Christoph Hellwig
2020-04-06 17:04 ` Sagi Grimberg
2020-04-06 12:13 ` Christoph Hellwig [this message]
2020-04-06 16:35 ` [PATCH 3/5] nvme: factor out a nvme_ns_remove_by_nsid helper Keith Busch
2020-04-06 17:04 ` Sagi Grimberg
2020-04-06 12:13 ` [PATCH 4/5] nvme: avoid an Identify Controller command for each namespace scan Christoph Hellwig
2020-04-06 12:13 ` [PATCH 5/5] nvme: remove the magic 1024 constant in nvme_scan_ns_list Christoph Hellwig
2020-04-06 17:07 ` Sagi Grimberg
2020-04-06 16:36 ` a few more namespace scanning cleanups Keith Busch
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=20200406121352.1151026-4-hch@lst.de \
--to=hch@lst.de \
--cc=kbusch@kernel.org \
--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).