shared: dedupe a single big file and verify integrity
[xfstests-dev.git] / tests / shared / 008
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 008
6 #
7 # Dedupe a single big file and verify integrity
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/reflink
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 # duperemove only supports btrfs and xfs (with reflink feature).
33 # Add other filesystems if it supports more later.
34 _supported_fs xfs btrfs
35 _supported_os Linux
36 _require_scratch_dedupe
37 _require_command "$DUPEREMOVE_PROG" duperemove
38
39 fssize=$((2 * 1024 * 1024 * 1024))
40 _scratch_mkfs_sized $fssize > $seqres.full 2>&1
41 _scratch_mount >> $seqres.full 2>&1
42
43 # fill the fs with a big file has same contents
44 $XFS_IO_PROG -f -c "pwrite -S 0x55 0 $fssize" $SCRATCH_MNT/${seq}.file \
45         >> $seqres.full 2>&1
46 md5sum $SCRATCH_MNT/${seq}.file > ${tmp}.md5sum
47
48 echo "= before cycle mount ="
49 # Dedupe with 1M blocksize
50 $DUPEREMOVE_PROG -dr --dedupe-options=same -b 1048576 $SCRATCH_MNT/ >>$seqres.full 2>&1
51 # Verify integrity
52 md5sum -c --quiet ${tmp}.md5sum
53 # Dedupe with 64k blocksize
54 $DUPEREMOVE_PROG -dr --dedupe-options=same -b 65536 $SCRATCH_MNT/ >>$seqres.full 2>&1
55 # Verify integrity again
56 md5sum -c --quiet ${tmp}.md5sum
57
58 # umount and mount again, verify pagecache contents don't mutate
59 _scratch_cycle_mount
60 echo "= after cycle mount ="
61 md5sum -c --quiet ${tmp}.md5sum
62
63 status=0
64 exit