2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Google, Inc. All Rights Reserved.
7 # Test checkpoint and zeroout of journal via ioctl EXT4_IOC_CHECKPOINT
11 _begin_fstest auto ioctl quick
13 # Import common functions.
16 # real QA test starts here
20 _require_command "$DEBUGFS_PROG" debugfs
22 checkpoint_journal=$here/src/checkpoint_journal
23 _require_test_program "checkpoint_journal"
25 testdir="${SCRATCH_MNT}/testdir"
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)
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"
36 # create some files to add some entries to journal
41 # make sure these files get to the journal
42 sync --file-system $testdir/1
44 # call ioctl to checkpoint and zero-fill journal blocks
45 $checkpoint_journal $SCRATCH_MNT --erase=zeroout || _fail "ioctl returned error"
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')
52 [ ! -z "$check" ] && _fail "Journal was not zeroed"
54 _scratch_unmount >> $seqres.full 2>&1
56 echo "Silence is golden"