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: Ocean He <hehy1@lenovo.com>, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [PATCH 2/3] libnvdimm, namespace_devs: add function nd_region_reset_ns_seed for namespace seed reset Date: Mon, 10 Sep 2018 02:21:47 -0400 [thread overview] Message-ID: <1536560508-24564-3-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, if a namespace seed is used for new namespace creation but fail, then it needs to be reset for next namespace creation. Add function nd_region_reset_ns_seed for namespace seed reset and declare it in nd-core.h. Signed-off-by: Ocean He <hehy1@lenovo.com> --- drivers/nvdimm/namespace_devs.c | 32 ++++++++++++++++++++++++++++++++ drivers/nvdimm/nd-core.h | 1 + 2 files changed, 33 insertions(+) diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c index 4a42662..6678bbe 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -2129,6 +2129,38 @@ void nd_region_create_ns_seed(struct nd_region *nd_region) nd_device_register(nd_region->ns_seed); } +void nd_region_reset_ns_seed(struct nd_region *nd_region) +{ + struct device *dev = nd_region->ns_seed; + unsigned long long val = 0; + ssize_t rc; + u8 **uuid = NULL; + + rc = __holder_class_store(dev, ""); + dev_dbg(dev, "%s(%zd)\n", rc < 0 ? "fail to reset claim_class " : "", rc); + + rc = __size_store(dev, val); + if (rc >= 0) + rc = nd_namespace_label_update(nd_region, dev); + dev_dbg(dev, "%s(%zd)\n", rc < 0 ? "fail to reset size " : "", rc); + + if (is_namespace_pmem(dev)) { + struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev); + + uuid = &nspm->uuid; + } else if (is_namespace_blk(dev)) { + struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); + + uuid = &nsblk->uuid; + } + + if (rc == 0 && val == 0 && uuid) { + /* setting size zero == 'delete namespace' */ + kfree(*uuid); + *uuid = NULL; + } +} + void nd_region_create_dax_seed(struct nd_region *nd_region) { WARN_ON(!is_nvdimm_bus_locked(&nd_region->dev)); diff --git a/drivers/nvdimm/nd-core.h b/drivers/nvdimm/nd-core.h index 7fd74d0..3ec6909 100644 --- a/drivers/nvdimm/nd-core.h +++ b/drivers/nvdimm/nd-core.h @@ -81,6 +81,7 @@ static inline bool is_memory(struct device *dev) void nd_region_probe_success(struct nvdimm_bus *nvdimm_bus, struct device *dev); struct nd_region; void nd_region_create_ns_seed(struct nd_region *nd_region); +void nd_region_reset_ns_seed(struct nd_region *nd_region); void nd_region_create_btt_seed(struct nd_region *nd_region); void nd_region_create_pfn_seed(struct nd_region *nd_region); void nd_region_create_dax_seed(struct nd_region *nd_region); -- 1.8.3.1 _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
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 2/3] libnvdimm, namespace_devs: add function nd_region_reset_ns_seed for namespace seed reset Date: Mon, 10 Sep 2018 02:21:47 -0400 [thread overview] Message-ID: <1536560508-24564-3-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, if a namespace seed is used for new namespace creation but fail, then it needs to be reset for next namespace creation. Add function nd_region_reset_ns_seed for namespace seed reset and declare it in nd-core.h. Signed-off-by: Ocean He <hehy1@lenovo.com> --- drivers/nvdimm/namespace_devs.c | 32 ++++++++++++++++++++++++++++++++ drivers/nvdimm/nd-core.h | 1 + 2 files changed, 33 insertions(+) diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c index 4a42662..6678bbe 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -2129,6 +2129,38 @@ void nd_region_create_ns_seed(struct nd_region *nd_region) nd_device_register(nd_region->ns_seed); } +void nd_region_reset_ns_seed(struct nd_region *nd_region) +{ + struct device *dev = nd_region->ns_seed; + unsigned long long val = 0; + ssize_t rc; + u8 **uuid = NULL; + + rc = __holder_class_store(dev, ""); + dev_dbg(dev, "%s(%zd)\n", rc < 0 ? "fail to reset claim_class " : "", rc); + + rc = __size_store(dev, val); + if (rc >= 0) + rc = nd_namespace_label_update(nd_region, dev); + dev_dbg(dev, "%s(%zd)\n", rc < 0 ? "fail to reset size " : "", rc); + + if (is_namespace_pmem(dev)) { + struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev); + + uuid = &nspm->uuid; + } else if (is_namespace_blk(dev)) { + struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); + + uuid = &nsblk->uuid; + } + + if (rc == 0 && val == 0 && uuid) { + /* setting size zero == 'delete namespace' */ + kfree(*uuid); + *uuid = NULL; + } +} + void nd_region_create_dax_seed(struct nd_region *nd_region) { WARN_ON(!is_nvdimm_bus_locked(&nd_region->dev)); diff --git a/drivers/nvdimm/nd-core.h b/drivers/nvdimm/nd-core.h index 7fd74d0..3ec6909 100644 --- a/drivers/nvdimm/nd-core.h +++ b/drivers/nvdimm/nd-core.h @@ -81,6 +81,7 @@ static inline bool is_memory(struct device *dev) void nd_region_probe_success(struct nvdimm_bus *nvdimm_bus, struct device *dev); struct nd_region; void nd_region_create_ns_seed(struct nd_region *nd_region); +void nd_region_reset_ns_seed(struct nd_region *nd_region); void nd_region_create_btt_seed(struct nd_region *nd_region); void nd_region_create_pfn_seed(struct nd_region *nd_region); void nd_region_create_dax_seed(struct nd_region *nd_region); -- 1.8.3.1
next prev parent reply other threads:[~2018-09-10 6:24 UTC|newest] Thread overview: 16+ 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 ` 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 ` Ocean He 2018-09-10 6:21 ` Ocean He [this message] 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 ` [PATCH 3/3] libnvdimm, region_devs: reset related seeds when fail to create namespace Ocean He 2018-09-10 6:21 ` Ocean He 2018-09-11 0:40 ` kbuild test robot 2018-09-11 0:40 ` 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:40 ` kbuild test robot 2018-09-11 0:50 ` [PATCH 0/3] libnvdimm: reset seeds for next namespace creation Dan Williams 2018-09-11 0:50 ` Dan Williams 2018-09-11 8:49 ` [External] " Ocean HY1 He 2018-09-11 8:49 ` 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-3-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: linkBe 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.