From: Dave Chinner Date: Tue, 26 Nov 2024 20:48:41 +0000 (+1100) Subject: fstests: use syncfs rather than sync X-Git-Tag: v2024.12.08~29 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f8d5367e01a7c859c3378a76b6afc047728b7652;p=xfstests-dev.git fstests: use syncfs rather than sync sync(1) is a system wide sync and is implemented by iterating all the superblocks in the system. In most cases, fstests require just the filesystem under test to be synced - we require syncfs(2) semantics but what we use is sync(2) semantics. The result of this is that when running many concurrent fstests at the same time, we can have *hundreds* of concurrent sync operations in progress (thanks fsstress!) and this causes excessive interference with other tests that are running on other filesystems. For example, some tests try to specifically control extent layout via specific write and fsync patterns. All these global syncs perturb them and cause them to spuriously fail. A random snapshot of running concurrent tests shows just how many tests are explicitly blocked in sync(1): check-parallel───check───077───077─┬─cut │ ├─du │ └─tail ├─check-parallel───check───311───xfs_scrub───{xfs_scrub} ├─check-parallel───check───531───128*[t_open_tmpfiles] ├─check-parallel───check───227 ├─check-parallel───check───388 ├─check-parallel───check───070───fsstress───fsstress───{fsstress+ ├─check-parallel───check───232───fsstress───7*[fsstress───{fsstr+ ├─check-parallel───check───648───sleep ├─check-parallel───check───409───sync ├─check-parallel───check───683───sync ├─check-parallel───check───013─┬─013───sleep │ └─fsstress───2*[fsstress───{fsstr+ ├─check-parallel───check───684───sync ├─check-parallel───check───673───sync ├─check-parallel───check───118───dd ├─check-parallel───check───467───open_by_handle ├─check-parallel───check─┬─622 │ └─check ├─check-parallel───check───685───sync ├─check-parallel───check───049───fsstress───fsstress───{fsstress+ ├─check-parallel───check───599 ├─check-parallel───check───426───open_by_handle ├─check-parallel───check───057───umount ├─check-parallel───check───390───fsstress─┬─18*[fsstress───{fsst+ │ └─fsstress ├─check-parallel───check───158───fsstress───fsstress───{fsstress+ ├─check-parallel───check───017 ├─check-parallel───check───032───fsstress───fsstress ├─check-parallel───check───076 ├─check-parallel───check───477───open_by_handle ├─check-parallel───check───170───2*[170───170] ├─check-parallel───check───112 ├─check-parallel───check───686───sync ├─4*[check-parallel───check───check───xfs_scrub───{xfs_scrub}] ├─check-parallel───check───387───xfs_io───{xfs_io} ├─check-parallel───check───615───615 ├─check-parallel───check─┬─051 │ └─check───xfs_repair ├─check-parallel───check───049 ├─check-parallel───check───247 ├─check-parallel───check───674───sync ├─check-parallel───check───040 ├─check-parallel───check───560───fsstress───fsstress───{fsstress+ ├─check-parallel───check───030─┬─030─┬─030───xfs_repair │ │ └─030───perl │ ├─sed │ └─uniq ├─check-parallel───check───055───055 ├─2*[check-parallel───check───check] ├─check-parallel───check───042 ├─check-parallel───check───204 ├─check-parallel───check───271─┬─271───sed │ └─md5sum ├─check-parallel───check───091─┬─fsx │ └─tee ├─check-parallel───check───063───sleep ├─check-parallel───check───026 ├─check-parallel───check───459───lvm ├─check-parallel───check───495 ├─check-parallel───check───141───fsstress───4*[fsstress] ├─check-parallel───check───011─┬─fsstress─┬─fsstress───{fsstress+ │ │ └─fsstress │ └─sleep ├─check-parallel───check───328───sync ├─check-parallel───check───507───507 ├─check-parallel───check ├─check-parallel───check───687───sync ├─check-parallel───check───109───mkfs.xfs ├─check-parallel───check───324 ├─check-parallel───check───114───aio-dio-eof-rac └─check-parallel───check───503───xfs_scrub───2*[{xfs_scrub}] There are ~10 sync(1) calls blocked and at least half of the 50-odd fsstress processes currently running are also going to be stuck in sync(2) calls. They are stuck because the superblock iteration has to wait for mount, unmount, freeze, thaw and any other operation that locks a superblock exclusively. When running dozens of tests concurrently, there can be tens of superblocks that are locked exclusively for every second for significant lengths of time. Hence the use of sync has impact on both performance and test behaviour and we need to minimise the amount of sync(1) and sync(2) usage as much as possible. Introduce _test_sync() and _scratch_sync() so we can implement a syncfs mechanism with a fallback to sync(1) if it is not supported without dirtying all the test code unnecessarily. Then convert fsstress to use syncfs(2) in preference to sync(2). This commit changes all the generic and XFS tests to use the new sync functions, other filesystem specific tests will eventually need to be converted to avoid similar problems. Signed-off-by: Dave Chinner Reviewed-by: Zorro lang Signed-off-by: Zorro Lang --- diff --git a/common/encrypt b/common/encrypt index d90a566a..52f23cd0 100644 --- a/common/encrypt +++ b/common/encrypt @@ -686,7 +686,7 @@ _get_ciphertext_block_list() { local file=$1 - sync + _sync_fs $file $XFS_IO_PROG -c fiemap $file | perl -ne ' next if not /^\s*\d+: \[\d+\.\.\d+\]: (\d+)\.\.(\d+)/; print $_ . "," foreach $1..$2;' | sed 's/,$//' diff --git a/common/log b/common/log index ea7e4158..ab7bc9f8 100644 --- a/common/log +++ b/common/log @@ -392,7 +392,7 @@ _create_log_sync() # add some syncs to get the log flushed to disk for file in $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}; do touch $file - sync + _scratch_sync done # unmount the FS diff --git a/common/quota b/common/quota index 3bf7d552..e8748919 100644 --- a/common/quota +++ b/common/quota @@ -336,7 +336,7 @@ _qmount_option() _check_quota_usage() { # Sync to get delalloc to disk - sync + _scratch_sync # kill caches to guarantee removal speculative delalloc # XXX: really need an ioctl instead of this big hammer diff --git a/common/rc b/common/rc index 16c3cf53..2442ef2e 100644 --- a/common/rc +++ b/common/rc @@ -6,6 +6,30 @@ BC="$(type -P bc)" || BC= +# Don't use sync(1) directly if at all possible. In most cases we only need to +# sync the fs under test, so we use syncfs if it is supported to prevent +# disturbance of other tests that may be running concurrently. +_sync_fs() +{ + local dir=$1 + + if [ -e $dir ]; then + $XFS_IO_PROG -rxc "syncfs" $dir > /dev/null 2>&1 + return + fi + sync +} + +_scratch_sync() +{ + _sync_fs $SCRATCH_MNT +} + +_test_sync() +{ + _sync_fs $TEST_DIR +} + # Common execution handling for fsstress invocation. # # We need per-test fsstress binaries because of the way fsstress forks and diff --git a/common/repair b/common/repair index 8945d002..0dae8305 100644 --- a/common/repair +++ b/common/repair @@ -119,7 +119,7 @@ _check_repair() _scratch_mount POSIXLY_CORRECT=yes \ dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd - sync + _scratch_sync rm -f $SCRATCH_MNT/sh _scratch_unmount diff --git a/common/report b/common/report index 0e91e481..7128bbeb 100644 --- a/common/report +++ b/common/report @@ -156,7 +156,7 @@ ENDL cat $report >> "$tmp_fn" fi echo "" >> "$tmp_fn" - sync "$tmp_fn" && mv "$tmp_fn" "$out_fn" + _sync_fs "$tmp_fn" && mv "$tmp_fn" "$out_fn" echo "Xunit report: $out_fn" } diff --git a/common/verity b/common/verity index 59b67e12..11e839d2 100644 --- a/common/verity +++ b/common/verity @@ -335,7 +335,7 @@ _fsv_scratch_corrupt_bytes() local dd_cmds=() local cmd - sync # Sync to avoid unwritten extents + _scratch_sync # Sync to avoid unwritten extents cat > $tmp.bytes local end=$(( offset + $(_get_filesize $tmp.bytes ) )) diff --git a/common/xfs b/common/xfs index 68abfa71..0417a40a 100644 --- a/common/xfs +++ b/common/xfs @@ -1087,7 +1087,7 @@ _scratch_xfs_unmount_dirty() rm -f "$f" echo "test" > "$f" - sync + _scratch_sync _scratch_shutdown _scratch_unmount } diff --git a/ltp/fsstress.c b/ltp/fsstress.c index a6840f28..8b8c9035 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -5241,6 +5241,18 @@ symlink_f(opnum_t opno, long r) void sync_f(opnum_t opno, long r) { + int fd; + + fd = open(homedir, O_RDONLY|O_DIRECTORY); + if (fd < 0) + goto use_sync; + syncfs(fd); + close(fd); + if (verbose) + printf("%d/%lld: syncfs\n", procid, opno); + return; + +use_sync: sync(); if (verbose) printf("%d/%lld: sync\n", procid, opno); diff --git a/tests/generic/015 b/tests/generic/015 index d4f81c7f..3cbb2f2d 100755 --- a/tests/generic/015 +++ b/tests/generic/015 @@ -85,7 +85,7 @@ fi echo "check free space:" -sync +_scratch_sync free2=`_free` if [ -z "$free2" ] diff --git a/tests/generic/029 b/tests/generic/029 index 0af46e89..c6162b0b 100755 --- a/tests/generic/029 +++ b/tests/generic/029 @@ -43,7 +43,7 @@ echo "==== Post-Remount ==" _hexdump $testfile rm -f $testfile -sync +_scratch_sync # second case is to do a mwrite between the truncate to a block on the # same page we are truncating within the EOF. This checks that a mapped diff --git a/tests/generic/030 b/tests/generic/030 index 3f0e5b99..b1b51469 100755 --- a/tests/generic/030 +++ b/tests/generic/030 @@ -48,7 +48,7 @@ echo "==== Post-Remount ==" _hexdump $testfile rm -f $testfile -sync +_scratch_sync # second case is to do a mwrite between the truncate to a block on the # same page we are truncating within the EOF. This checks that a mapped diff --git a/tests/generic/032 b/tests/generic/032 index 63abd62a..30290c72 100755 --- a/tests/generic/032 +++ b/tests/generic/032 @@ -29,7 +29,7 @@ _cleanup() _syncloop() { while [ true ]; do - sync + _scratch_sync done } diff --git a/tests/generic/034 b/tests/generic/034 index 71aae2a0..cd22f330 100755 --- a/tests/generic/034 +++ b/tests/generic/034 @@ -41,7 +41,7 @@ touch $SCRATCH_MNT/test_dir/foo # The intention is that at log recovery time we have a dir entry for 'foo' both # in the fs/subvol tree and in the log tree - this is necessary to trigger the # bug on btrfs. -sync +_scratch_sync touch $SCRATCH_MNT/test_dir/bar $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/test_dir diff --git a/tests/generic/039 b/tests/generic/039 index 5162e85b..00d4e4af 100755 --- a/tests/generic/039 +++ b/tests/generic/039 @@ -44,7 +44,7 @@ echo "hello world" > $SCRATCH_MNT/a/b/foo ln $SCRATCH_MNT/a/b/foo $SCRATCH_MNT/a/b/bar # Make sure all metadata and data are durably persisted. -sync +_scratch_sync # Now remove one of the hard links and fsync the inode. rm -f $SCRATCH_MNT/a/b/bar diff --git a/tests/generic/040 b/tests/generic/040 index eb88e9ee..8b4e3b70 100755 --- a/tests/generic/040 +++ b/tests/generic/040 @@ -60,7 +60,7 @@ for i in `seq 1 3000`; do done # Make sure all metadata and data are durably persisted. -sync +_scratch_sync # Add one more link to the inode that ends up being a btrfs extref and fsync # the inode. diff --git a/tests/generic/041 b/tests/generic/041 index 44701368..6d42d1a2 100755 --- a/tests/generic/041 +++ b/tests/generic/041 @@ -64,7 +64,7 @@ for i in `seq 1 3000`; do done # Make sure all metadata and data are durably persisted. -sync +_scratch_sync # Now remove one link, add a new one with a new name, add another new one with # the same name as the one we just removed and fsync the inode. diff --git a/tests/generic/048 b/tests/generic/048 index 7b28cb05..5c554d50 100755 --- a/tests/generic/048 +++ b/tests/generic/048 @@ -69,7 +69,7 @@ do done # sync, then shutdown immediately after, then remount and test -sync +_scratch_sync _scratch_shutdown _scratch_unmount _scratch_mount diff --git a/tests/generic/049 b/tests/generic/049 index 8e4b9956..94b5afe9 100755 --- a/tests/generic/049 +++ b/tests/generic/049 @@ -66,7 +66,7 @@ do done # sync, then shutdown immediately after, then remount and test -sync +_scratch_sync _scratch_shutdown _scratch_unmount _scratch_mount diff --git a/tests/generic/051 b/tests/generic/051 index 69250cde..5ee4dfdb 100755 --- a/tests/generic/051 +++ b/tests/generic/051 @@ -30,7 +30,7 @@ load_dir=$SCRATCH_MNT/test _run_fsstress_bg -n 10000000 -p $PROCS -d $load_dir sleep $SLEEP_TIME _kill_fsstress -sync +_scratch_sync _scratch_unmount # now mount again, run the load again, this time with a shutdown. @@ -38,7 +38,7 @@ _scratch_mount $XFS_FSR_PROG -v $load_dir >> $seqres.full 2>&1 _run_fsstress_bg -n10000000 -p $PROCS -d $load_dir sleep $SLEEP_TIME -sync +_scratch_sync # now shutdown and unmount sleep 5 diff --git a/tests/generic/054 b/tests/generic/054 index 20e9a1e9..0649b259 100755 --- a/tests/generic/054 +++ b/tests/generic/054 @@ -67,7 +67,7 @@ for s in sync nosync ; do # add some syncs to get the log flushed to disk for file in $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}; do touch $file - sync + _scratch_sync done else # generate some log traffic - but not too much - life gets a little diff --git a/tests/generic/057 b/tests/generic/057 index c92af5dd..c5db8097 100755 --- a/tests/generic/057 +++ b/tests/generic/057 @@ -41,7 +41,7 @@ $XFS_IO_PROG -f -c "pwrite -S 0xaa -b 8K 0 8K" \ $SCRATCH_MNT/foo | _filter_xfs_io # Make sure the file is durably persisted. -sync +_scratch_sync # Append some data to our file, to increase its size. $XFS_IO_PROG -f -c "pwrite -S 0xcc -b 4K 8K 4K" \ diff --git a/tests/generic/059 b/tests/generic/059 index 0d327078..db48de37 100755 --- a/tests/generic/059 +++ b/tests/generic/059 @@ -58,7 +58,7 @@ $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo # that modifies the data or metadata of our file, should update those fields in # the btrfs inode with values that make the next fsync operation write to the # fsync log. -sync +_scratch_sync # Sleep for 1 second, because we want to check that the next punch operations we # do update the file's mtime and ctime. diff --git a/tests/generic/065 b/tests/generic/065 index adf55b75..f7e1e276 100755 --- a/tests/generic/065 +++ b/tests/generic/065 @@ -42,7 +42,7 @@ $XFS_IO_PROG -f -c "pwrite -S 0xaa 0 8K" $SCRATCH_MNT/foo | _filter_xfs_io mkdir $SCRATCH_MNT/mydir # Make sure all metadata and data are durably persisted. -sync +_scratch_sync # Add a hard link to 'foo' inside our test directory and fsync only the # directory. The btrfs fsync implementation had a bug that caused the new diff --git a/tests/generic/066 b/tests/generic/066 index e32e9658..37d04e06 100755 --- a/tests/generic/066 +++ b/tests/generic/066 @@ -48,7 +48,7 @@ $SETFATTR_PROG -n user.attr2 -v val2 $SCRATCH_MNT/foobar $SETFATTR_PROG -n user.attr3 -v val3 $SCRATCH_MNT/foobar # Make sure everything is durably persisted. -sync +_scratch_sync # Now delete the second xattr and fsync the inode. $SETFATTR_PROG -x user.attr2 $SCRATCH_MNT/foobar diff --git a/tests/generic/073 b/tests/generic/073 index 5ebf634f..05df1ea8 100755 --- a/tests/generic/073 +++ b/tests/generic/073 @@ -51,7 +51,7 @@ touch $SCRATCH_MNT/testdir_1/bar mkdir $SCRATCH_MNT/testdir_2 # Make sure everything is durably persisted. -sync +_scratch_sync # Write more 8Kb of data to our file. $XFS_IO_PROG -c "pwrite -S 0xbb 8K 8K" $SCRATCH_MNT/foo | _filter_xfs_io diff --git a/tests/generic/090 b/tests/generic/090 index 36a9ee86..b1ea27bb 100755 --- a/tests/generic/090 +++ b/tests/generic/090 @@ -41,7 +41,7 @@ _mount_flakey $XFS_IO_PROG -f -c "pwrite -S 0xaa 0 32k" \ -c "fsync" \ $SCRATCH_MNT/foo | _filter_xfs_io -sync +_scratch_sync # Add a hard link to our file. # On btrfs this sets the flag BTRFS_INODE_COPY_EVERYTHING on the btrfs inode, @@ -50,7 +50,7 @@ ln $SCRATCH_MNT/foo $SCRATCH_MNT/bar # Sync the filesystem to force a commit of the current btrfs transaction, this # is a necessary condition to trigger the bug on btrfs. -sync +_scratch_sync # Now append more data to our file, increasing its size, and fsync the file. # In btrfs because the inode flag BTRFS_INODE_COPY_EVERYTHING was set and the diff --git a/tests/generic/092 b/tests/generic/092 index d8c22327..3a61f00f 100755 --- a/tests/generic/092 +++ b/tests/generic/092 @@ -36,7 +36,7 @@ _require_congruent_file_oplen $TEST_DIR $((7 * 1048576)) # past i_size $XFS_IO_PROG -f -c "falloc -k 0 10M" -c "pwrite 0 5M" -c "truncate 5M"\ $TEST_DIR/testfile.$seq | _filter_xfs_io -sync +_test_sync $XFS_IO_PROG -c "fiemap -v" $TEST_DIR/testfile.$seq | _filter_fiemap # Now verify that if we truncate up past i_size we don't trim the preallocated diff --git a/tests/generic/098 b/tests/generic/098 index 57de42e9..ff6cf908 100755 --- a/tests/generic/098 +++ b/tests/generic/098 @@ -38,7 +38,7 @@ workout() # Create our test file with some data and durably persist it. $XFS_IO_PROG -t -f -c "pwrite -S 0xaa 0 128K" $SCRATCH_MNT/foo | _filter_xfs_io - sync + _scratch_sync # Append some data to the file, increasing its size, and leave a hole between # the old size and the start offset if the following write. So our file gets @@ -49,7 +49,7 @@ workout() # This is required to trigger a bug in btrfs truncate where it updates on-disk # inode size incorrectly. if [ $need_sync -eq 1 ]; then - sync + _scratch_sync fi # Now truncate our file to a smaller size that is in the middle of the hole we diff --git a/tests/generic/101 b/tests/generic/101 index 2e954357..4295f080 100755 --- a/tests/generic/101 +++ b/tests/generic/101 @@ -49,7 +49,7 @@ $XFS_IO_PROG -f -c "pwrite -S 0xaa 0 64K" \ $XFS_IO_PROG -f -c "pwrite -S 0xee 0 64K" \ -c "pwrite -S 0xff 64K 61K" \ $SCRATCH_MNT/bar | _filter_xfs_io -sync +_scratch_sync # Now truncate our file foo to a smaller size (64Kb) and then truncate it to the # size it had before the shrinking truncate (125Kb). Then fsync our file. If a diff --git a/tests/generic/104 b/tests/generic/104 index 7f294e1b..9af3b558 100755 --- a/tests/generic/104 +++ b/tests/generic/104 @@ -38,7 +38,7 @@ touch $SCRATCH_MNT/testdir/foo touch $SCRATCH_MNT/testdir/bar # Make sure everything done so far is durably persisted. -sync +_scratch_sync # Create one hard link for file foo and another one for file bar. After that # fsync only the file bar. diff --git a/tests/generic/106 b/tests/generic/106 index 2b89ae69..8bcc7575 100755 --- a/tests/generic/106 +++ b/tests/generic/106 @@ -37,7 +37,7 @@ touch $SCRATCH_MNT/testdir/foo ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/bar # Make sure everything done so far is durably persisted. -sync +_scratch_sync # Now remove one of the links, trigger inode eviction and then fsync our # inode. diff --git a/tests/generic/107 b/tests/generic/107 index 177ca59c..8a82d146 100755 --- a/tests/generic/107 +++ b/tests/generic/107 @@ -41,7 +41,7 @@ ln $SCRATCH_MNT/foo $SCRATCH_MNT/testdir/foo2 ln $SCRATCH_MNT/foo $SCRATCH_MNT/testdir/foo3 # Make sure everything done so far is durably persisted. -sync +_scratch_sync # Now we remove one of our file's hardlinks in the directory testdir. unlink $SCRATCH_MNT/testdir/foo3 diff --git a/tests/generic/150 b/tests/generic/150 index 159a53c4..d9a53a5b 100755 --- a/tests/generic/150 +++ b/tests/generic/150 @@ -38,7 +38,7 @@ sz=$((blksz * blks)) nr=7 filesize=$((blksz * nr)) _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full -sync +_test_sync free_blocks0=$(stat -f $testdir -c '%f') echo "Create the reflink copies" diff --git a/tests/generic/151 b/tests/generic/151 index a335b927..d20477ab 100755 --- a/tests/generic/151 +++ b/tests/generic/151 @@ -43,7 +43,7 @@ free_blocks0=$(stat -f $testdir -c '%f') nr=7 filesize=$((blksz * nr)) _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full -sync +_test_sync echo "Create the reflink copies" for i in `seq 2 $nr`; do diff --git a/tests/generic/152 b/tests/generic/152 index 8d87dbac..afcbd6d9 100755 --- a/tests/generic/152 +++ b/tests/generic/152 @@ -44,7 +44,7 @@ free_blocks0=$(stat -f $testdir -c '%f') nr=4 filesize=$((blksz * nr)) _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full -sync +_test_sync echo "Create the reflink copies" for i in `seq 2 $nr`; do diff --git a/tests/generic/157 b/tests/generic/157 index cb914367..24415937 100755 --- a/tests/generic/157 +++ b/tests/generic/157 @@ -54,7 +54,8 @@ seq 1 $((2 * blksz / 250)) | while read f; do done mknod $testdir1/dev1 c 1 3 mkfifo $testdir1/fifo1 -sync +_test_sync +_scratch_sync _filter_enotty() { sed -e 's/Inappropriate ioctl for device/Invalid argument/g' diff --git a/tests/generic/158 b/tests/generic/158 index 171d3c0d..ccee3690 100755 --- a/tests/generic/158 +++ b/tests/generic/158 @@ -55,7 +55,8 @@ seq 1 $((2 * blksz / 250)) | while read f; do done mknod $testdir1/dev1 c 1 3 mkfifo $testdir1/fifo1 -sync +_test_sync +_scratch_sync _filter_enotty() { _filter_dedupe_error | \ diff --git a/tests/generic/159 b/tests/generic/159 index c4dec17c..a2d20622 100755 --- a/tests/generic/159 +++ b/tests/generic/159 @@ -39,7 +39,7 @@ nr=4 filesize=$((blksz * nr)) _pwrite_byte 0x61 0 $sz $testdir1/file1 >> $seqres.full _pwrite_byte 0x61 0 $sz $testdir1/file2 >> $seqres.full -sync +_test_sync do_filter_output() { diff --git a/tests/generic/160 b/tests/generic/160 index fc7a161e..c1f24ddb 100755 --- a/tests/generic/160 +++ b/tests/generic/160 @@ -39,7 +39,7 @@ nr=4 filesize=$((blksz * nr)) _pwrite_byte 0x61 0 $sz $testdir1/file1 >> $seqres.full _pwrite_byte 0x61 0 $sz $testdir1/file2 >> $seqres.full -sync +_test_sync do_filter_output() { diff --git a/tests/generic/171 b/tests/generic/171 index dd56aa79..5c8504d2 100755 --- a/tests/generic/171 +++ b/tests/generic/171 @@ -49,12 +49,12 @@ mkdir $testdir echo "Create a big file and reflink it" _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/bigfile >> $seqres.full 2>&1 _cp_reflink $testdir/bigfile $testdir/clonefile -sync +_scratch_sync echo "Allocate the rest of the space" nr_free=$(stat -f -c '%f' $testdir) _fill_fs $((nr_free * blksz)) $testdir/space $blksz 0 >> $seqres.full 2>&1 -sync +_scratch_sync echo "CoW the big file" out="$(_pwrite_byte 0x62 0 $((blksz * nr_blks)) $testdir/bigfile 2>&1 | \ diff --git a/tests/generic/172 b/tests/generic/172 index c23a1228..17f81780 100755 --- a/tests/generic/172 +++ b/tests/generic/172 @@ -47,11 +47,11 @@ mkdir $testdir echo "Create a big file and reflink it" _pwrite_byte 0x61 0 $file_size $testdir/bigfile >> $seqres.full 2>&1 _cp_reflink $testdir/bigfile $testdir/clonefile -sync +_scratch_sync echo "Allocate the rest of the space" _fill_fs $fs_size $testdir/space $blksz 0 >> $seqres.full 2>&1 -sync +_scratch_sync echo "CoW the big file" out="$(_pwrite_byte 0x62 0 $file_size $testdir/bigfile 2>&1 | \ diff --git a/tests/generic/173 b/tests/generic/173 index 8df3c6df..d7ac7b15 100755 --- a/tests/generic/173 +++ b/tests/generic/173 @@ -49,12 +49,12 @@ mkdir $testdir echo "Create a big file and reflink it" _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/bigfile >> $seqres.full 2>&1 _cp_reflink $testdir/bigfile $testdir/clonefile -sync +_scratch_sync echo "Allocate the rest of the space" nr_free=$(stat -f -c '%f' $testdir) _fill_fs $((blksz * nr_free)) $testdir/space $blksz 0 >> $seqres.full 2>&1 -sync +_scratch_sync echo "mmap CoW the big file" core_ulimit="$(ulimit -c)" diff --git a/tests/generic/174 b/tests/generic/174 index b9c29207..c7c62001 100755 --- a/tests/generic/174 +++ b/tests/generic/174 @@ -50,12 +50,12 @@ mkdir $testdir echo "Create a big file and reflink it" _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/bigfile >> $seqres.full 2>&1 _cp_reflink $testdir/bigfile $testdir/clonefile -sync +_scratch_sync echo "Allocate the rest of the space" nr_free=$(stat -f -c '%f' $testdir) _fill_fs $((blksz * nr_free)) $testdir/space $blksz 0 >> $seqres.full 2>&1 -sync +_scratch_sync echo "CoW the big file" out="$(_pwrite_byte 0x62 0 $((blksz * nr_blks)) $testdir/bigfile -d 2>&1 | \ diff --git a/tests/generic/204 b/tests/generic/204 index 9ef54e23..39483a09 100755 --- a/tests/generic/204 +++ b/tests/generic/204 @@ -9,17 +9,9 @@ . ./common/preamble _begin_fstest metadata rw auto -# Override the default cleanup function. -_cleanup() -{ - rm -f $tmp.* - sync -} - # Import common functions. . ./common/filter - _require_scratch # For xfs, we need to handle the different default log sizes that different diff --git a/tests/generic/247 b/tests/generic/247 index 47ff5c34..a758ae24 100755 --- a/tests/generic/247 +++ b/tests/generic/247 @@ -39,7 +39,7 @@ iosize=1048576 # Initialise file dd if=/dev/zero of=$testfile bs=$iosize count=$loops &> /dev/null [ $? -ne 0 ] && exit -sync +_test_sync # Direct I/O overwriter dd if=/dev/zero of=$testfile oflag=direct bs=$iosize count=$loops conv=notrunc &> /dev/null & diff --git a/tests/generic/250 b/tests/generic/250 index 196a34bb..605d7c8a 100755 --- a/tests/generic/250 +++ b/tests/generic/250 @@ -61,7 +61,7 @@ md5sum $testdir/file2 | _filter_scratch echo "Write and unmount" $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full -sync +_scratch_sync _dmerror_load_error_table $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 \ >> $seqres.full 2>&1 diff --git a/tests/generic/252 b/tests/generic/252 index 3ee2b0a6..ddf950e3 100755 --- a/tests/generic/252 +++ b/tests/generic/252 @@ -64,7 +64,7 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full -sync +_scratch_sync _dmerror_load_error_table $AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full _dmerror_load_working_table diff --git a/tests/generic/265 b/tests/generic/265 index 3c84e2a8..0f165e7e 100755 --- a/tests/generic/265 +++ b/tests/generic/265 @@ -53,7 +53,7 @@ md5sum $testdir/file1 | _filter_scratch md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" -sync +_scratch_sync _dmerror_load_error_table urk=$($XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" \ -c "fdatasync" $testdir/file2 2>&1) diff --git a/tests/generic/266 b/tests/generic/266 index d5675afb..02e290de 100755 --- a/tests/generic/266 +++ b/tests/generic/266 @@ -53,7 +53,7 @@ md5sum $testdir/file1 | _filter_scratch md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" -sync +_scratch_sync _dmerror_load_error_table urk=$($XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" \ -c "fdatasync" $testdir/file2 2>&1) diff --git a/tests/generic/267 b/tests/generic/267 index ddaf1064..48b1981f 100755 --- a/tests/generic/267 +++ b/tests/generic/267 @@ -53,7 +53,7 @@ md5sum $testdir/file1 | _filter_scratch md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" -sync +_scratch_sync _dmerror_load_error_table $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 >> $seqres.full 2>&1 _dmerror_load_working_table diff --git a/tests/generic/268 b/tests/generic/268 index c6068cf4..f46e0b75 100755 --- a/tests/generic/268 +++ b/tests/generic/268 @@ -54,7 +54,7 @@ md5sum $testdir/file1 | _filter_scratch md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" -sync +_scratch_sync _dmerror_load_error_table urk=$($XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" \ -c "fdatasync" $testdir/file2 2>&1) diff --git a/tests/generic/271 b/tests/generic/271 index ce647d15..854ea102 100755 --- a/tests/generic/271 +++ b/tests/generic/271 @@ -54,7 +54,7 @@ md5sum $testdir/file1 | _filter_scratch md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" -sync +_scratch_sync _dmerror_load_error_table urk=$($XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 2>&1) echo $urk >> $seqres.full diff --git a/tests/generic/272 b/tests/generic/272 index 3d2cace9..bc77365d 100755 --- a/tests/generic/272 +++ b/tests/generic/272 @@ -54,7 +54,7 @@ md5sum $testdir/file1 | _filter_scratch md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" -sync +_scratch_sync _dmerror_load_error_table urk=$($XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 2>&1) echo $urk >> $seqres.full diff --git a/tests/generic/273 b/tests/generic/273 index e0ee0483..5100e848 100755 --- a/tests/generic/273 +++ b/tests/generic/273 @@ -92,7 +92,7 @@ _porter() echo "_porter $_suffix not complete" fi - sync + _scratch_sync } _do_workload() diff --git a/tests/generic/274 b/tests/generic/274 index d526a9b7..916c7173 100755 --- a/tests/generic/274 +++ b/tests/generic/274 @@ -50,7 +50,7 @@ echo "Fill fs with 1M IOs; ENOSPC expected" >> $seqres.full dd if=/dev/zero of=$SCRATCH_MNT/tmp1 bs=1M >>$seqres.full 2>&1 echo "Fill fs with 4K IOs; ENOSPC expected" >> $seqres.full dd if=/dev/zero of=$SCRATCH_MNT/tmp2 bs=4K >>$seqres.full 2>&1 -sync +_scratch_sync # Last effort, use O_SYNC echo "Fill fs with 4K DIOs; ENOSPC expected" >> $seqres.full dd if=/dev/zero of=$SCRATCH_MNT/tmp3 bs=4K oflag=sync >>$seqres.full 2>&1 @@ -66,7 +66,7 @@ for i in `seq 1 2 1023`; do dd if=/dev/zero of=$SCRATCH_MNT/test seek=$i bs=4K count=1 conv=notrunc \ >>$seqres.full 2>/dev/null || _fail "failed to write to test file" done -sync +_scratch_sync echo >> $seqres.full echo "Fill in prealloc space; fill holes at offsets:" >> $seqres.full for i in `seq 2 2 1023`; do @@ -74,7 +74,7 @@ for i in `seq 2 2 1023`; do dd if=/dev/zero of=$SCRATCH_MNT/test seek=$i bs=4K count=1 conv=notrunc \ >>$seqres.full 2>/dev/null || _fail "failed to fill test file" done -sync +_scratch_sync echo >> $seqres.full echo "done" diff --git a/tests/generic/275 b/tests/generic/275 index 57de69b8..fbfe1581 100755 --- a/tests/generic/275 +++ b/tests/generic/275 @@ -51,9 +51,9 @@ dd if=/dev/zero of=$SCRATCH_MNT/tmp1 bs=256K count=1 >>$seqres.full 2>&1 # Attempt to completely fill fs dd if=/dev/zero of=$SCRATCH_MNT/tmp2 bs=1M >>$seqres.full 2>&1 -sync +_scratch_sync dd if=/dev/zero of=$SCRATCH_MNT/tmp3 bs=4K >>$seqres.full 2>&1 -sync +_scratch_sync # Last effort, use O_SYNC dd if=/dev/zero of=$SCRATCH_MNT/tmp4 bs=4K oflag=sync >>$seqres.full 2>&1 # Save space usage info to the full file @@ -62,7 +62,7 @@ $DF_PROG $SCRATCH_MNT >>$seqres.full 2>&1 # Should leave approx 256k free rm -f $SCRATCH_MNT/tmp1 -sync +_scratch_sync echo "Post rm space:" >> $seqres.full $DF_PROG $SCRATCH_MNT >>$seqres.full 2>&1 _freespace=`$DF_PROG -k $SCRATCH_MNT | tail -n 1 | awk '{print $5}'` diff --git a/tests/generic/276 b/tests/generic/276 index 3c3e75df..dfd2888c 100755 --- a/tests/generic/276 +++ b/tests/generic/276 @@ -54,7 +54,7 @@ md5sum $testdir/file1 | _filter_scratch md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" -sync +_scratch_sync _dmerror_load_error_table $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 \ >> $seqres.full 2>&1 diff --git a/tests/generic/278 b/tests/generic/278 index 5d9778f9..e303a74c 100755 --- a/tests/generic/278 +++ b/tests/generic/278 @@ -55,7 +55,7 @@ md5sum $testdir/file1 | _filter_scratch md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" -sync +_scratch_sync _dmerror_load_error_table urk=$($XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 2>&1) echo $urk >> $seqres.full diff --git a/tests/generic/279 b/tests/generic/279 index f4dac950..599b4b6d 100755 --- a/tests/generic/279 +++ b/tests/generic/279 @@ -53,7 +53,7 @@ md5sum $testdir/file1 | _filter_scratch md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" -sync +_scratch_sync _dmerror_load_error_table # Insulate ourselves against bash reporting the SIGBUS when we try to modify # the metadata. diff --git a/tests/generic/281 b/tests/generic/281 index 6d48c4b1..474b8b73 100755 --- a/tests/generic/281 +++ b/tests/generic/281 @@ -53,7 +53,7 @@ md5sum $testdir/file1 | _filter_scratch md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" -sync +_scratch_sync _dmerror_load_error_table # Insulate ourselves against bash reporting the SIGBUS when we try to modify # the metadata. diff --git a/tests/generic/282 b/tests/generic/282 index b3eb4806..72797813 100755 --- a/tests/generic/282 +++ b/tests/generic/282 @@ -53,7 +53,7 @@ md5sum $testdir/file1 | _filter_scratch md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" -sync +_scratch_sync _dmerror_load_error_table # Insulate ourselves against bash reporting the SIGBUS when we try to modify # the metadata. diff --git a/tests/generic/283 b/tests/generic/283 index b9104fe6..cdad47a2 100755 --- a/tests/generic/283 +++ b/tests/generic/283 @@ -54,7 +54,7 @@ md5sum $testdir/file1 | _filter_scratch md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" -sync +_scratch_sync _dmerror_load_error_table # Insulate ourselves against bash reporting the SIGBUS when we try to modify # the metadata. diff --git a/tests/generic/315 b/tests/generic/315 index 83f46655..cb660ed2 100755 --- a/tests/generic/315 +++ b/tests/generic/315 @@ -41,7 +41,7 @@ fsize=`_get_filesize $TEST_DIR/testfile.$seq` # Truncate the file size back to 0 truncate -s 0 $TEST_DIR/testfile.$seq -sync +_test_sync # Preallocated disk space should be released avail_done=`df -P $TEST_DIR | awk 'END {print $4}'` diff --git a/tests/generic/317 b/tests/generic/317 index 177d8852..1afec6a7 100755 --- a/tests/generic/317 +++ b/tests/generic/317 @@ -73,7 +73,7 @@ _print_numeric_uid echo "" echo "*** Remounting ***" echo "" -sync +_scratch_sync _scratch_cycle_mount >>$seqres.full 2>&1 || _fail "remount failed" _print_numeric_uid diff --git a/tests/generic/318 b/tests/generic/318 index d31ad2b1..033c0611 100755 --- a/tests/generic/318 +++ b/tests/generic/318 @@ -81,7 +81,7 @@ _print_getfacls echo "*** Remounting ***" echo "" -sync +_scratch_sync _scratch_cycle_mount >>$seqres.full 2>&1 || _fail "remount failed" _print_getfacls diff --git a/tests/generic/325 b/tests/generic/325 index 8fbd0d1d..f8506633 100755 --- a/tests/generic/325 +++ b/tests/generic/325 @@ -42,7 +42,7 @@ $XFS_IO_PROG -f -c "pwrite -S 0xff 0 256K" $SCRATCH_MNT/foo | _filter_xfs_io # Now sync the file data to disk using 'sync' and not an fsync. This is because # in btrfs the first fsync clears the btrfs inode full fsync flag, which must # be set when the first msync below happens in order to trigger the bug. -sync +_scratch_sync # Now update the first 4Kb and the last 4Kb of the file, using memory mapped IO # because an msync(), since the linux kernel commit diff --git a/tests/generic/328 b/tests/generic/328 index 25e1f2a0..7071ded2 100755 --- a/tests/generic/328 +++ b/tests/generic/328 @@ -62,12 +62,12 @@ _report_quota_blocks $SCRATCH_MNT echo "Try to dio write the whole file" _pwrite_byte 0x62 0 $sz $testdir/file1 -d >> $seqres.full -sync +_scratch_sync _report_quota_blocks $SCRATCH_MNT echo "Try to write the whole file" _pwrite_byte 0x62 0 $sz $testdir/file3 >> $seqres.full -sync +_scratch_sync _report_quota_blocks $SCRATCH_MNT # success, all done diff --git a/tests/generic/329 b/tests/generic/329 index ab37e047..e4300f92 100755 --- a/tests/generic/329 +++ b/tests/generic/329 @@ -57,7 +57,7 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full -sync +_scratch_sync _dmerror_load_error_table $AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full _dmerror_load_working_table diff --git a/tests/generic/330 b/tests/generic/330 index 4fa81f99..c67defc4 100755 --- a/tests/generic/330 +++ b/tests/generic/330 @@ -51,7 +51,7 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full -sync +_scratch_sync $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full $AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full _scratch_cycle_mount diff --git a/tests/generic/331 b/tests/generic/331 index c1949e1b..fe12ec4e 100755 --- a/tests/generic/331 +++ b/tests/generic/331 @@ -57,7 +57,7 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full -sync +_scratch_sync _dmerror_load_error_table $AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full $XFS_IO_PROG -c "fdatasync" $testdir/file2 diff --git a/tests/generic/332 b/tests/generic/332 index 4a61e4a0..cb15e77b 100755 --- a/tests/generic/332 +++ b/tests/generic/332 @@ -52,7 +52,7 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full -sync +_scratch_sync $AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full _scratch_cycle_mount diff --git a/tests/generic/335 b/tests/generic/335 index 280cf853..f287b515 100755 --- a/tests/generic/335 +++ b/tests/generic/335 @@ -38,7 +38,7 @@ mkdir $SCRATCH_MNT/c touch $SCRATCH_MNT/a/b/foo # Make sure everything is durably persisted. -sync +_scratch_sync # Now move our test file into a new parent directory. mv $SCRATCH_MNT/a/b/foo $SCRATCH_MNT/c/ diff --git a/tests/generic/336 b/tests/generic/336 index 47808197..06391a93 100755 --- a/tests/generic/336 +++ b/tests/generic/336 @@ -43,7 +43,7 @@ ln $SCRATCH_MNT/a/foo $SCRATCH_MNT/b/foo_link touch $SCRATCH_MNT/b/bar # Make sure everything is durably persisted. -sync +_scratch_sync # Now delete one of the hard links of file foo and move file bar into c/ unlink $SCRATCH_MNT/b/foo_link diff --git a/tests/generic/341 b/tests/generic/341 index bea36e26..80fdcbac 100755 --- a/tests/generic/341 +++ b/tests/generic/341 @@ -36,7 +36,7 @@ mkdir -p $SCRATCH_MNT/a/x $XFS_IO_PROG -f -c "pwrite -S 0xaf 0 32K" $SCRATCH_MNT/a/x/foo | _filter_xfs_io $XFS_IO_PROG -f -c "pwrite -S 0xba 0 32K" $SCRATCH_MNT/a/x/bar | _filter_xfs_io # Make sure everything done so far is durably persisted. -sync +_scratch_sync echo "File digests before power failure:" md5sum $SCRATCH_MNT/a/x/foo | _filter_scratch diff --git a/tests/generic/342 b/tests/generic/342 index 3f5aca67..a7aca860 100755 --- a/tests/generic/342 +++ b/tests/generic/342 @@ -40,7 +40,7 @@ _mount_flakey mkdir $SCRATCH_MNT/a $XFS_IO_PROG -f -c "pwrite -S 0xf1 0 16K" $SCRATCH_MNT/a/foo | _filter_xfs_io # Make sure everything done so far is durably persisted. -sync +_scratch_sync # Now rename file foo to bar and create a new file named foo under the same # directory. After a power failure we must see the two files. diff --git a/tests/generic/343 b/tests/generic/343 index 6659f198..97ff4f98 100755 --- a/tests/generic/343 +++ b/tests/generic/343 @@ -41,7 +41,7 @@ mkdir $SCRATCH_MNT/y/z touch $SCRATCH_MNT/y/foo2 # Make sure everything is durably persisted. -sync +_scratch_sync # Now add a link to foo at directory x, move directory z and file foo2 from # directory y to directory x and fsync foo's inode. We expect that after a diff --git a/tests/generic/347 b/tests/generic/347 index 7e1ea5d9..5c0e3f94 100755 --- a/tests/generic/347 +++ b/tests/generic/347 @@ -36,7 +36,7 @@ _workout() $XFS_IO_PROG -f -c "pwrite -W 0 1M" $SCRATCH_MNT/file$I &>/dev/null done - sync + _scratch_sync _dmthin_grow $GROW_SIZE diff --git a/tests/generic/348 b/tests/generic/348 index eb0587d2..1905a6e6 100755 --- a/tests/generic/348 +++ b/tests/generic/348 @@ -35,7 +35,7 @@ _mount_flakey mkdir $SCRATCH_MNT/testdir1 # Make sure it's durably persisted. -sync +_scratch_sync # Create our symlinks and fsync their parent directories. # We test both the case where the parent directory is new (not yet durably diff --git a/tests/generic/353 b/tests/generic/353 index ac5b9788..2114a74c 100755 --- a/tests/generic/353 +++ b/tests/generic/353 @@ -48,7 +48,7 @@ cmp -s $extmap1 $extmap2 || echo "mismatched extent maps before sync" # sync and recheck, to make sure the fiemap doesn't change just # due to sync -sync +_scratch_sync $XFS_IO_PROG -c "fiemap -v" $file1 | _filter_fiemap_flags > $extmap1 $XFS_IO_PROG -c "fiemap -v" $file2 | _filter_fiemap_flags > $extmap2 diff --git a/tests/generic/376 b/tests/generic/376 index cecd4e0d..17a5f290 100755 --- a/tests/generic/376 +++ b/tests/generic/376 @@ -36,7 +36,7 @@ _mount_flakey mkdir $SCRATCH_MNT/dir touch $SCRATCH_MNT/dir/foo # Make sure everything is durably persisted. -sync +_scratch_sync mv $SCRATCH_MNT/dir/foo $SCRATCH_MNT/dir/bar touch $SCRATCH_MNT/dir/foo $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/dir/bar diff --git a/tests/generic/382 b/tests/generic/382 index 162da41d..1634d85d 100755 --- a/tests/generic/382 +++ b/tests/generic/382 @@ -56,7 +56,7 @@ do_test() for ((i=0; i<30; i++));do _user_do "echo -n > ${SCRATCH_MNT}/file${i}" done - sync + _scratch_sync rm -f ${SCRATCH_MNT}/* >/dev/null 2>&1 } diff --git a/tests/generic/387 b/tests/generic/387 index 544e7552..c3b97249 100755 --- a/tests/generic/387 +++ b/tests/generic/387 @@ -37,7 +37,7 @@ done # consume all remaining free space dd if=/dev/zero of=$SCRATCH_MNT/space >/dev/null 2>&1 -sync +_scratch_sync # fs is full now and fs internal operations may need some free space, for # example, in btrfs, transaction will need to reserve space first, so here free diff --git a/tests/generic/391 b/tests/generic/391 index d19c4826..e41f644d 100755 --- a/tests/generic/391 +++ b/tests/generic/391 @@ -38,7 +38,7 @@ for ((off = 0; off < num_extents * extent_size; off += extent_size)); do done # To reproduce the Btrfs bug, the extent map must not be cached in memory. -sync +_test_sync echo 3 > /proc/sys/vm/drop_caches "$here/src/dio-interleaved" "$extent_size" "$num_extents" "$testfile" diff --git a/tests/generic/409 b/tests/generic/409 index ab7e7eb5..ac1b14ad 100755 --- a/tests/generic/409 +++ b/tests/generic/409 @@ -58,7 +58,7 @@ fs_stress() -f getdents=1 \ -f fiemap=1 \ -d $target - sync + _sync_fs $target } # prepare some mountpoint dir diff --git a/tests/generic/410 b/tests/generic/410 index f0f0921b..e0d0c57e 100755 --- a/tests/generic/410 +++ b/tests/generic/410 @@ -66,7 +66,7 @@ fs_stress() -f getdents=1 \ -f fiemap=1 \ -d $target - sync + _sync_fs $target } # prepare some mountpoint dir diff --git a/tests/generic/411 b/tests/generic/411 index 3b55b4f9..0a80554c 100755 --- a/tests/generic/411 +++ b/tests/generic/411 @@ -49,7 +49,7 @@ fs_stress() -f getdents=1 \ -f fiemap=1 \ -d $target - sync + _sync_fs $target } # prepare some mountpoint dir diff --git a/tests/generic/416 b/tests/generic/416 index 31a85c83..f6a516fb 100755 --- a/tests/generic/416 +++ b/tests/generic/416 @@ -52,7 +52,7 @@ _scratch_remount # remove all files with odd file names, which should free near half # of the space rm $SCRATCH_MNT/*[13579] -sync +_scratch_sync # We should be able to write at least 1/8 of the whole fs size # The number 1/8 is for btrfs, which only has about 47M for data. diff --git a/tests/generic/422 b/tests/generic/422 index 71a0e5a8..ad37b9ce 100755 --- a/tests/generic/422 +++ b/tests/generic/422 @@ -34,7 +34,7 @@ $XFS_IO_PROG -f \ touch $SCRATCH_MNT/foo4 # Make sure everything done so far is durably persisted. -sync +_scratch_sync # Now overwrite the extent of the first file. $XFS_IO_PROG -c "pwrite -S 0xff 0 64K" $SCRATCH_MNT/foo1 | _filter_xfs_io @@ -77,7 +77,7 @@ space_used > $SCRATCH_MNT/$seq.before cat $SCRATCH_MNT/$seq.before ) >> $seqres.full -sync +_scratch_sync # We expect the same file sizes reported by 'du' after writeback finishes. diff --git a/tests/generic/425 b/tests/generic/425 index 3367a956..352ae32d 100755 --- a/tests/generic/425 +++ b/tests/generic/425 @@ -52,7 +52,7 @@ while [ $i -lt $max_attrs ]; do $SETFATTR_PROG -n "user.$n" -v "$n" $testfile > $seqres.full 2>&1 || break i=$((i + 1)) done -sync +_scratch_sync echo "Check attr extent counts" f1=$(_count_attr_extents $testfile) diff --git a/tests/generic/461 b/tests/generic/461 index 95dd6a34..a2927f85 100755 --- a/tests/generic/461 +++ b/tests/generic/461 @@ -27,7 +27,7 @@ load_dir=$SCRATCH_MNT/test _run_fsstress_bg -n10000000 -p $PROCS -d $load_dir sleep $SLEEP_TIME -sync +_scratch_sync # now shutdown and unmount sleep 5 diff --git a/tests/generic/474 b/tests/generic/474 index 2fa087a8..961d0f06 100755 --- a/tests/generic/474 +++ b/tests/generic/474 @@ -36,7 +36,7 @@ _scratch_mount # accelerates syncfs on testing filesystem so that test case can finish # in 30 seconds. -sync +_scratch_sync # Large fs has a huge size .use_space file, will take long time on running # fssum $SCRATCH_MNT. So change the target path to a sub-dir of $SCRATCH_MNT. @@ -47,7 +47,7 @@ $XFS_IO_PROG -f -c "pwrite 0 4K" $localdir/testfile >/dev/null 2>&1 # fssum used for comparing checksum of test file(data & metedata), # exclude checking about atime, block structure, open error. $FSSUM_PROG -ugomAcdES -f -w $tmp.fssum $localdir -$XFS_IO_PROG -c "syncfs" $localdir/testfile >/dev/null 2>&1 +_sync_fs $localdir/testfile _scratch_shutdown _scratch_cycle_mount $FSSUM_PROG -r $tmp.fssum $localdir diff --git a/tests/generic/479 b/tests/generic/479 index 7f4aab4e..650c921b 100755 --- a/tests/generic/479 +++ b/tests/generic/479 @@ -53,7 +53,7 @@ run_test() _fail "Invalid file type argument: $file_type" esac # Make sure everything done so far is durably persisted. - sync + _scratch_sync # Create a file and fsync it just to create a journal/log. This file # must be in the same directory as our special file "foo". diff --git a/tests/generic/480 b/tests/generic/480 index 975c990f..6c599446 100755 --- a/tests/generic/480 +++ b/tests/generic/480 @@ -38,7 +38,7 @@ touch $SCRATCH_MNT/testdir/foo ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/bar # Make sure everything done so far is durably persisted. -sync +_scratch_sync # Now remove of the links of our file and create a new file with the same name # and in the same parent directory, and finally fsync this new file. diff --git a/tests/generic/483 b/tests/generic/483 index 60f9b109..a71f96ad 100755 --- a/tests/generic/483 +++ b/tests/generic/483 @@ -57,7 +57,7 @@ $XFS_IO_PROG -f -c "pwrite -S 0xf1 0 256K" \ $SCRATCH_MNT/baz >/dev/null # Make sure everything done so far is durably persisted. -sync +_scratch_sync # Allocate an extent beyond the size of the first test file and fsync it. $XFS_IO_PROG -c "falloc -k 256K 1M"\ diff --git a/tests/generic/489 b/tests/generic/489 index 62aa45a8..e76055fa 100755 --- a/tests/generic/489 +++ b/tests/generic/489 @@ -39,7 +39,7 @@ $SETFATTR_PROG -n user.xa3 -v test $SCRATCH_MNT/foobar $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foobar # Call sync to commit all fileystem metadata. -sync +_scratch_sync $XFS_IO_PROG -c "pwrite -S 0xea 0 64K" \ -c "fsync" \ diff --git a/tests/generic/502 b/tests/generic/502 index f6374f67..f488bd06 100755 --- a/tests/generic/502 +++ b/tests/generic/502 @@ -46,7 +46,7 @@ touch $SCRATCH_MNT/testdir/foo ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/bar # Make sure everything done so far is durably persisted. -sync +_scratch_sync # Now rename the first hard link (foo) to a new name and rename the second hard # link (bar) to the old name of the first hard link (foo). diff --git a/tests/generic/505 b/tests/generic/505 index a2596735..eb44573b 100755 --- a/tests/generic/505 +++ b/tests/generic/505 @@ -40,7 +40,7 @@ do_check() touch $testfile if [ "$1" == "sync" ]; then - sync + _scratch_sync fi chown 100 $testfile diff --git a/tests/generic/506 b/tests/generic/506 index 9a41e563..397e93d0 100755 --- a/tests/generic/506 +++ b/tests/generic/506 @@ -45,7 +45,7 @@ do_check() touch $testfile if [ "$1" == "sync" ]; then - sync + _scratch_sync fi $XFS_IO_PROG -x -c "chproj 100" $testfile diff --git a/tests/generic/507 b/tests/generic/507 index 6678e50f..b9e58067 100755 --- a/tests/generic/507 +++ b/tests/generic/507 @@ -59,7 +59,7 @@ do_check() if [ "$2" == "sync" ]; then echo "sync" >> $seqres.full - sync + _scratch_sync fi echo "Test chattr +$1" >> $seqres.full diff --git a/tests/generic/508 b/tests/generic/508 index 4e234160..02023cf0 100755 --- a/tests/generic/508 +++ b/tests/generic/508 @@ -44,7 +44,7 @@ do_check() touch $testfile if [ "$1" == "sync" ]; then - sync + _scratch_sync fi before=`$XFS_IO_PROG -f $testfile -c "statx -v" | grep btime` diff --git a/tests/generic/510 b/tests/generic/510 index 5ea0e067..abf18f1b 100755 --- a/tests/generic/510 +++ b/tests/generic/510 @@ -39,7 +39,7 @@ mkdir $SCRATCH_MNT/testdir/B touch $SCRATCH_MNT/testdir/B/bar # Make sure everything done so far is durably persisted. -sync +_scratch_sync # Now move our file bar from directory B to directory A and then replace # directory B with directory A, also renaming directory A to B. Finally diff --git a/tests/generic/520 b/tests/generic/520 index 00fa050e..f2523fca 100755 --- a/tests/generic/520 +++ b/tests/generic/520 @@ -125,7 +125,7 @@ test_link_sync() mkdir -p "${dest%/*}" touch $src ln $src $dest - sync + _scratch_sync before=`stat "$stat_opt" $src` check_consistency $src 0 diff --git a/tests/generic/526 b/tests/generic/526 index 7d47cf11..af77ccaf 100755 --- a/tests/generic/526 +++ b/tests/generic/526 @@ -43,7 +43,7 @@ echo -n "foo" > $SCRATCH_MNT/testdir/fname1 echo -n "hello" > $SCRATCH_MNT/testdir/fname2 # Make sure everything done so far is durably persisted. -sync +_scratch_sync # Rename and link files such that one new name corresponds to the name of # another renamed file and one new file has the old name of one of the renamed diff --git a/tests/generic/527 b/tests/generic/527 index 2ba1f319..90555077 100755 --- a/tests/generic/527 +++ b/tests/generic/527 @@ -49,7 +49,7 @@ ln $SCRATCH_MNT/testdir2/zz $SCRATCH_MNT/testdir2/zz_link echo -n "hello" > $SCRATCH_MNT/testdir2/a # Make sure everything done so far is durably persisted. -sync +_scratch_sync # Rename, remove and link files such that one new name corresponds to the name # of a deleted file and one new file has the old name of the renamed file. Then diff --git a/tests/generic/535 b/tests/generic/535 index c2338da6..98e2f238 100755 --- a/tests/generic/535 +++ b/tests/generic/535 @@ -59,7 +59,7 @@ do_check() echo "Test chmod $target" >> $seqres.full chmod 777 $target - sync + _scratch_sync chmod 755 $target $XFS_IO_PROG $target -c "fsync" diff --git a/tests/generic/546 b/tests/generic/546 index 97288685..ab4ea657 100755 --- a/tests/generic/546 +++ b/tests/generic/546 @@ -47,7 +47,7 @@ _pwrite_byte 0x00 0 512m "$SCRATCH_MNT/padding" >> $seqres.full 2>&1 # Sync to ensure that padding file reach disk so that at log recovery we # still have no data space -sync +_scratch_sync # This should not fail _pwrite_byte 0xcd 1m 16m "$SCRATCH_MNT/foobar" >> $seqres.full diff --git a/tests/generic/556 b/tests/generic/556 index d3396ae3..279ff58b 100755 --- a/tests/generic/556 +++ b/tests/generic/556 @@ -366,7 +366,7 @@ test_toplevel_dir_rename() # 'f2fs: don't use casefolded comparison for "." and ".."'. mkdir ${dir} _casefold_set_attr ${dir} - sync + _scratch_sync echo 2 > /proc/sys/vm/drop_caches mv ${dir} ${dir}.new } diff --git a/tests/generic/579 b/tests/generic/579 index 4187ab0f..d5fab489 100755 --- a/tests/generic/579 +++ b/tests/generic/579 @@ -86,7 +86,7 @@ done ( while [ ! -e $tmp.done ]; do sleep 2.$((RANDOM % 100)) - sync && echo 3 > /proc/sys/vm/drop_caches + _scratch_sync && echo 3 > /proc/sys/vm/drop_caches done ) & diff --git a/tests/generic/589 b/tests/generic/589 index 969a8ac6..b5860070 100755 --- a/tests/generic/589 +++ b/tests/generic/589 @@ -48,7 +48,7 @@ fs_stress() local target=$1 _run_fsstress -n 50 -p 3 -d $target - sync + _sync_fs $target } # prepare some mountpoint dir diff --git a/tests/generic/599 b/tests/generic/599 index e1454584..a8eb9370 100755 --- a/tests/generic/599 +++ b/tests/generic/599 @@ -24,7 +24,7 @@ _scratch_mount localdir=$SCRATCH_MNT/dir mkdir $localdir -sync +_scratch_sync # fssum used for comparing checksum of test file(data & metedata), # exclude checking about atime, block structure, open error. diff --git a/tests/generic/610 b/tests/generic/610 index 22f28c6d..00a676e6 100755 --- a/tests/generic/610 +++ b/tests/generic/610 @@ -30,7 +30,7 @@ $here/src/punch-alternating $SCRATCH_MNT/foobar >>$seqres.full # For btrfs, trigger a transaction commit to force metadata COW for the # following fallocate zero range operation. -sync +_scratch_sync $XFS_IO_PROG -c "fzero 0 100M" $SCRATCH_MNT/foobar diff --git a/tests/generic/628 b/tests/generic/628 index 8fd44364..6f891abc 100755 --- a/tests/generic/628 +++ b/tests/generic/628 @@ -54,7 +54,7 @@ $XFS_IO_PROG -f -c 'pwrite -S 0x59 0 1m -b 1m' $SCRATCH_MNT/c >> $seqres.full _cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/e _cp_reflink $SCRATCH_MNT/c $SCRATCH_MNT/d touch $SCRATCH_MNT/b -sync +_scratch_sync # Test that reflink forces dirty data/metadata to disk when destination file # opened with O_SYNC @@ -81,7 +81,7 @@ rm -f $SCRATCH_MNT/b $SCRATCH_MNT/d _cp_reflink $SCRATCH_MNT/c $SCRATCH_MNT/d touch $SCRATCH_MNT/b chattr +S $SCRATCH_MNT/b $SCRATCH_MNT/d -sync +_scratch_sync # Test that reflink forces dirty data/metadata to disk when destination file # has the sync iflag set diff --git a/tests/generic/629 b/tests/generic/629 index 92b7839a..1088e50e 100755 --- a/tests/generic/629 +++ b/tests/generic/629 @@ -50,7 +50,7 @@ md5sum $SCRATCH_MNT/0 | _filter_scratch # Set up initial files for copy test $XFS_IO_PROG -f -c 'pwrite -S 0x58 0 1m -b 1m' $SCRATCH_MNT/a >> $seqres.full touch $SCRATCH_MNT/b -sync +_scratch_sync # Test that unaligned copy file range forces dirty data/metadata to disk when # destination file opened with O_SYNC @@ -66,7 +66,7 @@ md5sum $SCRATCH_MNT/a $SCRATCH_MNT/b | _filter_scratch rm -f $SCRATCH_MNT/b touch $SCRATCH_MNT/b chattr +S $SCRATCH_MNT/b -sync +_scratch_sync # Test that unaligned copy file range forces dirty data/metadata to disk when # destination file has the sync iflag set diff --git a/tests/generic/640 b/tests/generic/640 index 038dde97..c3b33746 100755 --- a/tests/generic/640 +++ b/tests/generic/640 @@ -38,7 +38,7 @@ mkdir $SCRATCH_MNT/B echo -n "hello world" > $SCRATCH_MNT/A/foo # Persist everything done so far. -sync +_scratch_sync # Add some new file to directory A and fsync the directory. touch $SCRATCH_MNT/A/bar diff --git a/tests/generic/673 b/tests/generic/673 index 1230b51e..8f6def9c 100755 --- a/tests/generic/673 +++ b/tests/generic/673 @@ -28,7 +28,7 @@ setup_testfile() { _pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full _pwrite_byte 0x57 0 1m $SCRATCH_MNT/b >> $seqres.full chmod a+r $SCRATCH_MNT/b - sync + _scratch_sync } commit_and_check() { diff --git a/tests/generic/674 b/tests/generic/674 index 2e395290..1b711f27 100755 --- a/tests/generic/674 +++ b/tests/generic/674 @@ -29,7 +29,7 @@ setup_testfile() { _pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full _pwrite_byte 0x58 0 1m $SCRATCH_MNT/b >> $seqres.full chmod a+r $SCRATCH_MNT/b - sync + _scratch_sync } commit_and_check() { diff --git a/tests/generic/675 b/tests/generic/675 index 7c062db8..e66de84b 100755 --- a/tests/generic/675 +++ b/tests/generic/675 @@ -33,7 +33,7 @@ setup_testfile() { _pwrite_byte 0x57 0 1m $SCRATCH_MNT/b >> $seqres.full chmod a+rwx $SCRATCH_MNT/a $SCRATCH_MNT/b $SETCAP_PROG cap_setgid,cap_setuid+ep $SCRATCH_MNT/a - sync + _scratch_sync } commit_and_check() { diff --git a/tests/generic/677 b/tests/generic/677 index f2081c34..86099454 100755 --- a/tests/generic/677 +++ b/tests/generic/677 @@ -62,7 +62,7 @@ $XFS_IO_PROG -c "falloc -k 20M 1M" $SCRATCH_MNT/foo # On btrfs this commits the current transaction and it makes all the created # extents to have a generation lower than the generation of the transaction used # by the next write and fsync. -sync +_scratch_sync # Now overwrite only the first extent. # On btrfs, due to COW (both data and metadata), that results in modifying only diff --git a/tests/generic/683 b/tests/generic/683 index cf1ebbc4..cc9a9786 100755 --- a/tests/generic/683 +++ b/tests/generic/683 @@ -36,7 +36,7 @@ chmod a+rw $junk_dir/ setup_testfile() { rm -f $junk_file _pwrite_byte 0x58 0 192k $junk_file >> $seqres.full - sync + _test_sync } commit_and_check() { diff --git a/tests/generic/684 b/tests/generic/684 index e1eb4e11..2ca036fe 100755 --- a/tests/generic/684 +++ b/tests/generic/684 @@ -36,7 +36,7 @@ chmod a+rw $junk_dir/ setup_testfile() { rm -f $junk_file _pwrite_byte 0x58 0 192k $junk_file >> $seqres.full - sync + _test_sync } commit_and_check() { diff --git a/tests/generic/685 b/tests/generic/685 index bec2c5a0..de07a798 100755 --- a/tests/generic/685 +++ b/tests/generic/685 @@ -36,7 +36,7 @@ chmod a+rw $junk_dir/ setup_testfile() { rm -f $junk_file _pwrite_byte 0x58 0 192k $junk_file >> $seqres.full - sync + _test_sync } commit_and_check() { diff --git a/tests/generic/686 b/tests/generic/686 index efcc3f61..fc6761fe 100755 --- a/tests/generic/686 +++ b/tests/generic/686 @@ -36,7 +36,7 @@ chmod a+rw $junk_dir/ setup_testfile() { rm -f $junk_file _pwrite_byte 0x58 0 192k $junk_file >> $seqres.full - sync + _test_sync } commit_and_check() { diff --git a/tests/generic/687 b/tests/generic/687 index e05f0fdc..82dce88b 100755 --- a/tests/generic/687 +++ b/tests/generic/687 @@ -36,7 +36,7 @@ chmod a+rw $junk_dir/ setup_testfile() { rm -f $junk_file _pwrite_byte 0x58 0 192k $junk_file >> $seqres.full - sync + _test_sync } commit_and_check() { diff --git a/tests/generic/688 b/tests/generic/688 index 9c19356d..e491d5cf 100755 --- a/tests/generic/688 +++ b/tests/generic/688 @@ -40,7 +40,7 @@ setup_testfile() { touch $junk_file chmod a+rwx $junk_file $SETCAP_PROG cap_setgid,cap_setuid+ep $junk_file - sync + _test_sync } commit_and_check() { diff --git a/tests/generic/690 b/tests/generic/690 index ba0da30d..ef5bd198 100755 --- a/tests/generic/690 +++ b/tests/generic/690 @@ -52,7 +52,7 @@ _mount_flakey mkdir "$SCRATCH_MNT"/testdir # Commit the current transaction and persist the directory. -sync +_scratch_sync # Create a file in the test directory, so that the next fsync on the directory # actually does something (it logs the directory). diff --git a/tests/generic/694 b/tests/generic/694 index a68fc523..e5c4f88c 100755 --- a/tests/generic/694 +++ b/tests/generic/694 @@ -39,7 +39,7 @@ fi # make sure indirect block reservations and other temporary block reservations # are released before sampling i_blocks -sync $junk_file +_test_sync iblocks=`stat -c '%b' $junk_file` diff --git a/tests/generic/695 b/tests/generic/695 index 8179d59a..df81fdb7 100755 --- a/tests/generic/695 +++ b/tests/generic/695 @@ -51,7 +51,7 @@ $XFS_IO_PROG -f -c "truncate 12M" \ $SCRATCH_MNT/foobar | _filter_xfs_io # Persist everything, commit the filesystem's transaction. -sync +_scratch_sync # Now punch two holes in the file: # diff --git a/tests/generic/703 b/tests/generic/703 index 8ee1d558..2bace19d 100755 --- a/tests/generic/703 +++ b/tests/generic/703 @@ -70,7 +70,7 @@ fi $XFS_IO_PROG -c "falloc 0 256M" $test_file # Persist everything, make sure the file exists after power failure. -sync +_scratch_sync echo -e "Running fio with config:\n" >> $seqres.full cat $fio_config >> $seqres.full diff --git a/tests/generic/716 b/tests/generic/716 index a2b86225..d3923dc1 100755 --- a/tests/generic/716 +++ b/tests/generic/716 @@ -36,7 +36,7 @@ filesnap() { mkfile() { rm -f $dir/a _pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full - sync + _test_sync } dir=$TEST_DIR/test-$seq diff --git a/tests/generic/718 b/tests/generic/718 index ed3a1fee..4d322b22 100755 --- a/tests/generic/718 +++ b/tests/generic/718 @@ -31,7 +31,7 @@ nrblks=64 # Create some 4M files to test exchangerange _pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full _pwrite_byte 0x59 0 $((blksz * nrblks)) $dir/b >> $seqres.full -sync +_test_sync md5sum $dir/a $dir/b | _filter_test_dir # Set FSIZE to twice the blocksize (IOWs, 128k) diff --git a/tests/generic/719 b/tests/generic/719 index c82cf955..9cd6eed9 100755 --- a/tests/generic/719 +++ b/tests/generic/719 @@ -34,7 +34,7 @@ filesnap() { mkfile() { rm -f $dir/a _pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full - sync + _test_sync } dir=$TEST_DIR/test-$seq diff --git a/tests/generic/721 b/tests/generic/721 index 98505aac..a9565f18 100755 --- a/tests/generic/721 +++ b/tests/generic/721 @@ -35,7 +35,7 @@ mkfile() { rm -f $dir/a _pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full chown $qa_user $dir/a $dir/ - sync + _test_sync } dir=$TEST_DIR/test-$seq diff --git a/tests/generic/725 b/tests/generic/725 index e1db83b5..3a9005dd 100755 --- a/tests/generic/725 +++ b/tests/generic/725 @@ -31,7 +31,7 @@ _require_congruent_file_oplen $SCRATCH_MNT 65536 # Create original file _pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full -sync +_scratch_sync md5sum $SCRATCH_MNT/a | _filter_scratch # Test atomic scatter-gather file commits. diff --git a/tests/generic/726 b/tests/generic/726 index 00071b1d..131ac5b5 100755 --- a/tests/generic/726 +++ b/tests/generic/726 @@ -35,7 +35,7 @@ chmod a+rw $SCRATCH_MNT/ setup_testfile() { rm -f $SCRATCH_MNT/a _pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full - sync + _scratch_sync } commit_and_check() { diff --git a/tests/generic/727 b/tests/generic/727 index dbed1d45..ee7ed976 100755 --- a/tests/generic/727 +++ b/tests/generic/727 @@ -42,7 +42,7 @@ setup_testfile() { _pwrite_byte 0x57 0 1m $SCRATCH_MNT/b >> $seqres.full chmod a+rw $SCRATCH_MNT/a $SCRATCH_MNT/b $SETCAP_PROG cap_setgid,cap_setuid+ep $SCRATCH_MNT/a - sync + _scratch_sync } commit_and_check() { diff --git a/tests/generic/735 b/tests/generic/735 index 1aeeb9a4..9bbdf3a1 100755 --- a/tests/generic/735 +++ b/tests/generic/735 @@ -42,7 +42,7 @@ $XFS_IO_PROG -f -c "finsert 1M ${finsert_len}" "${SCRATCH_MNT}/file" >> $seqres. # Filling up the free space ensures that the pre-allocated space is the reserved space. nr_free=$(stat -f -c '%f' ${SCRATCH_MNT}) _fill_fs $((nr_free * file_blksz)) ${SCRATCH_MNT}/fill $file_blksz 0 >> $seqres.full 2>&1 -sync +_scratch_sync # Remove reserved space to gain free space for allocation rm -f ${SCRATCH_MNT}/tmp diff --git a/tests/generic/738 b/tests/generic/738 index 4da2d887..6f1ea7f8 100755 --- a/tests/generic/738 +++ b/tests/generic/738 @@ -36,7 +36,7 @@ $XFS_IO_PROG -fc "pwrite 0 64k" $SCRATCH_MNT/testfile >> $seqres.full for i in $(seq 0 1024); do create_eof_block_file $SCRATCH_MNT/$i done -sync +_scratch_sync xfs_freeze -f $SCRATCH_MNT # This will hang if bug reproduces diff --git a/tests/generic/745 b/tests/generic/745 index bed43578..62624b15 100755 --- a/tests/generic/745 +++ b/tests/generic/745 @@ -51,7 +51,7 @@ _mount_flakey # Create the test file with some initial data and make sure everything is # durably persisted. $XFS_IO_PROG -f -c "pwrite -S 0xaa 0 32k" $SCRATCH_MNT/foo | _filter_xfs_io -sync +_scratch_sync # Add many small xattrs to our file. # We create such a large amount because it's needed to trigger the issue found @@ -66,7 +66,7 @@ done # Sync the filesystem to force a commit of the current btrfs transaction, this # is a necessary condition to trigger the bug on btrfs. -sync +_scratch_sync # Now update our file's data and fsync the file. # After a successful fsync, if the fsync log/journal is replayed we expect to diff --git a/tests/generic/746 b/tests/generic/746 index 651affe0..5734f254 100755 --- a/tests/generic/746 +++ b/tests/generic/746 @@ -170,7 +170,7 @@ for i in `seq 1 10`; do done # Get reference fiemap, this can contain i.e. uninitialized inode table -sync +_sync_fs $loop_mnt get_holes > $fiemap_ref # Delete some files @@ -184,7 +184,7 @@ echo "done." echo -n "Detecting interesting holes in image..." # Get after-trim fiemap -sync +_sync_fs $loop_mnt get_holes > $fiemap_after echo "done." diff --git a/tests/generic/747 b/tests/generic/747 index b92098f9..44834186 100755 --- a/tests/generic/747 +++ b/tests/generic/747 @@ -57,7 +57,7 @@ _used_percent() { _delete_random_file() { local to_delete=$(find ${SCRATCH_MNT} -type f | shuf | head -1) rm $to_delete - sync ${SCRATCH_MNT} + _scratch_sync } _get_random_fsz() { @@ -110,7 +110,7 @@ echo "Starting mixed write/delete test using buffered IO" _mixed_write_delete "" echo "Syncing" -sync ${SCRATCH_MNT}/* +_scratch_sync echo "Done, all good" diff --git a/tests/generic/749 b/tests/generic/749 index 8b2c7fef..fc747738 100755 --- a/tests/generic/749 +++ b/tests/generic/749 @@ -100,7 +100,7 @@ do_mmap_tests() $XFS_IO_PROG -f -c "pwrite -S 0xaa -b 512 $offset $len" \ $test_file >> $seqres.full - sync + _scratch_sync new_filelen=$(_get_filesize $test_file) map_len=$(_round_up_to_page_boundary $new_filelen) csum_orig="$(_md5_checksum $test_file)" @@ -141,7 +141,7 @@ do_mmap_tests() -c "mmap -w 0 $map_len" \ -c "mwrite $new_filelen $zero_filled_data_len" \ -c "munmap" - sync + _scratch_sync csum_post="$(_md5_checksum $test_file)" if [[ "$csum_orig" != "$csum_post" ]]; then let failed=$failed+1 diff --git a/tests/xfs/016 b/tests/xfs/016 index 1abc06c4..f8076cc8 100755 --- a/tests/xfs/016 +++ b/tests/xfs/016 @@ -101,9 +101,9 @@ _log_traffic() while [ $count -ge 0 ] do touch $out - sync + _scratch_sync rm $out - sync + _scratch_sync let "count = count - 1" done diff --git a/tests/xfs/052 b/tests/xfs/052 index adeab538..af6e938e 100755 --- a/tests/xfs/052 +++ b/tests/xfs/052 @@ -54,7 +54,7 @@ fi # create 100 (fs-blocksize) blocks _file_as_id $SCRATCH_MNT/foo $id $type $dbsize 220 -sync +_scratch_sync # set limit at 1001 (1k) blocks bsoft=1001 diff --git a/tests/xfs/110 b/tests/xfs/110 index 0c8c87ea..fc51d183 100755 --- a/tests/xfs/110 +++ b/tests/xfs/110 @@ -43,7 +43,7 @@ do done wait -sync +_scratch_sync I=10030585 E=10030599 diff --git a/tests/xfs/118 b/tests/xfs/118 index 73e42938..b5a1eabf 100755 --- a/tests/xfs/118 +++ b/tests/xfs/118 @@ -38,7 +38,7 @@ echo "Silence is golden" # preallocation added. Let's say... 64k free chunks. $XFS_IO_PROG -fs -c "falloc 0 40000k" $SCRATCH_MNT/fill >> $seqres.full 2>&1 -sync +_scratch_sync dd if=/dev/zero of=$SCRATCH_MNT/remainder oflag=direct > /dev/null 2>&1 @@ -55,7 +55,7 @@ for I in `seq 1 64`; do >> $seqres.full 2>&1 done # sync to get extents on disk so fsr sees them -sync +_scratch_sync # Free up some space for defragmentation temp file rm -f $SCRATCH_MNT/fill diff --git a/tests/xfs/119 b/tests/xfs/119 index 334d0693..7c1cd6a5 100755 --- a/tests/xfs/119 +++ b/tests/xfs/119 @@ -30,7 +30,7 @@ _require_scratch _require_freeze # this may hang -sync +_scratch_sync export MKFS_OPTIONS="-l version=2,su=64k" logblks=$(_scratch_find_xfs_min_logblocks) diff --git a/tests/xfs/128 b/tests/xfs/128 index 0f190529..0bfda0e0 100755 --- a/tests/xfs/128 +++ b/tests/xfs/128 @@ -42,7 +42,7 @@ blksz_factor=$((blksz / real_blksz)) # preallocate space to try to produce a single extent. $XFS_IO_PROG -f -c "falloc 0 $((blks * blksz))" $testdir/file1 >> $seqres.full _pwrite_byte 0x61 0 $((blks * blksz)) $testdir/file1 >> $seqres.full -sync +_scratch_sync nextents=$($XFS_IO_PROG -c 'stat' $testdir/file1 | grep 'fsxattr.nextents' | awk '{print $3}') diff --git a/tests/xfs/133 b/tests/xfs/133 index 39f4f74a..c9bae5d9 100755 --- a/tests/xfs/133 +++ b/tests/xfs/133 @@ -49,7 +49,7 @@ fi echo "Remount, try to append" _scratch_mount dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)." -sync +_scratch_sync # success, all done status=0 diff --git a/tests/xfs/134 b/tests/xfs/134 index b8626521..77505718 100755 --- a/tests/xfs/134 +++ b/tests/xfs/134 @@ -52,7 +52,7 @@ fi echo "Remount, try to append" _scratch_mount dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=direct,append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)." -sync +_scratch_sync # success, all done status=0 diff --git a/tests/xfs/161 b/tests/xfs/161 index 948121c0..e13a646a 100755 --- a/tests/xfs/161 +++ b/tests/xfs/161 @@ -51,7 +51,7 @@ lim_bhard=$(( 100 * blksz )) # Force the block counters for uid 1 and 2 above zero _pwrite_byte 0x61 0 $filesz $SCRATCH_MNT/a >> $seqres.full _pwrite_byte 0x61 0 $filesz $SCRATCH_MNT/b >> $seqres.full -sync +_scratch_sync chown 1 $SCRATCH_MNT/a chown 2 $SCRATCH_MNT/b diff --git a/tests/xfs/176 b/tests/xfs/176 index 8d58590f..e3fa87c4 100755 --- a/tests/xfs/176 +++ b/tests/xfs/176 @@ -151,7 +151,7 @@ for ((ino = icluster_ino; ino < icluster_ino + XFS_INODES_PER_CHUNK; ino++)); do find $SCRATCH_MNT/urk/ -inum "$ino" -print0 | xargs -r -0 mv -t $SCRATCH_MNT/save/ done rm -rf $SCRATCH_MNT/urk/ $SCRATCH_MNT/save/*/* -sync +_scratch_sync $XFS_IO_PROG -c 'fsmap -vvvvv' $SCRATCH_MNT &>> $seqres.full # Propose shrinking the filesystem such that the end of the fs ends up in the diff --git a/tests/xfs/195 b/tests/xfs/195 index f965d9c3..9d23c32d 100755 --- a/tests/xfs/195 +++ b/tests/xfs/195 @@ -56,7 +56,7 @@ $CHATTR_PROG +d $TEST_DIR/d/t _do_dump echo "Dump exclude flag set, after sync (should be skipped)" -sync +_test_sync _do_dump # success, all done diff --git a/tests/xfs/201 b/tests/xfs/201 index 60cc84ed..ffd05f8a 100755 --- a/tests/xfs/201 +++ b/tests/xfs/201 @@ -64,8 +64,8 @@ do_pwrite 5000 6455 $min_align do_pwrite 1728 4999 $min_align do_pwrite 0 1727 $min_align -sync -sync +_scratch_sync +_scratch_sync # and truncate it again > $SCRATCH_MNT/bigfile diff --git a/tests/xfs/212 b/tests/xfs/212 index 54ece22a..51d21116 100755 --- a/tests/xfs/212 +++ b/tests/xfs/212 @@ -52,7 +52,7 @@ echo "CoW and leave leftovers" $XFS_IO_PROG -f -c "extsize" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 $((filesize - 1)) 1" -c "fsync" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 $((filesize - 1)) 1" -c "fsync" $testdir/file2.chk >> $seqres.full -sync +_scratch_sync echo "Crash and recover" $XFS_IO_PROG -x -c "shutdown" $testdir/file2 >> $seqres.full diff --git a/tests/xfs/227 b/tests/xfs/227 index 3f01b175..2ad910cb 100755 --- a/tests/xfs/227 +++ b/tests/xfs/227 @@ -60,7 +60,7 @@ fragment_freespace() $XFS_IO_PROG -f -c "unresvsp ${i}k 4k" $_file \ > /dev/null 2>&1 done - sync + _scratch_sync # and now use up all the remaining extents larger than 3 blocks $XFS_IO_PROG -fs -c "resvsp 0 4m" $_file.large > /dev/null 2>&1 diff --git a/tests/xfs/231 b/tests/xfs/231 index c01682fa..ea494a15 100755 --- a/tests/xfs/231 +++ b/tests/xfs/231 @@ -71,7 +71,7 @@ seq 2 2 $((nr - 1)) | while read f; do $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz * f - 1)) 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz * f - 1)) 1" $testdir/file2.chk >> $seqres.full done -sync +_scratch_sync echo "Wait for CoW expiration" sleep 3 @@ -88,7 +88,7 @@ seq 2 2 $((nr - 1)) | while read f; do $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz * f)) 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz * f)) 1" $testdir/file2.chk >> $seqres.full done -sync +_scratch_sync echo "Compare files" md5sum $testdir/file1 | _filter_scratch diff --git a/tests/xfs/232 b/tests/xfs/232 index c7eba95a..0eea2c09 100755 --- a/tests/xfs/232 +++ b/tests/xfs/232 @@ -74,7 +74,7 @@ seq 2 2 $((nr - 1)) | while read f; do $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz * f - 1)) 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz * f - 1)) 1" $testdir/file2.chk >> $seqres.full done -sync +_scratch_sync echo "Wait for CoW expiration" $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz * 2)) 1" $testdir/file2 >> $seqres.full @@ -92,7 +92,7 @@ seq 2 2 $((nr - 1)) | while read f; do $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz * f)) 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 $((blksz * f)) 1" $testdir/file2.chk >> $seqres.full done -sync +_scratch_sync echo "Compare files" md5sum $testdir/file1 | _filter_scratch diff --git a/tests/xfs/234 b/tests/xfs/234 index 4d6e30c0..e57bf38c 100755 --- a/tests/xfs/234 +++ b/tests/xfs/234 @@ -39,7 +39,7 @@ echo "Create the original file blocks" blksz="$(_get_block_size $testdir)" nr_blks=$((4 * blksz / 12)) _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full -sync +_scratch_sync echo "Punch every other block" seq 1 2 $((nr_blks - 1)) | while read nr; do diff --git a/tests/xfs/236 b/tests/xfs/236 index a374a300..29cab319 100755 --- a/tests/xfs/236 +++ b/tests/xfs/236 @@ -38,7 +38,7 @@ nr_blks=$((8 * blksz / 12)) for i in 1 2 x; do _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full _pwrite_byte 0x62 0 $((blksz * nr_blks)) $testdir/file2 >> $seqres.full - sync + _scratch_sync echo "$i: Reflink every other block" seq 1 2 $((nr_blks - 1)) | while read nr; do diff --git a/tests/xfs/237 b/tests/xfs/237 index 194cd045..f172aaf5 100755 --- a/tests/xfs/237 +++ b/tests/xfs/237 @@ -60,7 +60,7 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full -sync +_scratch_sync _dmerror_load_error_table $AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full _dmerror_load_working_table diff --git a/tests/xfs/239 b/tests/xfs/239 index bfe722c0..11a0d125 100755 --- a/tests/xfs/239 +++ b/tests/xfs/239 @@ -56,7 +56,7 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full -sync +_scratch_sync $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full $AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full _scratch_cycle_mount diff --git a/tests/xfs/240 b/tests/xfs/240 index 4f9311e8..e95cf3f5 100755 --- a/tests/xfs/240 +++ b/tests/xfs/240 @@ -62,7 +62,7 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full -sync +_scratch_sync _dmerror_load_error_table $AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full $XFS_IO_PROG -c "fdatasync" $testdir/file2 diff --git a/tests/xfs/241 b/tests/xfs/241 index 15324939..6d73d48e 100755 --- a/tests/xfs/241 +++ b/tests/xfs/241 @@ -57,7 +57,7 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full -sync +_scratch_sync $AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full _scratch_cycle_mount diff --git a/tests/xfs/243 b/tests/xfs/243 index ea83a7b4..964e94e1 100755 --- a/tests/xfs/243 +++ b/tests/xfs/243 @@ -66,7 +66,7 @@ seq 3 5 $nr | while read f; do _pwrite_byte 0x71 $((blksz * f)) $blksz $testdir/file3 >> $seqres.full _pwrite_byte 0x71 $((blksz * f)) $blksz $testdir/file3.chk >> $seqres.full done -sync +_scratch_sync # 4 blocks are delalloc (do later) seq 4 5 $nr | while read f; do _pwrite_byte 0x62 $((blksz * f)) $blksz $testdir/file3 >> $seqres.full @@ -102,7 +102,7 @@ echo "Regular data extents:" test $(_xfs_bmapx_find data $testdir/file3 -E '00[01]{4}$') -gt 0 || \ echo "Expected to find a regular data extent" -sync +_scratch_sync echo "Dump extents after sync" $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch diff --git a/tests/xfs/246 b/tests/xfs/246 index ce97fad5..997a7ad4 100755 --- a/tests/xfs/246 +++ b/tests/xfs/246 @@ -25,7 +25,7 @@ mkdir $testdir echo "Create the original files" touch $testdir/file1 -sync +_scratch_sync echo "Dump extents after sync" echo "Hole CoW extents:" diff --git a/tests/xfs/265 b/tests/xfs/265 index 21de4c05..e7f939c1 100755 --- a/tests/xfs/265 +++ b/tests/xfs/265 @@ -44,7 +44,7 @@ for i in 1 2 x; do seq 1 $nr_blks | while read nr; do _cp_reflink $testdir/file1 $testdir/file1.$nr >> $seqres.full done - sync + _scratch_sync echo "$i: Truncate files" seq 1 $nr_blks | while read nr; do diff --git a/tests/xfs/272 b/tests/xfs/272 index b65e2fae..3e3ceec5 100755 --- a/tests/xfs/272 +++ b/tests/xfs/272 @@ -33,7 +33,7 @@ _scratch_mount _xfs_force_bdev data $SCRATCH_MNT _pwrite_byte 0x80 0 737373 $SCRATCH_MNT/urk >> $seqres.full -sync +_scratch_sync $here/src/punch-alternating $SCRATCH_MNT/urk >> $seqres.full ino=$(stat -c '%i' $SCRATCH_MNT/urk) diff --git a/tests/xfs/274 b/tests/xfs/274 index d06e7fc1..a6bdc7c0 100755 --- a/tests/xfs/274 +++ b/tests/xfs/274 @@ -32,7 +32,7 @@ _scratch_mkfs > "$seqres.full" 2>&1 _scratch_mount _pwrite_byte 0x80 0 737373 $SCRATCH_MNT/f1 >> $seqres.full -sync +_scratch_sync $here/src/punch-alternating $SCRATCH_MNT/f1 >> $seqres.full _cp_reflink $SCRATCH_MNT/f1 $SCRATCH_MNT/f2 ino=$(stat -c '%i' $SCRATCH_MNT/f1) diff --git a/tests/xfs/276 b/tests/xfs/276 index f21f7a86..69de69d8 100755 --- a/tests/xfs/276 +++ b/tests/xfs/276 @@ -37,7 +37,7 @@ _scratch_mount test $rtextsz -eq $dbsize || _notrun "Skipping test due to rtextsize > 1 fsb" $XFS_IO_PROG -f -R -c 'pwrite -S 0x80 0 737373' $SCRATCH_MNT/urk >> $seqres.full -sync +_scratch_sync $here/src/punch-alternating $SCRATCH_MNT/urk >> $seqres.full ino=$(stat -c '%i' $SCRATCH_MNT/urk) diff --git a/tests/xfs/291 b/tests/xfs/291 index 0141c075..777968a9 100755 --- a/tests/xfs/291 +++ b/tests/xfs/291 @@ -41,12 +41,12 @@ mkdir $SCRATCH_MNT/fragdir for I in `seq 0 26200`; do (echo data > $SCRATCH_MNT/fragdir/f$I) >> $seqres.full 2>&1 done -sync +_scratch_sync for I in `seq 0 2 26200`; do rm -f $SCRATCH_MNT/fragdir/f$I >> $seqres.full 2>&1 done -sync +_scratch_sync # Soak up any remaining freespace $XFS_IO_PROG -f -c "pwrite 0 16m" -c "fsync" $SCRATCH_MNT/space_file.large >> $seqres.full 2>&1 diff --git a/tests/xfs/309 b/tests/xfs/309 index 63ca0a67..429a506c 100755 --- a/tests/xfs/309 +++ b/tests/xfs/309 @@ -44,7 +44,7 @@ for i in 1 2 x; do seq 1 $nr_blks | while read nr; do _cp_reflink $testdir/file1 $testdir/file1.$nr >> $seqres.full done - sync + _scratch_sync echo "$i: Truncate files" seq 1 $nr_blks | while read nr; do diff --git a/tests/xfs/312 b/tests/xfs/312 index 6e47d442..4c0fbf74 100755 --- a/tests/xfs/312 +++ b/tests/xfs/312 @@ -45,7 +45,7 @@ _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3 seq 1 2 $blks | while read off; do $XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full done -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch diff --git a/tests/xfs/313 b/tests/xfs/313 index d0c77db8..8f533041 100755 --- a/tests/xfs/313 +++ b/tests/xfs/313 @@ -44,7 +44,7 @@ _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3 seq 1 2 $blks | while read off; do $XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full done -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch diff --git a/tests/xfs/314 b/tests/xfs/314 index 07596e00..b86d06ae 100755 --- a/tests/xfs/314 +++ b/tests/xfs/314 @@ -45,7 +45,7 @@ _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3 seq 1 2 $blks | while read off; do $XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full done -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch diff --git a/tests/xfs/315 b/tests/xfs/315 index f6c346e1..af783a7a 100755 --- a/tests/xfs/315 +++ b/tests/xfs/315 @@ -43,7 +43,7 @@ echo "Create files" _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full _pwrite_byte 0x66 $((sz / 2)) $((sz / 2)) $SCRATCH_MNT/file2 >> $seqres.full _reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file2 0 $((sz / 2)) >> $seqres.full -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch @@ -54,7 +54,7 @@ _scratch_inject_error "free_extent" echo "CoW a few blocks" $XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full 2>&1 -sync +_scratch_sync echo "FS should be shut down, touch will fail" touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch diff --git a/tests/xfs/316 b/tests/xfs/316 index 63711ed4..3c92d1a1 100755 --- a/tests/xfs/316 +++ b/tests/xfs/316 @@ -45,7 +45,7 @@ _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3 seq 1 2 $blks | while read off; do $XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full done -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch diff --git a/tests/xfs/317 b/tests/xfs/317 index 192107f5..2ae0b903 100755 --- a/tests/xfs/317 +++ b/tests/xfs/317 @@ -36,7 +36,7 @@ _scratch_mount >> $seqres.full echo "Create files" touch $SCRATCH_MNT/file1 _pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file0 >> $seqres.full -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file0 | _filter_scratch diff --git a/tests/xfs/318 b/tests/xfs/318 index 590d268e..4ff11be4 100755 --- a/tests/xfs/318 +++ b/tests/xfs/318 @@ -43,7 +43,7 @@ touch $SCRATCH_MNT/file1 echo "Write files" $XFS_IO_PROG -c "pwrite -S 0x67 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch @@ -53,7 +53,7 @@ _scratch_inject_error "free_extent" echo "Remove files" rm -rf $SCRATCH_MNT/file1 -sync +_scratch_sync $XFS_IO_PROG -x -c 'freeze' -c 'thaw' $SCRATCH_MNT >> $seqres.full 2>&1 echo "FS should be shut down, touch will fail" diff --git a/tests/xfs/319 b/tests/xfs/319 index 45b958d8..66f19112 100755 --- a/tests/xfs/319 +++ b/tests/xfs/319 @@ -38,7 +38,7 @@ echo "Create files" _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2 _pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file3 >> $seqres.full -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch diff --git a/tests/xfs/320 b/tests/xfs/320 index f7e4949a..4cf174b8 100755 --- a/tests/xfs/320 +++ b/tests/xfs/320 @@ -37,7 +37,7 @@ _scratch_mount >> $seqres.full echo "Create files" _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2 -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch diff --git a/tests/xfs/321 b/tests/xfs/321 index a09e4a8c..4ebde3e2 100755 --- a/tests/xfs/321 +++ b/tests/xfs/321 @@ -37,7 +37,7 @@ _scratch_mount >> $seqres.full echo "Create files" _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full $XFS_IO_PROG -f -c "truncate $sz" $SCRATCH_MNT/file3 >> $seqres.full -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch diff --git a/tests/xfs/322 b/tests/xfs/322 index 4cb36a51..0492b647 100755 --- a/tests/xfs/322 +++ b/tests/xfs/322 @@ -39,7 +39,7 @@ _require_congruent_file_oplen $SCRATCH_MNT $blksz echo "Create files" _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full $XFS_IO_PROG -f -c "truncate $sz" $SCRATCH_MNT/file3 >> $seqres.full -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch diff --git a/tests/xfs/323 b/tests/xfs/323 index 0579d4a7..ee45ba60 100755 --- a/tests/xfs/323 +++ b/tests/xfs/323 @@ -37,7 +37,7 @@ _scratch_mount >> $seqres.full echo "Create files" _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full _pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file3 >> $seqres.full -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch diff --git a/tests/xfs/324 b/tests/xfs/324 index 485b1621..b86bb0ea 100755 --- a/tests/xfs/324 +++ b/tests/xfs/324 @@ -45,7 +45,7 @@ _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3 seq 1 2 $blks | while read off; do $XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full done -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch diff --git a/tests/xfs/325 b/tests/xfs/325 index 2387b8d8..f06eda64 100755 --- a/tests/xfs/325 +++ b/tests/xfs/325 @@ -39,7 +39,7 @@ _scratch_mount >> $seqres.full echo "Create files" _pwrite_byte 0x66 0 $((blksz * blks)) $SCRATCH_MNT/file1 >> $seqres.full _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2 -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch @@ -52,7 +52,7 @@ echo "Inject error" _scratch_inject_error "free_extent" rm $SCRATCH_MNT/file1 -sync +_scratch_sync $XFS_IO_PROG -x -c 'freeze' -c 'thaw' $SCRATCH_MNT >> $seqres.full 2>&1 echo "FS should be shut down, touch will fail" diff --git a/tests/xfs/326 b/tests/xfs/326 index 5d7afe9b..a06879c3 100755 --- a/tests/xfs/326 +++ b/tests/xfs/326 @@ -62,7 +62,7 @@ _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3 seq 1 2 $blks | while read off; do $XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full done -sync +_scratch_sync echo "Check files" md5sum $SCRATCH_MNT/file1 | _filter_scratch @@ -70,7 +70,7 @@ md5sum $SCRATCH_MNT/file2 | _filter_scratch md5sum $SCRATCH_MNT/file3 | _filter_scratch $XFS_IO_PROG -c "pwrite -W -S 0x67 $((10 * blksz)) 1" $SCRATCH_MNT/file2 >> $seqres.full -sync +_scratch_sync echo "Inject error" _scratch_inject_error "refcount_finish_one" diff --git a/tests/xfs/327 b/tests/xfs/327 index 44728c11..1f2ee548 100755 --- a/tests/xfs/327 +++ b/tests/xfs/327 @@ -37,7 +37,7 @@ _pwrite_byte 0x66 0 1 $SCRATCH_MNT/file.0 >> $seqres.full seq 1 $nr | while read i; do _cp_reflink $SCRATCH_MNT/file.0 $SCRATCH_MNT/file.$i done -sync +_scratch_sync ino_0=$(stat -c '%i' $SCRATCH_MNT/file.0) ino_64=$(stat -c '%i' $SCRATCH_MNT/file.64) diff --git a/tests/xfs/420 b/tests/xfs/420 index 038682ef..37fb8c6b 100755 --- a/tests/xfs/420 +++ b/tests/xfs/420 @@ -109,7 +109,7 @@ md5sum $testdir/file3 | _filter_scratch echo 1 > /proc/sys/vm/drop_caches echo "sync filesystem" | tee -a $seqres.full -sync +_scratch_sync $XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file1 >> $seqres.full 2>&1 $XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file2 >> $seqres.full 2>&1 diff --git a/tests/xfs/421 b/tests/xfs/421 index ab565e1f..fdee45ce 100755 --- a/tests/xfs/421 +++ b/tests/xfs/421 @@ -94,7 +94,7 @@ md5sum $testdir/file3 | _filter_scratch echo 1 > /proc/sys/vm/drop_caches echo "sync filesystem" | tee -a $seqres.full -sync +_scratch_sync $XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file1 >> $seqres.full 2>&1 $XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file2 >> $seqres.full 2>&1 diff --git a/tests/xfs/423 b/tests/xfs/423 index 1fbf500d..78fd9130 100755 --- a/tests/xfs/423 +++ b/tests/xfs/423 @@ -31,7 +31,7 @@ _scratch_mount $XFS_IO_PROG -f -c 'falloc 0 10m' $SCRATCH_MNT/a >> $seqres.full $XFS_IO_PROG -f -c 'falloc 0 10m' $SCRATCH_MNT/b >> $seqres.full $here/src/punch-alternating $SCRATCH_MNT/b -sync +_scratch_sync echo "Set up delalloc extents" $XFS_IO_PROG -c 'pwrite -S 0x66 10m 128k' $SCRATCH_MNT/a >> $seqres.full diff --git a/tests/xfs/438 b/tests/xfs/438 index 0239778c..6d1988c8 100755 --- a/tests/xfs/438 +++ b/tests/xfs/438 @@ -136,7 +136,7 @@ $DMSETUP_PROG table >> $seqres.full $XFS_QUOTA_PROG -x -c "limit -u isoft=400 $qa_user" $SCRATCH_MNT $XFS_QUOTA_PROG -x -c "report -ih" $SCRATCH_MNT >> $seqres.full -sync +_scratch_sync # wait for the push of the dquota log item in AIL and # the completion of the retried write of dquota buffer diff --git a/tests/xfs/440 b/tests/xfs/440 index fc731944..0cc679ae 100755 --- a/tests/xfs/440 +++ b/tests/xfs/440 @@ -43,7 +43,7 @@ $XFS_IO_PROG -c 'stat -r' $SCRATCH_MNT/a | grep stat.size >> $seqres.full _report_quota_blocks "-u $SCRATCH_MNT" echo "Sync" -sync +_scratch_sync _report_quota_blocks "-u $SCRATCH_MNT" echo "Chown and check quota" diff --git a/tests/xfs/442 b/tests/xfs/442 index 5cbd8dd1..58e56b5d 100755 --- a/tests/xfs/442 +++ b/tests/xfs/442 @@ -36,7 +36,7 @@ compare_quota_to_du() { # This ensures that we did the quota accounting correctly and that we're # accurately reporting cow preallocation blocks in stat. check_quota_du_blocks() { - sync + _scratch_sync #$XFS_QUOTA_PROG -x -c 'report' $SCRATCH_MNT >> $seqres.full du_rep=$(du -ks $SCRATCH_MNT | awk '{print $1}') u_rep=$(report_quota_blocks -u) diff --git a/tests/xfs/511 b/tests/xfs/511 index b55c34b9..a942e92e 100755 --- a/tests/xfs/511 +++ b/tests/xfs/511 @@ -33,7 +33,7 @@ _require_prjquota $SCRATCH_DEV # Create a directory to be project object, and create a file to take 64k space mkdir $SCRATCH_MNT/t -$XFS_IO_PROG -f -c "pwrite 0 65536" -c sync $SCRATCH_MNT/t/file >>$seqres.full +$XFS_IO_PROG -f -c "pwrite 0 65536" -c syncfs $SCRATCH_MNT/t/file >>$seqres.full quota_cmd="$XFS_QUOTA_PROG -x" $quota_cmd -c "project -s -p $SCRATCH_MNT/t 42" $SCRATCH_MNT >/dev/null 2>&1 diff --git a/tests/xfs/519 b/tests/xfs/519 index ac815f12..37a139c9 100755 --- a/tests/xfs/519 +++ b/tests/xfs/519 @@ -28,7 +28,7 @@ $XFS_IO_PROG -f -c 'pwrite -S 0x59 0 1m -b 1m' $SCRATCH_MNT/c >> $seqres.full _cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/e _cp_reflink $SCRATCH_MNT/c $SCRATCH_MNT/d touch $SCRATCH_MNT/b -sync +_scratch_sync # Test that setting the reflink flag on the dest file forces the log echo "test reflink flag not set" diff --git a/tests/xfs/520 b/tests/xfs/520 index 3734d874..2d80188b 100755 --- a/tests/xfs/520 +++ b/tests/xfs/520 @@ -46,7 +46,7 @@ force_crafted_metadata() { if [ $mounted -ne 0 ]; then dd if=/dev/zero of=$SCRATCH_MNT/test bs=65536 count=1 >> \ $seqres.full 2>&1 - sync + _scratch_sync fi _dmesg_since_test_start | tac | sed -ne "0,\#${kmsg}#p" | tac | \ diff --git a/tests/xfs/541 b/tests/xfs/541 index 518373fa..9be15d1f 100755 --- a/tests/xfs/541 +++ b/tests/xfs/541 @@ -91,7 +91,7 @@ test $after_rtextsz_blocks -eq $new_rtextsz_blocks || \ # Create a new realtime file to prove that we can. echo moo > $SCRATCH_MNT/a -sync -f $SCRATCH_MNT +_scratch_sync $XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/a | \ cut -d ' ' -f 1 | \ grep -q realtime || \ diff --git a/tests/xfs/553 b/tests/xfs/553 index f4294e9c..13ef629e 100755 --- a/tests/xfs/553 +++ b/tests/xfs/553 @@ -45,7 +45,7 @@ $XFS_IO_PROG -c "cowextsize $((blksz * 4096))" $destination >> $seqres.full echo "Fragment FS" $XFS_IO_PROG -f -c "pwrite 0 $((blksz * 16384))" $fragmented_file \ >> $seqres.full -sync +_scratch_sync $here/src/punch-alternating $fragmented_file >> $seqres.full echo "Inject bmap_alloc_minlen_extent error tag" @@ -54,7 +54,7 @@ _scratch_inject_error bmap_alloc_minlen_extent 1 echo "Create delalloc extent of length 4096 blocks in destination file's CoW fork" $XFS_IO_PROG -c "pwrite 0 $blksz" $destination >> $seqres.full -sync +_scratch_sync echo "Direct I/O write at 3rd block in destination file" $XFS_IO_PROG -d -c "pwrite $((blksz * 3)) $((blksz * 2))" $destination \ diff --git a/tests/xfs/558 b/tests/xfs/558 index ec2fbcb6..ba137ae8 100755 --- a/tests/xfs/558 +++ b/tests/xfs/558 @@ -140,13 +140,13 @@ $XFS_IO_PROG -c 'cowextsize 1m' $SCRATCH_MNT # Write out a file with the first two blocks unshared and the rest shared. _pwrite_byte 0x59 0 $((160 * blksz)) $SCRATCH_MNT/file >> $seqres.full _pwrite_byte 0x59 0 $((160 * blksz)) $SCRATCH_MNT/file.compare >> $seqres.full -sync +_scratch_sync _cp_reflink $SCRATCH_MNT/file $SCRATCH_MNT/file.reflink _pwrite_byte 0x58 0 $((2 * blksz)) $SCRATCH_MNT/file >> $seqres.full _pwrite_byte 0x58 0 $((2 * blksz)) $SCRATCH_MNT/file.compare >> $seqres.full -sync +_scratch_sync # Avoid creation of large folios on newer kernels by cycling the mount and # immediately writing to the page cache. @@ -156,7 +156,7 @@ _scratch_cycle_mount # before slowing down writeback to avoid unnecessary delay. _pwrite_byte 0x57 0 $((2 * blksz)) $SCRATCH_MNT/file.compare >> $seqres.full _pwrite_byte 0x56 $((2 * blksz)) $((2 * blksz)) $SCRATCH_MNT/file.compare >> $seqres.full -sync +_scratch_sync # Introduce a half-second wait to each writeback block mapping call. This # gives us a chance to race speculative cow prealloc with writeback. diff --git a/tests/xfs/607 b/tests/xfs/607 index 530fea9e..ae1e19a9 100755 --- a/tests/xfs/607 +++ b/tests/xfs/607 @@ -53,7 +53,7 @@ fi echo "Create source file" $XFS_IO_PROG -f -c "pwrite 0 $((blksz * 256))" $file1 >> $seqres.full -sync +_test_sync echo "Create Reflinked file" _cp_reflink $file1 $file2 >> $seqres.full @@ -63,7 +63,7 @@ $XFS_IO_PROG -c "cowextsize $((blksz * 128))" -c stat $file1 >> $seqres.full echo "Fragment FS" $XFS_IO_PROG -f -c "pwrite 0 $((blksz * 512))" $fragmentedfile >> $seqres.full -sync +_test_sync $here/src/punch-alternating $fragmentedfile echo "Allocate block sized extent from now onwards" @@ -72,7 +72,7 @@ _test_inject_error bmap_alloc_minlen_extent 1 echo "Create big delalloc extent in CoW fork" $XFS_IO_PROG -c "pwrite 0 $blksz" $file1 >> $seqres.full -sync +_test_sync $XFS_IO_PROG -c 'bmap -elpv' -c 'bmap -celpv' $file1 &>> $seqres.full diff --git a/tests/xfs/617 b/tests/xfs/617 index 2f5bf523..e0ad7d81 100755 --- a/tests/xfs/617 +++ b/tests/xfs/617 @@ -35,7 +35,7 @@ swap_and_check_contents() { local b="$2" local tag="$3" - sync + _scratch_sync # Test exchangerange. -w means skip holes in /b echo "swap $tag" >> $seqres.full diff --git a/tests/xfs/629 b/tests/xfs/629 index 58beedc0..34b3ca0d 100755 --- a/tests/xfs/629 +++ b/tests/xfs/629 @@ -55,7 +55,7 @@ for ((n=0; n /dev/null 2>&1 & done wait -sync +_scratch_sync for ((n=0; n /dev/null 2>&1 & done wait -sync +_scratch_sync for ((n=0; n /dev/null 2>&1 & done wait -sync +_scratch_sync for ((n=0; n> $seqres.full _pwrite_byte 0x59 0 $((blksz * nrblks)) $dir/c >> $seqres.full _pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full -sync +_test_sync # Inject a bmap error and trigger it via exchangerange. filesnap "before commit" diff --git a/tests/xfs/791 b/tests/xfs/791 index bca58042..0fcc4819 100755 --- a/tests/xfs/791 +++ b/tests/xfs/791 @@ -38,7 +38,7 @@ _pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full $XFS_IO_PROG -f -c 'truncate 1m' $SCRATCH_MNT/b _pwrite_byte 0x59 64k 64k $SCRATCH_MNT/b >> $seqres.full _pwrite_byte 0x57 768k 64k $SCRATCH_MNT/b >> $seqres.full -sync +_scratch_sync md5sum $SCRATCH_MNT/a | _filter_scratch md5sum $SCRATCH_MNT/b | _filter_scratch diff --git a/tests/xfs/792 b/tests/xfs/792 index cdfa6369..6c7b2db1 100755 --- a/tests/xfs/792 +++ b/tests/xfs/792 @@ -33,7 +33,7 @@ _scratch_mount # Create original file _pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full -sync +_scratch_sync md5sum $SCRATCH_MNT/a | _filter_scratch # Test atomic scatter-gather file commits.