2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Fujitsu. All Rights Reserved.
7 # Regression test for commit:
8 # 688f869 ext4: Initialize fsync transaction ids in ext4_new_inode()
11 _begin_fstest auto quick
13 # Import common functions.
15 # real QA test starts here
20 _scratch_mkfs >> $seqres.full 2>&1
22 blocksize=$(_get_block_size $SCRATCH_MNT)
25 # With 4k block size, this amounts to 10M FS instance.
26 fssize=$((2560 * $blocksize))
27 _scratch_mkfs_sized $fssize >> $seqres.full 2>&1
28 _require_metadata_journaling $SCRATCH_DEV
32 # this is the jbd2 journal superblock magic number on disk, in big endian
35 while [ $offset -lt $fssize ]; do
36 if od -j $offset -N 4 -t x1 $SCRATCH_DEV | \
37 grep -i "$magic" >/dev/null; then
38 echo "Found journal: $offset" >> $seqres.full
42 offset=$((offset + blocksize))
44 if [ $found -ne 1 ]; then
45 echo "Found no journal"
49 # Overwrite journal.s_squence to 0x 81d1a480
50 # 0x81d1a480 is hex form of 2178000000, and jbd2 journal is big endian on
51 # disk, the s_squence offset to the beginning of journal superblock is 24
52 # we do this to let jbd2 start to run with a initial big transaction id,
53 # which will reduce the time taken to trigger this bug.
54 $XFS_IO_PROG -c "pwrite -S 0x81 $((offset+24)) 1" \
55 -c "pwrite -S 0xd1 $((offset+25)) 1" \
56 -c "pwrite -S 0xa4 $((offset+26)) 1" \
57 -c "pwrite -S 0x80 $((offset+27)) 1" $SCRATCH_DEV >> $seqres.full 2>&1
59 trans_id=`$DUMPE2FS_PROG $SCRATCH_DEV 2>/dev/null | grep "Journal sequence" | \
61 echo "Initial transaction id is $trans_id"
66 # Wait for running subcommand before exitting so that
67 # mountpoint is not busy when we try to unmount it
68 trap "wait; exit" SIGTERM
71 $XFS_IO_PROG -f -c "fdatasync" $SCRATCH_MNT/testfile
78 kill $datasync_work_pid >/dev/null 2>&1