Skip to contentSkip to conversation

generic: test statfs on project quota directory

PATCH Superseded Zorro Lang 3 participants 5 messages May 13, 2019 – Jun 14, 2019

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH 1/1 generic: test statfs on project quota directory

There's a bug on xfs cause statfs get negative f_ffree value from a project quota directory. It's fixed by "de7243057 fs/xfs: fix f_ffree value for statfs when project quota is set". So add statfs testing on project quota block and inode count limit.

For testing foreign fs quota, change _qmount() function, turn on project if quotaon support.

---

Hi,

(Long time passed, re-send this patch again to get reviewing)

There's one thing I don't understand, so CC ext4 mail list. Please feel free to reply, if anyone knows that:

$ mkfs.ext4 $SCRATCH_DEV
$ tune2fs -O quota,project $SCRATCH_DEV
$ mount $SCRATCH_DEV $SCRATCH_MNT -o prjquota
$ quotaon -P $SCRATCH_MNT
$ mkdir $SCRATCH_MNT/t
$ xfs_quota -f -x -c "project -p $SCRATCH_MNT/t -s 42" $SCRATCH_MNT
$ xfs_quota -f -x -c "limit -p bsoft=100m answer" $SCRATCH_MNT
$ df -k $SCRATCH_MNT/t
Filesystem    1K-blocks  Used Available Use% Mounted on
SCRATCH_DEV    102400     4    102396   1% SCRATCH_MNT

On XFS, the 'Used' field always shows '0'. But why ext4 always has more 4k? Is it a bug or expected.

Thanks,
Zorro

 common/quota          |  4 +++
 tests/generic/999     | 74 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/999.out |  3 ++
 tests/generic/group   |  1 +
 4 files changed, 82 insertions(+)
 create mode 100755 tests/generic/999
 create mode 100644 tests/generic/999.out
common/quota +4 -0
index f19f81a1..315df8cb 100644
@@ -200,6 +200,10 @@ _qmount()
     if [ "$FSTYP" != "xfs" ]; then
         quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
         quotaon -ug $SCRATCH_MNT >>$seqres.full 2>&1
+	# try to turn on project quota if it's supported
+	if quotaon --help 2>&1 | grep -q '\-\-project'; then
+		quotaon --project $SCRATCH_MNT >>$seqres.full 2>&1
+	fi
     fi
     chmod ugo+rwx $SCRATCH_MNT
 }
tests/generic/999 new file +74 -0

74 lines not on this page · raw message

tests/generic/999.out new file +3 -0
new file mode 100644
index 00000000..1bebabd4
@@ -0,0 +1,3 @@
+QA output created by 999
+File Inodes IUsed 1K-blocks Used
+SCRATCH_MNT/t 53 2 102400 N
tests/generic/group +1 -0
index 9f4845c6..35da10a5 100644
@@ -542,3 +542,4 @@
 537 auto quick trim
 538 auto quick aio
 539 auto quick punch seek
+999 auto quick quota
Signature · 1 line
2.17.2
#1 lore raw
Quoted 30 lines · Zorro Lang

There's a bug on xfs cause statfs get negative f_ffree value from a project quota directory. It's fixed by "de7243057 fs/xfs: fix f_ffree value for statfs when project quota is set". So add statfs testing on project quota block and inode count limit.

For testing foreign fs quota, change _qmount() function, turn on project if quotaon support.

---

Hi,

(Long time passed, re-send this patch again to get reviewing)

There's one thing I don't understand, so CC ext4 mail list. Please feel free to reply, if anyone knows that:

