generic/611: Use _getfattr instead of GETFATTR_PROG
[xfstests-dev.git] / tests / generic / 470
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Intel Corporation.  All Rights Reserved.
4 #
5 # FS QA Test No. 470
6 #
7 # Use dm-log-writes to verify that MAP_SYNC actually syncs metadata during
8 # page faults.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 tmp=/tmp/$$
15 here=`pwd`
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         _log_writes_cleanup
23         _dmthin_cleanup
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30 . ./common/dmthin
31 . ./common/dmlogwrites
32
33 # remove previous $seqres.full before test
34 rm -f $seqres.full
35
36 # real QA test starts here
37 _supported_fs generic
38 _require_scratch_nocheck
39 _require_log_writes_dax_mountopt "dax"
40 _require_dm_target thin-pool
41 _require_xfs_io_command "mmap" "-S"
42 _require_xfs_io_command "log_writes"
43
44 devsize=$((1024*1024*200 / 512))        # 200m phys/virt size
45 csize=$((1024*64 / 512))                # 64k cluster size
46 lowspace=$((1024*1024 / 512))           # 1m low space threshold
47
48 # Use a thin device to provide deterministic discard behavior. Discards are used
49 # by the log replay tool for fast zeroing to prevent out-of-order replay issues.
50 _dmthin_init $devsize $devsize $csize $lowspace
51
52 _log_writes_init $DMTHIN_VOL_DEV
53 _log_writes_mkfs >> $seqres.full 2>&1
54 _log_writes_mount -o dax
55
56 LEN=$((1024 * 1024)) # 1 MiB
57
58 $XFS_IO_PROG -t -c "truncate $LEN" -c "mmap -S 0 $LEN" -c "mwrite 0 $LEN" \
59         -c "log_writes -d $LOGWRITES_NAME -m preunmap" \
60         -f $SCRATCH_MNT/test
61
62 # Unmount the scratch dir and tear down the log writes target
63 _log_writes_unmount
64 _log_writes_remove
65 _dmthin_check_fs
66
67 # destroy previous filesystem so we can be sure our rebuild works
68 _mkfs_dev $DMTHIN_VOL_DEV >> $seqres.full 2>&1
69
70 # check pre-unmap state
71 _log_writes_replay_log preunmap $DMTHIN_VOL_DEV
72 _dmthin_mount
73
74 # We should see $SCRATCH_MNT/test as having 1 MiB in block allocations
75 du -sh $SCRATCH_MNT/test | _filter_scratch | _filter_spaces
76
77 status=0
78 exit