summaryrefslogtreecommitdiff
path: root/tests/xfs/287
blob: 31bbf0d77a4bffc1b20fceee754a17afc221c477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2012 Red Hat, Inc. All Rights Reserved.
#
# FS QA Test No. 287
#
# Test to verify project quota xfs_admin, xfsdump/xfsrestore and
# xfs_db functionality
#
. ./common/preamble
_begin_fstest auto dump quota quick

# Import common functions.
. ./common/quota
. ./common/dump

# Override the default cleanup function.
_cleanup()
{
	_cleanup_dump
	cd /
	rm -rf $tmp.*
}

_print_projid()
{
	_scratch_xfs_db -r -c "inode $1" \
		-c "print core.projid_lo" \
		-c "print core.projid_hi"
}

# real QA test starts here
_supported_fs xfs
_require_xfs_quota
_require_scratch
_require_projid32bit
_require_projid16bit

# create xfs fs without projid32bit ability, will be gained by xfs_admin
_scratch_mkfs_xfs -i projid32bit=0 -d size=200m >> $seqres.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 \
		>> $seqres.full
$XFS_QUOTA_PROG -x -c "project -s -p $dir/32bit 2123456789" $SCRATCH_DEV \
		>> $seqres.full 2>&1

echo "No 32bit project quotas:"
$XFS_IO_PROG -r -c "lsproj" $dir/16bit
$XFS_IO_PROG -r -c "lsproj" $dir/32bit

_scratch_unmount

# Now, enable projid32bit support by xfs_admin
_scratch_xfs_admin -p >> $seqres.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 \
		>> $seqres.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 >> $seqres.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 >> $seqres.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 >> $seqres.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

_scratch_unmount

# 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