$ mkfs.ext4 $SCRATCH_DEV
$ tune2fs -O quota,project $SCRATCH_DEV
$ mount $SCRATCH_DEV $SCRATCH_MNT -o prjquota
$ quotaon -P $SCRATCH_MNT
$ mkdir $SCRATCH_MNT/t
$ xfs_quota -f -x -c "project -p $SCRATCH_MNT/t -s 42" $SCRATCH_MNT
$ xfs_quota -f -x -c "limit -p bsoft=100m answer" $SCRATCH_MNT
$ df -k $SCRATCH_MNT/t
Filesystem    1K-blocks  Used Available Use% Mounted on
SCRATCH_DEV    102400     4    102396   1% SCRATCH_MNT
Quoted 2 lines

On XFS, the 'Used' field always shows '0'. But why ext4 always has more 4k? Is it a bug or expected.

Each directory in ext4 consumes a 4KB block, so setting the project quota on a directory always consumes at least one block.

Cheers, Andreas

Quoted 117 lines
common/quota          |  4 +++
tests/generic/999     | 74 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/999.out |  3 ++
tests/generic/group   |  1 +
4 files changed, 82 insertions(+)

create mode 100755 tests/generic/999
create mode 100644 tests/generic/999.out

common/quota +4 -0
index f19f81a1..315df8cb 100644
@@ -200,6 +200,10 @@ _qmount()
   if [ "$FSTYP" != "xfs" ]; then
       quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
       quotaon -ug $SCRATCH_MNT >>$seqres.full 2>&1
+	# try to turn on project quota if it's supported
+	if quotaon --help 2>&1 | grep -q '\-\-project'; then
+		quotaon --project $SCRATCH_MNT >>$seqres.full 2>&1
+	fi
   fi
   chmod ugo+rwx $SCRATCH_MNT
 }
tests/generic/999 new file +74 -0
new file mode 100755
index 00000000..555341f1
@@ -0,0 +1,74 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test No. 999
+#
+# Test statfs when project quota is set.
+# Uncover de7243057 fs/xfs: fix f_ffree value for statfs when project quota is set
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	_scratch_unmount
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/quota
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_quota
+_require_xfs_quota_foreign
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_enable_pquota
+_qmount_option "prjquota"
+_qmount
+_require_prjquota $SCRATCH_DEV
+
+# Create a directory to be project object, and create a file to take 64k space
+mkdir $SCRATCH_MNT/t
+$XFS_IO_PROG -f -c "pwrite 0 65536" -c sync $SCRATCH_MNT/t/file >>$seqres.full
+
+# Setup temporary replacements for /etc/projects and /etc/projid
+cat >$tmp.projects <<EOF
+42:$SCRATCH_MNT/t
+EOF
+
+cat >$tmp.projid <<EOF
+answer:42
+EOF
+
+quota_cmd="$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid"
+$quota_cmd -x -c 'project -s answer' $SCRATCH_MNT >/dev/null 2>&1
+$quota_cmd -x -c 'limit -p isoft=53 bsoft=100m answer' $SCRATCH_MNT
+
+# The itotal and size should be 53 and 102400(k), as above project quota limit.
+# The isued and used should be 2 and 64(k), as this case takes. But ext4 always
+# shows more 4k 'used' space than XFS, it prints 68k at here. So filter the
+# 6[48] at the end.
+df -k --output=file,itotal,iused,size,used $SCRATCH_MNT/t | \
+	_filter_scratch | _filter_spaces | \
+	sed -e "/SCRATCH_MNT/s/6[48]/N/"
+
+# success, all done
+status=0
+exit
tests/generic/999.out new file +3 -0
new file mode 100644
index 00000000..1bebabd4
@@ -0,0 +1,3 @@
+QA output created by 999
+File Inodes IUsed 1K-blocks Used
+SCRATCH_MNT/t 53 2 102400 N
tests/generic/group +0 -0
index 9f4845c6..35da10a5 100644
@@ -542,3 +542,4 @@
Quoted 7 lines

537 auto quick trim
538 auto quick aio
539 auto quick punch seek
+999 auto quick quota
--
2.17.2

Cheers, Andreas

Cheers, Andreas

author
#2 lore raw
Quoted 31 lines · Andreas Dilger
Quoted 30 lines · Zorro Lang

