From: Jeff Liu <jeff.liu@oracle.com>
To: xfs@oss.sgi.com
Cc: Christoph Hellwig <hch@infradead.org>
Subject: [PATCH] xfstests: Introduce test case 285 for project quota negative test collections
Date: Wed, 04 Apr 2012 22:14:50 +0800 [thread overview]
Message-ID: <4F7C575A.7030507@oracle.com> (raw)
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
next reply other threads:[~2012-04-04 14:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-04 14:14 Jeff Liu [this message]
2012-04-11 20:02 ` [PATCH] xfstests: Introduce test case 285 for project quota negative test collections Christoph Hellwig
2012-04-12 13:14 ` Jeff Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F7C575A.7030507@oracle.com \
--to=jeff.liu@oracle.com \
--cc=hch@infradead.org \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.