From patchwork Mon Jul 24 09:49:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 9859041 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 1A0ED60385 for ; Mon, 24 Jul 2017 09:49:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B52928403 for ; Mon, 24 Jul 2017 09:49:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 000BD28574; Mon, 24 Jul 2017 09:49:14 +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 3606A28403 for ; Mon, 24 Jul 2017 09:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751359AbdGXJtN (ORCPT ); Mon, 24 Jul 2017 05:49:13 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:24114 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750998AbdGXJtN (ORCPT ); Mon, 24 Jul 2017 05:49:13 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="21718085" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 24 Jul 2017 17:49:11 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id B446646B5DF4; Mon, 24 Jul 2017 17:49:08 +0800 (CST) Received: from localhost.localdomain (10.167.220.81) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 24 Jul 2017 17:49:13 +0800 From: Xiao Yang To: CC: , Xiao Yang Subject: [PATCH] common/rc: factor out _ext4_disable_extent_zeroout() helper Date: Mon, 24 Jul 2017 17:49:07 +0800 Message-ID: <1500889747-12149-1-git-send-email-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20170721070752.GH2478@eguan.usersys.redhat.com> References: <20170721070752.GH2478@eguan.usersys.redhat.com> MIME-Version: 1.0 X-Originating-IP: [10.167.220.81] X-yoursite-MailScanner-ID: B446646B5DF4.AA7F4 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 1) This pattern is repeated in several seek_data/hole tests (e.g. generic/285, generic/436, generic/445 generic/448) and generic/009. A common _ext4_disable_extent_zeroout() helper could be added and applied by generic/009 and _require_seek_data_hole(). 2) On some old kernels(e.g. v3.1-v3.6), when vfs recognizes SEEK_DATA/HOLE flag && ext4 has no extent zeroout tunable in sysfs, these cases may trigger "sysfs entry not found" issue. We can add check if extent_max_zeroout_kb exists on ext4 filesystem. The extent_max_zeroout_kb is introduced by: '67a5da564f97 ("ext4: make the zero-out chunk size tunable")' 3) Declare several vars as local in _require_seek_data_hole(). Signed-off-by: Xiao Yang --- common/rc | 29 ++++++++++++++++++++++------- tests/generic/009 | 7 +------ tests/generic/285 | 6 ------ tests/generic/436 | 6 ------ tests/generic/445 | 6 ------ tests/generic/448 | 6 ------ 6 files changed, 23 insertions(+), 37 deletions(-) diff --git a/common/rc b/common/rc index bd989bb..b36a9bf 100644 --- a/common/rc +++ b/common/rc @@ -2304,16 +2304,31 @@ _require_fail_make_request() not found. Seems that CONFIG_FAIL_MAKE_REQUEST kernel config option not enabled" } -# +# Disable extent zeroing for ext4 on the given device +_ext4_disable_extent_zeroout() +{ + local dev=${1:-$TEST_DEV} + local sdev=`_short_dev $dev` + + if [ "$FSTYP" == "ext4" ]; then + [ -f /sys/fs/ext4/$sdev/extent_max_zeroout_kb ] && \ + echo 0 >/sys/fs/ext4/$sdev/extent_max_zeroout_kb + fi +} + # Check if the file system supports seek_data/hole -# _require_seek_data_hole() { - testfile=$TEST_DIR/$$.seek - testseek=`$here/src/seek_sanity_test -t $testfile 2>&1` - rm -f $testfile &>/dev/null - echo $testseek | grep -q "Kernel does not support" && \ - _notrun "File system does not support llseek(2) SEEK_DATA/HOLE" + local dev=${1:-$TEST_DEV} + local testfile=$TEST_DIR/$$.seek + local testseek=`$here/src/seek_sanity_test -t $testfile 2>&1` + + rm -f $testfile &>/dev/null + echo $testseek | grep -q "Kernel does not support" && \ + _notrun "File system does not support llseek(2) SEEK_DATA/HOLE" + # Disable extent zeroing for ext4 as that change where holes are + # created + _ext4_disable_extent_zeroout $dev } _require_runas() diff --git a/tests/generic/009 b/tests/generic/009 index 5902afd..a7ca060 100755 --- a/tests/generic/009 +++ b/tests/generic/009 @@ -48,15 +48,10 @@ _require_xfs_io_command "fzero" _require_xfs_io_command "fiemap" _require_xfs_io_command "falloc" _require_test +_ext4_disable_extent_zeroout testfile=$TEST_DIR/009.$$ -# Disable extent zeroing for ext4 as that change where holes are created -if [ "$FSTYP" = "ext4" ]; then - DEV=`_short_dev $TEST_DEV` - echo 0 >/sys/fs/ext4/$DEV/extent_max_zeroout_kb -fi - # When PAGE_SIZE > 4096 xfs extent layout is different so it would not match # the output. if [ "$FSTYP" = "xfs" ]; then diff --git a/tests/generic/285 b/tests/generic/285 index 16e70b1..3f7d298 100755 --- a/tests/generic/285 +++ b/tests/generic/285 @@ -47,12 +47,6 @@ BASE_TEST_FILE=$TEST_DIR/seek_sanity_testfile _require_test_program "seek_sanity_test" -# Disable extent zeroing for ext4 as that change where holes are created -if [ "$FSTYP" = "ext4" ]; then - DEV=`_short_dev $TEST_DEV` - echo 0 >/sys/fs/ext4/$DEV/extent_max_zeroout_kb -fi - _cleanup() { eval "rm -f $BASE_TEST_FILE.*" diff --git a/tests/generic/436 b/tests/generic/436 index bcd6ddc..6cda008 100755 --- a/tests/generic/436 +++ b/tests/generic/436 @@ -44,12 +44,6 @@ BASE_TEST_FILE=$TEST_DIR/seek_sanity_testfile _require_test_program "seek_sanity_test" -# Disable extent zeroing for ext4 as that change where holes are created -if [ "$FSTYP" = "ext4" ]; then - DEV=`_short_dev $TEST_DEV` - echo 0 >/sys/fs/ext4/$DEV/extent_max_zeroout_kb -fi - _cleanup() { rm -f $tmp.* $BASE_TEST_FILE.* diff --git a/tests/generic/445 b/tests/generic/445 index 81dd916..323a0ca 100755 --- a/tests/generic/445 +++ b/tests/generic/445 @@ -44,12 +44,6 @@ BASE_TEST_FILE=$TEST_DIR/seek_sanity_testfile _require_test_program "seek_sanity_test" -# Disable extent zeroing for ext4 as that change where holes are created -if [ "$FSTYP" = "ext4" ]; then - DEV=`_short_dev $TEST_DEV` - echo 0 >/sys/fs/ext4/$DEV/extent_max_zeroout_kb -fi - _cleanup() { rm -f $tmp.* $BASE_TEST_FILE.* diff --git a/tests/generic/448 b/tests/generic/448 index 87b99d7..22656f6 100755 --- a/tests/generic/448 +++ b/tests/generic/448 @@ -48,12 +48,6 @@ BASE_TEST_FILE=$TEST_DIR/seek_sanity_testfile_$seq _require_test_program "seek_sanity_test" -# Disable extent zeroing for ext4 as that change where holes are created -if [ "$FSTYP" = "ext4" ]; then - DEV=`_short_dev $TEST_DEV` - echo 0 >/sys/fs/ext4/$DEV/extent_max_zeroout_kb -fi - $here/src/seek_sanity_test -s 18 -e 18 $BASE_TEST_FILE > $seqres.full 2>&1 || _fail "seek sanity check failed!"