There's a bug on xfs cause statfs get negative f_ffree value from a project quota directory. It's fixed by "de7243057 fs/xfs: fix f_ffree value for statfs when project quota is set". So add statfs testing on project quota block and inode count limit.

For testing foreign fs quota, change _qmount() function, turn on project if quotaon support.

---

Hi,

(Long time passed, re-send this patch again to get reviewing)

There's one thing I don't understand, so CC ext4 mail list. Please feel free to reply, if anyone knows that:

$ mkfs.ext4 $SCRATCH_DEV
$ tune2fs -O quota,project $SCRATCH_DEV
$ mount $SCRATCH_DEV $SCRATCH_MNT -o prjquota
$ quotaon -P $SCRATCH_MNT
$ mkdir $SCRATCH_MNT/t
$ xfs_quota -f -x -c "project -p $SCRATCH_MNT/t -s 42" $SCRATCH_MNT
$ xfs_quota -f -x -c "limit -p bsoft=100m answer" $SCRATCH_MNT
$ df -k $SCRATCH_MNT/t
Filesystem    1K-blocks  Used Available Use% Mounted on
SCRATCH_DEV    102400     4    102396   1% SCRATCH_MNT
Quoted 5 lines
Quoted 2 lines

On XFS, the 'Used' field always shows '0'. But why ext4 always has more 4k? Is it a bug or expected.

Each directory in ext4 consumes a 4KB block, so setting the project quota on a directory always consumes at least one block.

Ping [email protected].

One month passed. Is there anything else block this patch merge?

Thanks,
Zorro

Quoted 144 lines

Cheers, Andreas

Quoted 117 lines
common/quota          |  4 +++
tests/generic/999     | 74 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/999.out |  3 ++
tests/generic/group   |  1 +
4 files changed, 82 insertions(+)

create mode 100755 tests/generic/999
create mode 100644 tests/generic/999.out

common/quota +4 -0
index f19f81a1..315df8cb 100644
@@ -200,6 +200,10 @@ _qmount()
   if [ "$FSTYP" != "xfs" ]; then
       quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
       quotaon -ug $SCRATCH_MNT >>$seqres.full 2>&1
+	# try to turn on project quota if it's supported
+	if quotaon --help 2>&1 | grep -q '\-\-project'; then
+		quotaon --project $SCRATCH_MNT >>$seqres.full 2>&1
+	fi
   fi
   chmod ugo+rwx $SCRATCH_MNT
 }
tests/generic/999 new file +74 -0
new file mode 100755
index 00000000..555341f1
@@ -0,0 +1,74 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test No. 999
+#
+# Test statfs when project quota is set.
+# Uncover de7243057 fs/xfs: fix f_ffree value for statfs when project quota is set
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	_scratch_unmount
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/quota
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_quota
+_require_xfs_quota_foreign
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_enable_pquota
+_qmount_option "prjquota"
+_qmount
+_require_prjquota $SCRATCH_DEV
+
+# Create a directory to be project object, and create a file to take 64k space
+mkdir $SCRATCH_MNT/t
+$XFS_IO_PROG -f -c "pwrite 0 65536" -c sync $SCRATCH_MNT/t/file >>$seqres.full
+
+# Setup temporary replacements for /etc/projects and /etc/projid
+cat >$tmp.projects <<EOF
+42:$SCRATCH_MNT/t
+EOF
+
+cat >$tmp.projid <<EOF
+answer:42
+EOF
+
+quota_cmd="$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid"
+$quota_cmd -x -c 'project -s answer' $SCRATCH_MNT >/dev/null 2>&1
+$quota_cmd -x -c 'limit -p isoft=53 bsoft=100m answer' $SCRATCH_MNT
+
+# The itotal and size should be 53 and 102400(k), as above project quota limit.
+# The isued and used should be 2 and 64(k), as this case takes. But ext4 always
+# shows more 4k 'used' space than XFS, it prints 68k at here. So filter the
+# 6[48] at the end.
+df -k --output=file,itotal,iused,size,used $SCRATCH_MNT/t | \
+	_filter_scratch | _filter_spaces | \
+	sed -e "/SCRATCH_MNT/s/6[48]/N/"
+
+# success, all done
+status=0
+exit
tests/generic/999.out new file +3 -0
new file mode 100644
index 00000000..1bebabd4
@@ -0,0 +1,3 @@
+QA output created by 999
+File Inodes IUsed 1K-blocks Used
+SCRATCH_MNT/t 53 2 102400 N
tests/generic/group +0 -0
index 9f4845c6..35da10a5 100644
@@ -542,3 +542,4 @@
Quoted 7 lines

