From patchwork Wed Nov 1 21:46:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10037425 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 EE3B1600C5 for ; Wed, 1 Nov 2017 21:46:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2D9328BFF for ; Wed, 1 Nov 2017 21:46:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7D4628C05; Wed, 1 Nov 2017 21:46:49 +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, UNPARSEABLE_RELAY autolearn=unavailable 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 671F028BFF for ; Wed, 1 Nov 2017 21:46:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933937AbdKAVqq (ORCPT ); Wed, 1 Nov 2017 17:46:46 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:19736 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933891AbdKAVqj (ORCPT ); Wed, 1 Nov 2017 17:46:39 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vA1Lkaa4011346 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Nov 2017 21:46:37 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vA1LkaWI017082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Nov 2017 21:46:36 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vA1LkaTm030358; Wed, 1 Nov 2017 21:46:36 GMT Received: from localhost (/10.145.178.58) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 01 Nov 2017 14:46:36 -0700 Subject: [PATCH 01/14] common/xfs: refactor xfs_scrub presence testing From: "Darrick J. Wong" To: eguan@redhat.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Wed, 01 Nov 2017 14:46:34 -0700 Message-ID: <150957279473.18388.16116724960221536771.stgit@magnolia> In-Reply-To: <150957278824.18388.17975162441125293654.stgit@magnolia> References: <150957278824.18388.17975162441125293654.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Move all the requirements checking for xfs_scrub into a helper function. Make sure the helper properly detects the presence of the scrub ioctl and situations where we can't run scrub (e.g. norecovery). Refactor the existing three xfs_scrub call sites to use the helper to check if it's appropriate to run scrub. Signed-off-by: Darrick J. Wong --- README | 6 +++--- common/rc | 2 +- common/xfs | 41 ++++++++++++++++++++++++++++++++++------- tests/generic/453 | 11 +---------- tests/generic/454 | 11 +---------- 5 files changed, 40 insertions(+), 31 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/README b/README index 4963d28..a9da4f0 100644 --- a/README +++ b/README @@ -88,9 +88,9 @@ Preparing system for tests: run xfs_repair -n to check the filesystem; xfs_repair to rebuild metadata indexes; and xfs_repair -n (a third time) to check the results of the rebuilding. - - set TEST_XFS_SCRUB=1 to have _check_xfs_filesystem run - xfs_scrub -vd to scrub the filesystem metadata online before - unmounting to run the offline check. + - xfs_scrub, if present, will always check the test and scratch + filesystems if they are still online at the end of the test. + It is no longer necessary to set TEST_XFS_SCRUB. - setenv LOGWRITES_DEV to a block device to use for power fail testing. diff --git a/common/rc b/common/rc index 1a4d81e..83aaced 100644 --- a/common/rc +++ b/common/rc @@ -2091,7 +2091,7 @@ _require_xfs_io_command() _notrun "xfs_io $command support is missing" ;; "scrub"|"repair") - testio=`$XFS_IO_PROG -x -c "$command test 0" $TEST_DIR 2>&1` + testio=`$XFS_IO_PROG -x -c "$command probe 0" $TEST_DIR 2>&1` echo $testio | grep -q "Inappropriate ioctl" && \ _notrun "xfs_io $command support is missing" ;; diff --git a/common/xfs b/common/xfs index dff8454..de3c560 100644 --- a/common/xfs +++ b/common/xfs @@ -298,6 +298,30 @@ _require_xfs_db_command() _notrun "xfs_db $command support is missing" } +# Does the filesystem mounted from a particular device support scrub? +_supports_xfs_scrub() +{ + mountpoint="$1" + device="$2" + + if [ ! -b "$device" ] || [ ! -e "$mountpoint" ]; then + echo "Usage: _supports_xfs_scrub mountpoint device" + exit 1 + fi + + test "$FSTYP" = "xfs" || return 1 + test -x "$XFS_SCRUB_PROG" || return 1 + + # Probe for kernel support... + $XFS_IO_PROG -c 'help scrub' 2>&1 | grep -q 'types are:.*probe' || return 1 + $XFS_IO_PROG -c "scrub probe 0" "$mountpoint" 2>&1 | grep -q "Inappropriate ioctl" && return 1 + + # Scrub can't run on norecovery mounts + _fs_options "$device" | grep -q "norecovery" && return 1 + + return 0 +} + # run xfs_check and friends on a FS. _check_xfs_filesystem() { @@ -330,14 +354,17 @@ _check_xfs_filesystem() type=`_fs_type $device` ok=1 - if [ "$type" = "xfs" ]; then - if [ -n "$TEST_XFS_SCRUB" ] && [ -x "$XFS_SCRUB_PROG" ]; then - "$XFS_SCRUB_PROG" $scrubflag -v -d -n $device >>$seqres.full - if [ $? -ne 0 ]; then - _log_err "filesystem on $device failed scrub" - ok=0 - fi + # Run online scrub if we can. + mntpt="$(_is_mounted $device)" + if [ -n "$mntpt" ] && _supports_xfs_scrub "$mntpt" "$device"; then + "$XFS_SCRUB_PROG" $scrubflag -v -d -n $device >>$seqres.full 2>&1 + if [ $? -ne 0 ]; then + _log_err "filesystem on $device failed scrub" + ok=0 fi + fi + + if [ "$type" = "xfs" ]; then # mounted ... mountpoint=`_umount_or_remount_ro $device` fi diff --git a/tests/generic/453 b/tests/generic/453 index bda1112..16589d1 100755 --- a/tests/generic/453 +++ b/tests/generic/453 @@ -136,10 +136,7 @@ echo "Test XFS online scrub, if applicable" # Only run this on xfs if xfs_scrub is available and has the unicode checker check_xfs_scrub() { - # Ignore non-XFS fs or no scrub program... - if [ "${FSTYP}" != "xfs" ] || [ ! -x "${XFS_SCRUB_PROG}" ]; then - return 1 - fi + _supports_xfs_scrub "$SCRATCH_MNT" "$SCRATCH_DEV" || return 1 # We only care if xfs_scrub has unicode string support... if ! type ldd > /dev/null 2>&1 || \ @@ -147,12 +144,6 @@ check_xfs_scrub() { return 1 fi - # Does the ioctl work? - if $XFS_IO_PROG -x -c "scrub probe 0" $SCRATCH_MNT 2>&1 | \ - grep -q "Inappropriate ioctl"; then - return 1 - fi - return 0 } diff --git a/tests/generic/454 b/tests/generic/454 index d1f93b2..efac860 100755 --- a/tests/generic/454 +++ b/tests/generic/454 @@ -132,10 +132,7 @@ echo "Test XFS online scrub, if applicable" # Only run this on xfs if xfs_scrub is available and has the unicode checker check_xfs_scrub() { - # Ignore non-XFS fs or no scrub program... - if [ "${FSTYP}" != "xfs" ] || [ ! -x "${XFS_SCRUB_PROG}" ]; then - return 1 - fi + _supports_xfs_scrub "$SCRATCH_MNT" "$SCRATCH_DEV" || return 1 # We only care if xfs_scrub has unicode string support... if ! type ldd > /dev/null 2>&1 || \ @@ -143,12 +140,6 @@ check_xfs_scrub() { return 1 fi - # Does the ioctl work? - if $XFS_IO_PROG -x -c "scrub probe 0" $SCRATCH_MNT 2>&1 | \ - grep -q "Inappropriate ioctl"; then - return 1 - fi - return 0 }