From: Jeff Liu <jeff.liu@oracle.com>
To: "xfs@oss.sgi.com" <xfs@oss.sgi.com>
Subject: [PATCH] xfstests: generic/315, verify preallocated disk space is released per truncate
Date: Mon, 01 Jul 2013 18:29:19 +0800 [thread overview]
Message-ID: <51D159FF.401@oracle.com> (raw)
From: Jie Liu <jeff.liu@oracle.com>
Introduce generic test 315 to verify if the disk space is
released after truncating a preallocated file back to the
old smaller size. Before Linux-3.10, Btrfs/OCFS2 test
failed in this case.
The test file is fallocated with FALLOC_FL_KEEP_SIZE option.
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
---
tests/generic/315 | 79 +++++++++++++++++++++++++++++++++++++++++++++++++
tests/generic/315.out | 2 ++
tests/generic/group | 1 +
3 files changed, 82 insertions(+)
mode change 100644 => 100755 tests/generic/311
create mode 100755 tests/generic/315
create mode 100644 tests/generic/315.out
diff --git a/tests/generic/311 b/tests/generic/311
old mode 100644
new mode 100755
diff --git a/tests/generic/315 b/tests/generic/315
new file mode 100755
index 0000000..7cfc40d
--- /dev/null
+++ b/tests/generic/315
@@ -0,0 +1,79 @@
+#! /bin/bash
+# FS QA Test No. 315
+#
+# fallocate/truncate tests with FALLOC_FL_KEEP_SIZE option.
+# Verify if the disk space is released after truncating a file back
+# to the old smaller size. Before Linux 3.10, Btrfs/OCFS2 are test
+# failed in this case.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2013 Oracle, 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`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=0 # success is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ cd /
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+
+rm -f $seqres.full
+
+echo "Slience is golden"
+
+# Check the current avaliable disk space on $TEST_DIR.
+# 1024KiB at least
+avail_begin=`df -P $TEST_DIR | awk 'END {print $4}'`
+[ "$avail_begin" -ge 1024 ] || _notrun "Test device is too small ($avail_begin KiB)"
+
+# Preallocate half size of the available disk space to a file
+# starts from offset 0 with FALLOC_FL_KEEP_SIZE option on the
+# test file system.
+fallocate -n -o 0 -l $(($avail_begin/2)) $TEST_DIR/testfile.$seq >>$seqres.full 2>&1
+
+# Verify the file size, it should keep unchanged as 0 in this case
+fsize=`ls -l $TEST_DIR/testfile.$seq | awk '{print $5}'`
+[ "$fsize" -eq 0 ] || _fail "File size is changed to ($fsize Bytes)"
+
+# Truncate the file size back to 0
+truncate -s 0 $TEST_DIR/testfile.$seq
+sync
+
+# Preallocated disk space should be released
+avail_done=`df -P $TEST_DIR | awk 'END {print $4}'`
+[ "$avail_done" -eq "$avail_begin" ] || _fail "Available disk space ($avail_done KiB)"
+
+# success, all done
+exit
diff --git a/tests/generic/315.out b/tests/generic/315.out
new file mode 100644
index 0000000..8414add
--- /dev/null
+++ b/tests/generic/315.out
@@ -0,0 +1,2 @@
+QA output created by 315
+Slience is golden
diff --git a/tests/generic/group b/tests/generic/group
index bd443c1..30889bd 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -115,3 +115,4 @@
310 auto
311 auto metadata log
312 auto quick prealloc enospc
+315 auto quick rw prealloc
--
1.7.9.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2013-07-01 10:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-01 10:29 Jeff Liu [this message]
2013-07-19 22:17 ` [PATCH] xfstests: generic/315, verify preallocated disk space is released per truncate Ben Myers
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=51D159FF.401@oracle.com \
--to=jeff.liu@oracle.com \
--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.