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 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
19 # get standard environment, filters and checks
27 _scratch_unmount 2>/dev/null
33 _scratch_xfs_db -r -c "inode $1" \
34 -c "print core.projid_lo" \
35 -c "print core.projid_hi"
38 # real QA test starts here
45 # create xfs fs without projid32bit ability, will be gained by xfs_admin
46 _scratch_mkfs_xfs -i projid32bit=0 -d size=200m >> $seqres.full \
47 || _fail "mkfs failed"
48 _qmount_option "pquota"
50 # require project quotas
51 _require_prjquota $SCRATCH_DEV
53 dir=$SCRATCH_MNT/pquota
59 inode16a=$(ls -i $dir/16bit | cut -d ' ' -f 1)
60 inode32a=$(ls -i $dir/32bit | cut -d ' ' -f 1)
61 $XFS_QUOTA_PROG -x -c "project -s -p $dir/16bit 1234" $SCRATCH_DEV \
63 $XFS_QUOTA_PROG -x -c "project -s -p $dir/32bit 2123456789" $SCRATCH_DEV \
66 echo "No 32bit project quotas:"
67 $XFS_IO_PROG -r -c "lsproj" $dir/16bit
68 $XFS_IO_PROG -r -c "lsproj" $dir/32bit
72 # Now, enable projid32bit support by xfs_admin
73 xfs_admin -p $SCRATCH_DEV >> $seqres.full 2>&1 || _fail "xfs_admin failed"
75 # Now mount the fs, 32bit project quotas shall be supported, now
76 _qmount_option "pquota"
78 $XFS_QUOTA_PROG -x -c "project -s -p $dir/32bit 2123456789" $SCRATCH_DEV \
81 # These will be checked by $seq.out
82 echo "With 32bit project quota support:"
83 $XFS_IO_PROG -r -c "lsproj" $dir/16bit
84 $XFS_IO_PROG -r -c "lsproj" $dir/32bit
86 # Dump the fs to a temporary file
88 $XFSDUMP_PROG -f $tmp.dump -L label -M media -l 0 $SCRATCH_MNT >> $seqres.full \
89 || _fail "dump failed"
91 # Prepare the device to restore the dumped file system
92 restore_dir=$SCRATCH_MNT/restore/pquota
94 # Just make the restore dir, the pquota dir will be created by xfsrestore
95 mkdir -p $SCRATCH_MNT/restore
98 $XFSRESTORE_PROG -f $tmp.dump $SCRATCH_MNT/restore >> $seqres.full 2>&1 \
99 || _fail "xfsrestore failed"
101 # Check that they are the same
102 diff -urpN $SCRATCH_MNT/{,restore}/pquota || _fail "diff failed"
104 touch $restore_dir/32bitv2
105 inode16b=$(ls -i $restore_dir/16bit | cut -d ' ' -f 1)
106 inode32b=$(ls -i $restore_dir/32bit | cut -d ' ' -f 1)
107 inode32v2=$(ls -i $restore_dir/32bitv2 | cut -d ' ' -f 1)
108 $XFS_QUOTA_PROG -x -c "project -s -p $restore_dir/32bitv2 2123456789" \
109 $SCRATCH_MNT >> $seqres.full
110 echo "The restored file system + one additional file:"
111 $XFS_IO_PROG -r -c "lsproj" $restore_dir/16bit
112 $XFS_IO_PROG -r -c "lsproj" $restore_dir/32bit
113 $XFS_IO_PROG -r -c "lsproj" $restore_dir/32bitv2
117 # Now, we can examine the file systems with xfs_db
118 echo "These two values of 16bit project quota ids shall be the same"
119 _print_projid $inode16a
120 _print_projid $inode16b
122 echo "These three values of 32bit project quota ids shall be the same"
123 _print_projid $inode32b
124 _print_projid $inode32a
125 _print_projid $inode32v2