Skip to contentSkip to conversation

xfstests 224: test aio hole-fill at 4g

PATCH In review Eric Sandeen 4 participants 9 messages Jan 29, 2010 – Oct 26, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests 224: test aio hole-fill at 4g

Testcase from Giel de Nijs <[email protected]> on linux-ext4 list, ""Possible ext4 data corruption with large files and async I/O," on 29 Jan 2010

ext4 put byte offsets in a block offset u32 container in the endio struct, so 4g wrapped to 0 leading to data corruption when the unwritten extent did not get converted.

---

224 new file +68 -0
new file mode 100755
index 0000000..47e614c
@@ -0,0 +1,68 @@
+#! /bin/bash
+# FS QA Test No. 224
+#
+# Test aio hole-filling past 2^32 bytes
+#
+# Testcase from Giel de Nijs <[email protected]>
+# on linux-ext4 list, ""Possible ext4 data corruption
+# with large files and async I/O," on 29 Jan 2010
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2010 Eric Sandeen.  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
[email protected]
+
+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
+
+[ ! -x $here/src/aio-write ] && _notrun "aio-write not built"
+
+TESTFILE=$TEST_DIR/$seq-aio-write-testfile
+
+rm -f $TESTFILE
+$here/src/aio-write -v -s 0xab -o 6g -l 512k $TESTFILE
+$here/src/aio-write -v -s 0xcd -o 4g -l 512k $TESTFILE
+
+# Bug in ext4 caused the 4g offset to wrap and io
+# completion happened at 0, leaving extent unwritten,
+# and 0s returned
+
+$XFS_IO_PROG -F -c "pread -v 4g 512k" -c "pread -v 6g 512k" $TESTFILE | \
+	_filter_xfs_io_unique
+
+status=0 ; exit
224.out new file +19 -0
new file mode 100644
index 0000000..4bb51d5
@@ -0,0 +1,19 @@
+QA output created by 224
+opening file /mnt/test/224-aio-write-testfile
+submitting write of 524288 bytes at offset 6442450944
+waiting for write to be finished
+got 1 events
+written 524288 bytes
+opening file /mnt/test/224-aio-write-testfile
+submitting write of 524288 bytes at offset 4294967296
+waiting for write to be finished
+got 1 events
+written 524288 bytes
+100000000:  cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd  ................
+*
+read 524288/524288 bytes at offset 4294967296
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+180000000:  ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab  ................
+*
+read 524288/524288 bytes at offset 6442450944
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
group +1 -0
index c66d965..46acc2b 100644
@@ -336,4 +336,5 @@ deprecated
 220 auto quota quick
 221 auto metadata quick
 222 auto fsr ioctl quick
+224 auto aio quick
 223 auto quick
src/Makefile +2 -0
index 619a752..2ac7041 100644
@@ -42,6 +42,8 @@ LLDLIBS += $(LIBGDBM)
 endif
 
 ifeq ($(HAVE_AIO), true)
+LINUX_TARGETS += aio-write
+LLDLIBS += -laio
 SUBDIRS += aio-dio-regress
 endif
 
src/aio-write.c new file +174 -0

174 lines not on this page · raw message

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 8 lines · Eric Sandeen

Testcase from Giel de Nijs <[email protected]> on linux-ext4 list, ""Possible ext4 data corruption with large files and async I/O," on 29 Jan 2010

ext4 put byte offsets in a block offset u32 container in the endio struct, so 4g wrapped to 0 leading to data corruption when the unwritten extent did not get converted.

There's various type messups in the test program that make it fail for me on a 32-bit machine. The patch below fixes it up, but it seems like we should rather add a variant of that code as aio_read/write commands to xfs_io instead of adding a new test program.

src/aio-write.c +7 -6
Index: xfstests-dev/src/aio-write.c
===================================================================
@@ -42,7 +42,7 @@ void usage(void)
 /*
  * Scale value by kilo, mega, or giga.
  */
