2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2012 Red Hat, Inc. All Rights Reserved.
7 # Test to verify project quota xfs_admin, xfsdump/xfsrestore and
11 _begin_fstest auto dump quota quick
13 # Import common functions.
17 # Override the default cleanup function.
27 _scratch_xfs_db -r -c "inode $1" \
28 -c "print core.projid_lo" \
29 -c "print core.projid_hi"
32 # real QA test starts here
39 # create xfs fs without projid32bit ability, will be gained by xfs_admin
40 _scratch_mkfs_xfs -i projid32bit=0 -d size=200m >> $seqres.full \
41 || _fail "mkfs failed"
42 _qmount_option "pquota"
44 # require project quotas
45 _require_prjquota $SCRATCH_DEV
47 dir=$SCRATCH_MNT/pquota
53 inode16a=$(ls -i $dir/16bit | cut -d ' ' -f 1)
54 inode32a=$(ls -i $dir/32bit | cut -d ' ' -f 1)
55 $XFS_QUOTA_PROG -x -c "project -s -p $dir/16bit 1234" $SCRATCH_DEV \
57 $XFS_QUOTA_PROG -x -c "project -s -p $dir/32bit 2123456789" $SCRATCH_DEV \
60 echo "No 32bit project quotas:"
61 $XFS_IO_PROG -r -c "lsproj" $dir/16bit
62 $XFS_IO_PROG -r -c "lsproj" $dir/32bit
66 # Now, enable projid32bit support by xfs_admin
67 _scratch_xfs_admin -p >> $seqres.full 2>&1 || _fail "xfs_admin failed"
69 # Now mount the fs, 32bit project quotas shall be supported, now
70 _qmount_option "pquota"
72 $XFS_QUOTA_PROG -x -c "project -s -p $dir/32bit 2123456789" $SCRATCH_DEV \
75 # These will be checked by $seq.out
76 echo "With 32bit project quota support:"
77 $XFS_IO_PROG -r -c "lsproj" $dir/16bit
78 $XFS_IO_PROG -r -c "lsproj" $dir/32bit
80 # Dump the fs to a temporary file
82 $XFSDUMP_PROG -f $tmp.dump -L label -M media -l 0 $SCRATCH_MNT >> $seqres.full \
83 || _fail "dump failed"
85 # Prepare the device to restore the dumped file system
86 restore_dir=$SCRATCH_MNT/restore/pquota
88 # Just make the restore dir, the pquota dir will be created by xfsrestore
89 mkdir -p $SCRATCH_MNT/restore
92 $XFSRESTORE_PROG -f $tmp.dump $SCRATCH_MNT/restore >> $seqres.full 2>&1 \
93 || _fail "xfsrestore failed"
95 # Check that they are the same
96 diff -urpN $SCRATCH_MNT/{,restore}/pquota || _fail "diff failed"
98 touch $restore_dir/32bitv2
99 inode16b=$(ls -i $restore_dir/16bit | cut -d ' ' -f 1)
100 inode32b=$(ls -i $restore_dir/32bit | cut -d ' ' -f 1)
101 inode32v2=$(ls -i $restore_dir/32bitv2 | cut -d ' ' -f 1)
102 $XFS_QUOTA_PROG -x -c "project -s -p $restore_dir/32bitv2 2123456789" \
103 $SCRATCH_MNT >> $seqres.full
104 echo "The restored file system + one additional file:"
105 $XFS_IO_PROG -r -c "lsproj" $restore_dir/16bit
106 $XFS_IO_PROG -r -c "lsproj" $restore_dir/32bit
107 $XFS_IO_PROG -r -c "lsproj" $restore_dir/32bitv2
111 # Now, we can examine the file systems with xfs_db
112 echo "These two values of 16bit project quota ids shall be the same"
113 _print_projid $inode16a
114 _print_projid $inode16b
116 echo "These three values of 32bit project quota ids shall be the same"
117 _print_projid $inode32b
118 _print_projid $inode32a
119 _print_projid $inode32v2