2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat Inc. All Rights Reserved.
5 # FS QA Test generic/560
7 # Iterate dedupe integrity test. Copy an original data0 several
8 # times (d0 -> d1, d1 -> d2, ... dn-1 -> dn), dedupe dataN everytime
9 # before copy. At last, verify dataN same with data0.
12 _begin_fstest auto stress dedupe
14 # Import common functions.
18 # real QA test starts here
20 _require_scratch_duperemove
22 _scratch_mkfs > $seqres.full 2>&1
23 _scratch_mount >> $seqres.full 2>&1
25 function iterate_dedup_verify()
30 for ((index = 1; index <= times; index++)); do
32 find $dest -type f -exec md5sum {} \; \
35 $FSSTRESS_PROG $fsstress_opts -d $noisedir \
36 -n 200 -p $((5 * LOAD_FACTOR)) >/dev/null 2>&1
37 # Too many output, so only save error output
38 $DUPEREMOVE_PROG -dr --dedupe-options=same $dupdir \
39 >/dev/null 2>$seqres.full
40 md5sum -c --quiet $md5file$index
42 dest=$dupdir/$((index + 1))
46 srcdir=$SCRATCH_MNT/src
47 dupdir=$SCRATCH_MNT/dup
48 noisedir=$dupdir/noise
55 # Create some files to be original data
56 $FSSTRESS_PROG $fsstress_opts -d $srcdir \
57 -n 500 -p $((5 * LOAD_FACTOR)) >/dev/null 2>&1
59 # Calculate how many test cycles will be run
60 src_size=`du -ks $srcdir | awk '{print $1}'`
61 free_size=`df -kP $SCRATCH_MNT | grep -v Filesystem | awk '{print $4}'`
62 times=$((free_size / src_size))
63 if [ $times -gt $((4 * TIME_FACTOR)) ]; then
64 times=$((4 * TIME_FACTOR))
67 echo "= Do dedup and verify ="
70 # Use the last checksum file to verify the original data
71 sed -e s#dup/$times#src#g $md5file$times > $md5file
72 echo "= Backwords verify ="
73 md5sum -c --quiet $md5file
75 # read from the disk also doesn't show mutations.
77 echo "= Verify after cycle mount ="
78 for ((index = 1; index <= times; index++)); do
79 md5sum -c --quiet $md5file$index