537 auto quick trim
538 auto quick aio
539 auto quick punch seek
+999 auto quick quota
--
2.17.2

Cheers, Andreas

Cheers, Andreas

#3 lore raw
Quoted 35 lines · Zorro Lang
Quoted 34 lines · Andreas Dilger
Quoted 32 lines · Zorro Lang

There's a bug on xfs cause statfs get negative f_ffree value from a project quota directory. It's fixed by "de7243057 fs/xfs: fix f_ffree value for statfs when project quota is set". So add statfs testing on project quota block and inode count limit.

For testing foreign fs quota, change _qmount() function, turn on project if quotaon support.

---

Hi,

(Long time passed, re-send this patch again to get reviewing)

There's one thing I don't understand, so CC ext4 mail list. Please feel free to reply, if anyone knows that:

$ mkfs.ext4 $SCRATCH_DEV
$ tune2fs -O quota,project $SCRATCH_DEV
$ mount $SCRATCH_DEV $SCRATCH_MNT -o prjquota
$ quotaon -P $SCRATCH_MNT
$ mkdir $SCRATCH_MNT/t
$ xfs_quota -f -x -c "project -p $SCRATCH_MNT/t -s 42" $SCRATCH_MNT
$ xfs_quota -f -x -c "limit -p bsoft=100m answer" $SCRATCH_MNT
$ df -k $SCRATCH_MNT/t
Filesystem    1K-blocks  Used Available Use% Mounted on
SCRATCH_DEV    102400     4    102396   1% SCRATCH_MNT

On XFS, the 'Used' field always shows '0'. But why ext4 always has more 4k? Is it a bug or expected.

Quoted 6 lines
Quoted 2 lines

Each directory in ext4 consumes a 4KB block, so setting the project quota on a directory always consumes at least one block.

Ping [email protected].

One month passed. Is there anything else block this patch merge?

If this is a regression test for an xfs bug, why isn't this in tests/xfs/ ? Especially because ext4 has different behaviors that clash with the golden output -- what happens if you run this with inline data enabled?

--D

Quoted 149 lines

Thanks,
Zorro

Quoted 144 lines

Cheers, Andreas

Quoted 117 lines
common/quota          |  4 +++
tests/generic/999     | 74 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/999.out |  3 ++
tests/generic/group   |  1 +
4 files changed, 82 insertions(+)

create mode 100755 tests/generic/999
create mode 100644 tests/generic/999.out

common/quota +4 -0
index f19f81a1..315df8cb 100644
@@ -200,6 +200,10 @@ _qmount()
   if [ "$FSTYP" != "xfs" ]; then
       quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
       quotaon -ug $SCRATCH_MNT >>$seqres.full 2>&1
+	# try to turn on project quota if it's supported
+	if quotaon --help 2>&1 | grep -q '\-\-project'; then
+		quotaon --project $SCRATCH_MNT >>$seqres.full 2>&1
+	fi
   fi
   chmod ugo+rwx $SCRATCH_MNT
 }
