linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Huaisheng Ye <yehs2007@zoho.com>
To: mpatocka@redhat.com, snitzer@redhat.com, agk@redhat.com
Cc: dan.j.williams@intel.com, hch@lst.de, jack@suse.cz,
	corbet@lwn.net, dm-devel@redhat.com,
	linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org,
	linux-doc@vger.kernel.org, Huaisheng Ye <yehs1@lenovo.com>
Subject: [PATCH v3 3/5] dm-writecache: expand pmem_reinit for struct dm_writecache
Date: Thu, 31 Jan 2019 10:29:53 +0800	[thread overview]
Message-ID: <20190131022955.9920-4-yehs2007@zoho.com> (raw)
In-Reply-To: <20190131022955.9920-1-yehs2007@zoho.com>

From: Huaisheng Ye <yehs1@lenovo.com>

When use persistent memory as cache data device, sometimes
the super block of pmem has messy data stored in it. That would
have risk to lead fn ctr failed to work due to invalid magic or
version.

Here we expand pmem_reinit to optional parameters in order to solve
this issue. When user gets pmem device, which has unrelated data,
as cache device, he should use paramenter 'reinit' to avoid s.magic
and s.version don't equal to NULL or correct
MEMORY_SUPERBLOCK_MAGIC/VERSION.

Signed-off-by: Huaisheng Ye <yehs1@lenovo.com>
---
 drivers/md/dm-writecache.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
index c69317c..2c1e825 100644
--- a/drivers/md/dm-writecache.c
+++ b/drivers/md/dm-writecache.c
@@ -149,6 +149,7 @@ struct dm_writecache {
 
 	bool pmem_mode:1;
 	bool writeback_fua:1;
+	bool pmem_reinit:1;
 
 	bool overwrote_committed:1;
 	bool memory_vmapped:1;
@@ -2026,6 +2027,10 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 				wc->writeback_fua = false;
 				wc->writeback_fua_set = true;
 			} else goto invalid_optional;
+		} else if (!strcasecmp(string, "reinit")) {
+			if (WC_MODE_PMEM(wc))
+				wc->pmem_reinit = true;
+			else goto invalid_optional;
 		} else {
 invalid_optional:
 			r = -EINVAL;
@@ -2127,7 +2132,7 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 		ti->error = "Hardware memory error when reading superblock";
 		goto bad;
 	}
-	if (!le32_to_cpu(s.magic) && !le32_to_cpu(s.version)) {
+	if (wc->pmem_reinit || (!le32_to_cpu(s.magic) && !le32_to_cpu(s.version))) {
 		r = init_memory(wc);
 		if (r) {
 			ti->error = "Unable to initialize device";
-- 
1.8.3.1



  parent reply	other threads:[~2019-01-31  2:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31  2:29 [PATCH v3 0/5] Optimize writecache when using pmem as cache Huaisheng Ye
2019-01-31  2:29 ` [PATCH v3 1/5] dm-writecache: remove unused size to writecache_flush_region Huaisheng Ye
2019-01-31  2:29 ` [PATCH v3 2/5] dm-writecache: get rid of memory_data flush to writecache_flush_entry Huaisheng Ye
2019-01-31  2:29 ` Huaisheng Ye [this message]
2019-01-31  2:29 ` [PATCH v3 4/5] Documentation/device-mapper: add optional parameter reinit Huaisheng Ye
2019-01-31  2:29 ` [PATCH v3 5/5] dm-writecache: output seq_count within status Huaisheng Ye
2019-02-04 11:27 ` [PATCH v3 0/5] Optimize writecache when using pmem as cache Mikulas Patocka
2019-02-11  6:47   ` [External] " Huaisheng HS1 Ye

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=20190131022955.9920-4-yehs2007@zoho.com \
    --to=yehs2007@zoho.com \
    --cc=agk@redhat.com \
    --cc=corbet@lwn.net \
    --cc=dan.j.williams@intel.com \
    --cc=dm-devel@redhat.com \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@redhat.com \
    --cc=yehs1@lenovo.com \
    /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).