From a07c706bc4a6db7cf5543cdd71daee5c95be3c63 Mon Sep 17 00:00:00 2001 From: Mohamed Barwani Date: Wed, 3 Oct 2007 16:23:57 +0000 Subject: [PATCH] Modify existing test cases, and add a new one. Merge of master-melb:xfs-cmds:29822a by kenmcd. reduce number of files on the existing test cases. Remounted the fs with dmapi enabled and a call for a new test case. --- 177 | 16 ++- 177.out | 137 +++++--------------- src/Makefile | 2 +- src/bulkstat_unlink_test_modified.c | 191 ++++++++++++++++++++++++++++ 4 files changed, 237 insertions(+), 109 deletions(-) create mode 100644 src/bulkstat_unlink_test_modified.c diff --git a/177 b/177 index c37e744a..ab334c07 100755 --- a/177 +++ b/177 @@ -45,10 +45,20 @@ _scratch_mount \ # run Mark Goodwin test here # Usage: ./bulkstat_unlink_test iterations nfiles stride dir # Create dir with nfiles, unlink each stride'th file, sync, bulkstat -$here/src/bulkstat_unlink_test 50 100 1 $SCRATCH_MNT/bulkstat +echo "Start original bulkstat_unlink_test" +$here/src/bulkstat_unlink_test 10 100 1 $SCRATCH_MNT/bulkstat $here/src/bulkstat_unlink_test 10 1000 1 $SCRATCH_MNT/bulkstat -$here/src/bulkstat_unlink_test 50 100 6 $SCRATCH_MNT/bulkstat -$here/src/bulkstat_unlink_test 50 1000 3 $SCRATCH_MNT/bulkstat +$here/src/bulkstat_unlink_test 15 100 6 $SCRATCH_MNT/bulkstat +$here/src/bulkstat_unlink_test 20 1000 3 $SCRATCH_MNT/bulkstat + +# Mount scratch with ikeep enabled +umount $SCRATCH_MNT +_scratch_mount "-o dmapi,mtpt=$SCRATCH_MNT" \ + || _fail "mount failed" + +echo "Start bulkstat_unlink_test_modified" +$here/src/bulkstat_unlink_test_modified 10 1000 1 $SCRATCH_MNT/bulkstat + # success, all done status=0 diff --git a/177.out b/177.out index e610a01f..85d280d8 100644 --- a/177.out +++ b/177.out @@ -1,4 +1,5 @@ QA output created by 177 +Start original bulkstat_unlink_test Iteration 0 ... passed Iteration 1 ... passed Iteration 2 ... passed @@ -9,46 +10,6 @@ Iteration 6 ... passed Iteration 7 ... passed Iteration 8 ... passed Iteration 9 ... passed -Iteration 10 ... passed -Iteration 11 ... passed -Iteration 12 ... passed -Iteration 13 ... passed -Iteration 14 ... passed -Iteration 15 ... passed -Iteration 16 ... passed -Iteration 17 ... passed -Iteration 18 ... passed -Iteration 19 ... passed -Iteration 20 ... passed -Iteration 21 ... passed -Iteration 22 ... passed -Iteration 23 ... passed -Iteration 24 ... passed -Iteration 25 ... passed -Iteration 26 ... passed -Iteration 27 ... passed -Iteration 28 ... passed -Iteration 29 ... passed -Iteration 30 ... passed -Iteration 31 ... passed -Iteration 32 ... passed -Iteration 33 ... passed -Iteration 34 ... passed -Iteration 35 ... passed -Iteration 36 ... passed -Iteration 37 ... passed -Iteration 38 ... passed -Iteration 39 ... passed -Iteration 40 ... passed -Iteration 41 ... passed -Iteration 42 ... passed -Iteration 43 ... passed -Iteration 44 ... passed -Iteration 45 ... passed -Iteration 46 ... passed -Iteration 47 ... passed -Iteration 48 ... passed -Iteration 49 ... passed Iteration 0 ... passed Iteration 1 ... passed Iteration 2 ... passed @@ -74,41 +35,6 @@ Iteration 11 ... passed Iteration 12 ... passed Iteration 13 ... passed Iteration 14 ... passed -Iteration 15 ... passed -Iteration 16 ... passed -Iteration 17 ... passed -Iteration 18 ... passed -Iteration 19 ... passed -Iteration 20 ... passed -Iteration 21 ... passed -Iteration 22 ... passed -Iteration 23 ... passed -Iteration 24 ... passed -Iteration 25 ... passed -Iteration 26 ... passed -Iteration 27 ... passed -Iteration 28 ... passed -Iteration 29 ... passed -Iteration 30 ... passed -Iteration 31 ... passed -Iteration 32 ... passed -Iteration 33 ... passed -Iteration 34 ... passed -Iteration 35 ... passed -Iteration 36 ... passed -Iteration 37 ... passed -Iteration 38 ... passed -Iteration 39 ... passed -Iteration 40 ... passed -Iteration 41 ... passed -Iteration 42 ... passed -Iteration 43 ... passed -Iteration 44 ... passed -Iteration 45 ... passed -Iteration 46 ... passed -Iteration 47 ... passed -Iteration 48 ... passed -Iteration 49 ... passed Iteration 0 ... passed Iteration 1 ... passed Iteration 2 ... passed @@ -129,33 +55,34 @@ Iteration 16 ... passed Iteration 17 ... passed Iteration 18 ... passed Iteration 19 ... passed -Iteration 20 ... passed -Iteration 21 ... passed -Iteration 22 ... passed -Iteration 23 ... passed -Iteration 24 ... passed -Iteration 25 ... passed -Iteration 26 ... passed -Iteration 27 ... passed -Iteration 28 ... passed -Iteration 29 ... passed -Iteration 30 ... passed -Iteration 31 ... passed -Iteration 32 ... passed -Iteration 33 ... passed -Iteration 34 ... passed -Iteration 35 ... passed -Iteration 36 ... passed -Iteration 37 ... passed -Iteration 38 ... passed -Iteration 39 ... passed -Iteration 40 ... passed -Iteration 41 ... passed -Iteration 42 ... passed -Iteration 43 ... passed -Iteration 44 ... passed -Iteration 45 ... passed -Iteration 46 ... passed -Iteration 47 ... passed -Iteration 48 ... passed -Iteration 49 ... passed +Start bulkstat_unlink_test_modified +Iteration 0 ... +testFiles 1000 ... +passed +Iteration 1 ... +testFiles 1000 ... +passed +Iteration 2 ... +testFiles 1000 ... +passed +Iteration 3 ... +testFiles 1000 ... +passed +Iteration 4 ... +testFiles 1000 ... +passed +Iteration 5 ... +testFiles 1000 ... +passed +Iteration 6 ... +testFiles 1000 ... +passed +Iteration 7 ... +testFiles 1000 ... +passed +Iteration 8 ... +testFiles 1000 ... +passed +Iteration 9 ... +testFiles 1000 ... +passed diff --git a/src/Makefile b/src/Makefile index 637ed5d3..fa181657 100644 --- a/src/Makefile +++ b/src/Makefile @@ -15,7 +15,7 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \ LINUX_TARGETS = loggen xfsctl bstat t_mtab getdevicesize \ preallo_rw_pattern_reader preallo_rw_pattern_writer ftrunc trunc \ fs_perms testx looptest locktest unwritten_mmap \ - bulkstat_unlink_test + bulkstat_unlink_test bulkstat_unlink_test_modified IRIX_TARGETS = open_unlink diff --git a/src/bulkstat_unlink_test_modified.c b/src/bulkstat_unlink_test_modified.c new file mode 100644 index 00000000..7f1a98af --- /dev/null +++ b/src/bulkstat_unlink_test_modified.c @@ -0,0 +1,191 @@ +/* + * $Id: bulkstat_unlink_test_modified.c,v 1.1 2007/10/03 16:23:57 mohamedb.longdrop.melbourne.sgi.com Exp $ + * Test bulkstat doesn't returned unlinked inodes. + * Mark Goodwin Fri Jul 20 09:13:57 EST 2007 + * + * This is a modified version of bulkstat_unlink_test.c to reproduce a specific + * problem see pv 969192 + */ +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int e; + int fd = 0; + int i; + int j; + int k; + int nfiles; + int stride; + struct stat sbuf; + ino_t *inodelist; + __u32 *genlist; + xfs_fsop_bulkreq_t a; + xfs_bstat_t *ret; + int iterations; + char fname[MAXPATHLEN]; + char *dirname; + + if (argc != 5) { + fprintf(stderr, "Usage: %s iterations nfiles stride dir\n", argv[0]); + fprintf(stderr, "Create dir with nfiles, unlink each stride'th file, sync, bulkstat\n"); + exit(1); + } + + iterations = atoi(argv[1]); + nfiles = atoi(argv[2]); + stride = atoi(argv[3]); + dirname = argv[4]; + if (!nfiles || !iterations) { + fprintf(stderr, "Iterations and nfiles showld be non zero.\n"); + exit(1); + } + + inodelist = (ino_t *)malloc(nfiles * sizeof(ino_t)); + genlist = (__u32 *)malloc(nfiles * sizeof(__u32)); + ret = (xfs_bstat_t *)malloc(nfiles * sizeof(xfs_bstat_t)); + + for (k=0; k < iterations; k++) { + xfs_ino_t last_inode = 0; + int count = 0; + int testFiles = 0; + + printf("Iteration %d ... \n", k); + + memset(inodelist, 0, nfiles * sizeof(ino_t)); + memset(genlist, 0, nfiles * sizeof(__u32)); + memset(ret, 0, nfiles * sizeof(xfs_bstat_t)); + memset(&a, 0, sizeof(xfs_fsop_bulkreq_t)); + a.lastip = &last_inode; + a.icount = nfiles; + a.ubuffer = ret; + a.ocount = &count; + + if (mkdir(dirname, 0755) < 0) { + perror(dirname); + exit(1); + } + + /* create nfiles and store their inode numbers in inodelist */ + for (i=0; i < nfiles; i++) { + sprintf(fname, "%s/file%06d", dirname, i); + if ((fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0644)) < 0) { + perror(fname); + exit(1); + } + write(fd, fname, sizeof(fname)); + if (fstat(fd, &sbuf) < 0) { + perror(fname); + exit(1); + } + inodelist[i] = sbuf.st_ino; + close(fd); + } + + sync(); + + /* collect bs_gen for the nfiles files */ + if ((fd = open(dirname, O_RDONLY)) < 0) { + perror(dirname); + exit(1); + } + + testFiles = 0; + for (;;) { + if ((e = xfsctl(dirname, fd, XFS_IOC_FSBULKSTAT, &a)) < 0) { + perror("XFS_IOC_FSBULKSTAT1:"); + exit(1); + } + + if (count == 0) + break; + + for (i=0; i < count; i++) { + for (j=0; j < nfiles; j += stride) { + if (ret[i].bs_ino == inodelist[j]) { + genlist[j] = ret[i].bs_gen; + testFiles++; + } + } + } + } + close(fd); + + printf("testFiles %d ... \n", testFiles); + + /* remove some of the first set of files */ + for (i=0; i < nfiles; i += stride) { + sprintf(fname, "%s/file%06d", dirname, i); + if (unlink(fname) < 0) { + perror(fname); + exit(1); + } + } + + /* create a new set of files (replacing the unlinked ones) */ + for (i=0; i < nfiles; i += stride) { + sprintf(fname, "%s/file%06d", dirname, i); + if ((fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0644)) < 0) { + perror(fname); + exit(1); + } + write(fd, fname, sizeof(fname)); + close(fd); + } + + sync(); + last_inode = 0; count = 0; + + if ((fd = open(dirname, O_RDONLY)) < 0) { + perror(dirname); + exit(1); + } + + for (;;) { + if ((e = xfsctl(dirname, fd, XFS_IOC_FSBULKSTAT, &a)) < 0) { + perror("XFS_IOC_FSBULKSTAT:"); + exit(1); + } + + if (count == 0) + break; + + for (i=0; i < count; i++) { + for (j=0; j < nfiles; j += stride) { + if ((ret[i].bs_ino == inodelist[j]) && + (ret[i].bs_gen == genlist[j])) { + /* oops, the same inode with old gen number */ + printf("Unlinked inode %ld with generation %d " + "returned by bulkstat\n", + inodelist[j], genlist[j]); + exit(1); + } + if ((ret[i].bs_ino == inodelist[j])) { + if ((genlist[j] + 1) != ret[i].bs_gen) { + /* oops, the new gen number is not 1 bigger than the old */ + printf("Inode with old generation %d, new generation %d\n", + genlist[j], ret[i].bs_gen); + exit(1); + } + } + } + } + } + + close(fd); + + sprintf(fname, "rm -rf %s\n", dirname); + system(fname); + + sync(); + sleep(2); + printf("passed\n"); + } + + exit(0); +} -- 2.39.5