* [PATCH] xfstests: Introduce test case 285 for project quota negative test collections
@ 2012-04-04 14:14 Jeff Liu
2012-04-11 20:02 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Liu @ 2012-04-04 14:14 UTC (permalink / raw)
To: xfs; +Cc: Christoph Hellwig
Hello,
Call statfs(2) against a directory with project quota setup, the vanilla kernel-3.3 will crashed if the
underlaying XFS file system was mounted without pquota option.
For detail, please take a look at the following link for the bug report:
http://patchwork.xfs.org/patch/3477/
I'd like to introduce a new test to verify something like this, it is intended to run as a negative test
collections for project quota. It only verify the above issue for now, maybe its better to wrap the steps in a individual function?
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
---
285 | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
285.out | 9 +++++
group | 1 +
3 files changed, 124 insertions(+), 0 deletions(-)
create mode 100755 285
create mode 100644 285.out
diff --git a/285 b/285
new file mode 100755
index 0000000..a7bace8
--- /dev/null
+++ b/285
@@ -0,0 +1,114 @@
+#! /bin/bash
+# FS QA Test No. 285
+#
+# Negative test cases collection for project quota
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2012 Oracle Liu Jie. 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
+#-----------------------------------------------------------------------
+#
+# creator
+owner=jeff.liu@oracle.com
+
+seq=`basename $0`
+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()
+{
+ umount $tmpdir
+ rmdir $tmpdir
+ rm -f $tmp
+ rm -f $tmpfile
+ rm -f /etc/projects.bak
+ rm -f /etc/projid.bak
+}
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+. ./common.quota
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs xfs
+_supported_os Linux
+_require_xfs_quota
+
+tmpfile=$TEST_DIR/fsfile.$$
+tmpdir=$TEST_DIR/tmpdir.$$
+project_name="pquota_test"
+testfile=$tmpdir/testme
+
+_backup_pquota_config_files()
+{
+ cp /etc/projects /etc/projects.bak
+ cp /etc/projid /etc/projid.bak
+}
+
+_restore_pquota_config_files()
+{
+ cp /etc/projects.bak /etc/projects
+ cp /etc/projid.bak /etc/projid
+}
+
+_create_pquota_config_files()
+{
+ echo "1:$tmpdir" > /etc/projects
+ echo "$project_name:1" > /etc/projid
+}
+
+mkdir -p $tmpdir || _fail "!!! failed to create temp mount dir"
+
+echo "*** create loopback image file ***"
+dd if=/dev/zero of=$tmpfile bs=4k count=4096 >/dev/null 2>&1
+
+echo "*** mkfs.xfs ***"
+mkfs.xfs -b size=4096 $tmpfile >/dev/null 2>&1
+
+# mount loopback image but without pquota option
+mount -o loop $tmpfile $tmpdir || _fail "!!! failed to loopback mount"
+
+echo "*** backup old project quota config files ***"
+_backup_pquota_config_files
+
+echo "*** setup project quota for testing ***"
+_create_pquota_config_files
+
+# create a file to trigger du(1) call statfs(2) against a directory with
+# project quota configed but without 'pquota' mount option.
+# XFS crashed on vanilla kernel-3.3 in this case.
+echo "*** create a file under the project directory ***"
+echo "project quota test" > $testfile
+
+echo "*** setup project quota ***"
+xfs_quota -x -c "project -s $project_name" $tmpdir >/dev/null 2>&1
+
+du -sh $tmpdir >/dev/null 2>&1
+
+echo "*** clearing project quota ***"
+xfs_quota -x -c "project -C $project_name" $tmpdir >/dev/null 2>&1
+
+echo "*** restore old project quota config files ***"
+_restore_pquota_config_files
+
+status=0
+exit
diff --git a/285.out b/285.out
new file mode 100644
index 0000000..088cc08
--- /dev/null
+++ b/285.out
@@ -0,0 +1,9 @@
+QA output created by 285
+*** create loopback image file ***
+*** mkfs.xfs ***
+*** backup old project quota config files ***
+*** setup project quota for testing ***
+*** create a file under the project directory ***
+*** setup project quota ***
+*** clearing project quota ***
+*** restore old project quota config files ***
diff --git a/group b/group
index 104ed35..0b33178 100644
--- a/group
+++ b/group
@@ -403,3 +403,4 @@ deprecated
282 dump ioctl auto quick
283 dump ioctl auto quick
284 auto
+285 auto
--
1.7.9
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xfstests: Introduce test case 285 for project quota negative test collections
2012-04-04 14:14 [PATCH] xfstests: Introduce test case 285 for project quota negative test collections Jeff Liu
@ 2012-04-11 20:02 ` Christoph Hellwig
2012-04-12 13:14 ` Jeff Liu
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2012-04-11 20:02 UTC (permalink / raw)
To: Jeff Liu; +Cc: Christoph Hellwig, xfs
Hi Jeff,
thanks a lot for sending this patch!
> I'd like to introduce a new test to verify something like this, it is intended to run as a negative test
> collections for project quota. It only verify the above issue for now, maybe its better to wrap the steps in a individual function?
We should have one testcase for one thing to test - by that defintion
this bug should really stay a test case on it's own. Some more comments
below.
> +_create_pquota_config_files()
> +{
> + echo "1:$tmpdir" > /etc/projects
> + echo "$project_name:1" > /etc/projid
> +}
We can use numeric ids for projects directly, and the -p object to
various xfs_quota subcommands also allows refering to a path instead
of a project name, that way we don't have to rewrite the config files
in /etc.
> +echo "*** create loopback image file ***"
> +dd if=/dev/zero of=$tmpfile bs=4k count=4096 >/dev/null 2>&1
> +
> +echo "*** mkfs.xfs ***"
> +mkfs.xfs -b size=4096 $tmpfile >/dev/null 2>&1
> +
> +# mount loopback image but without pquota option
> +mount -o loop $tmpfile $tmpdir || _fail "!!! failed to loopback mount"
This should use _scratch_mkfs _scratch_mount and so on instead of
opencoding it.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfstests: Introduce test case 285 for project quota negative test collections
2012-04-11 20:02 ` Christoph Hellwig
@ 2012-04-12 13:14 ` Jeff Liu
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Liu @ 2012-04-12 13:14 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs
Hi Christoph,
Thanks for your comments below, I'll fix them up and repost it here.
-Jeff
On 04/12/2012 04:02 AM, Christoph Hellwig wrote:
> Hi Jeff,
>
> thanks a lot for sending this patch!
>
>> I'd like to introduce a new test to verify something like this, it is intended to run as a negative test
>> collections for project quota. It only verify the above issue for now, maybe its better to wrap the steps in a individual function?
>
> We should have one testcase for one thing to test - by that defintion
> this bug should really stay a test case on it's own. Some more comments
> below.
>
>> +_create_pquota_config_files()
>> +{
>> + echo "1:$tmpdir" > /etc/projects
>> + echo "$project_name:1" > /etc/projid
>> +}
>
> We can use numeric ids for projects directly, and the -p object to
> various xfs_quota subcommands also allows refering to a path instead
> of a project name, that way we don't have to rewrite the config files
> in /etc.
>
>> +echo "*** create loopback image file ***"
>> +dd if=/dev/zero of=$tmpfile bs=4k count=4096 >/dev/null 2>&1
>> +
>> +echo "*** mkfs.xfs ***"
>> +mkfs.xfs -b size=4096 $tmpfile >/dev/null 2>&1
>> +
>> +# mount loopback image but without pquota option
>> +mount -o loop $tmpfile $tmpdir || _fail "!!! failed to loopback mount"
>
> This should use _scratch_mkfs _scratch_mount and so on instead of
> opencoding it.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-04-12 13:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-04 14:14 [PATCH] xfstests: Introduce test case 285 for project quota negative test collections Jeff Liu
2012-04-11 20:02 ` Christoph Hellwig
2012-04-12 13:14 ` Jeff Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox