mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
0d39941c04
The test currently fails on filesystems with a block size greater
than 4Kb, as dedupe operations fail with -EINVAL because the file
offsets used are not multiples of such block sizes (but they are
multiples of 4Kb, 2Kb and 1Kb).
So update the test to use offsets that are multiples of 64Kb, since
that allows the test to work on filesystems with any block size
between 4Kb and 64Kb (8Kb, 16Kb, 32Kb). Verified it works as
expected on kernels that have the fixes for the issue tested by this
test case (listed in the changelog of commit
91540ef980), and on systems without
those fixes (a 4.18 kernel), it fails as it is supposed to.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
101 lines
3.4 KiB
Bash
Executable File
101 lines
3.4 KiB
Bash
Executable File
#! /bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
|
|
#
|
|
# FS QA Test No. 517
|
|
#
|
|
# Test that deduplication of an entire file that has a size that is not aligned
|
|
# to the filesystem's block size into the middle of a different file does not
|
|
# corrupt the destination's file data by reflinking the last (eof) block.
|
|
#
|
|
seq=`basename $0`
|
|
seqres=$RESULT_DIR/$seq
|
|
echo "QA output created by $seq"
|
|
tmp=/tmp/$$
|
|
status=1 # failure is the default!
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
_cleanup()
|
|
{
|
|
cd /
|
|
rm -f $tmp.*
|
|
}
|
|
|
|
# get standard environment, filters and checks
|
|
. ./common/rc
|
|
. ./common/filter
|
|
. ./common/reflink
|
|
|
|
# real QA test starts here
|
|
_supported_fs generic
|
|
_supported_os Linux
|
|
_require_scratch_dedupe
|
|
|
|
rm -f $seqres.full
|
|
|
|
_scratch_mkfs >>$seqres.full 2>&1
|
|
_scratch_mount
|
|
|
|
# The first byte with a value of 0xae starts at an offset (512Kb + 100) which is
|
|
# not a multiple of the block size.
|
|
$XFS_IO_PROG -f \
|
|
-c "pwrite -S 0x6b 0 524388" \
|
|
-c "pwrite -S 0xae 524388 256K" \
|
|
$SCRATCH_MNT/foo | _filter_xfs_io
|
|
|
|
# Create a second file with a length not aligned to the block size (128K + 100),
|
|
# whose bytes all have the value 0x6b, so that its extent(s) can be deduplicated
|
|
# with the first file.
|
|
$XFS_IO_PROG -f -c "pwrite -S 0x6b 0 131172" $SCRATCH_MNT/bar | _filter_xfs_io
|
|
|
|
# The file is filled with bytes having the value 0x6b from offset 0 to offset
|
|
# 524388 (512K + 100) and with the value 0xae from offset 524388 to offset
|
|
# 786532 (512K + 100 + 256K).
|
|
echo "File content before first deduplication:"
|
|
od -A d -t x1 $SCRATCH_MNT/foo
|
|
|
|
# Now deduplicate the entire second file into a range of the first file that
|
|
# also has all bytes with the value 0x6b. The destination range's end offset
|
|
# must not be aligned to the block size and must be less then the offset of
|
|
# the first byte with the value 0xae (byte at offset 524388).
|
|
$XFS_IO_PROG -c "dedupe $SCRATCH_MNT/bar 0 64K 131172" $SCRATCH_MNT/foo \
|
|
| _filter_xfs_io
|
|
|
|
# We should have exactly the same data we had before we asked for deduplication.
|
|
echo "File content after first deduplication and before unmounting:"
|
|
od -A d -t x1 $SCRATCH_MNT/foo
|
|
|
|
# Unmount the filesystem and mount it again. This guarantees any file data in
|
|
# the page cache is dropped.
|
|
_scratch_cycle_mount
|
|
|
|
# We should have exactly the same data we had before we asked for deduplication.
|
|
echo "File content after first unmount:"
|
|
od -A d -t x1 $SCRATCH_MNT/foo
|
|
|
|
# Now do a similar test when trying to dedup just the last (eof) block of a file
|
|
# into the middle of another file. This triggered a different bug on btrfs.
|
|
$XFS_IO_PROG -f -c "pwrite -S 0xae 0 100" $SCRATCH_MNT/baz | _filter_xfs_io
|
|
|
|
# Unmount the filesystem and mount it again before attempting to dedupe baz's
|
|
# last block into foo. This is necessary to trigger that btrfs bug mentioned
|
|
# before.
|
|
_scratch_cycle_mount
|
|
|
|
# Now attempt to dedupe the single block of baz into foo. The destination range,
|
|
# in file foo, has all bytes with the same value (0xae) as file baz.
|
|
$XFS_IO_PROG -c "dedupe $SCRATCH_MNT/baz 0 640K 100" $SCRATCH_MNT/foo \
|
|
| _filter_xfs_io
|
|
|
|
# Now attempt to unmount the filesystem before reading from the file. This is
|
|
# meant to trigger the btrfs bug which caused an infinite loop during inode
|
|
# eviction.
|
|
_scratch_cycle_mount
|
|
|
|
# We should have exactly the same data we had before we asked for deduplication.
|
|
echo "File content after second deduplication:"
|
|
od -A d -t x1 $SCRATCH_MNT/foo
|
|
|
|
status=0
|
|
exit
|