From: Ritesh Harjani Date: Thu, 22 Oct 2020 12:16:32 +0000 (+0530) Subject: ext4: verify unwritten extent conversion in buff-io X-Git-Tag: v2022.05.01~630 X-Git-Url: http://git.apps.os.sepia.ceph.com/?p=xfstests-dev.git;a=commitdiff_plain;h=31f6949f385aad3aa3f1f68c8b03fa0ab3469e69 ext4: verify unwritten extent conversion in buff-io There was an issue where with filesize > 4G, map.m_lblk was getting overflow in buff-IO path while converting unwritten to written extent with dioread_nolock mount option with bs < ps. Adding a testcase to test for such regressions with dioread_nolock mount option. To reproduce the same regression w/o the fix in the kernel, test with bs < ps config. The following commit fixed the issue in linux. id1e18b8824dd ("ext4: fix bs < ps issue reported with dioread_nolock mount opt") Signed-off-by: Ritesh Harjani Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- diff --git a/tests/ext4/046 b/tests/ext4/046 new file mode 100755 index 00000000..5524024e --- /dev/null +++ b/tests/ext4/046 @@ -0,0 +1,84 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 IBM Corporation. All Rights Reserved. +# +# FS QA Test No. ext4/046 +# +# Test writes to falloc file with filesize > 4GB and make sure to verify +# the file checksum both before and after mount. +# This test is to check whether unwritten extents gets properly converted +# to written extent on a filesystem with bs < ps with dioread_nolock. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +_supported_fs ext4 +_require_scratch +_require_xfs_io_command "falloc" +_require_scratch_size $((6 * 1024 * 1024)) #kB + +_scratch_mkfs >> $seqres.full 2>&1 +_scratch_mount "-o dioread_nolock" >> $seqres.full 2>&1 + +# Get blksz +blksz=$(_get_file_block_size $SCRATCH_MNT) + +testfile=$SCRATCH_MNT/testfile-$seq + +# Fallocate testfile with size > 4G +fsize=$((5 * 1024 * 1024 * 1024)) +$XFS_IO_PROG -f -c "falloc 0 $fsize" $testfile >> $seqres.full 2>&1 + +# First write at offset < 4G (at few alternative blks) +off=$((3 * 1024 * 1024 * 1024)) +for i in 1 2 3 4; do + $XFS_IO_PROG -f \ + -c "pwrite $off $blksz" \ + $testfile >> $seqres.full 2>&1 + off=$(($off + (2*$blksz))) +done + +# Then write at offset > 4G (at few alternative blks) to check +# any 32bit overflow case in map.m_lblk +off=$((4 * 1024 * 1024 * 1024)) +for i in 1 2 3 4; do + $XFS_IO_PROG -f \ + -c "pwrite $off $blksz" \ + $testfile >> $seqres.full 2>&1 + off=$(($off + (2*$blksz))) +done + +# ==== Pre-Remount === +md5_pre=`md5sum $testfile | cut -d' ' -f1` +echo "Pre-Remount md5sum of $testfile = $md5_pre" >> $seqres.full + +_scratch_cycle_mount + +# ==== Post-Remount === +md5_post=`md5sum $testfile | cut -d' ' -f1` +echo "Post-Remount md5sum of $testfile = $md5_post" >> $seqres.full +test $md5_pre != $md5_post && echo "md5sum mismatch" + +# success, all done +echo "Silence is golden" +status=0 +exit diff --git a/tests/ext4/046.out b/tests/ext4/046.out new file mode 100644 index 00000000..52c445eb --- /dev/null +++ b/tests/ext4/046.out @@ -0,0 +1,2 @@ +QA output created by 046 +Silence is golden diff --git a/tests/ext4/group b/tests/ext4/group index 40351fd9..70c0bca6 100644 --- a/tests/ext4/group +++ b/tests/ext4/group @@ -48,6 +48,7 @@ 043 auto quick 044 auto quick 045 auto dir +046 auto prealloc quick 271 auto rw quick 301 aio auto ioctl rw stress defrag 302 aio auto ioctl rw stress defrag