public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfstests: add test for fallocate with hole punching
@ 2010-11-12 21:55 Josef Bacik
  2010-11-18  5:30 ` Dave Chinner
  0 siblings, 1 reply; 3+ messages in thread
From: Josef Bacik @ 2010-11-12 21:55 UTC (permalink / raw)
  To: xfs

This test is based on 242, just modified to use fiemap, fallocate and fallocate
-p.  I've looked at all of the output by hand and verified that it's working
properly.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
---
 245       |  189 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 245.out   |   47 +++++++++++++++
 common.rc |   27 +++++++++
 group     |    1 +
 4 files changed, 264 insertions(+), 0 deletions(-)
 create mode 100755 245
 create mode 100644 245.out

diff --git a/245 b/245
new file mode 100755
index 0000000..6f7a502
--- /dev/null
+++ b/245
@@ -0,0 +1,189 @@
+#! /bin/bash
+# FS QA Test No. 242
+#
+# Test XFS_IOC_ZERO_RANGE
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2010 Red Hat.  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=dchinner@redhat.com
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+
+_cleanup()
+{
+    rm -f $tmp.*
+}
+
+trap "_cleanup ; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_xfs_io_falloc_punch
+_require_xfs_io_fiemap
+
+_filter_bmap()
+{
+    awk --posix '$3 ~ /hole/ { print $1, $2, $3; next }
+		 $5 ~ /0x[[:digit:]]*8[[:digit:]]{2}/ { print $1, $2, "unwritten"; next }
+		 $5 ~ /0x[[:digit:]]+/ {print $1, $2, "data" }'
+}
+
+# test the different corner cases for falloc -ping a range:
+#
+#	1. into a hole
+#	2. into allocated space
+#	3. into unwritten space
+#	4. hole -> data
+#	5. hole -> unwritten
+#	6. data -> hole
+#	7. data -> unwritten
+#	8. unwritten -> hole
+#	9. unwritten -> data
+#	10. hole -> data -> hole
+#	11. data -> hole -> data
+#	12. unwritten -> data -> unwritten
+#	13. data -> unwritten -> data
+
+testfile=$TEST_DIR/242.$$
+
+echo "	1. into a hole"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "falloc -p 4k 8k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+echo "	2. into allocated space"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "pwrite 0 20k" -c "fsync" \
+	-c "falloc -p 4k 8k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+echo "	3. into unwritten space"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "falloc 0 20k" \
+	-c "falloc -p 4k 8k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+echo "	4. hole -> data"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "pwrite 8k 8k" -c "fsync" \
+	-c "falloc -p 4k 8k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+echo "	5. hole -> unwritten"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "falloc 8k 8k" \
+	-c "falloc -p 4k 8k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+echo "	6. data -> hole"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "pwrite 0 8k" -c "fsync" \
+	-c "falloc -p 4k 8k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+echo "	7. data -> unwritten"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "pwrite 0 8k" -c "fsync" \
+	-c "falloc 8k 8k" \
+	-c "falloc -p 4k 8k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+echo "	8. unwritten -> hole"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "falloc 0 8k" \
+	-c "falloc -p 4k 8k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+echo "	9. unwritten -> data"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "falloc 0 8k" \
+	-c "pwrite 8k 8k" -c "fsync" \
+	-c "falloc -p 4k 8k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+echo "	10. hole -> data -> hole"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "pwrite 8k 4k" -c "fsync" \
+	-c "falloc -p 4k 12k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+echo "	11. data -> hole -> data"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "falloc 0 20k" \
+	-c "pwrite 0 8k" \
+	-c "pwrite 12k 8k" -c "fsync" \
+	-c "falloc -p 8k 4k" \
+	-c "falloc -p 4k 12k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+echo "	12. unwritten -> data -> unwritten"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "falloc 0 20k" \
+	-c "pwrite 8k 4k" -c "fsync" \
+	-c "falloc -p 4k 12k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+
+echo "	13. data -> unwritten -> data"
+rm -f $testfile
+$XFS_IO_PROG -F -f -c "truncate 20k" \
+	-c "falloc 0 20k" \
+	-c "pwrite 0k 8k" -c "fsync" \
+	-c "pwrite 12k 8k" -c "fsync" \
+	-c "falloc -p 4k 12k" \
+	-c "fiemap -v" $testfile | _filter_bmap
+[ $? -ne 0 ] && die_now
+
+status=0 ; exit
diff --git a/245.out b/245.out
new file mode 100644
index 0000000..b6cbf9c
--- /dev/null
+++ b/245.out
@@ -0,0 +1,47 @@
+QA output created by 245
+	1. into a hole
+	2. into allocated space
+0: [0..7]: data
+1: [8..23]: hole
+2: [24..39]: data
+	3. into unwritten space
+0: [0..7]: unwritten
+1: [8..23]: hole
+2: [24..39]: unwritten
+	4. hole -> data
+0: [0..23]: hole
+1: [24..31]: data
+2: [32..39]: hole
+	5. hole -> unwritten
+0: [0..23]: hole
+1: [24..31]: unwritten
+2: [32..39]: hole
+	6. data -> hole
+0: [0..7]: data
+1: [8..39]: hole
+	7. data -> unwritten
+0: [0..7]: data
+1: [8..23]: hole
+2: [24..31]: unwritten
+3: [32..39]: hole
+	8. unwritten -> hole
+0: [0..7]: unwritten
+1: [8..39]: hole
+	9. unwritten -> data
+0: [0..7]: unwritten
+1: [8..23]: hole
+2: [24..31]: data
+3: [32..39]: hole
+	10. hole -> data -> hole
+	11. data -> hole -> data
+0: [0..7]: data
+1: [8..31]: hole
+2: [32..39]: data
+	12. unwritten -> data -> unwritten
+0: [0..7]: unwritten
+1: [8..31]: hole
+2: [32..39]: unwritten
+	13. data -> unwritten -> data
+0: [0..7]: data
+1: [8..31]: hole
+2: [32..39]: data
diff --git a/common.rc b/common.rc
index b3bb65c..63c3a01 100644
--- a/common.rc
+++ b/common.rc
@@ -844,6 +844,33 @@ _require_xfs_io_falloc()
 		_notrun "xfs_io fallocate command failed (old kernel/wrong fs?)"
 }
 
+# check that xfs_io, kernel and filesystem all support fallocate with hole
+# punching
+_require_xfs_io_falloc_punch()
+{
+	testfile=$TEST_DIR/$$.falloc
+	testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
+		-c "falloc -p 4k 8k" $testfile 2>&1`
+	rm -f $testfile 2>&1 > /dev/null
+	echo $testio | grep -q "not found" && \
+		_notrun "xfs_io fallocate punch support is missing"
+	echo $testio | grep -q "Operation not supported" && \
+		_notrun "xfs_io fallocate punch command failed (no fs support?)"
+}
+
+# check that xfs_io, kernel and filesystem support fiemap
+_require_xfs_io_fiemap()
+{
+	testfile=$TEST_DIR/$$.fiemap
+	testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
+		-c "fiemap -v" $testfile 2>&1`
+	rm -f $testfile 2>&1 > /dev/null
+	echo $testio | grep -q "not found" && \
+		_notrun "xfs_io fiemap support is missing"
+	echo $testio | grep -q "Operation not supported" && \
+		_notrun "xfs_io fiemap command failed (no fs support?)"
+}
+
 # Check that a fs has enough free space (in 1024b blocks)
 #
 _require_fs_space()
diff --git a/group b/group
index d45c266..38909b1 100644
--- a/group
+++ b/group
@@ -358,3 +358,4 @@ deprecated
 242 auto quick prealloc
 243 auto quick prealloc
 244 auto quota quick
+245 auto quick prealloc
-- 
1.6.6.1

_______________________________________________
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: add test for fallocate with hole punching
  2010-11-12 21:55 [PATCH] xfstests: add test for fallocate with hole punching Josef Bacik
@ 2010-11-18  5:30 ` Dave Chinner
  2010-11-18  8:32   ` Josef Bacik
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Chinner @ 2010-11-18  5:30 UTC (permalink / raw)
  To: Josef Bacik; +Cc: xfs

On Fri, Nov 12, 2010 at 04:55:49PM -0500, Josef Bacik wrote:
> This test is based on 242, just modified to use fiemap, fallocate and fallocate
> -p.  I've looked at all of the output by hand and verified that it's working
> properly.  Thanks,
> 
> Signed-off-by: Josef Bacik <josef@redhat.com>
> ---
>  245       |  189 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  245.out   |   47 +++++++++++++++
>  common.rc |   27 +++++++++
>  group     |    1 +
>  4 files changed, 264 insertions(+), 0 deletions(-)
>  create mode 100755 245
>  create mode 100644 245.out
> 
> diff --git a/245 b/245
> new file mode 100755
> index 0000000..6f7a502
> --- /dev/null
> +++ b/245
> @@ -0,0 +1,189 @@
> +#! /bin/bash
> +# FS QA Test No. 242

Not test 242 anymore...

> +#
> +# Test XFS_IOC_ZERO_RANGE

Nor that. ;)

> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2010 Red Hat.  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=dchinner@redhat.com

Not me ;)

> +
> +seq=`basename $0`
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +
> +_cleanup()
> +{
> +    rm -f $tmp.*
> +}
> +
> +trap "_cleanup ; exit \$status" 0 1 2 3 15
> +
> +# get standard environment, filters and checks
> +. ./common.rc
> +. ./common.filter
> +
> +# real QA test starts here
> +_supported_fs generic
> +_supported_os Linux
> +
> +_require_xfs_io_falloc_punch
> +_require_xfs_io_fiemap
> +
> +_filter_bmap()
> +{
> +    awk --posix '$3 ~ /hole/ { print $1, $2, $3; next }
> +		 $5 ~ /0x[[:digit:]]*8[[:digit:]]{2}/ { print $1, $2, "unwritten"; next }
> +		 $5 ~ /0x[[:digit:]]+/ {print $1, $2, "data" }'
> +}
> +
> +# test the different corner cases for falloc -ping a range:

                                         punching

> +#
> +#	1. into a hole
> +#	2. into allocated space
> +#	3. into unwritten space
> +#	4. hole -> data
> +#	5. hole -> unwritten
> +#	6. data -> hole
> +#	7. data -> unwritten
> +#	8. unwritten -> hole
> +#	9. unwritten -> data
> +#	10. hole -> data -> hole
> +#	11. data -> hole -> data
> +#	12. unwritten -> data -> unwritten
> +#	13. data -> unwritten -> data
> +
> +testfile=$TEST_DIR/242.$$
                      ^^^

> +
> +echo "	1. into a hole"
> +rm -f $testfile
> +$XFS_IO_PROG -F -f -c "truncate 20k" \
> +	-c "falloc -p 4k 8k" \
> +	-c "fiemap -v" $testfile | _filter_bmap
> +[ $? -ne 0 ] && die_now

This looks almost almost exactly the same test as 242 just with the
alloc, map and punch commands changed.  I'd suggest making all these
cases into a function that takes three parameters - alloc_cmd
punch_cmd and map_cmd - and pulling it into common.punch.

e.g. we end up with a function full of commands like:

$XFS_IO_PROG -F -f -c "truncate 20k" \
	-c "$punch_cmd 4k 8k" \
	-c "$map_cmd" $testfile | _filter_bmap

Which means it can be used for 242, this test, and another test for
the xfs resvsp/unresvsp ioctls...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
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: add test for fallocate with hole punching
  2010-11-18  5:30 ` Dave Chinner
@ 2010-11-18  8:32   ` Josef Bacik
  0 siblings, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2010-11-18  8:32 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Josef Bacik, xfs

On Thu, Nov 18, 2010 at 04:30:52PM +1100, Dave Chinner wrote:
> On Fri, Nov 12, 2010 at 04:55:49PM -0500, Josef Bacik wrote:
> > This test is based on 242, just modified to use fiemap, fallocate and fallocate
> > -p.  I've looked at all of the output by hand and verified that it's working
> > properly.  Thanks,
> > 
> > Signed-off-by: Josef Bacik <josef@redhat.com>
> > ---
> >  245       |  189 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  245.out   |   47 +++++++++++++++
> >  common.rc |   27 +++++++++
> >  group     |    1 +
> >  4 files changed, 264 insertions(+), 0 deletions(-)
> >  create mode 100755 245
> >  create mode 100644 245.out
> > 
> > diff --git a/245 b/245
> > new file mode 100755
> > index 0000000..6f7a502
> > --- /dev/null
> > +++ b/245
> > @@ -0,0 +1,189 @@
> > +#! /bin/bash
> > +# FS QA Test No. 242
> 
> Not test 242 anymore...
> 
> > +#
> > +# Test XFS_IOC_ZERO_RANGE
> 
> Nor that. ;)
>

Crap what the hell this is all right in my local copy.  I must have forgotten
to commit my changes.
 
> > +#
> > +#-----------------------------------------------------------------------
> > +# Copyright (c) 2010 Red Hat.  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=dchinner@redhat.com
> 
> Not me ;)
> 
> > +
> > +seq=`basename $0`
> > +echo "QA output created by $seq"
> > +
> > +here=`pwd`
> > +tmp=/tmp/$$
> > +status=1	# failure is the default!
> > +
> > +_cleanup()
> > +{
> > +    rm -f $tmp.*
> > +}
> > +
> > +trap "_cleanup ; exit \$status" 0 1 2 3 15
> > +
> > +# get standard environment, filters and checks
> > +. ./common.rc
> > +. ./common.filter
> > +
> > +# real QA test starts here
> > +_supported_fs generic
> > +_supported_os Linux
> > +
> > +_require_xfs_io_falloc_punch
> > +_require_xfs_io_fiemap
> > +
> > +_filter_bmap()
> > +{
> > +    awk --posix '$3 ~ /hole/ { print $1, $2, $3; next }
> > +		 $5 ~ /0x[[:digit:]]*8[[:digit:]]{2}/ { print $1, $2, "unwritten"; next }
> > +		 $5 ~ /0x[[:digit:]]+/ {print $1, $2, "data" }'
> > +}
> > +
> > +# test the different corner cases for falloc -ping a range:
> 
>                                          punching
> 
> > +#
> > +#	1. into a hole
> > +#	2. into allocated space
> > +#	3. into unwritten space
> > +#	4. hole -> data
> > +#	5. hole -> unwritten
> > +#	6. data -> hole
> > +#	7. data -> unwritten
> > +#	8. unwritten -> hole
> > +#	9. unwritten -> data
> > +#	10. hole -> data -> hole
> > +#	11. data -> hole -> data
> > +#	12. unwritten -> data -> unwritten
> > +#	13. data -> unwritten -> data
> > +
> > +testfile=$TEST_DIR/242.$$
>                       ^^^
> 
> > +
> > +echo "	1. into a hole"
> > +rm -f $testfile
> > +$XFS_IO_PROG -F -f -c "truncate 20k" \
> > +	-c "falloc -p 4k 8k" \
> > +	-c "fiemap -v" $testfile | _filter_bmap
> > +[ $? -ne 0 ] && die_now
> 
> This looks almost almost exactly the same test as 242 just with the
> alloc, map and punch commands changed.  I'd suggest making all these
> cases into a function that takes three parameters - alloc_cmd
> punch_cmd and map_cmd - and pulling it into common.punch.
> 

Oh yeah, like I said I just did "cp 242 245" and then changed everything to use
falloc -p instead of zero :).

> e.g. we end up with a function full of commands like:
> 
> $XFS_IO_PROG -F -f -c "truncate 20k" \
> 	-c "$punch_cmd 4k 8k" \
> 	-c "$map_cmd" $testfile | _filter_bmap
> 
> Which means it can be used for 242, this test, and another test for
> the xfs resvsp/unresvsp ioctls...
> 

Sounds good I can do that.  Thanks,

Josef

_______________________________________________
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:[~2010-11-18  8:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-12 21:55 [PATCH] xfstests: add test for fallocate with hole punching Josef Bacik
2010-11-18  5:30 ` Dave Chinner
2010-11-18  8:32   ` Josef Bacik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox