check: use generated group files
[xfstests-dev.git] / tests / ext4 / 020
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc. All Rights Reserved.
4 #
5 # FS QA Test 020
6 #
7 # Test partial blocksize defrag integrity issue.
8 #
9 # Calling EXT4_IOC_MOVE_EXTENT on file not aligned with block size and block
10 # size is smaller than page size would cause integrity issue on the
11 # partial-blocksize part when copying data between orign file and donor file.
12 #
13 . ./common/preamble
14 _begin_fstest auto quick ioctl rw defrag
15
16 # Import common functions.
17 . ./common/filter
18 . ./common/defrag
19
20 # real QA test starts here
21 _supported_fs ext4
22 _require_scratch
23 _require_defrag
24
25 e4compact=$here/src/e4compact
26 _require_test_program "e4compact"
27
28 testfile=$SCRATCH_MNT/$seq.orig
29 donorfile=$SCRATCH_MNT/$seq.donor
30 _scratch_mkfs >>$seqres.full 2>&1
31 _scratch_mount
32
33 # reserve space for donor file, written by 0xaa and sync to disk to avoid
34 # EBUSY on EXT4_IOC_MOVE_EXT
35 $XFS_IO_PROG -fc "pwrite -S 0xaa 0 1m" -c "fsync" $donorfile | _filter_xfs_io
36
37 # create test file with 1023 in size, written by 0xbb
38 # 1023 is smaller than 1k and works for any block size filesystems
39 $XFS_IO_PROG -fc "pwrite -S 0xbb 0 1023" -c "fsync" $testfile | _filter_xfs_io
40
41 # compute initial md5sum
42 md5sum $testfile > $tmp.md5sum
43
44 # drop cache, force e4compact to read data from disk
45 echo 3 > /proc/sys/vm/drop_caches
46
47 # test defrag
48 echo "$testfile" | $e4compact -i -v -f $donorfile >>$seqres.full
49
50 # check md5sum
51 md5sum -c $tmp.md5sum | _filter_scratch
52
53 # success, all done
54 status=0
55 exit