| #! /bin/bash |
| # SPDX-License-Identifier: GPL-2.0 |
| # Copyright (c) 2025 Oracle. All Rights Reserved. |
| # |
| # FS QA Test No. 769 |
| # |
| # reflink tests for large atomic writes with mixed mappings |
| # |
| . ./common/preamble |
| _begin_fstest auto quick rw atomicwrites |
| |
| . ./common/atomicwrites |
| . ./common/filter |
| . ./common/reflink |
| |
| _require_scratch |
| _require_block_device $SCRATCH_DEV |
| _require_xfs_io_command "statx" "-r" |
| _require_atomic_write_test_commands |
| _require_scratch_write_atomic_multi_fsblock |
| _require_cp_reflink |
| _require_scratch_reflink |
| |
| _scratch_mkfs_sized $((500 * 1048576)) >> $seqres.full 2>&1 |
| _scratch_mount |
| |
| file1=$SCRATCH_MNT/file1 |
| file2=$SCRATCH_MNT/file2 |
| file3=$SCRATCH_MNT/file3 |
| |
| touch $file1 |
| |
| max_awu=$(_get_atomic_write_unit_max $file1) |
| test $max_awu -ge 262144 || _notrun "test requires atomic writes up to 256k" |
| |
| min_awu=$(_get_atomic_write_unit_min $file1) |
| test $min_awu -le 4096 || _notrun "test requires atomic writes down to 4k" |
| |
| bsize=$(_get_file_block_size $SCRATCH_MNT) |
| test $max_awu -gt $((bsize * 2)) || \ |
| _notrun "max atomic write $max_awu less than 2 fsblocks $bsize" |
| |
| # reflink tests (files with shared extents) |
| |
| echo "atomic write shared data and unshared+shared data" |
| dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 |
| cp --reflink=always $file1 $file2 |
| $XFS_IO_PROG -dc "pwrite -A -D -V1 0 32768" $file1 >>$seqres.full 2>&1 |
| $XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 |
| md5sum $file1 | _filter_scratch |
| md5sum $file2 | _filter_scratch |
| |
| echo "atomic write shared data and shared+unshared data" |
| dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 |
| cp --reflink=always $file1 $file2 |
| $XFS_IO_PROG -dc "pwrite -A -D -V1 32768 32768" $file1 >>$seqres.full 2>&1 |
| $XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 |
| md5sum $file1 | _filter_scratch |
| md5sum $file2 | _filter_scratch |
| |
| echo "atomic overwrite unshared data" |
| dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 |
| cp --reflink=always $file1 $file2 |
| $XFS_IO_PROG -dc "pwrite -D -V1 0 65536" $file1 >>$seqres.full 2>&1 |
| $XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 |
| md5sum $file1 | _filter_scratch |
| md5sum $file2 | _filter_scratch |
| |
| echo "atomic write shared+unshared+shared data" |
| dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 |
| cp --reflink=always $file1 $file2 |
| $XFS_IO_PROG -dc "pwrite -D -V1 4096 4096" $file1 >>$seqres.full 2>&1 |
| $XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 |
| md5sum $file1 | _filter_scratch |
| md5sum $file2 | _filter_scratch |
| |
| echo "atomic write interweaved hole+unwritten+written+reflinked" |
| dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 |
| blksz=4096 |
| nr=32 |
| _weave_reflink_rainbow $blksz $nr $file1 $file2 >>$seqres.full 2>&1 |
| $XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 |
| md5sum $file1 | _filter_scratch |
| md5sum $file2 | _filter_scratch |
| |
| # success, all done |
| status=0 |
| exit |