xfs: refactor minimum log size formatting code
[xfstests-dev.git] / tests / xfs / 295
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 295
6 #
7 # Test xfs_logprint w/ multiply-logged inodes & continued transactions
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/attr
28
29 # real QA test starts here
30
31 # Modify as appropriate.
32 _supported_fs xfs
33 _supported_os Linux
34 _require_scratch
35 _require_attrs
36
37 rm -f $seqres.full
38
39 logblks=$(_scratch_find_xfs_min_logblocks)
40 _scratch_mkfs -l size=${logblks}b >/dev/null 2>&1
41
42 # Should yield a multiply-logged inode, thanks to xattr
43 # Old logprint says this, then coredumps:
44 #       xlog_print_trans_inode: illegal inode type
45 _scratch_mount
46 echo hello > $SCRATCH_MNT/hello; setfattr -n user.name -v value $SCRATCH_MNT/hello
47 _scratch_unmount
48 _scratch_xfs_logprint 2>&1 >> $seqres.full
49
50 # Now go for a continued transaction
51 # The trick here is to get a transaction which is exactly the size of a
52 # xfs_inode_log_format_32_t or xfs_inode_log_format_64_t
53 # Prior to the bugfix, this was parsed like an inode due to the size
54 # match, not as a continued transaction.  If that happens we'll see:
55 #       xfs_logprint: unknown log operation type (494e)
56
57 _scratch_mkfs -l size=${logblks}b >/dev/null 2>&1
58 _scratch_mount
59 for I in `seq 0 8192`; do
60         echo a >> $SCRATCH_MNT/cat
61         touch $SCRATCH_MNT/tmp$I
62 done
63 _scratch_unmount
64 _scratch_xfs_logprint 2>&1 >> $seqres.full
65
66 # success, all done
67 status=0
68 exit