From: Ocean He <oceanhehy@gmail.com>
To: dan.j.williams@intel.com, zwisler@kernel.org,
vishal.l.verma@intel.com, dave.jiang@intel.com
Cc: linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org,
Ocean He <hehy1@lenovo.com>
Subject: [PATCH 3/3] libnvdimm, region_devs: reset related seeds when fail to create namespace
Date: Mon, 10 Sep 2018 02:21:48 -0400 [thread overview]
Message-ID: <1536560508-24564-4-git-send-email-oceanhehy@gmail.com> (raw)
In-Reply-To: <1536560508-24564-1-git-send-email-oceanhehy@gmail.com>
From: Ocean He <hehy1@lenovo.com>
During runtime, namespace creation may fail if blocked by
commit 15d36fecd0bdc7510b70 ("mm: disallow mappings that conflict for
devm_memremap_pages()"). To ensure pfn_seed/dax_seed and namespace_seed
are ready for next namespace creation, here to do detach and reset.
Signed-off-by: Ocean He <hehy1@lenovo.com>
---
drivers/nvdimm/region_devs.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index fa37afc..4c46fb6 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -703,7 +703,27 @@ void nd_mapping_free_labels(struct nd_mapping *nd_mapping)
kfree(label_ent);
}
}
+/*
+ * To ensure pfn_seed/dax_seed and namespace_seed are ready for
+ * next namespace creation, here to do detach and reset.
+ */
+void nd_region_detach_and_reset(struct device *dev,
+ struct nd_region *nd_region)
+{
+ /* Only nd_pmem has been verified, fix me for other dev type. */
+ if (!is_nd_pmem(&nd_region->dev))
+ return;
+ if (is_nd_pfn(dev) || is_nd_dax(dev)) {
+ struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev);
+ struct nd_namespace_common *ndns = to_ndns(nd_region->ns_seed);
+
+ if (nd_pfn->ndns == ndns && ndns->claim == dev) {
+ nd_detach_and_reset(dev, &nd_pfn->ndns);
+ nd_region_reset_ns_seed(nd_region);
+ }
+ }
+}
/*
* Upon successful probe/remove, take/release a reference on the
* associated interleave set (if present), and plant new btt + namespace
@@ -774,6 +794,20 @@ static void nd_region_notify_driver_action(struct nvdimm_bus *nvdimm_bus,
nd_region_create_ns_seed(nd_region);
nvdimm_bus_unlock(dev);
}
+ if (is_nd_pfn(dev) && !probe) {
+ nd_region = to_nd_region(dev->parent);
+ nvdimm_bus_lock(dev);
+ if (nd_region->pfn_seed == dev)
+ nd_region_detach_and_reset(dev, nd_region);
+ nvdimm_bus_unlock(dev);
+ }
+ if (is_nd_dax(dev) && !probe) {
+ nd_region = to_nd_region(dev->parent);
+ nvdimm_bus_lock(dev);
+ if (nd_region->dax_seed == dev)
+ nd_region_detach_and_reset(dev, nd_region);
+ nvdimm_bus_unlock(dev);
+ }
}
void nd_region_probe_success(struct nvdimm_bus *nvdimm_bus, struct device *dev)
--
1.8.3.1
next prev parent reply other threads:[~2018-09-10 6:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-10 6:21 [PATCH 0/3] libnvdimm: reset seeds for next namespace creation Ocean He
2018-09-10 6:21 ` [PATCH 1/3] libnvdimm, claim: remove static attribute of nd_detach_and_reset Ocean He
2018-09-10 6:21 ` [PATCH 2/3] libnvdimm, namespace_devs: add function nd_region_reset_ns_seed for namespace seed reset Ocean He
2018-09-10 6:21 ` Ocean He [this message]
2018-09-11 0:40 ` [PATCH 3/3] libnvdimm, region_devs: reset related seeds when fail to create namespace kbuild test robot
2018-09-11 0:40 ` [RFC PATCH] libnvdimm, region_devs: nd_region_detach_and_reset() can be static kbuild test robot
2018-09-11 0:50 ` [PATCH 0/3] libnvdimm: reset seeds for next namespace creation Dan Williams
2018-09-11 8:49 ` [External] " Ocean HY1 He
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=1536560508-24564-4-git-send-email-oceanhehy@gmail.com \
--to=oceanhehy@gmail.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=hehy1@lenovo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=vishal.l.verma@intel.com \
--cc=zwisler@kernel.org \
/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
Powered by JetHome