tests/generic/999 new file +74 -0
new file mode 100755
index 00000000..555341f1
@@ -0,0 +1,74 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test No. 999
+#
+# Test statfs when project quota is set.
+# Uncover de7243057 fs/xfs: fix f_ffree value for statfs when project quota is set
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	_scratch_unmount
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/quota
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_quota
+_require_xfs_quota_foreign
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_enable_pquota
+_qmount_option "prjquota"
+_qmount
+_require_prjquota $SCRATCH_DEV
+
+# Create a directory to be project object, and create a file to take 64k space
+mkdir $SCRATCH_MNT/t
+$XFS_IO_PROG -f -c "pwrite 0 65536" -c sync $SCRATCH_MNT/t/file >>$seqres.full
+
+# Setup temporary replacements for /etc/projects and /etc/projid
+cat >$tmp.projects <<EOF
+42:$SCRATCH_MNT/t
+EOF
+
+cat >$tmp.projid <<EOF
+answer:42
+EOF
+
+quota_cmd="$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid"
+$quota_cmd -x -c 'project -s answer' $SCRATCH_MNT >/dev/null 2>&1
+$quota_cmd -x -c 'limit -p isoft=53 bsoft=100m answer' $SCRATCH_MNT
+
+# The itotal and size should be 53 and 102400(k), as above project quota limit.
+# The isued and used should be 2 and 64(k), as this case takes. But ext4 always
+# shows more 4k 'used' space than XFS, it prints 68k at here. So filter the
+# 6[48] at the end.
+df -k --output=file,itotal,iused,size,used $SCRATCH_MNT/t | \
+	_filter_scratch | _filter_spaces | \
+	sed -e "/SCRATCH_MNT/s/6[48]/N/"
+
+# success, all done
+status=0
+exit
tests/generic/999.out new file +3 -0
new file mode 100644
index 00000000..1bebabd4
@@ -0,0 +1,3 @@
+QA output created by 999
+File Inodes IUsed 1K-blocks Used
+SCRATCH_MNT/t 53 2 102400 N
tests/generic/group +0 -0
index 9f4845c6..35da10a5 100644
@@ -542,3 +542,4 @@
Quoted 7 lines

537 auto quick trim
538 auto quick aio
539 auto quick punch seek
+999 auto quick quota
--
2.17.2

Cheers, Andreas

Cheers, Andreas

author
#4 lore raw
Quoted 39 lines · Darrick J. Wong
Quoted 38 lines · Zorro Lang
Quoted 36 lines · Andreas Dilger
Quoted 30 lines · Zorro Lang

There's a bug on xfs cause statfs get negative f_ffree value from a project quota directory. It's fixed by "de7243057 fs/xfs: fix f_ffree value for statfs when project quota is set". So add statfs testing on project quota block and inode count limit.

For testing foreign fs quota, change _qmount() function, turn on project if quotaon support.

---

Hi,

(Long time passed, re-send this patch again to get reviewing)

There's one thing I don't understand, so CC ext4 mail list. Please feel free to reply, if anyone knows that:

$ mkfs.ext4 $SCRATCH_DEV
$ tune2fs -O quota,project $SCRATCH_DEV
$ mount $SCRATCH_DEV $SCRATCH_MNT -o prjquota
$ quotaon -P $SCRATCH_MNT
$ mkdir $SCRATCH_MNT/t
$ xfs_quota -f -x -c "project -p $SCRATCH_MNT/t -s 42" $SCRATCH_MNT
$ xfs_quota -f -x -c "limit -p bsoft=100m answer" $SCRATCH_MNT
$ df -k $SCRATCH_MNT/t
Filesystem    1K-blocks  Used Available Use% Mounted on
SCRATCH_DEV    102400     4    102396   1% SCRATCH_MNT
Quoted 2 lines

On XFS, the 'Used' field always shows '0'. But why ext4 always has more 4k? Is it a bug or expected.

Each directory in ext4 consumes a 4KB block, so setting the project quota on a directory always consumes at least one block.

Quoted 8 lines
Quoted 3 lines

