From patchwork Sun Jul 16 01:30:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 9842581 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 5C0A960212 for ; Sun, 16 Jul 2017 01:31:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FB60285E2 for ; Sun, 16 Jul 2017 01:31:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 319CF285DB; Sun, 16 Jul 2017 01:31:06 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 7D704285DB for ; Sun, 16 Jul 2017 01:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751220AbdGPBbE (ORCPT ); Sat, 15 Jul 2017 21:31:04 -0400 Received: from imap.thunk.org ([74.207.234.97]:53634 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751213AbdGPBbD (ORCPT ); Sat, 15 Jul 2017 21:31:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=f6NKCikaB5n1sgntuvMS2DES+6iPRvY5jNgMaPhCfYo=; b=uZMeYrqH7h2d2JgCWhycae+BuNkGQjBLvzfw7wCRWwOAJmb0iGsYFHzwf17M/NVEqwCC0+vaRJeWZvYiyEamsrqAsB90dGbS7PLZFFA7d1b4HuUGABA8TP+sZtkvwd+/adRwO5uvTbR96HX54XOrGVct7zDG/xYEdNOiLs6ZmwQ=; Received: from root (helo=callcc.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.84_2) (envelope-from ) id 1dWYOh-0008F6-C5; Sun, 16 Jul 2017 01:30:59 +0000 Received: by callcc.thunk.org (Postfix, from userid 15806) id 3C45DC002F4; Sat, 15 Jul 2017 21:30:58 -0400 (EDT) Date: Sat, 15 Jul 2017 21:30:58 -0400 From: Theodore Ts'o To: Eryu Guan Cc: "Darrick J. Wong" , fstests@vger.kernel.org Subject: Re: [RFC PATCH] check: try to fix the test device if it gets corrupted Message-ID: <20170716013058.r46jceccqmoedkde@thunk.org> References: <20170302232050.31125-1-tytso@mit.edu> <20170303090332.GP14226@eguan.usersys.redhat.com> <20170303172157.GA5070@birch.djwong.org> <20170303230129.apzqe77r4d5jtf63@thunk.org> <20170327014802.wc5as2tdgecy3rzu@thunk.org> <20170327085103.GQ14226@eguan.usersys.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170327085103.GQ14226@eguan.usersys.redhat.com> User-Agent: NeoMutt/20170609 (1.8.3) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Mar 27, 2017 at 04:51:03PM +0800, Eryu Guan wrote: > > Sorry I lost this thread, I thought I've replied but apparently I didn't.. > > I agreed with both of you and Darrick, I think we can try to repair the > corrupted test fs, and if repair succeeds we can continue the test, and > stop running the whole test if repair fails. Sorry for the delay in getting back to this. Things got busy and this got dropped on my end. I've fixed the whitespace nits that you pointed out and am using _log_err. > I think we should try to fix other filesystems too? Hmm... yeah. The main reason why I hadn't was because xfs has _scratch_xfs_repair and _scratch_xfs_check, which are very similar. But _check_xfs_test_fs looks *very* different from _scratch_xfs_check, and I'm not sure why. So I've created a _repair_xfs_test_fs which is modelled after the simpler _scratch_xfs_repair function, but I'm not 100% sure that is correct. Anyways, WDYT? - Ted From 96a13cc22878ee5c016a606d76f8e9a6bd84eb20 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 1 Mar 2017 19:54:08 -0500 Subject: [PATCH] check: try to fix the test device if it gets corrupted If the test device gets corrupted all subsequent tests will fail. To prevent this from causing all subsequent tests to be useless, try repair the file system on TEST_DEV if possible. We don't need to do this with the scratch device since that file system gets recreated each time anyway. Signed-off-by: Theodore Ts'o --- check | 7 ++++++- common/rc | 41 +++++++++++++++++++++++++++++++++++++++++ common/xfs | 12 ++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/check b/check index f8db3cd6..d89d2e91 100755 --- a/check +++ b/check @@ -476,7 +476,12 @@ _summary() _check_filesystems() { if [ -f ${RESULT_DIR}/require_test ]; then - _check_test_fs || err=true + if ! _check_test_fs ; then + err=true + echo "Trying to repair broken TEST_DEV file system" + _repair_test_fs + _test_mount + fi rm -f ${RESULT_DIR}/require_test* fi if [ -f ${RESULT_DIR}/require_scratch ]; then diff --git a/common/rc b/common/rc index 328b6b07..d37a1611 100644 --- a/common/rc +++ b/common/rc @@ -1201,6 +1201,47 @@ _repair_scratch_fs() esac } +_repair_test_fs() +{ + case $FSTYP in + xfs) + _repair_xfs_test_fs "$@" >$tmp.repair 2>&1 + res=$? + if [ "$res" -ne 0 ]; then + echo "xfs_repair returns $res; replay log?" >>$tmp.repair + _test_mount + res=$? + if [ $res -gt 0 ]; then + echo "mount returns $res; zap log?" >>$tmp.repair + _xfs_repair_test_fs -L >>$tmp.repair 2>&1 + echo "log zap returns $?" >> $tmp.repair + else + umount "$TEST_DEV" + fi + _xfs_repair_test_fs "$@" >>$tmp.repair 2>&1 + res=$? + fi + ;; + *) + # Let's hope fsck -y suffices... + fsck -t $FSTYP -fy $TEST_DEV >$tmp.repair 2>&1 + res=$? + if test "$res" -lt 4 ; then + res=0 + fi + ;; + esac + if [ $res -ne 0 ]; then + _log_err "_repair_test_fs: failed, err=$res" + echo "*** fsck.$FSTYP output ***" >>$seqres.full + cat $tmp.repair >>$seqres.full + echo "*** end fsck.$FSTYP output" >>$seqres.full + + fi + rm -f $tmp.repair + return $res +} + _get_pids_by_name() { if [ $# -ne 1 ] diff --git a/common/xfs b/common/xfs index a1ee3847..c8f4e46b 100644 --- a/common/xfs +++ b/common/xfs @@ -443,6 +443,18 @@ _check_xfs_test_fs() fi } +# modeled after _scratch_xfs_repair +_repair_xfs_test_fs() +{ + TEST_OPTIONS="" + [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \ + TEST_OPTIONS="-l$TEST_LOGDEV" + [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \ + TEST_OPTIONS=$TEST_OPTIONS" -r$TEST_RTDEV" + [ "$LARGE_TEST_DEV" = yes ] && TEST_OPTIONS=$TEST_OPTIONS" -t" + $XFS_REPAIR_PROG $TEST_OPTIONS $* $TEST_DEV +} + _require_xfs_test_rmapbt() { _require_test