From patchwork Wed Nov 15 00:30:37 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: 10058577 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 80FB56023A for ; Wed, 15 Nov 2017 00:30:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 675BE29AB5 for ; Wed, 15 Nov 2017 00:30:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A95C29ACB; Wed, 15 Nov 2017 00:30:42 +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 D167229AB5 for ; Wed, 15 Nov 2017 00:30:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755156AbdKOAak (ORCPT ); Tue, 14 Nov 2017 19:30:40 -0500 Received: from imap.thunk.org ([74.207.234.97]:45760 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755093AbdKOAaj (ORCPT ); Tue, 14 Nov 2017 19:30:39 -0500 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:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=8bFcoRwityncIB4bwcU2O0cfp88kBfJto9uybEfRYtQ=; b=Rq9q6kZnsgnIDWOEinhbGsEUML JHdtJmWlWvOOr7PSbG9K8XTlXuqanza7cf01eZSsC3pYQ7+g8qCZrc9PlYslBFNyygl2DJuiYxJmA M+ZVFO2voF71+5lSBXeRdxlOBXP6jtkILhhS8Hlb4Cwwp/Fa0Dx5NyXP1lL0tAC6ffKI=; Received: from root (helo=callcc.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.89) (envelope-from ) id 1eElbC-0002a9-43; Wed, 15 Nov 2017 00:30:38 +0000 Received: by callcc.thunk.org (Postfix, from userid 15806) id 6351BC002C5; Tue, 14 Nov 2017 19:30:37 -0500 (EST) Date: Tue, 14 Nov 2017 19:30:37 -0500 From: Theodore Ts'o To: Eryu Guan Cc: fstests@vger.kernel.org Subject: [PATCH -v3] common: rework _require_ext4_mkfs_feature Message-ID: <20171115003037.wypomnpzxrmwmspd@thunk.org> References: <20171112133621.2474-1-tytso@mit.edu> <20171114114315.GH17339@eguan.usersys.redhat.com> <20171114233849.fnbutentfj4i7tcs@thunk.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171114233849.fnbutentfj4i7tcs@thunk.org> 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 Tue, Nov 14, 2017 at 06:38:49PM -0500, Theodore Ts'o wrote: > > Sure. How about simply including _require_scratch into the function? Nope, that won't work, since we need _require_scratch_nocheck for one of the tests. OK, here's V3 of the patch. WDYT? - Ted commit b9d9da8b901acc5b6cb5da7149b7e8ce986e436e Author: Theodore Ts'o Date: Sat Nov 11 23:28:51 2017 -0500 common: rework _require_ext4_mkfs_feature In all of the places where we need check to see if mkfs.ext4 can support a set of file system features, we also should be checking to see if the kernel can support those file system features. So rename _require_ext4_mkfs_feature to _require_ext4_feature, and actually format the file system in $SCRATCH. To avoid running mkfs twice in most tests, we will teach the tests to assume that _require_ext4_feature actually leaves $SCRATCH formatted with a file system with those features. Also allow ext4/306 to run on systems where mke2fs doesn't support the "64bit" option. Signed-off-by: Theodore Ts'o --- 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/rc b/common/rc index da6213a0..6f6901c4 100644 --- a/common/rc +++ b/common/rc @@ -1899,31 +1899,23 @@ _require_scratch_ext4_crc() _scratch_unmount } -# Check the specified feature whether it is available in mkfs.ext4 or not. -_require_ext4_mkfs_feature() +# Check whether the specified feature whether it is supported by +# mkfs.ext4 and the kernel. +_require_scratch_ext4_feature() { - local feature=$1 - local testfile=/tmp/$$.ext4_mkfs + local feature="$1" + local sz="$2" if [ -z "$feature" ]; then - echo "Usage: _require_ext4_mkfs_feature feature" + echo "Usage: _require_scratch_ext4_feature feature [size]" exit 1 fi - touch $testfile - local result=$($MKFS_EXT4_PROG -F -O $feature -n $testfile 512m 2>&1) - rm -f $testfile - echo $result | grep -q "Invalid filesystem option" && \ - _notrun "mkfs.ext4 doesn't support $feature feature" -} - -# this test requires the ext4 kernel support bigalloc feature -# -_require_ext4_bigalloc() -{ - $MKFS_EXT4_PROG -F -O bigalloc $SCRATCH_DEV 512m >/dev/null 2>&1 + $MKFS_EXT4_PROG -F $MKFS_OPTIONS -O "$feature" \ + $SCRATCH_DEV $sz >>$seqres.full 2>&1 \ + || _notrun "mkfs.ext4 doesn't support $feature feature" _scratch_mount >/dev/null 2>&1 \ - || _notrun "Ext4 kernel doesn't support bigalloc feature" + || _notrun "Kernel doesn't support the ext4 feature: $feature" _scratch_unmount } diff --git a/tests/ext4/003 b/tests/ext4/003 index 9be40178..bdce00d0 100755 --- a/tests/ext4/003 +++ b/tests/ext4/003 @@ -38,8 +38,7 @@ _supported_fs ext4 _supported_os Linux _require_scratch -_require_ext4_mkfs_feature "bigalloc" -_require_ext4_bigalloc +_require_scratch_ext4_feature "bigalloc" "512m" rm -f $seqres.full diff --git a/tests/ext4/025 b/tests/ext4/025 index 49ecb462..3e32e7f1 100755 --- a/tests/ext4/025 +++ b/tests/ext4/025 @@ -48,10 +48,9 @@ _supported_fs ext4 _supported_os Linux _require_scratch_nocheck _require_command "$DEBUGFS_PROG" debugfs -_require_ext4_mkfs_feature "bigalloc,meta_bg,^resize_inode" +_require_scratch_ext4_feature "bigalloc,meta_bg,^resize_inode" echo "Create ext4 fs and modify first_meta_bg's value" -_scratch_mkfs "-O bigalloc,meta_bg,^resize_inode" >> $seqres.full 2>&1 # set a big enough first_meta_bg to trigger buffer overrun # 842150400 is from original fuzzed ext4 image in bug report diff --git a/tests/ext4/026 b/tests/ext4/026 index 94a737ce..832e4646 100755 --- a/tests/ext4/026 +++ b/tests/ext4/026 @@ -50,9 +50,8 @@ _supported_fs ext4 _supported_os Linux _require_scratch _require_attrs -_require_ext4_mkfs_feature ea_inode +_require_scratch_ext4_feature "ea_inode" -_scratch_mkfs_ext4 -O ea_inode >/dev/null 2>&1 _scratch_mount # Sets an extended attribute on a file. diff --git a/tests/ext4/306 b/tests/ext4/306 index be765e6a..70f281db 100755 --- a/tests/ext4/306 +++ b/tests/ext4/306 @@ -44,12 +44,15 @@ _supported_fs ext4 _supported_os Linux _require_scratch -_require_ext4_mkfs_feature "64bit" rm -f $seqres.full # Make a small ext4 fs with extents disabled & mount it -$MKFS_EXT4_PROG -F -O ^extents,^64bit $SCRATCH_DEV 512m >> $seqres.full 2>&1 +features="^extents" +if grep -q 64bit /etc/mke2fs.conf ; then + features="^extents,^64bit" +fi +$MKFS_EXT4_PROG -F -O "$features" $SCRATCH_DEV 512m >> $seqres.full 2>&1 _scratch_mount || _fail "couldn't mount fs" # Create a small non-extent-based file