| #! /bin/bash |
| # SPDX-License-Identifier: GPL-2.0 |
| # Copyright (c) 2018 Oracle, Inc. All Rights Reserved. |
| # |
| # FS QA Test No. 515 |
| # |
| # Ensure that reflinking into a file well beyond EOF zeroes everything between |
| # the old EOF and the start of the newly linked chunk. This is an adaptation |
| # of a reproducer script that Eric Sandeen formulated from a stale data |
| # exposure bug uncovered by shared/010. |
| # |
| . ./common/preamble |
| _begin_fstest auto quick clone |
| |
| # Import common functions. |
| . ./common/filter |
| . ./common/reflink |
| |
| # real QA test starts here |
| _supported_fs generic |
| _require_scratch_reflink |
| _require_xfs_io_command "falloc" |
| |
| # Fill disk with a well known pattern so that stale data exposure becomes much |
| # more obvious. |
| $XFS_IO_PROG -c "pwrite -S 0x58 -b 1m 0 300m" $SCRATCH_DEV >> $seqres.full |
| _scratch_mkfs_sized $((300 * 1048576)) >>$seqres.full 2>&1 |
| _scratch_mount |
| |
| DONOR1=$SCRATCH_MNT/a |
| TARGET=$SCRATCH_MNT/b |
| blksz=65536 |
| |
| $XFS_IO_PROG -f -c "pwrite -S 0x72 0 $blksz" $DONOR1 >> $seqres.full |
| |
| $XFS_IO_PROG -f \ |
| -c "falloc -k $((blksz*2)) $blksz" \ |
| -c "pwrite -S 0x57 $((blksz*16)) 8192" \ |
| -c "fdatasync" \ |
| -c 'stat' \ |
| -c "reflink $DONOR1 0 $((blksz*17)) $blksz" \ |
| $TARGET >> $seqres.full |
| |
| od -tx1 -Ad -c $TARGET >> $seqres.full |
| md5sum $DONOR1 | _filter_scratch |
| md5sum $TARGET | _filter_scratch |
| |
| _scratch_cycle_mount |
| |
| od -tx1 -Ad -c $TARGET >> $seqres.full |
| md5sum $DONOR1 | _filter_scratch |
| md5sum $TARGET | _filter_scratch |
| |
| status=0 |
| exit |