From patchwork Wed Jan 9 05:31:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng Ye X-Patchwork-Id: 10753417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8320414E5 for ; Wed, 9 Jan 2019 05:32:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 710CC28DCE for ; Wed, 9 Jan 2019 05:32:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6249328DF3; Wed, 9 Jan 2019 05:32:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0CC4D28DCE for ; Wed, 9 Jan 2019 05:32:09 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 04781211B5076; Tue, 8 Jan 2019 21:32:09 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=135.84.80.237; helo=sender-pp-092.zoho.com; envelope-from=yehs2007@zoho.com; receiver=linux-nvdimm@lists.01.org Received: from sender-pp-092.zoho.com (sender-pp-092.zoho.com [135.84.80.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F1198211B506F for ; Tue, 8 Jan 2019 21:32:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547011907; cv=none; d=zoho.com; s=zohoarc; b=US18iSuJFNbFijQQv4IWkQvBldvgT5/oUSj9DFSPlVtZy76M1uwhO06BSgoq/R43jbDbgCm37pfHVHkYo/eG00TtgNKgor+V3KZD8a7v7qv4Z8V/5MCWcUD0Rc2ywuYI2/yoNkCdFCa+KXr01/A07C3+GuwfyI0Y0ZBH6gLkXWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1547011907; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=AaMjv5WPbSe3HlhnR3ynjCjoc6GHdluN4WYLbfJCURI=; b=jMWPybOiLnL3FxWFin9YxjYq87dk/71NvmhQpuSOZeVBLlLVnyp8JZ1S8aSsNBl5S7E1zyFIUHqB94tP3uAes37zKRMRAH1m2MxS1oi05wSJWGcfJg4fnUmfar7mLpmnU6etRhLkIC9FhwH3Pum6kRYy03o76pZVuPiBaJ55ZPo= 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=eEsI0jY+aKdoKT8mfVMz8ZpgFCvlfRWwn03DUU4lVhIalboIZH8z1G10B2gItKTSx0MEuTbnuD6l UjPiLUA8PVc7AZGFuJsZvjG3FPXIBP15KNpjYzS44H25BHwf2Xxg DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1547011907; s=default; d=zoho.com; i=yehs2007@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=2630; bh=AaMjv5WPbSe3HlhnR3ynjCjoc6GHdluN4WYLbfJCURI=; b=gc/Lj5JwQ86LaXgx7sSJgmabBhSQn/M6vzL6J6ATK1HP5K+N5nFeJxVEGubiMgNU GuxmMPgB4hwgHG8V5VM83Q9TEotFXpjdpveEFjkkOLTZBf/8GRqYoDLCFPfhMHg0vzi FsR1+0PiRMSx2nSJz3xvkchX5UM+PB3s39SycJvo= Received: from YEHS1XR956R00D1.lenovo.com (123.120.89.99 [123.120.89.99]) by mx.zohomail.com with SMTPS id 1547011905451850.9507713112295; Tue, 8 Jan 2019 21:31:45 -0800 (PST) From: Huaisheng Ye To: snitzer@redhat.com, agk@redhat.com Subject: [RFC PATCH v2 1/4] dm-writecache: remove unused size to writecache_flush_region Date: Wed, 9 Jan 2019 13:31:24 +0800 Message-Id: <20190109053127.8128-2-yehs2007@zoho.com> X-Mailer: git-send-email 2.17.0.windows.1 In-Reply-To: <20190109053127.8128-1-yehs2007@zoho.com> References: <20190109053127.8128-1-yehs2007@zoho.com> X-ZohoMailClient: External X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jack@suse.cz, corbet@lwn.net, chengnt@lenovo.com, linux-nvdimm@lists.01.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, hch@lst.de MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Huaisheng Ye writecache_flush_region doesn't use size to calculate flush region. That uses _set_bits to mark the region in dirty_bitmap directly. Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 2d50eec..2d8e0c0 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -418,7 +418,7 @@ static void writecache_flush_all_metadata(struct dm_writecache *wc) memset(wc->dirty_bitmap, -1, wc->dirty_bitmap_size); } -static void writecache_flush_region(struct dm_writecache *wc, void *ptr, size_t size) +static void writecache_flush_region(struct dm_writecache *wc, void *ptr) { if (!WC_MODE_PMEM(wc)) __set_bit(((char *)ptr - (char *)wc->memory_map) / BITMAP_GRANULARITY, @@ -657,7 +657,7 @@ static void writecache_free_entry(struct dm_writecache *wc, struct wc_entry *e) writecache_unlink(wc, e); writecache_add_to_freelist(wc, e); clear_seq_count(wc, e); - writecache_flush_region(wc, memory_entry(wc, e), sizeof(struct wc_memory_entry)); + writecache_flush_region(wc, memory_entry(wc, e)); if (unlikely(waitqueue_active(&wc->freelist_wait))) wake_up(&wc->freelist_wait); } @@ -687,9 +687,9 @@ static void writecache_poison_lists(struct dm_writecache *wc) static void writecache_flush_entry(struct dm_writecache *wc, struct wc_entry *e) { - writecache_flush_region(wc, memory_entry(wc, e), sizeof(struct wc_memory_entry)); + writecache_flush_region(wc, memory_entry(wc, e)); if (WC_MODE_PMEM(wc)) - writecache_flush_region(wc, memory_data(wc, e), wc->block_size); + writecache_flush_region(wc, memory_data(wc, e)); } static bool writecache_entry_is_committed(struct dm_writecache *wc, struct wc_entry *e) @@ -733,7 +733,7 @@ static void writecache_flush(struct dm_writecache *wc) wc->seq_count++; pmem_assign(sb(wc)->seq_count, cpu_to_le64(wc->seq_count)); - writecache_flush_region(wc, &sb(wc)->seq_count, sizeof sb(wc)->seq_count); + writecache_flush_region(wc, &sb(wc)->seq_count); writecache_commit_flushed(wc); wc->overwrote_committed = false; @@ -1757,7 +1757,7 @@ static int init_memory(struct dm_writecache *wc) writecache_flush_all_metadata(wc); writecache_commit_flushed(wc); pmem_assign(sb(wc)->magic, cpu_to_le32(MEMORY_SUPERBLOCK_MAGIC)); - writecache_flush_region(wc, &sb(wc)->magic, sizeof sb(wc)->magic); + writecache_flush_region(wc, &sb(wc)->magic); writecache_commit_flushed(wc); return 0; From patchwork Wed Jan 9 05:31:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng Ye X-Patchwork-Id: 10753419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4482614E5 for ; Wed, 9 Jan 2019 05:32:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F9A028DCE for ; Wed, 9 Jan 2019 05:32:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2098428DF3; Wed, 9 Jan 2019 05:32:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2535028DEF for ; Wed, 9 Jan 2019 05:32:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1C8A9211B5073; Tue, 8 Jan 2019 21:32:20 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=135.84.80.237; helo=sender-pp-092.zoho.com; envelope-from=yehs2007@zoho.com; receiver=linux-nvdimm@lists.01.org Received: from sender-pp-092.zoho.com (sender-pp-092.zoho.com [135.84.80.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7E345211B506D for ; Tue, 8 Jan 2019 21:32:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547011910; cv=none; d=zoho.com; s=zohoarc; b=D1bvQiE33wdc6DwxL+NxjEVKGDOIBmX+a67WChzSQfmO1uq4Jb1ELnkt0yDVO/wxW8svMSyIX9Au81xUJTPRC9rNc2v481HmwNFyR9/3eM65kDlgUmpvGU7gDP1MSobyNr3Kls48+mfRAKLW08jKsFDqQBcLzTxW7YVPAr34aOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1547011910; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=le5j2hLw5GH/PW3GIzsYH2jGxnhrLnZ93bpxcuJQ8Vk=; b=d+nujjZsNMbmscIeW4HtLKTRhnoKRdmLu7um1gv1P4q9TOtaRMo7VoBolhiCXp+R+++TlrdMrMzrZHa5VBCQXc27BHQgk69DxE68Huq6lWtbTNmq951dYFgD/T1wSNi1HYlovIRfhznRONhfSQxilkA1aOy9dPwt8tbcfZJEMgs= 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=LhS5yzC5u2acAzldvuV+A7CeZiHE2dHqLVxe7bR4IGwd5nYm50Va49pVrSP99RhYSZwMvBHGeA1w 0oX53NaX71SPutTKNz4Nbwei4kjGQNMqVgF3tfjsclAV+7c+V7qW DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1547011910; s=default; d=zoho.com; i=yehs2007@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=897; bh=le5j2hLw5GH/PW3GIzsYH2jGxnhrLnZ93bpxcuJQ8Vk=; b=YZS1IfqEQkbCTAsk+rx98Uw+CswngQBkGYFjbuPl9MQtB/QTdH6FH8DJS/45cBIP p+g3iTJinGqVtpOXY+9kQeA/QX60aefBU+mzs0rOd75OSIB+hjbEAhS0QjBXlVexBBv bNKg8G3b3KGa69LrWwG9oZRNW1vC3zI44WeIPikQ= Received: from YEHS1XR956R00D1.lenovo.com (123.120.89.99 [123.120.89.99]) by mx.zohomail.com with SMTPS id 154701190890385.06785696697204; Tue, 8 Jan 2019 21:31:48 -0800 (PST) From: Huaisheng Ye To: snitzer@redhat.com, agk@redhat.com Subject: [RFC PATCH v2 2/4] dm-writecache: get rid of memory_data flush to writecache_flush_entry Date: Wed, 9 Jan 2019 13:31:25 +0800 Message-Id: <20190109053127.8128-3-yehs2007@zoho.com> X-Mailer: git-send-email 2.17.0.windows.1 In-Reply-To: <20190109053127.8128-1-yehs2007@zoho.com> References: <20190109053127.8128-1-yehs2007@zoho.com> X-ZohoMailClient: External X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jack@suse.cz, corbet@lwn.net, chengnt@lenovo.com, linux-nvdimm@lists.01.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, hch@lst.de MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Huaisheng Ye writecache_flush_region only works when SSD mode. If wc->pmem_mode sets, writecache_flush_region doesn't need to be called in writecache_flush_entry. Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 2d8e0c0..c69317c 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -688,8 +688,6 @@ static void writecache_poison_lists(struct dm_writecache *wc) static void writecache_flush_entry(struct dm_writecache *wc, struct wc_entry *e) { writecache_flush_region(wc, memory_entry(wc, e)); - if (WC_MODE_PMEM(wc)) - writecache_flush_region(wc, memory_data(wc, e)); } static bool writecache_entry_is_committed(struct dm_writecache *wc, struct wc_entry *e) From patchwork Wed Jan 9 05:31:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng Ye X-Patchwork-Id: 10753421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C40F514E5 for ; Wed, 9 Jan 2019 05:32:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B009A28DCE for ; Wed, 9 Jan 2019 05:32:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A321128DF3; Wed, 9 Jan 2019 05:32:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 555B328DCE for ; Wed, 9 Jan 2019 05:32:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 33EAF211B5078; Tue, 8 Jan 2019 21:32:30 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=135.84.80.237; helo=sender-pp-092.zoho.com; envelope-from=yehs2007@zoho.com; receiver=linux-nvdimm@lists.01.org Received: from sender-pp-092.zoho.com (sender-pp-092.zoho.com [135.84.80.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2A42F211B506F for ; Tue, 8 Jan 2019 21:32:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547011914; cv=none; d=zoho.com; s=zohoarc; b=KvXOoTXYyfw46ddGR7sGmAszBd3zNz+y4VRwvDv+kzmsBnQkah6dX/MsVwJUEwEhvL18YY28gVt5nQRXCAjmbGgJLtPmc5GHFIOEolpor4wkXrCY6/tWfzNi8WSSTud9xdBMlA59wmjV7X3r8J2/rQnmHhZ7qblQ3CWoaJ3VL7k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1547011914; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=dw8ZJTmgcsYczIjoDQEr8j6GGcL35J1OcAqunEg0lrU=; b=dZbpCgY5lfthLyqcJaD4LeyIaWORytR7eW+PfurzN9yRbiw/DthK2oDPeK+vXzp/DcSK4kgEBBKuV7+7ob7UKAWzfR4NiLyt9qugWfbzFU8vCn1GttO18Shg9do324ku4AmevtZDafa9xXASqpc9Hnp5IKJTFR2CQXDpvoIIfwY= 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=GlVOwrDbvVZaHCGu4pCzKpgZ5rgBwI+63BwbUa5nMjHSqGDedyJ/5OSvHRlpe/b1ukdJQwBVcSd6 keqnu/+NXwwVX5g801DYVYsijtlyK1Z6EGlQ2HwWx2dnh6oySYQE DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1547011914; s=default; d=zoho.com; i=yehs2007@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=1798; bh=dw8ZJTmgcsYczIjoDQEr8j6GGcL35J1OcAqunEg0lrU=; b=KkYjXWsGOkw1VS5TkVerYjTXSCsfEWTjhL9ElCg+WYNqJwDoK6CEaXgveHejQnwg vApNHnXTEVH3lvZqbaJzkyL7t6UM730sH+oQHmOKc2mDg91at3Z9q+9uwfTNN7Rl9hv R1FkBvSPJezoSB3ezWMxh10AbQSOnT3dLMpXofus= Received: from YEHS1XR956R00D1.lenovo.com (123.120.89.99 [123.120.89.99]) by mx.zohomail.com with SMTPS id 1547011912293631.2697486393442; Tue, 8 Jan 2019 21:31:52 -0800 (PST) From: Huaisheng Ye To: snitzer@redhat.com, agk@redhat.com Subject: [RFC PATCH v2 3/4] dm-writecache: expand pmem_reinit for struct dm_writecache Date: Wed, 9 Jan 2019 13:31:26 +0800 Message-Id: <20190109053127.8128-4-yehs2007@zoho.com> X-Mailer: git-send-email 2.17.0.windows.1 In-Reply-To: <20190109053127.8128-1-yehs2007@zoho.com> References: <20190109053127.8128-1-yehs2007@zoho.com> X-ZohoMailClient: External X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jack@suse.cz, corbet@lwn.net, chengnt@lenovo.com, linux-nvdimm@lists.01.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, hch@lst.de MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP 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 in it, 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"; From patchwork Wed Jan 9 05:31:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng Ye X-Patchwork-Id: 10753423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D12436C2 for ; Wed, 9 Jan 2019 05:32:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF30228DCE for ; Wed, 9 Jan 2019 05:32:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2E8928DF3; Wed, 9 Jan 2019 05:32:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 61F2A28DCE for ; Wed, 9 Jan 2019 05:32:48 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 57D28211B5079; Tue, 8 Jan 2019 21:32:48 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=135.84.80.237; helo=sender-pp-092.zoho.com; envelope-from=yehs2007@zoho.com; receiver=linux-nvdimm@lists.01.org Received: from sender-pp-092.zoho.com (sender-pp-092.zoho.com [135.84.80.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 947FF211B506F for ; Tue, 8 Jan 2019 21:32:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547011918; cv=none; d=zoho.com; s=zohoarc; b=Yutn97Lc2kuInlcxUBGNCYuI50Zanxpo2dh5A7MiMoDfsCToa/UNQGDiaiy8JlEbuhbrwBbeyvVmNQU7tgfm+UIOdez7h3BEVPS7rO/PCvz9X2C+hZ+4H+DPU5ajc3TF2HG5bxh43fd8WdeyuSFDL+wPL/FvHBcnayCcPhO5aLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1547011918; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=LQScH7Z9ASTjwz+BDMoHBx4OT6Si3H3lqWmXMhgmtTk=; b=N6kBWgKrIcNY5+3jwICp+rfxfClpH0T3sJ64omwr9Ob1kjx+x/RjDuL9Z88imR/rw4yG0pugpOOdfxT1cAbypyoV+qKtpJ5R5B+pMFUoXoRrfX9MUWfKQ8SzUJsHEjOjFNK48sf+dl/Z44REUM59ieduWH2qTAnF4LkljZ+Rdno= 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=RrFUyYGiJw4aW79hat51p/nWRHJuirwkadiGOu3A2pxubRqY7TF1uAEfDpnIFkyVMueEAIvIcSzy ab/11lmt2LkWBDMLc9j7tBoqzswyvNahXV8EsOG2CNYTXiSlx4WO DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1547011918; s=default; d=zoho.com; i=yehs2007@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=927; bh=LQScH7Z9ASTjwz+BDMoHBx4OT6Si3H3lqWmXMhgmtTk=; b=Nhv+ay56yWrVvTn+ZcbZ9JM2YzBxzlrC1iU5NdnNk91u3KdoNh/viZW1jVTuTMMx rn08rsklR70jHOb1bUxl2kKGmeWngSF/o2D7GXOTOLcD6+em9BEraJ/UWynLbwpXz3P uw5gbZFhA45eD4bWTrzJjiFX0oCyI3JStLbQPVNw= Received: from YEHS1XR956R00D1.lenovo.com (123.120.89.99 [123.120.89.99]) by mx.zohomail.com with SMTPS id 1547011915743450.1697423849781; Tue, 8 Jan 2019 21:31:55 -0800 (PST) From: Huaisheng Ye To: snitzer@redhat.com, agk@redhat.com Subject: [RFC PATCH v2 4/4] Documentation/device-mapper: add optional parameter reinit Date: Wed, 9 Jan 2019 13:31:27 +0800 Message-Id: <20190109053127.8128-5-yehs2007@zoho.com> X-Mailer: git-send-email 2.17.0.windows.1 In-Reply-To: <20190109053127.8128-1-yehs2007@zoho.com> References: <20190109053127.8128-1-yehs2007@zoho.com> X-ZohoMailClient: External X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jack@suse.cz, corbet@lwn.net, chengnt@lenovo.com, linux-nvdimm@lists.01.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, hch@lst.de MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Huaisheng Ye Add intro and usage guide for reinit. Signed-off-by: Huaisheng Ye --- Documentation/device-mapper/writecache.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/device-mapper/writecache.txt b/Documentation/device-mapper/writecache.txt index 01532b3..255c68c 100644 --- a/Documentation/device-mapper/writecache.txt +++ b/Documentation/device-mapper/writecache.txt @@ -45,6 +45,10 @@ Constructor parameters: afterwards - some underlying devices perform better with fua, some with nofua. The user should test it + reinit (by default off) + applicable only to persistent memory - use the REINIT flag + when the surper block has messy data, that would cause fn ctr + failed to work with invalid magic or version in the superblock Status: 1. error indicator - 0 if there was no error, otherwise error number