-loff_t scale_by_kmg(long long value, char scale)
+long long scale_by_kmg(long long value, char scale)
 {
 switch (scale) {
 	case 'g':
@@ -69,7 +69,7 @@ switch (scale) {
 int main(int argc, char ** argv)
 {
 	char filename[PATH_MAX];
-	loff_t offset = 0;
+	long long offset = 0;
 	size_t length = 0;
 	int seed = 0xFF;
 	int queue_depth = 8;
@@ -95,12 +95,12 @@ int main(int argc, char ** argv)
 			seed = (int)strtol(optarg, &endp, 0);
 			break;
 		case 'o':
-			offset = strtol(optarg, &endp, 0);
-			offset = scale_by_kmg((long long)offset, *endp);
+			offset = strtoll(optarg, &endp, 0);
+			offset = scale_by_kmg(offset, *endp);
 			break;
 		case 'l':
 			length = strtol(optarg, &endp, 0);
-			length = scale_by_kmg((long long)length, *endp);
+			length = scale_by_kmg(length, *endp);
 			break;
 		case 'v':
 			verbose++;
@@ -141,7 +141,8 @@ int main(int argc, char ** argv)
 	io_prep_pwrite(&iocb, fd, buf, length, offset);
 	iocblist[0] = &iocb;
 	if (verbose)
-		printf("submitting write of %zd bytes at offset %zd\n", length, offset);
+		printf("submitting write of %zd bytes at offset %lld\n",
+			length, offset);
 	err = io_submit(io_ctx, 1, iocblist);
 	if (err < 0) {
 		printf("error submitting I/O requests: %s\n", strerror(-err));
#2 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 8 lines · Eric Sandeen

Testcase from Giel de Nijs <[email protected]> on linux-ext4 list, ""Possible ext4 data corruption with large files and async I/O," on 29 Jan 2010

ext4 put byte offsets in a block offset u32 container in the endio struct, so 4g wrapped to 0 leading to data corruption when the unwritten extent did not get converted.

There's various type messups in the test program that make it fail for

oops, thanks for checking.

Quoted 3 lines

me on a 32-bit machine. The patch below fixes it up, but it seems like we should rather add a variant of that code as aio_read/write commands to xfs_io instead of adding a new test program.

ok, that's probably better - again, though, it takes at least a release cycle before most folks can test it. But I guess that's not the end of the world.

-Eric

Quoted 40 lines

Index: xfstests-dev/src/aio-write.c
===================================================================

src/aio-write.c +5 -5
@@ -42,7 +42,7 @@ void usage(void)
 /*
  * Scale value by kilo, mega, or giga.
  */
-loff_t scale_by_kmg(long long value, char scale)
+long long scale_by_kmg(long long value, char scale)
 {
 switch (scale) {
 	case 'g':
@@ -69,7 +69,7 @@ switch (scale) {
 int main(int argc, char ** argv)
 {
 	char filename[PATH_MAX];
-	loff_t offset = 0;
+	long long offset = 0;
 	size_t length = 0;
 	int seed = 0xFF;
 	int queue_depth = 8;
@@ -95,12 +95,12 @@ int main(int argc, char ** argv)
 			seed = (int)strtol(optarg, &endp, 0);
 			break;
 		case 'o':
-			offset = strtol(optarg, &endp, 0);
-			offset = scale_by_kmg((long long)offset, *endp);
+			offset = strtoll(optarg, &endp, 0);
+			offset = scale_by_kmg(offset, *endp);
 			break;
 		case 'l':
 			length = strtol(optarg, &endp, 0);
-			length = scale_by_kmg((long long)length, *endp);
+			length = scale_by_kmg(length, *endp);
 			break;
 		case 'v':
 			verbose++;

src/aio-write.c int main(int argc, char ** argv) · line 148

Quoted 9 lines
src/aio-write.c +2 -1
@@ -141,7 +141,8 @@ int main(int argc, char ** argv)
 	io_prep_pwrite(&iocb, fd, buf, length, offset);
 	iocblist[0] = &iocb;
 	if (verbose)
-		printf("submitting write of %zd bytes at offset %zd\n", length, offset);
+		printf("submitting write of %zd bytes at offset %lld\n",
+			length, offset);
 	err = io_submit(io_ctx, 1, iocblist);
 	if (err < 0) {
 		printf("error submitting I/O requests: %s\n", strerror(-err));

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
Quoted 7 lines · Eric Sandeen
Quoted 3 lines

me on a 32-bit machine. The patch below fixes it up, but it seems like we should rather add a variant of that code as aio_read/write commands to xfs_io instead of adding a new test program.

ok, that's probably better - again, though, it takes at least a release cycle before most folks can test it. But I guess that's not the end of the world.

Stupid question --- who uses xfs_io besides xfstests? Any chance we could consider dropping in some version of xfs_io into xfstests, or actually moving it into xfstests from xfsprogs if xfstests is the exclusive user of that program? I've been trying to get more people to use xfstests, since it would be good if more companies and more projects were using it --- and one of the things that makes it hard is all of the dependencies that it has. If there was some way we could gradually make xfstests more self-contained, it would certainly be nice.

- Ted

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw
Quoted 18 lines · [email protected] wrote:
Quoted 6 lines · Eric Sandeen
Quoted 3 lines

me on a 32-bit machine. The patch below fixes it up, but it seems like we should rather add a variant of that code as aio_read/write commands to xfs_io instead of adding a new test program.

ok, that's probably better - again, though, it takes at least a release cycle before most folks can test it. But I guess that's not the end of the world.

Stupid question --- who uses xfs_io besides xfstests? Any chance we could consider dropping in some version of xfs_io into xfstests, or actually moving it into xfstests from xfsprogs if xfstests is the exclusive user of that program? I've been trying to get more people to use xfstests, since it would be good if more companies and more projects were using it --- and one of the things that makes it hard is all of the dependencies that it has. If there was some way we could gradually make xfstests more self-contained, it would certainly be nice.

Quoted 1 line

- Ted

These are the deps that I know xfstests has, to build and to run:

BuildRequires:  autoconf, libtool, xfsprogs-devel, e2fsprogs-devel
BuildRequires:  libacl-devel, libattr-devel, libaio-devel
Requires:       bash, xfsprogs, xfsdump, perl, acl, attr, bind-utils
Requires:       bc, indent, quota

which isn't so bad...
(and tests are just skipped if xfsdump isn't there)

I'm not sure an xfsprogs dependency is so onerous; plenty has depended on e2fsprogs through the years and we've lived with that ;) But the lag time for xfsprogs to use released xfs_io functionality is a bit of a bummer.

But I guess I don't have a great answer for who else uses xfs_io:

xfs_io(8) xfs_io(8)

NAME
xfs_io - debug the I/O path of an XFS filesystem

SYNOPSIS
xfs_io [ -adFfmrRstx ] [ -c cmd ] ... [ -p prog ] file

DESCRIPTION
xfs_io is a debugging tool like xfs_db(8), but is aimed at examining the regular file I/O paths rather than the raw XFS volume itself.

I guess it's not really advertised as a generic tool, and it's in the sbin path...

I guess I could live with it either way - I suppose my main concern is that xfstests is a mess to package for a distro, and I really like easy access to xfs_io for my own use outside of xfstests.

-Eric

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#5 lore raw
Quoted 9 lines · Eric Sandeen

These are the deps that I know xfstests has, to build and to run:

BuildRequires:  autoconf, libtool, xfsprogs-devel, e2fsprogs-devel
BuildRequires:  libacl-devel, libattr-devel, libaio-devel
Requires:       bash, xfsprogs, xfsdump, perl, acl, attr, bind-utils
Requires:       bc, indent, quota

which isn't so bad...

Doesn't seem to bad. Indent is afaik only needed for the weird 122 test which doesn't apply to non-xfs filesystems.

Quoted 6 lines

I'm not sure an xfsprogs dependency is so onerous; plenty has depended on e2fsprogs through the years and we've lived with that ;) But the lag time for xfsprogs to use released xfs_io functionality is a bit of a bummer.

But I guess I don't have a great answer for who else uses xfs_io:

I use xfs_io in lots various local scripts. It's a really handly tool for exercising some of the more weird I/O related syscalls.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#6 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 5 lines · Eric Sandeen

These are the deps that I know xfstests has, to build and to run:

BuildRequires:  autoconf, libtool, xfsprogs-devel, e2fsprogs-devel
BuildRequires:  libacl-devel, libattr-devel, libaio-devel
Quoted 7 lines
Quoted 4 lines
Requires:       bash, xfsprogs, xfsdump, perl, acl, attr, bind-utils
Requires:       bc, indent, quota

which isn't so bad...

Doesn't seem to bad. Indent is afaik only needed for the weird 122 test which doesn't apply to non-xfs filesystems.

and FWIW, we do:

_require_command /usr/bin/indent

so it'll just not run if it's not there (the above was for an rpm attempt I made, wishing to automatically pull in everything that might possibly be needed.)

-Eric

Quoted 10 lines
Quoted 6 lines

I'm not sure an xfsprogs dependency is so onerous; plenty has depended on e2fsprogs through the years and we've lived with that ;) But the lag time for xfsprogs to use released xfs_io functionality is a bit of a bummer.

But I guess I don't have a great answer for who else uses xfs_io:

I use xfs_io in lots various local scripts. It's a really handly tool for exercising some of the more weird I/O related syscalls.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#7 lore raw
In reply to Eric Sandeen
Quoted 4 lines · Eric Sandeen

Testcase from Giel de Nijs <[email protected]> on linux-ext4 list, ""Possible ext4 data corruption with large files and async I/O," on 29 Jan 2010

Quoted 8 lines

ext4 put byte offsets in a block offset u32 container in the endio struct, so 4g wrapped to 0 leading to data corruption when the unwritten extent did not get converted.

---

Hey Eric

Just going through the list trying to clean it up. Is this patch still valid or does one of the other hole tests cover this?

Regards
--Rich

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#8 lore raw
Quoted 10 lines · Rich Johnston
Quoted 9 lines · Eric Sandeen

Testcase from Giel de Nijs <[email protected]> on linux-ext4 list, ""Possible ext4 data corruption with large files and async I/O," on 29 Jan 2010

ext4 put byte offsets in a block offset u32 container in the endio struct, so 4g wrapped to 0 leading to data corruption when the unwritten extent did not get converted.

Quoted 7 lines
Quoted 3 lines

---

Hey Eric

Just going through the list trying to clean it up. Is this patch still valid or does one of the other hole tests cover this?

There was some question on the list about whether there should be a dedicated test program to do this, or an AIO addition to xfs_io - that probably needs some thought. AFAIK xfs_io still doesn't know anything about AIO.

I doubt that this particular AIO testcase got covered anywhere else.

-Eric

Quoted 8 lines

Regards
--Rich

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs