generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / ext4 / 050
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Google, Inc. All Rights Reserved.
4 #
5 # FS QA Test No. 050
6 #
7 # Test checkpoint and zeroout of journal via ioctl EXT4_IOC_CHECKPOINT
8 #
9
10 . ./common/preamble
11 _begin_fstest auto ioctl quick
12
13 # Import common functions.
14 . ./common/filter
15
16 # real QA test starts here
17 _supported_fs ext4
18
19 _require_scratch
20 _require_command "$DEBUGFS_PROG" debugfs
21
22 checkpoint_journal=$here/src/checkpoint_journal
23 _require_test_program "checkpoint_journal"
24
25 testdir="${SCRATCH_MNT}/testdir"
26
27 _scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1
28 _require_metadata_journaling $SCRATCH_DEV
29 _scratch_mount >> $seqres.full 2>&1
30 blocksize=$(_get_block_size $SCRATCH_MNT)
31 mkdir $testdir
32
33 # check if ioctl present, skip test if not present
34 $checkpoint_journal $SCRATCH_MNT --dry-run || _notrun "journal checkpoint ioctl not present on device"
35
36 # create some files to add some entries to journal
37 for i in {1..100}; do
38         echo > $testdir/$i
39 done
40
41 # make sure these files get to the journal
42 sync --file-system $testdir/1
43
44 # call ioctl to checkpoint and zero-fill journal blocks
45 $checkpoint_journal $SCRATCH_MNT --erase=zeroout || _fail "ioctl returned error"
46
47 # check journal blocks zeroed out
48 $DEBUGFS_PROG $SCRATCH_DEV -R "cat <8>" 2> /dev/null | od >> $seqres.full
49 check=$($DEBUGFS_PROG $SCRATCH_DEV -R "cat <8>" 2> /dev/null | \
50             od --skip-bytes="$blocksize" -An -v | sed -e '/^[0 \t]*$/d')
51
52 [ ! -z "$check" ] && _fail "Journal was not zeroed"
53
54 _scratch_unmount >> $seqres.full 2>&1
55
56 echo "Silence is golden"
57
58 status=0
59 exit