From patchwork Thu Mar 9 01:34:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9612195 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 502BB602B4 for ; Thu, 9 Mar 2017 01:50:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F8AA28646 for ; Thu, 9 Mar 2017 01:50:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4489C28648; Thu, 9 Mar 2017 01:50:01 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7B1128646 for ; Thu, 9 Mar 2017 01:49:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754721AbdCIBty (ORCPT ); Wed, 8 Mar 2017 20:49:54 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:48491 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754559AbdCIBtw (ORCPT ); Wed, 8 Mar 2017 20:49:52 -0500 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="16354897" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Mar 2017 09:35:39 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 378AF47C4E9A; Thu, 9 Mar 2017 09:35:36 +0800 (CST) Received: from localhost.localdomain (10.167.226.34) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 9 Mar 2017 09:35:36 +0800 From: Qu Wenruo To: , Subject: [PATCH v3.1 5/7] btrfs: Allow barrier_all_devices to do chunk level device check Date: Thu, 9 Mar 2017 09:34:40 +0800 Message-ID: <20170309013442.19957-6-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170309013442.19957-1-quwenruo@cn.fujitsu.com> References: <20170309013442.19957-1-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.34] X-yoursite-MailScanner-ID: 378AF47C4E9A.AF25F X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The last user of num_tolerated_disk_barrier_failures is barrier_all_devices(). But it's can be easily changed to new per-chunk degradable check framework. Now btrfs_device will have two extra members, representing send/wait error, set at write_dev_flush() time. With these 2 new members, btrfs_check_rw_degradable() can check if the fs is still OK when the fs is committed to disk. Signed-off-by: Qu Wenruo Tested-by: Austin S. Hemmelgarn Tested-by: Adam Borowski Tested-by: Dmitrii Tcvetkov --- fs/btrfs/disk-io.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 658b8fab1d39..549045a3e15f 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3570,17 +3570,20 @@ static int barrier_all_devices(struct btrfs_fs_info *info) { struct list_head *head; struct btrfs_device *dev; - int errors_send = 0; - int errors_wait = 0; + struct extra_rw_degrade_errors *errors; int ret; + errors = alloc_extra_rw_degrade_errors(info->fs_devices->num_devices); + if (!errors) + return -ENOMEM; + /* send down all the barriers */ head = &info->fs_devices->devices; list_for_each_entry_rcu(dev, head, dev_list) { if (dev->missing) continue; if (!dev->bdev) { - errors_send++; + record_extra_rw_degrade_error(errors, dev->devid); continue; } if (!dev->in_fs_metadata || !dev->writeable) @@ -3588,7 +3591,7 @@ static int barrier_all_devices(struct btrfs_fs_info *info) ret = write_dev_flush(dev, 0); if (ret) - errors_send++; + record_extra_rw_degrade_error(errors, dev->devid); } /* wait for all the barriers */ @@ -3596,7 +3599,7 @@ static int barrier_all_devices(struct btrfs_fs_info *info) if (dev->missing) continue; if (!dev->bdev) { - errors_wait++; + record_extra_rw_degrade_error(errors, dev->devid); continue; } if (!dev->in_fs_metadata || !dev->writeable) @@ -3604,11 +3607,13 @@ static int barrier_all_devices(struct btrfs_fs_info *info) ret = write_dev_flush(dev, 1); if (ret) - errors_wait++; + record_extra_rw_degrade_error(errors, dev->devid); } - if (errors_send > info->num_tolerated_disk_barrier_failures || - errors_wait > info->num_tolerated_disk_barrier_failures) + if (!btrfs_check_rw_degradable(info, errors)) { + kfree(errors); return -EIO; + } + kfree(errors); return 0; }