Ping [email protected].

One month passed. Is there anything else block this patch merge?

If this is a regression test for an xfs bug, why isn't this in tests/xfs/ ? Especially because ext4 has different behaviors that clash with the golden output -- what happens if you run this with inline data enabled?

Hi Darrick,

Yes, it's a regression test for xfs bug:
de7243057e7c fs/xfs: fix f_ffree value for statfs when project quota is set

It's not a xfs only case, due to I thought the test steps are common. If I change it to a generic case, it can cover more. Do you think I should change it back to XFS only case?

Thanks,
Zorro

Quoted 152 lines

--D

Quoted 149 lines

Thanks,
Zorro

Quoted 144 lines

Cheers, Andreas

Quoted 117 lines
common/quota          |  4 +++
tests/generic/999     | 74 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/999.out |  3 ++
tests/generic/group   |  1 +
4 files changed, 82 insertions(+)

create mode 100755 tests/generic/999
create mode 100644 tests/generic/999.out

common/quota +4 -0
index f19f81a1..315df8cb 100644
@@ -200,6 +200,10 @@ _qmount()
   if [ "$FSTYP" != "xfs" ]; then
       quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
       quotaon -ug $SCRATCH_MNT >>$seqres.full 2>&1
+	# try to turn on project quota if it's supported
+	if quotaon --help 2>&1 | grep -q '\-\-project'; then
+		quotaon --project $SCRATCH_MNT >>$seqres.full 2>&1
+	fi
   fi
   chmod ugo+rwx $SCRATCH_MNT
 }
tests/generic/999 new file +74 -0
new file mode 100755
index 00000000..555341f1
@@ -0,0 +1,74 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test No. 999
+#
+# Test statfs when project quota is set.
+# Uncover de7243057 fs/xfs: fix f_ffree value for statfs when project quota is set
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	_scratch_unmount
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/quota
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_quota
+_require_xfs_quota_foreign
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_enable_pquota
+_qmount_option "prjquota"
+_qmount
+_require_prjquota $SCRATCH_DEV
+
+# Create a directory to be project object, and create a file to take 64k space
+mkdir $SCRATCH_MNT/t
+$XFS_IO_PROG -f -c "pwrite 0 65536" -c sync $SCRATCH_MNT/t/file >>$seqres.full
+
+# Setup temporary replacements for /etc/projects and /etc/projid
+cat >$tmp.projects <<EOF
+42:$SCRATCH_MNT/t
+EOF
+
+cat >$tmp.projid <<EOF
+answer:42
+EOF
+
+quota_cmd="$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid"
+$quota_cmd -x -c 'project -s answer' $SCRATCH_MNT >/dev/null 2>&1
+$quota_cmd -x -c 'limit -p isoft=53 bsoft=100m answer' $SCRATCH_MNT
+
+# The itotal and size should be 53 and 102400(k), as above project quota limit.
+# The isued and used should be 2 and 64(k), as this case takes. But ext4 always
+# shows more 4k 'used' space than XFS, it prints 68k at here. So filter the
+# 6[48] at the end.
+df -k --output=file,itotal,iused,size,used $SCRATCH_MNT/t | \
+	_filter_scratch | _filter_spaces | \
+	sed -e "/SCRATCH_MNT/s/6[48]/N/"
+
+# success, all done
+status=0
+exit
tests/generic/999.out new file +3 -0
new file mode 100644
index 00000000..1bebabd4
@@ -0,0 +1,3 @@
+QA output created by 999
+File Inodes IUsed 1K-blocks Used
+SCRATCH_MNT/t 53 2 102400 N
tests/generic/group +0 -0
index 9f4845c6..35da10a5 100644
@@ -542,3 +542,4 @@
Quoted 7 lines

537 auto quick trim
538 auto quick aio
539 auto quick punch seek
+999 auto quick quota
--
2.17.2

Cheers, Andreas

Cheers, Andreas