Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6597786imu; Wed, 30 Jan 2019 18:33:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN6qrrki0pKc9xxnYa+5N3IvftKantWFFp5UYM24fM9756BJB9OILEMq/9wgfDoaKsfZf0da X-Received: by 2002:a17:902:5ac7:: with SMTP id g7mr33304552plm.212.1548902000993; Wed, 30 Jan 2019 18:33:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1548902000; cv=pass; d=google.com; s=arc-20160816; b=rd0FDpg06F8pXG/5DelW32oC2k0L/lCLZ0GDljfSUus/XytHt8nCW/MjJU2nMpioVY 2ozoCfRBdHYBPgp5gfT2rhsDjMPwZKLwn+QJvFYwanx30RyVTup2BVlMF7WK+pL14M5m pfk4otR2GNSgsH91C9XOXrBw3rp+OKBzswn7fbX8/bErw9fqEX4KJMBfr+gXCcvDMp80 NC43zYzzJTsNzJ87iEKbjMr7LTOAJqP3U9RzaoAC8UC/naBi18Bi+N7q/t1pEhA/hL2F 0GpLG4p+A//ofFEbT/hKygrxtOYKpnmsSPn/sTRiDoZCvUS6uW2q14qutwhM5Dm2dOsd UzSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:domainkey-signature; bh=QBdUFHHZxjJDyMep6irBUJTyGeKnwnY2Xb6sUXvAs/8=; b=Rbry8VUBnHCT78WJLUyRZNHhSPKxxn3/qtBS6EQ/qMyW50LyzuSZih8Eobv3O4z6VT 8A5lvvP/HOB0qn2zk2EVuw7/tfGIwUM7N5U7EjV0flMmwFCAzAhSnRllwD08TuGdfaq+ z4QFwRJVoyOCbgqcAx99uhp50PEv63k//gIfULczts9w23HHhDmq2c6+ckI+jv1+CdHl SqW+NWyVAfG1G3CZDi3xKg+/p02UKnIbGe9DxlUTpzFXTHL+TlTOR+sjZ3AR87i2uw2N W8Fvz9naSoBz8vLEz6+U6f1zCI+KvKswROCZRBMTq9Jb2VIhagAEYmp7IaprlUjWfI+E I3QQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@zoho.com header.s=default header.b=cbOACc31; arc=pass (i=1 spf=pass spfdomain=zoho.com dkim=pass dkdomain=zoho.com dmarc=pass fromdomain=zoho.com>); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zoho.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v5si2948581pgg.1.2019.01.30.18.33.04; Wed, 30 Jan 2019 18:33:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@zoho.com header.s=default header.b=cbOACc31; arc=pass (i=1 spf=pass spfdomain=zoho.com dkim=pass dkdomain=zoho.com dmarc=pass fromdomain=zoho.com>); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zoho.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730573AbfAaCcJ (ORCPT + 99 others); Wed, 30 Jan 2019 21:32:09 -0500 Received: from sender-pp-092.zoho.com ([135.84.80.237]:25395 "EHLO sender-pp-092.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbfAaCcJ (ORCPT ); Wed, 30 Jan 2019 21:32:09 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1548901882; cv=none; d=zoho.com; s=zohoarc; b=K7iq8hS56tegnOe4RWsYVNW4oLhY/6NLylfEiQpxzGXmsYtsRMn50h3cP18/WrwFH46wNZRcpGflqWilFojdiUfX5GHZwind3CqSOIXDDo1xXFgknpFXTJNPWHslLY4nL5nwjNMLWxm9MJttKz3TfYw7XOcpnt+vCUMZfImEzPA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1548901882; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=QBdUFHHZxjJDyMep6irBUJTyGeKnwnY2Xb6sUXvAs/8=; b=cA0SPelfccOv9wflHNPDsYWiZlLxTOWdvpPmqu0fttuSnidkAU/yMUxHbvGiZJwjdMT93ckQgvebdT5EOc5yrl1jW+7MocjI+NPYKk550a3ACU2CIJI4uJiLF9fgCZqM+L2fUYEWGlJ+M3HGDGod1YwCa5btbTjMhuU1DDm0mmg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=yehs2007@zoho.com; dmarc=pass header.from= header.from= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:in-reply-to:references; b=Cijfa0RMYhaDqGsZEVvnS7SY4AJ3n9BqzKEvQCBVjwGWMyJe8X9BZXgC448mrVTaY8RDVC8GYgG3 Xq7dTyTDD4BKnKNM/Qb8jIZCx3NdYg7N3brzBE2wPFErvZoyUDH8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1548901882; s=default; d=zoho.com; i=yehs2007@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=1792; bh=QBdUFHHZxjJDyMep6irBUJTyGeKnwnY2Xb6sUXvAs/8=; b=cbOACc31jVwC3kk0JgUvKYSi24l/2kBaCzLsREzrxvmeq5gWLSSyjXYRrRVeYS3x I9e9nlY3NkYwvpjoo+RooI3nK+hZ/XF19ydWQqg1+HW9IH2+rfWGhH42vVRpnoLRanx FPkchWOnh8uKj/3Z5Gs/c+DpnFiIHj8bCgEK4CfY= Received: from YEHS1XR956R00D1.lenovo.com (106.38.1.115 [106.38.1.115]) by mx.zohomail.com with SMTPS id 154890188148863.55614782976397; Wed, 30 Jan 2019 18:31:21 -0800 (PST) From: Huaisheng Ye 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 Subject: [PATCH v3 3/5] dm-writecache: expand pmem_reinit for struct dm_writecache Date: Thu, 31 Jan 2019 10:29:53 +0800 Message-Id: <20190131022955.9920-4-yehs2007@zoho.com> X-Mailer: git-send-email 2.17.0.windows.1 In-Reply-To: <20190131022955.9920-1-yehs2007@zoho.com> References: <20190131022955.9920-1-yehs2007@zoho.com> X-ZohoMailClient: External Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huaisheng Ye 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 --- 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