mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
0925cbea74
Back many years ago, the owner field was used to email the test owner when auto-qa failed that test. It is not needed anymore - if you want to know who wrote the test, look it up in git.... Script used was: $ sed -i -e "/^# creator/d" -e "/^owner/d" [0-3][0-9][0-9] Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Phil White <pwhite@sgi.com> [rjohnston@sgi.com added TOT changes] Signed-off-by: Rich Johnston <rjohnston@sgi.com>
143 lines
4.0 KiB
Bash
143 lines
4.0 KiB
Bash
#! /bin/bash
|
|
# FS QA Test No. 285
|
|
#
|
|
# Test to verify project quota xfs_admin, xfsdump/xfsrestore and
|
|
# xfs_db functionality
|
|
#
|
|
#-----------------------------------------------------------------------
|
|
# Copyright (c) 2012 Red Hat, Inc. All Rights Reserved.
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License as
|
|
# published by the Free Software Foundation.
|
|
#
|
|
# This program is distributed in the hope that it would be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write the Free Software Foundation,
|
|
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
#
|
|
#-----------------------------------------------------------------------
|
|
#
|
|
|
|
seq=`basename $0`
|
|
echo "QA output created by $seq"
|
|
tmp=/tmp/$$
|
|
here=`pwd`
|
|
status=1 # failure is the default!
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
rm -f $seq.full
|
|
|
|
# get standard environment, filters and checks
|
|
. ./common.rc
|
|
. ./common.quota
|
|
|
|
_cleanup()
|
|
{
|
|
cd /
|
|
umount $SCRATCH_MNT 2>/dev/null
|
|
rm -rf $tmp.*
|
|
}
|
|
|
|
_print_projid()
|
|
{
|
|
$XFS_DB_PROG -c "inode $1" \
|
|
-c "print core.projid_lo" \
|
|
-c "print core.projid_hi" \
|
|
$SCRATCH_DEV
|
|
}
|
|
|
|
# real QA test starts here
|
|
_supported_fs xfs
|
|
_require_xfs_quota
|
|
_require_scratch
|
|
_require_projid32bit
|
|
|
|
# create xfs fs without projid32bit ability, will be gained by xfs_admin
|
|
_scratch_mkfs_xfs -i projid32bit=0 -d size=200m >> $seq.full \
|
|
|| _fail "mkfs failed"
|
|
_qmount_option "pquota"
|
|
_qmount
|
|
# require project quotas
|
|
_require_prjquota $SCRATCH_DEV
|
|
|
|
dir=$SCRATCH_MNT/pquota
|
|
|
|
status=1
|
|
|
|
mkdir -p $dir
|
|
touch $dir/{16,32}bit
|
|
inode16a=$(ls -i $dir/16bit | cut -d ' ' -f 1)
|
|
inode32a=$(ls -i $dir/32bit | cut -d ' ' -f 1)
|
|
$XFS_QUOTA_PROG -x -c "project -s -p $dir/16bit 1234" $SCRATCH_DEV \
|
|
>> $seq.full
|
|
$XFS_QUOTA_PROG -x -c "project -s -p $dir/32bit 2123456789" $SCRATCH_DEV \
|
|
>> $seq.full 2>&1
|
|
|
|
echo "No 32bit project quotas:"
|
|
$XFS_IO_PROG -r -c "lsproj" $dir/16bit
|
|
$XFS_IO_PROG -r -c "lsproj" $dir/32bit
|
|
|
|
umount $SCRATCH_MNT
|
|
|
|
# Now, enable projid32bit support by xfs_admin
|
|
xfs_admin -p $SCRATCH_DEV >> $seq.full 2>&1 || _fail "xfs_admin failed"
|
|
|
|
# Now mount the fs, 32bit project quotas shall be supported, now
|
|
_qmount_option "pquota"
|
|
_qmount
|
|
$XFS_QUOTA_PROG -x -c "project -s -p $dir/32bit 2123456789" $SCRATCH_DEV \
|
|
>> $seq.full
|
|
|
|
# These will be checked by $seq.out
|
|
echo "With 32bit project quota support:"
|
|
$XFS_IO_PROG -r -c "lsproj" $dir/16bit
|
|
$XFS_IO_PROG -r -c "lsproj" $dir/32bit
|
|
|
|
# Dump the fs to a temporary file
|
|
rm -f $tmp.dump.img
|
|
$XFSDUMP_PROG -f $tmp.dump -L label -M media -l 0 $SCRATCH_MNT >> $seq.full \
|
|
|| _fail "dump failed"
|
|
|
|
# Prepare the device to restore the dumped file system
|
|
restore_dir=$SCRATCH_MNT/restore/pquota
|
|
|
|
# Just make the restore dir, the pquota dir will be created by xfsrestore
|
|
mkdir -p $SCRATCH_MNT/restore
|
|
|
|
# Restore
|
|
$XFSRESTORE_PROG -f $tmp.dump $SCRATCH_MNT/restore >> $seq.full 2>&1 \
|
|
|| _fail "xfsrestore failed"
|
|
|
|
# Check that they are the same
|
|
diff -urpN $SCRATCH_MNT/{,restore}/pquota || _fail "diff failed"
|
|
|
|
touch $restore_dir/32bitv2
|
|
inode16b=$(ls -i $restore_dir/16bit | cut -d ' ' -f 1)
|
|
inode32b=$(ls -i $restore_dir/32bit | cut -d ' ' -f 1)
|
|
inode32v2=$(ls -i $restore_dir/32bitv2 | cut -d ' ' -f 1)
|
|
$XFS_QUOTA_PROG -x -c "project -s -p $restore_dir/32bitv2 2123456789" \
|
|
$SCRATCH_MNT >> $seq.full
|
|
echo "The restored file system + one additional file:"
|
|
$XFS_IO_PROG -r -c "lsproj" $restore_dir/16bit
|
|
$XFS_IO_PROG -r -c "lsproj" $restore_dir/32bit
|
|
$XFS_IO_PROG -r -c "lsproj" $restore_dir/32bitv2
|
|
|
|
umount $SCRATCH_MNT
|
|
|
|
# Now, we can examine the file systems with xfs_db
|
|
echo "These two values of 16bit project quota ids shall be the same"
|
|
_print_projid $inode16a
|
|
_print_projid $inode16b
|
|
|
|
echo "These three values of 32bit project quota ids shall be the same"
|
|
_print_projid $inode32b
|
|
_print_projid $inode32a
|
|
_print_projid $inode32v2
|
|
|
|
status=0
|
|
exit
|