xfstests: test the aio unwrittent extent conversion race
PATCH 1/1 xfstests: test the aio unwrittent extent conversion race
239 new file +58 -0
@@ -0,0 +1,58 @@ +#! /bin/bash +# FS QA Test No. 239 +# +# Read from a sparse file immedialy after filling a hole to test for races +# in unwritten extent conversion. +# +#----------------------------------------------------------------------- +# Copyright (c) 2010 Red Hat, 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 +#----------------------------------------------------------------------- +# +# creator [email protected] + +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() +{ + cd / + rm -f $TEST_DIR/tst-aio-dio-sparse-unwritten +} + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fs generic +_supported_os Linux + +AIO_TEST=src/aio-dio-regress/aio-dio-hole-filling-race +[ -x $AIO_TEST ] || _notrun "$AIO_TEST not built" + +echo "Silence is golden" + +for i in `seq 1 500`; do + $AIO_TEST $TEST_DIR/tst-aio-dio-hole-filling-race || break +done + +status=$? +exit
239.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 239 +Silence is golden
group +1 -0
@@ -352,3 +352,4 @@ deprecated 236 auto quick metadata 237 auto quick acl 238 auto quick metadata ioctl +239 auto aio rw
src/aio-dio-regress/aio-dio-hole-filling-race.c new file +123 -0
123 lines not on this page · raw message
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
ping?
Quoted 210 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>Index: xfstests-dev/239
===================================================================239 new file +58
-0@@ -0,0 +1,58 @@ +#! /bin/bash +# FS QA Test No. 239 +# +# Read from a sparse file immedialy after filling a hole to test for races +# in unwritten extent conversion. +# +#----------------------------------------------------------------------- +# Copyright (c) 2010 Red Hat, 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 +#----------------------------------------------------------------------- +# +# creator [email protected] + +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() +{ + cd / + rm -f $TEST_DIR/tst-aio-dio-sparse-unwritten +} + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fs generic +_supported_os Linux + +AIO_TEST=src/aio-dio-regress/aio-dio-hole-filling-race +[ -x $AIO_TEST ] || _notrun "$AIO_TEST not built" + +echo "Silence is golden" + +for i in `seq 1 500`; do + $AIO_TEST $TEST_DIR/tst-aio-dio-hole-filling-race || break +done + +status=$? +exitIndex: xfstests-dev/239.out
===================================================================239.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 239 +Silence is goldenIndex: xfstests-dev/group
===================================================================group +1
-0@@ -352,3 +352,4 @@ deprecated 236 auto quick metadata 237 auto quick acl 238 auto quick metadata ioctl +239 auto aio rwIndex:
xfstests-dev/src/aio-dio-regress/aio-dio-hole-filling-race.c
===================================================================src/aio-dio-regress/aio-dio-hole-filling-race.c new file +123
-0@@ -0,0 +1,123 @@ +/* +* Read from a sparse file immedialy after filling a hole to test for races +* in unwritten extent conversion. +* +* Copyright (C) 2010 Red Hat, 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; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will 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 to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#include <sys/stat.h> +#include <sys/types.h> +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <libaio.h> + +#define BUF_SIZE 4096 +#define IO_PATTERN 0xab + +int main (int argc,char *argv[]) +{ +struct io_context *ctx =NULL ; +struct io_event ev; +struct iocb iocb, *iocbs[] = { &iocb }; +void *buf; +char cmp_buf[BUF_SIZE ]; +int fd, err =0 ; + + fd =open (argv[1 ],O_DIRECT |O_CREAT |O_TRUNC |O_RDWR ,0600 ); +if (fd ==-1 ) { +perror ("open" ); +return 1 ; + } + + err =posix_memalign (&buf,BUF_SIZE ,BUF_SIZE ); +if (err) { +fprintf (stderr,"error %s during %s\n" , +strerror (-err), +"posix_memalign" ); +return 1 ; + } +memset (buf,IO_PATTERN ,BUF_SIZE ); +memset (cmp_buf,IO_PATTERN ,BUF_SIZE ); + +/* +* Truncate to some random large file size. Just make sure +* it's not smaller than our I/O size. +*/ +if (ftruncate (fd,1024 *1024 *1024 ) <0 ) { +perror ("ftruncate" ); +return 1 ; + } + + +/* +* Do a simple 4k write into a hole using aio. +*/ + err =io_setup (1 , &ctx); +if (err) { +fprintf (stderr,"error %s during %s\n" , +strerror (-err), +"io_setup" ); +return 1 ; + } + +io_prep_pwrite (&iocb, fd, buf,BUF_SIZE ,0 ); + + err =io_submit (ctx,1 , iocbs); +if (err !=1 ) { +fprintf (stderr,"error %s during %s\n" , +strerror (-err), +"io_submit" ); +return 1 ; + } + + err =io_getevents (ctx,1 ,1 , &ev,NULL ); +if (err !=1 ) { +fprintf (stderr,"error %s during %s\n" , +strerror (-err), +"io_getevents" ); +return 1 ; + } + +/* +* And then read it back. +* +* Using pread to keep it simple, but AIO has the same effect. +*/ +if (pread (fd, buf,BUF_SIZE ,0 ) !=BUF_SIZE ) { +perror ("pread" ); +return 1 ; + } + +/* +* And depending on the machine we'll just get zeroes back quite +* often here. That's because the unwritten extent conversion +* hasn't finished. +*/ +if (memcmp (buf, cmp_buf,BUF_SIZE )) { +unsigned long long *ubuf = (unsigned long long *)buf; +int i; + +for (i =0 ; i <BUF_SIZE /sizeof (unsigned long long ); i++) +printf ("%d: 0x%llx\n" , i, ubuf[i]); +return 1 ; + } + +return 0 ; +}
Quoted 4 lines
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
---end quoted text---
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 22 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>Index: xfstests-dev/239
===================================================================239 new file +15
-0@@ -0,0 +1,58 @@ +#! /bin/bash +# FS QA Test No. 239 +# +# Read from a sparse file immedialy after filling a hole to test for races +# in unwritten extent conversion. +# +#----------------------------------------------------------------------- +# Copyright (c) 2010 Red Hat, 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
239 line 25
Quoted 10 lines
239 new file +10
-0+# 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]
Maybe not. ;)
Otherwise looks fine.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 8 lines · Dave Chinner
239 line 25
Quoted 2 lines
239 new file +2
-0+# creator [email protected]Maybe not. ;)
Otherwise looks fine.
Reviewed-by Dave Chinner <[email protected]>
That's what you get for copy & pasting test stubs. Pushed out with the owner fixed.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs