From patchwork Tue May 22 00:53:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "monty_pavel@sina.com" X-Patchwork-Id: 10414481 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1AAD5600CC for ; Mon, 21 May 2018 09:43:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0950E287C5 for ; Mon, 21 May 2018 09:43:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F15DF287D1; Mon, 21 May 2018 09:43:18 +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=-4.7 required=2.0 tests=BAYES_00, DATE_IN_FUTURE_12_24, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 DE0F9287C5 for ; Mon, 21 May 2018 09:43:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6C533179B4F; Mon, 21 May 2018 09:43:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D6D9630B7791; Mon, 21 May 2018 09:43:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EC53C1801242; Mon, 21 May 2018 09:43:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4L9h3SM000856 for ; Mon, 21 May 2018 05:43:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id F09FF977A5; Mon, 21 May 2018 09:43:03 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E987F977A4 for ; Mon, 21 May 2018 09:43:01 +0000 (UTC) Received: from mail115-76.sinamail.sina.com.cn (mail115-76.sinamail.sina.com.cn [218.30.115.76]) by mx1.redhat.com (Postfix) with SMTP id 2B6C4B2B7F for ; Mon, 21 May 2018 09:42:57 +0000 (UTC) Received: from unknown (HELO yyp.?)([220.113.8.82]) by sina.com with ESMTP id 5B02949B00001FC2; Mon, 21 May 2018 17:42:54 +0800 (CST) X-Sender: monty_pavel@sina.com X-Auth-ID: monty_pavel@sina.com X-SMAIL-MID: 293110133968 Date: Mon, 21 May 2018 20:53:36 -0400 From: Monty Pavel To: dm-devel@redhat.com Message-ID: <20180522005336.GA30152@yyp.> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 21 May 2018 09:42:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 21 May 2018 09:42:59 +0000 (UTC) for IP:'218.30.115.76' DOMAIN:'mail115-76.sinamail.sina.com.cn' HELO:'mail115-76.sinamail.sina.com.cn' FROM:'monty_pavel@sina.com' RCPT:'' X-RedHat-Spam-Score: 2.479 ** (DATE_IN_FUTURE_12_24, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 218.30.115.76 mail115-76.sinamail.sina.com.cn 218.30.115.76 mail115-76.sinamail.sina.com.cn X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH] dm thin: superblock may write succeed before other metadata blocks because of wirting metadata in async mode. X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 21 May 2018 09:43:16 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP If dm_bufio_write_dirty_buffers func is called by __commit_transaction func and power loss happens during executing it, coincidencely superblock wrote correctly but some metadata blocks didn't. The reason is we write all metadata in async mode. We can guarantee that we send superblock after other blocks but we cannot guarantee that superblock write completely early than other blocks. So, We need to commit other metadata blocks before change superblock. Signed-off-by: Monty Pavel --- drivers/md/dm-thin-metadata.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index 36ef284..897d7d6 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c @@ -813,6 +813,14 @@ static int __commit_transaction(struct dm_pool_metadata *pmd) if (r) return r; + r = dm_tm_commit(pmd->tm, sblock); + if (r) + return r; + + r = superblock_lock(pmd, &sblock); + if (r) + return r; + disk_super = dm_block_data(sblock); disk_super->time = cpu_to_le32(pmd->time); disk_super->data_mapping_root = cpu_to_le64(pmd->root);