common/rc: factor out _ext4_disable_extent_zeroout() helper

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 <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
Xiao Yang
2017-07-24 18:44:31 +08:00
committed by Eryu Guan
parent 8489391928
commit 22b17d9e4f
6 changed files with 23 additions and 33 deletions
+22 -7
View File
@@ -2295,16 +2295,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`
[ -f /sys/fs/ext4/$sdev/extent_max_zeroout_kb ] && \
echo 0 >/sys/fs/ext4/$sdev/extent_max_zeroout_kb
}
# 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
if [ "$FSTYP" = "ext4" ]; then
_ext4_disable_extent_zeroout $dev
fi
}
_require_runas()
+1 -2
View File
@@ -53,8 +53,7 @@ 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
_ext4_disable_extent_zeroout
fi
# When PAGE_SIZE > 4096 xfs extent layout is different so it would not match
-6
View File
@@ -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.*"
-6
View File
@@ -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.*
-6
View File
@@ -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.*
-6
View File
@@ -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!"