From patchwork Mon Nov 17 06:06:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 5315541 Return-Path: X-Original-To: patchwork-fstests@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 51D9F9F1E1 for ; Mon, 17 Nov 2014 06:06:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B716201F2 for ; Mon, 17 Nov 2014 06:06:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D6C2201BC for ; Mon, 17 Nov 2014 06:06:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751674AbaKQGGR (ORCPT ); Mon, 17 Nov 2014 01:06:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55911 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751506AbaKQGGQ (ORCPT ); Mon, 17 Nov 2014 01:06:16 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAH666ib029103 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Nov 2014 01:06:06 -0500 Received: from localhost (dhcp-13-42.nay.redhat.com [10.66.13.42]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAH664c5029726; Mon, 17 Nov 2014 01:06:05 -0500 Date: Mon, 17 Nov 2014 14:06:03 +0800 From: Eryu Guan To: Dave Chinner Cc: Steve French , fstests@vger.kernel.org, "linux-nfs@vger.kernel.org" , "linux-cifs@vger.kernel.org" , Weston Andros Adamson Subject: Re: [PATCH v2 1/5] common: re-enable tests that require scratch dev on NFS Message-ID: <20141117060603.GO2863@dhcp-13-216.nay.redhat.com> References: <1414775040-4051-1-git-send-email-eguan@redhat.com> <1414775040-4051-2-git-send-email-eguan@redhat.com> <20141113033317.GC28565@dastard> <20141115053533.GK2863@dhcp-13-216.nay.redhat.com> <20141117054141.GK23575@dastard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20141117054141.GK23575@dastard> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Nov 17, 2014 at 04:41:41PM +1100, Dave Chinner wrote: > On Sat, Nov 15, 2014 at 01:35:33PM +0800, Eryu Guan wrote: > > On Fri, Nov 14, 2014 at 11:02:50AM -0600, Steve French wrote: > > > On Wed, Nov 12, 2014 at 9:33 PM, Dave Chinner wrote: > > > > On Wed, Nov 12, 2014 at 12:36:13PM -0600, Steve French wrote: > > > >> On Fri, Oct 31, 2014 at 12:03 PM, Eryu Guan wrote: > > > >> > This commit disables tests requires scratch dev running on NFS > > > >> > > > > >> > c041421 xfstests: stop special casing nfs and udf > > > >> > > > > >> > Now re-enable them to get a larger test coverage on NFS. > > > >> > > > > >> > Signed-off-by: Eryu Guan > > > >> > --- > > > >> > common/rc | 22 +++++++++++++++++++--- > > > >> > 1 file changed, 19 insertions(+), 3 deletions(-) > > > >> > > > > >> > diff --git a/common/rc b/common/rc > > > >> > index 747cf72..ae03712 100644 > > > >> > --- a/common/rc > > > >> > +++ b/common/rc > > > >> > @@ -551,6 +551,14 @@ _mkfs_dev() > > > >> > rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd > > > >> > } > > > >> > > > > >> > +# remove all files in $SCRATCH_MNT, useful when testing on NFS/CIFS > > > >> > +_scratch_cleanup_files() > > > >> > +{ > > > >> > + _scratch_mount > > > >> > + rm -rf $SCRATCH_MNT/* > > > >> > + _scratch_unmount > > > >> > +} > > > >> > > > >> There should be a check to make sure SCRATCH_MNT exists before you > > > >> wipe the whole disk .... > > > >> > > > >> so if no SCRATCH_MNT then this does rm -rf/* > > > >> right ... (and wipes out your whole system ...) > > > > > > > > You can't get to that function until after all the checks that > > > > SCRATCH_MNT exists. i.e. this happens during _scratch_mkfs, and that > > > > is only called in tests after all the startup checks validate > > > > devices and mounts exist. i.e. see common/config::get_next_config() > > > > > > Well, I reproduced it easily enough again today (after taking a > > > snapshot of the VM) > > > by simply running generic/120 against NFS with SCRATCH_MNT not > > > specified in local.config > > > Dros also ran into this problem. > > > > You're right, I missed that _scratch_mkfs is also called by ./check, > > and if there's no SCRATCH_MNT set in local.config, only SCRATCH_DEV is > > set, _scratch_mkfs can be dangerous. > > As I asked earlier in this thread: why isn't get_next_config() > catching this? I think I see the problem, this patch catches the empty SCRATCH_MNT and works for me: eguan@dhcp-13-216:~/workspace/src/xfstests$ git diff If it looks sane I will send out a patch. > > > I propose this patch, which skips _scratch_cleanup_files if called by check > > > > [root@hp-dl388eg8-01 xfstests]# git diff > > diff --git a/common/rc b/common/rc > > index 435f74f..254fb66 100644 > > --- a/common/rc > > +++ b/common/rc > > @@ -554,6 +554,11 @@ _mkfs_dev() > > # remove all files in $SCRATCH_MNT, useful when testing on NFS/CIFS > > _scratch_cleanup_files() > > { > > + # do nothing if called by check, variables are not fully valided yet > > + # SCRATCH_MNT can be empty, which is dangerous > > + if [ "$iam" == "check" ]; then > > + return > > + fi > > Again, this is the wrong place to try to fix this - we haven't fixed > the landmine that has left us running with an invalid config. IOWs, > by the time _scratch_mkfs is called from *anywhere* we should have > fully validated the environment to be correct and valid. Parsing and > validating the config we have loaded from the config file is the job > of get_next_config(), yes? Yes, that makes more sense, thanks for the explanation! Thanks, Eryu > > Cheers, > > Dave. > -- > Dave Chinner > david@fromorbit.com > -- > To unsubscribe from this list: send the line "unsubscribe fstests" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html --- To unsubscribe from this list: send the line "unsubscribe fstests" 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/common/config b/common/config index 1cb08c0..409f1b8 100644 --- a/common/config +++ b/common/config @@ -464,7 +464,7 @@ get_next_config() { exit 1 fi - if [ ! -z "$SCRATCH_MNT" -a ! -d "$SCRATCH_MNT" ]; then + if [ ! -z "$SCRATCH_MNT" -o ! -d "$SCRATCH_MNT" ]; then echo "common/config: Error: \$SCRATCH_MNT ($SCRATCH_MNT) is not a directory" exit 1 fi