4 # Test to verify project quota xfs_admin, xfsdump/xfsrestore and
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2012 Red Hat, Inc. All Rights Reserved.
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
44 umount $SCRATCH_MNT 2>/dev/null
50 $XFS_DB_PROG -c "inode $1" \
51 -c "print core.projid_lo" \
52 -c "print core.projid_hi" \
56 # real QA test starts here
62 # create xfs fs without projid32bit ability, will be gained by xfs_admin
63 _scratch_mkfs_xfs -i projid32bit=0 -d size=200m >> $seqres.full \
64 || _fail "mkfs failed"
65 _qmount_option "pquota"
67 # require project quotas
68 _require_prjquota $SCRATCH_DEV
70 dir=$SCRATCH_MNT/pquota
76 inode16a=$(ls -i $dir/16bit | cut -d ' ' -f 1)
77 inode32a=$(ls -i $dir/32bit | cut -d ' ' -f 1)
78 $XFS_QUOTA_PROG -x -c "project -s -p $dir/16bit 1234" $SCRATCH_DEV \
80 $XFS_QUOTA_PROG -x -c "project -s -p $dir/32bit 2123456789" $SCRATCH_DEV \
83 echo "No 32bit project quotas:"
84 $XFS_IO_PROG -r -c "lsproj" $dir/16bit
85 $XFS_IO_PROG -r -c "lsproj" $dir/32bit
89 # Now, enable projid32bit support by xfs_admin
90 xfs_admin -p $SCRATCH_DEV >> $seqres.full 2>&1 || _fail "xfs_admin failed"
92 # Now mount the fs, 32bit project quotas shall be supported, now
93 _qmount_option "pquota"
95 $XFS_QUOTA_PROG -x -c "project -s -p $dir/32bit 2123456789" $SCRATCH_DEV \
98 # These will be checked by $seq.out
99 echo "With 32bit project quota support:"
100 $XFS_IO_PROG -r -c "lsproj" $dir/16bit
101 $XFS_IO_PROG -r -c "lsproj" $dir/32bit
103 # Dump the fs to a temporary file
105 $XFSDUMP_PROG -f $tmp.dump -L label -M media -l 0 $SCRATCH_MNT >> $seqres.full \
106 || _fail "dump failed"
108 # Prepare the device to restore the dumped file system
109 restore_dir=$SCRATCH_MNT/restore/pquota
111 # Just make the restore dir, the pquota dir will be created by xfsrestore
112 mkdir -p $SCRATCH_MNT/restore
115 $XFSRESTORE_PROG -f $tmp.dump $SCRATCH_MNT/restore >> $seqres.full 2>&1 \
116 || _fail "xfsrestore failed"
118 # Check that they are the same
119 diff -urpN $SCRATCH_MNT/{,restore}/pquota || _fail "diff failed"
121 touch $restore_dir/32bitv2
122 inode16b=$(ls -i $restore_dir/16bit | cut -d ' ' -f 1)
123 inode32b=$(ls -i $restore_dir/32bit | cut -d ' ' -f 1)
124 inode32v2=$(ls -i $restore_dir/32bitv2 | cut -d ' ' -f 1)
125 $XFS_QUOTA_PROG -x -c "project -s -p $restore_dir/32bitv2 2123456789" \
126 $SCRATCH_MNT >> $seqres.full
127 echo "The restored file system + one additional file:"
128 $XFS_IO_PROG -r -c "lsproj" $restore_dir/16bit
129 $XFS_IO_PROG -r -c "lsproj" $restore_dir/32bit
130 $XFS_IO_PROG -r -c "lsproj" $restore_dir/32bitv2
134 # Now, we can examine the file systems with xfs_db
135 echo "These two values of 16bit project quota ids shall be the same"
136 _print_projid $inode16a
137 _print_projid $inode16b
139 echo "These three values of 32bit project quota ids shall be the same"
140 _print_projid $inode32b
141 _print_projid $inode32a
142 _print_projid $inode32v2