2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Intel Corporation. All Rights Reserved.
7 # Use dm-log-writes to verify that MAP_SYNC actually syncs metadata during
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment, filters and checks
31 . ./common/dmlogwrites
33 # remove previous $seqres.full before test
36 # real QA test starts here
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"
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
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
52 _log_writes_init $DMTHIN_VOL_DEV
53 _log_writes_mkfs >> $seqres.full 2>&1
54 _log_writes_mount -o dax
56 LEN=$((1024 * 1024)) # 1 MiB
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" \
62 # Unmount the scratch dir and tear down the log writes target
67 # destroy previous filesystem so we can be sure our rebuild works
68 _mkfs_dev $DMTHIN_VOL_DEV >> $seqres.full 2>&1
70 # check pre-unmap state
71 _log_writes_replay_log preunmap $DMTHIN_VOL_DEV
74 # We should see $SCRATCH_MNT/test as having 1 MiB in block allocations
75 du -sh $SCRATCH_MNT/test | _filter_scratch | _filter_spaces