linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] Bunch of new stress tests -v4
@ 2011-11-03 14:24 Dmitry Monakhov
  2011-11-03 14:24 ` [PATCH 01/12] xfstests: fsstress dump inode info when possible Dmitry Monakhov
                   ` (12 more replies)
  0 siblings, 13 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:24 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov

Changes from v3 ( in request to  Christoph's comments)
 - hard code fsstress's options for explicit regression tests
 - add two new regression tests
Changes from v2 ( in request to  Christoph's comments)
 - rearange patch sequance
 - codestyle cleanups
 - give better description
 - add tunable mask for FS_IOC_SETFLAGS test.

LOG:
# Following patches improves fsstress logging,
# First three patches was already pulled by Chris to it's internal tree,
# but not push it to public tree yet
 xfstests: fsstress dump inode info when possible
 xfstests: add different logging option to fsstress
 xfstests: fsstress should kill children tasks before exit
# First patch add dump configuration in command line style, second use it's output
 xfstests: fsstress add command line style output for show_opts
 xfstests: freeze fsstress options for 117'th
# Following patches add new operations to fsstress.
 xfstests: add fallocate support to fsstress
 xfstests: fsstress add FS_IOC_{SET,GET}FLAGS operations v2
 xfstests: add fiemap operation to fsstress
# Following testcase may fail on recent kernel in case of ext4
# Some fixes are already available here:
#  http://www.spinics.net/lists/linux-ext4/msg27857.html
#  http://www.spinics.net/lists/linux-ext4/msg28552.html
 xfstests: add a new test that runs fsstress under ENOSPC conditions
 xfstress: add regression testcase for d583fb87a3ff0
# Fixes available here:
#  http://patchwork.ozlabs.org/patch/120581/
#  http://patchwork.ozlabs.org/patch/120582/
 xfstests: add a new quota test that runs fsstress under ENOSPC conditions
# Following testcase may fail on recent kernel in case of ext3/4
# In case of ext4 kernel will probably panic.  
 xfstress: Test data journaling flag switch for a single file


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 01/12] xfstests: fsstress dump inode info when possible
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
@ 2011-11-03 14:24 ` Dmitry Monakhov
  2011-11-03 14:24 ` [PATCH 02/12] xfstests: add different logging option to fsstress Dmitry Monakhov
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:24 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov

Fsstress exec behaviour is not completely determinated in case of
low resources mode due to ENOMEM, ENOSPC, etc. In some places we
call stat(2). This information may be halpfull for future
investigations purposes. Let's dump stat info where possible.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 ltp/fsstress.c |   83 +++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 55 insertions(+), 28 deletions(-)

diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index c37cddf..51ecda2 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -1391,6 +1391,14 @@ zero_freq(void)
 		p->freq = 0;
 }
 
+void inode_info(char *str, size_t sz, struct stat64 *s, int verbose)
+{
+	if (verbose)
+		snprintf(str, sz, "[%ld %ld %d %d %lld %lld]", (long)s->st_ino,
+			 (long)s->st_nlink,  s->st_uid, s->st_gid,
+			 (long long) s->st_blocks, (long long) s->st_size);
+}
+
 void
 allocsp_f(int opno, long r)
 {
@@ -1402,6 +1410,7 @@ allocsp_f(int opno, long r)
 	off64_t		off;
 	struct stat64	stb;
 	int		v;
+	char		st[1024];
 
 	init_pathname(&f);
 	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -1428,6 +1437,7 @@ allocsp_f(int opno, long r)
 		close(fd);
 		return;
 	}
+	inode_info(st, sizeof(st), &stb, v);
 	lr = ((__int64_t)random() << 32) + random();
 	off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
 	off %= maxfsize;
@@ -1435,9 +1445,10 @@ allocsp_f(int opno, long r)
 	fl.l_start = off;
 	fl.l_len = 0;
 	e = xfsctl(f.path, fd, XFS_IOC_ALLOCSP64, &fl) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: xfsctl(XFS_IOC_ALLOCSP64) %s %lld 0 %d\n",
-			procid, opno, f.path, (long long)off, e);
+	if (v) {
+		printf("%d/%d: xfsctl(XFS_IOC_ALLOCSP64) %s%s %lld 0 %d\n",
+		       procid, opno, f.path, st, (long long)off, e);
+	}
 	free_pathname(&f);
 	close(fd);
 }
@@ -1779,6 +1790,7 @@ dread_f(int opno, long r)
 	off64_t		off;
 	struct stat64	stb;
 	int		v;
+	char		st[1024];
 
 	init_pathname(&f);
 	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -1800,15 +1812,16 @@ dread_f(int opno, long r)
 	if (fstat64(fd, &stb) < 0) {
 		if (v)
 			printf("%d/%d: dread - fstat64 %s failed %d\n",
-				procid, opno, f.path, errno);
+			       procid, opno, f.path, errno);
 		free_pathname(&f);
 		close(fd);
 		return;
 	}
+	inode_info(st, sizeof(st), &stb, v);
 	if (stb.st_size == 0) {
 		if (v)
-			printf("%d/%d: dread - %s zero size\n", procid, opno,
-				f.path);
+			printf("%d/%d: dread - %s%s zero size\n", procid, opno,
+			       f.path, st);
 		free_pathname(&f);
 		close(fd);
 		return;
@@ -1816,8 +1829,8 @@ dread_f(int opno, long r)
 	if (xfsctl(f.path, fd, XFS_IOC_DIOINFO, &diob) < 0) {
 		if (v)
 			printf(
-			"%d/%d: dread - xfsctl(XFS_IOC_DIOINFO) %s failed %d\n",
-				procid, opno, f.path, errno);
+			"%d/%d: dread - xfsctl(XFS_IOC_DIOINFO) %s%s failed %d\n",
+				procid, opno, f.path, st, errno);
 		free_pathname(&f);
 		close(fd);
 		return;
@@ -1837,8 +1850,8 @@ dread_f(int opno, long r)
 	e = read(fd, buf, len) < 0 ? errno : 0;
 	free(buf);
 	if (v)
-		printf("%d/%d: dread %s [%lld,%d] %d\n",
-			procid, opno, f.path, (long long)off, (int)len, e);
+		printf("%d/%d: dread %s%s [%lld,%d] %d\n",
+		       procid, opno, f.path, st, (long long)off, (int)len, e);
 	free_pathname(&f);
 	close(fd);
 }
@@ -1857,6 +1870,7 @@ dwrite_f(int opno, long r)
 	off64_t		off;
 	struct stat64	stb;
 	int		v;
+	char		st[1024];
 
 	init_pathname(&f);
 	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -1883,11 +1897,12 @@ dwrite_f(int opno, long r)
 		close(fd);
 		return;
 	}
+	inode_info(st, sizeof(st), &stb, v);
 	if (xfsctl(f.path, fd, XFS_IOC_DIOINFO, &diob) < 0) {
 		if (v)
 			printf("%d/%d: dwrite - xfsctl(XFS_IOC_DIOINFO)"
-				" %s failed %d\n",
-				procid, opno, f.path, errno);
+				" %s%s failed %d\n",
+			       procid, opno, f.path, st, errno);
 		free_pathname(&f);
 		close(fd);
 		return;
@@ -1910,8 +1925,8 @@ dwrite_f(int opno, long r)
 	e = write(fd, buf, len) < 0 ? errno : 0;
 	free(buf);
 	if (v)
-		printf("%d/%d: dwrite %s [%lld,%d] %d\n",
-			procid, opno, f.path, (long long)off, (int)len, e);
+		printf("%d/%d: dwrite %s%s [%lld,%d] %d\n",
+		       procid, opno, f.path, st, (long long)off, (int)len, e);
 	free_pathname(&f);
 	close(fd);
 }
@@ -1960,6 +1975,7 @@ freesp_f(int opno, long r)
 	off64_t		off;
 	struct stat64	stb;
 	int		v;
+	char		st[1024];
 
 	init_pathname(&f);
 	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -1986,6 +2002,7 @@ freesp_f(int opno, long r)
 		close(fd);
 		return;
 	}
+	inode_info(st, sizeof(st), &stb, v);
 	lr = ((__int64_t)random() << 32) + random();
 	off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
 	off %= maxfsize;
@@ -1994,8 +2011,8 @@ freesp_f(int opno, long r)
 	fl.l_len = 0;
 	e = xfsctl(f.path, fd, XFS_IOC_FREESP64, &fl) < 0 ? errno : 0;
 	if (v)
-		printf("%d/%d: xfsctl(XFS_IOC_FREESP64) %s %lld 0 %d\n",
-			procid, opno, f.path, (long long)off, e);
+		printf("%d/%d: xfsctl(XFS_IOC_FREESP64) %s%s %lld 0 %d\n",
+		       procid, opno, f.path, st, (long long)off, e);
 	free_pathname(&f);
 	close(fd);
 }
@@ -2198,6 +2215,7 @@ read_f(int opno, long r)
 	off64_t		off;
 	struct stat64	stb;
 	int		v;
+	char		st[1024];
 
 	init_pathname(&f);
 	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -2224,10 +2242,11 @@ read_f(int opno, long r)
 		close(fd);
 		return;
 	}
+	inode_info(st, sizeof(st), &stb, v);
 	if (stb.st_size == 0) {
 		if (v)
-			printf("%d/%d: read - %s zero size\n", procid, opno,
-				f.path);
+			printf("%d/%d: read - %s%s zero size\n", procid, opno,
+			       f.path, st);
 		free_pathname(&f);
 		close(fd);
 		return;
@@ -2240,8 +2259,8 @@ read_f(int opno, long r)
 	e = read(fd, buf, len) < 0 ? errno : 0;
 	free(buf);
 	if (v)
-		printf("%d/%d: read %s [%lld,%d] %d\n",
-			procid, opno, f.path, (long long)off, (int)len, e);
+		printf("%d/%d: read %s%s [%lld,%d] %d\n",
+		       procid, opno, f.path, st, (long long)off, (int)len, e);
 	free_pathname(&f);
 	close(fd);
 }
@@ -2348,6 +2367,7 @@ resvsp_f(int opno, long r)
 	off64_t		off;
 	struct stat64	stb;
 	int		v;
+	char		st[1024];
 
 	init_pathname(&f);
 	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -2374,6 +2394,7 @@ resvsp_f(int opno, long r)
 		close(fd);
 		return;
 	}
+	inode_info(st, sizeof(st), &stb, v);
 	lr = ((__int64_t)random() << 32) + random();
 	off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
 	off %= maxfsize;
@@ -2382,8 +2403,8 @@ resvsp_f(int opno, long r)
 	fl.l_len = (off64_t)(random() % (1024 * 1024));
 	e = xfsctl(f.path, fd, XFS_IOC_RESVSP64, &fl) < 0 ? errno : 0;
 	if (v)
-		printf("%d/%d: xfsctl(XFS_IOC_RESVSP64) %s %lld %lld %d\n",
-			procid, opno, f.path,
+		printf("%d/%d: xfsctl(XFS_IOC_RESVSP64) %s%s %lld %lld %d\n",
+		       procid, opno, f.path, st,
 			(long long)off, (long long)fl.l_len, e);
 	free_pathname(&f);
 	close(fd);
@@ -2506,6 +2527,7 @@ truncate_f(int opno, long r)
 	off64_t		off;
 	struct stat64	stb;
 	int		v;
+	char		st[1024];
 
 	init_pathname(&f);
 	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -2523,14 +2545,15 @@ truncate_f(int opno, long r)
 		free_pathname(&f);
 		return;
 	}
+	inode_info(st, sizeof(st), &stb, v);
 	lr = ((__int64_t)random() << 32) + random();
 	off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
 	off %= maxfsize;
 	e = truncate64_path(&f, off) < 0 ? errno : 0;
 	check_cwd();
 	if (v)
-		printf("%d/%d: truncate %s %lld %d\n", procid, opno, f.path,
-			(long long)off, e);
+		printf("%d/%d: truncate %s%s %lld %d\n", procid, opno, f.path,
+		       st, (long long)off, e);
 	free_pathname(&f);
 }
 
@@ -2574,6 +2597,7 @@ unresvsp_f(int opno, long r)
 	off64_t		off;
 	struct stat64	stb;
 	int		v;
+	char		st[1024];
 
 	init_pathname(&f);
 	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -2600,6 +2624,7 @@ unresvsp_f(int opno, long r)
 		close(fd);
 		return;
 	}
+	inode_info(st, sizeof(st), &stb, v);
 	lr = ((__int64_t)random() << 32) + random();
 	off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
 	off %= maxfsize;
@@ -2608,8 +2633,8 @@ unresvsp_f(int opno, long r)
 	fl.l_len = (off64_t)(random() % (1 << 20));
 	e = xfsctl(f.path, fd, XFS_IOC_UNRESVSP64, &fl) < 0 ? errno : 0;
 	if (v)
-		printf("%d/%d: xfsctl(XFS_IOC_UNRESVSP64) %s %lld %lld %d\n",
-			procid, opno, f.path,
+		printf("%d/%d: xfsctl(XFS_IOC_UNRESVSP64) %s%s %lld %lld %d\n",
+		       procid, opno, f.path, st,
 			(long long)off, (long long)fl.l_len, e);
 	free_pathname(&f);
 	close(fd);
@@ -2627,6 +2652,7 @@ write_f(int opno, long r)
 	off64_t		off;
 	struct stat64	stb;
 	int		v;
+	char		st[1024];
 
 	init_pathname(&f);
 	if (!get_fname(FT_REGm, r, &f, NULL, NULL, &v)) {
@@ -2653,6 +2679,7 @@ write_f(int opno, long r)
 		close(fd);
 		return;
 	}
+	inode_info(st, sizeof(st), &stb, v);
 	lr = ((__int64_t)random() << 32) + random();
 	off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
 	off %= maxfsize;
@@ -2663,8 +2690,8 @@ write_f(int opno, long r)
 	e = write(fd, buf, len) < 0 ? errno : 0;
 	free(buf);
 	if (v)
-		printf("%d/%d: write %s [%lld,%d] %d\n",
-			procid, opno, f.path, (long long)off, (int)len, e);
+		printf("%d/%d: write %s%s [%lld,%d] %d\n",
+		       procid, opno, f.path, st, (long long)off, (int)len, e);
 	free_pathname(&f);
 	close(fd);
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 02/12] xfstests: add different logging option to fsstress
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
  2011-11-03 14:24 ` [PATCH 01/12] xfstests: fsstress dump inode info when possible Dmitry Monakhov
@ 2011-11-03 14:24 ` Dmitry Monakhov
  2011-11-03 14:24 ` [PATCH 03/12] xfstests: fsstress should kill children tasks before exit Dmitry Monakhov
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:24 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov

Currently the only way to log fsstress's output is to redirect it's shared
stdout to pipe which is very painfull because:

1) Pipe writers are serialized via i_mutex so we waste cpu-cores power on stupid
   sinchronization for loging purpose, instead of hunting real race conditions,
   and bugs inside file system.
2) Usually output is corrupted due to luck of sychronization on shared stdout.

Since fsstress's children operate on independend paths, let's just open didicated
log file for each child and simply avoid useless sycnhronization.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 ltp/fsstress.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 51ecda2..c7001f3 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -258,6 +258,8 @@ int main(int argc, char **argv)
 	char		buf[10];
 	int		c;
 	char		*dirname = NULL;
+	char		*logname = NULL;
+	char		rpath[PATH_MAX];
 	int		fd;
 	int		i;
 	int		j;
@@ -273,7 +275,7 @@ int main(int argc, char **argv)
 	nops = sizeof(ops) / sizeof(ops[0]);
 	ops_end = &ops[nops];
 	myprog = argv[0];
-	while ((c = getopt(argc, argv, "d:e:f:i:m:n:p:rs:vwzHS")) != -1) {
+	while ((c = getopt(argc, argv, "d:e:f:i:m:n:o:p:rs:vwzHS")) != -1) {
 		switch (c) {
 		case 'd':
 			dirname = optarg;
@@ -311,6 +313,10 @@ int main(int argc, char **argv)
 		case 'n':
 			operations = atoi(optarg);
 			break;
+		case 'o':
+			logname = optarg;
+			break;
+
 		case 'p':
 			nproc = atoi(optarg);
 			break;
@@ -351,10 +357,26 @@ int main(int argc, char **argv)
         }
 
 	(void)mkdir(dirname, 0777);
+	if (logname && logname[0] != '/') {
+		if (getcwd(rpath, sizeof(rpath)) < 0){
+			perror("getcwd failed");
+			exit(1);
+		}
+	} else {
+		rpath[0] = '\0';
+	}
 	if (chdir(dirname) < 0) {
 		perror(dirname);
 		exit(1);
 	}
+	if (logname) {
+		char path[PATH_MAX];
+		snprintf(path, sizeof(path), "%s/%s", rpath, logname);
+		if (freopen(path, "a", stdout) == NULL) {
+			perror("freopen logfile failed");
+			exit(1);
+		}
+	}
 	sprintf(buf, "fss%x", (unsigned int)getpid());
 	fd = creat(buf, 0666);
 	if (lseek64(fd, (off64_t)(MAXFSIZE32 + 1ULL), SEEK_SET) < 0)
@@ -409,6 +431,15 @@ int main(int argc, char **argv)
 		close(fd);
 	for (i = 0; i < nproc; i++) {
 		if (fork() == 0) {
+			if (logname) {
+				char path[PATH_MAX];
+				snprintf(path, sizeof(path), "%s/%s.%d",
+					 rpath, logname, i);
+				if (freopen(path, "a", stdout) == NULL) {
+					perror("freopen logfile failed");
+					exit(1);
+				}
+			}
 			procid = i;
 			doproc();
 			return 0;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 03/12] xfstests: fsstress should kill children tasks before exit
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
  2011-11-03 14:24 ` [PATCH 01/12] xfstests: fsstress dump inode info when possible Dmitry Monakhov
  2011-11-03 14:24 ` [PATCH 02/12] xfstests: add different logging option to fsstress Dmitry Monakhov
@ 2011-11-03 14:24 ` Dmitry Monakhov
  2011-11-03 14:24 ` [PATCH 04/12] xfstests: fsstress add command line style output for show_opts Dmitry Monakhov
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:24 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov

It is very hard to predict runtime for fsstress. In many cases it
is useful to give test to run a reasonable time, and then kill it.
But currently there is no reliable way to kill test without leaving
running children.
This patch add sanity cleanup logic which looks follow:
 - On sigterm received by parent, it resend signal to it's children
 - Wait for each child to terminates
 - EXTRA_SANITY: Even if parent was killed by other signal, children
   will be terminated with SIGKILL to preven staled children.

So now one can simply run fsstress like this:
./fsstress -p 1000 -n999999999 -d $TEST_DIR &
PID=$!
sleep 300
kill $PID
wait $PID

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 aclocal.m4     |    5 +++++
 configure.in   |    1 +
 ltp/fsstress.c |   37 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index 168eb59..5532606 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -16,6 +16,11 @@ AC_DEFUN([AC_PACKAGE_WANT_LINUX_FIEMAP_H],
     AC_SUBST(have_fiemap)
   ])
 
+AC_DEFUN([AC_PACKAGE_WANT_LINUX_PRCTL_H],
+  [ AC_CHECK_HEADERS([sys/prctl.h], [ have_prctl=true ], [ have_prctl=false ])
+    AC_SUBST(have_prctl)
+  ])
+
 AC_DEFUN([AC_PACKAGE_WANT_FALLOCATE],
   [ AC_MSG_CHECKING([for fallocate])
     AC_TRY_LINK([
diff --git a/configure.in b/configure.in
index c697b4f..76d23e4 100644
--- a/configure.in
+++ b/configure.in
@@ -67,6 +67,7 @@ in
 		AC_PACKAGE_WANT_DMAPI
 		AC_PACKAGE_WANT_LINUX_FIEMAP_H
 		AC_PACKAGE_WANT_FALLOCATE
+		AC_PACKAGE_WANT_LINUX_PRCTL_H
 		;;
 esac
 
diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index c7001f3..133a247 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -28,7 +28,9 @@
 #ifndef HAVE_ATTR_LIST
 #define attr_list(path, buf, size, flags, cursor) (errno = -ENOSYS, -1)
 #endif
-
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
 #include <math.h>
 #define XFS_ERRTAG_MAX		17
 #define XFS_IDMODULO_MAX	31	/* user/group IDs (1 << x)  */
@@ -209,6 +211,7 @@ int		rtpct;
 unsigned long	seed = 0;
 ino_t		top_ino;
 int		verbose = 0;
+sig_atomic_t	should_stop = 0;
 
 void	add_to_flist(int, int, int);
 void	append_pathname(pathname_t *, char *);
@@ -253,6 +256,11 @@ void	usage(void);
 void	write_freq(void);
 void	zero_freq(void);
 
+void sg_handler(int signum)
+{
+	should_stop = 1;
+}
+
 int main(int argc, char **argv)
 {
 	char		buf[10];
@@ -269,6 +277,7 @@ int main(int argc, char **argv)
 	ptrdiff_t	srval;
 	int             nousage = 0;
 	xfs_error_injection_t	        err_inj;
+	struct sigaction action;
 
 	errrange = errtag = 0;
 	umask(0);
@@ -429,8 +438,27 @@ int main(int argc, char **argv)
 		}
 	} else
 		close(fd);
+
+	setpgid(0, 0);
+	action.sa_handler = sg_handler;
+	sigemptyset(&action.sa_mask);
+	action.sa_flags = 0;
+	if (sigaction(SIGTERM, &action, 0)) {
+		perror("sigaction failed");
+		exit(1);
+	}
+
 	for (i = 0; i < nproc; i++) {
 		if (fork() == 0) {
+			action.sa_handler = SIG_DFL;
+			sigemptyset(&action.sa_mask);
+			if (sigaction(SIGTERM, &action, 0))
+				return 1;
+#ifdef HAVE_SYS_PRCTL_H
+			prctl(PR_SET_PDEATHSIG, SIGKILL);
+			if (getppid() == 1) /* parent died already? */
+				return 0;
+#endif
 			if (logname) {
 				char path[PATH_MAX];
 				snprintf(path, sizeof(path), "%s/%s.%d",
@@ -445,8 +473,15 @@ int main(int argc, char **argv)
 			return 0;
 		}
 	}
+	while (wait(&stat) > 0 && !should_stop) {
+		continue;
+	}
+	action.sa_flags = SA_RESTART;
+	sigaction(SIGTERM, &action, 0);
+	kill(-getpid(), SIGTERM);
 	while (wait(&stat) > 0)
 		continue;
+
 	if (errtag != 0) {
 		err_inj.errtag = 0;
 		err_inj.fd = fd;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 04/12] xfstests: fsstress add command line style output for show_opts
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
                   ` (2 preceding siblings ...)
  2011-11-03 14:24 ` [PATCH 03/12] xfstests: fsstress should kill children tasks before exit Dmitry Monakhov
@ 2011-11-03 14:24 ` Dmitry Monakhov
  2011-11-03 14:24 ` [PATCH 05/12] xfstests: freeze fsstress options for 117'th Dmitry Monakhov
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:24 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov

Once some combination of seed+fs_ops result in regression it is
reasonable to document that combination. It is usefull to dump
that configuration in command line style. Later this line may be
simply hardcoded in to regression test.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 070            |    2 +-
 117            |    2 +-
 ltp/fsstress.c |   22 ++++++++++++++++++----
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/070 b/070
index 4458011..f48c33c 100755
--- a/070
+++ b/070
@@ -62,7 +62,7 @@ $FSSTRESS_PROG \
 	-f unresvsp=0 \
 	-f attr_set=100 \
 	-f attr_remove=100 \
-	-S -p 1 -n 10000 >$seq.full 2>&1
+        -p 1 -n 10000 -S c >$seq.full 2>&1
 
 status=$?
 exit
diff --git a/117 b/117
index fcf0485..edec157 100755
--- a/117
+++ b/117
@@ -85,7 +85,7 @@ while [ $i -lt $ITERATIONS ]; do
 	-f attr_set=100 \
 	-f attr_remove=100 \
         -s $seed \
-	-S -p 1 -n 1000 >>$seq.full 2>&1
+	-p 1 -n 1000 -S c >>$seq.full 2>&1
 
     let i=$i+1
 done
diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 133a247..77e0682 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -284,7 +284,7 @@ int main(int argc, char **argv)
 	nops = sizeof(ops) / sizeof(ops[0]);
 	ops_end = &ops[nops];
 	myprog = argv[0];
-	while ((c = getopt(argc, argv, "d:e:f:i:m:n:o:p:rs:vwzHS")) != -1) {
+	while ((c = getopt(argc, argv, "d:e:f:i:m:n:o:p:rs:S:vwzH")) != -1) {
 		switch (c) {
 		case 'd':
 			dirname = optarg;
@@ -345,7 +345,10 @@ int main(int argc, char **argv)
 			zero_freq();
 			break;
 		case 'S':
-			show_ops(0, NULL);
+			i = 0;
+			if (optarg[0] == 'c')
+				i = 1;
+			show_ops(1, NULL);
 			printf("\n");
                         nousage=1;
 			break;
@@ -1310,7 +1313,8 @@ show_ops(int flag, char *lead_str)
                         x+=printf("%s ", p->name);
                 }
                 printf("\n");
-        } else {
+        } else if (flag == 0) {
+		/* Table view style */
 	        int		f;
 	        for (f = 0, p = ops; p < ops_end; p++)
 		        f += p->freq;
@@ -1327,6 +1331,16 @@ show_ops(int flag, char *lead_str)
 			        (p->iswrite == 0) ? " " : "write op");
 		        }
                 }
+	} else {
+		/* Command line style */
+		if (lead_str != NULL)
+			printf("%s", lead_str);
+		printf ("-z -s %ld -m %d -n %d -p %d ", seed, idmodulo,
+			operations, nproc);
+	        for (p = ops; p < ops_end; p++)
+		        if (p->freq > 0)
+			        printf("-f%s=%d ",p->name, p->freq);
+		printf("\n");
 	}
 }
 
@@ -1433,7 +1447,7 @@ usage(void)
 	printf("   -v               specifies verbose mode\n");
 	printf("   -w               zeros frequencies of non-write operations\n");
 	printf("   -z               zeros frequencies of all operations\n");
-	printf("   -S               prints the table of operations (omitting zero frequency)\n");
+	printf("   -S [c,t]         prints the list of operations (omitting zero frequency) in command line or table style\n");
 	printf("   -H               prints usage and exits\n");
 }
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 05/12] xfstests: freeze fsstress options for 117'th
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
                   ` (3 preceding siblings ...)
  2011-11-03 14:24 ` [PATCH 04/12] xfstests: fsstress add command line style output for show_opts Dmitry Monakhov
@ 2011-11-03 14:24 ` Dmitry Monakhov
  2011-11-03 14:24 ` [PATCH 06/12] xfstests: add fallocate support to fsstress Dmitry Monakhov
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:24 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov

This is regression tescase for explicit combination of seed+fs_opts.
Let's hardcode all options to prevent interactions with fsstress
changes in future.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 117 |   39 ++++++++++++++++++++++++++++-----------
 1 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/117 b/117
index edec157..2e3f658 100755
--- a/117
+++ b/117
@@ -33,8 +33,34 @@ tmp=/tmp/$$
 status=1	# failure is the default!
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
-# seed for fsstress known to cause curruptions
+# seed and options for fsstress known to cause curruptions
 seed=1122413794
+fss_ops=" -z \
+    -f attr_remove=100 \
+    -f attr_set=100 \
+    -f chown=3 \
+    -f creat=4 \
+    -f dread=4 \
+    -f dwrite=4 \
+    -f fdatasync=1 \
+    -f fsync=1 \
+    -f getdents=1 \
+    -f link=1 \
+    -f mkdir=2 \
+    -f mknod=2 \
+    -f read=1 \
+    -f readlink=1 \
+    -f rename=2 \
+    -f rmdir=1 \
+    -f setxattr=1 \
+    -f stat=1 \
+    -f symlink=2 \
+    -f sync=1 \
+    -f truncate=2 \
+    -f unlink=1 \
+    -f write=4 \
+    -s $seed \
+    -m 31 -n 1000 -p 1"
 
 ITERATIONS=10
 
@@ -76,16 +102,7 @@ while [ $i -lt $ITERATIONS ]; do
     echo fsstress iteration: $i | tee -a $seq.full
     $FSSTRESS_PROG \
 	-d $SCRATCH_MNT/fsstress \
-	-f allocsp=0 \
-	-f freesp=0 \
-	-f bulkstat=0 \
-	-f bulkstat1=0 \
-	-f resvsp=0 \
-	-f unresvsp=0 \
-	-f attr_set=100 \
-	-f attr_remove=100 \
-        -s $seed \
-	-p 1 -n 1000 -S c >>$seq.full 2>&1
+	$fss_ops -S c >>$seq.full 2>&1
 
     let i=$i+1
 done
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 06/12] xfstests: add fallocate support to fsstress
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
                   ` (4 preceding siblings ...)
  2011-11-03 14:24 ` [PATCH 05/12] xfstests: freeze fsstress options for 117'th Dmitry Monakhov
@ 2011-11-03 14:24 ` Dmitry Monakhov
  2011-11-03 14:24 ` [PATCH 07/12] xfstests: fsstress add FS_IOC_{SET,GET}FLAGS operations v2 Dmitry Monakhov
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:24 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov

Add tests for fallocate(2) syscall
- fallocate: reserve the disk space
- punch: de-allocates the disk space
Since FALLOC_FL_PUNCH_HOLE is relatively new it's value defined
explicitly if not yet defined. Later we may clear that define.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 ltp/fsstress.c |  127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 126 insertions(+), 1 deletions(-)

diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 77e0682..f4c8d81 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -24,7 +24,13 @@
 #ifdef HAVE_ATTR_ATTRIBUTES_H
 #include <attr/attributes.h>
 #endif
-
+#ifdef FALLOCATE
+#include <linux/falloc.h>
+#ifndef FALLOC_FL_PUNCH_HOLE
+/* Copy-paste from linux/falloc.h */
+#define FALLOC_FL_PUNCH_HOLE    0x02 /* de-allocates range */
+#endif
+#endif
 #ifndef HAVE_ATTR_LIST
 #define attr_list(path, buf, size, flags, cursor) (errno = -ENOSYS, -1)
 #endif
@@ -48,6 +54,7 @@ typedef enum {
 	OP_CREAT,
 	OP_DREAD,
 	OP_DWRITE,
+	OP_FALLOCATE,
 	OP_FDATASYNC,
 	OP_FREESP,
 	OP_FSYNC,
@@ -55,6 +62,7 @@ typedef enum {
 	OP_LINK,
 	OP_MKDIR,
 	OP_MKNOD,
+	OP_PUNCH,
 	OP_READ,
 	OP_READLINK,
 	OP_RENAME,
@@ -128,6 +136,7 @@ void	chown_f(int, long);
 void	creat_f(int, long);
 void	dread_f(int, long);
 void	dwrite_f(int, long);
+void	fallocate_f(int, long);
 void	fdatasync_f(int, long);
 void	freesp_f(int, long);
 void	fsync_f(int, long);
@@ -135,6 +144,7 @@ void	getdents_f(int, long);
 void	link_f(int, long);
 void	mkdir_f(int, long);
 void	mknod_f(int, long);
+void	punch_f(int, long);
 void	read_f(int, long);
 void	readlink_f(int, long);
 void	rename_f(int, long);
@@ -159,6 +169,7 @@ opdesc_t	ops[] = {
 	{ OP_CREAT, "creat", creat_f, 4, 1 },
 	{ OP_DREAD, "dread", dread_f, 4, 0 },
 	{ OP_DWRITE, "dwrite", dwrite_f, 4, 1 },
+	{ OP_FALLOCATE, "fallocate", fallocate_f, 1, 1 },
 	{ OP_FDATASYNC, "fdatasync", fdatasync_f, 1, 1 },
 	{ OP_FREESP, "freesp", freesp_f, 1, 1 },
 	{ OP_FSYNC, "fsync", fsync_f, 1, 1 },
@@ -166,6 +177,7 @@ opdesc_t	ops[] = {
 	{ OP_LINK, "link", link_f, 1, 1 },
 	{ OP_MKDIR, "mkdir", mkdir_f, 2, 1 },
 	{ OP_MKNOD, "mknod", mknod_f, 2, 1 },
+	{ OP_PUNCH, "punch", punch_f, 1, 1 },
 	{ OP_READ, "read", read_f, 1, 0 },
 	{ OP_READLINK, "readlink", readlink_f, 1, 0 },
 	{ OP_RENAME, "rename", rename_f, 2, 1 },
@@ -2012,6 +2024,63 @@ dwrite_f(int opno, long r)
 }
 
 void
+fallocate_f(int opno, long r)
+{
+#ifdef FALLOCATE
+	int		e;
+	pathname_t	f;
+	int		fd;
+	__int64_t	lr;
+	off64_t		off;
+	off64_t		len;
+	struct stat64	stb;
+	int		v;
+	char		st[1024];
+	int mode = 0;
+
+	init_pathname(&f);
+	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
+		if (v)
+			printf("%d/%d: fallocate - no filename\n", procid, opno);
+		free_pathname(&f);
+		return;
+	}
+	fd = open_path(&f, O_RDWR);
+	e = fd < 0 ? errno : 0;
+	check_cwd();
+	if (fd < 0) {
+		if (v)
+			printf("%d/%d: fallocate - open %s failed %d\n",
+				procid, opno, f.path, e);
+		free_pathname(&f);
+		return;
+	}
+	if (fstat64(fd, &stb) < 0) {
+		if (v)
+			printf("%d/%d: fallocate - fstat64 %s failed %d\n",
+				procid, opno, f.path, errno);
+		free_pathname(&f);
+		close(fd);
+		return;
+	}
+	inode_info(st, sizeof(st), &stb, v);
+	lr = ((__int64_t)random() << 32) + random();
+	off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
+	off %= maxfsize;
+	len = (off64_t)(random() % (1024 * 1024));
+	mode |= FALLOC_FL_KEEP_SIZE & random();
+	e = fallocate(fd, mode, (loff_t)off, (loff_t)len) < 0 ? errno : 0;
+	if (v)
+		printf("%d/%d: fallocate(%d) %s %st %lld %lld %d\n",
+		       procid, opno, mode,
+		       f.path, st, (long long)off, (long long)len, e);
+	free_pathname(&f);
+	close(fd);
+#endif
+}
+
+
+void
 fdatasync_f(int opno, long r)
 {
 	int		e;
@@ -2284,6 +2353,62 @@ mknod_f(int opno, long r)
 }
 
 void
+punch_f(int opno, long r)
+{
+#ifdef FALLOCATE
+	int		e;
+	pathname_t	f;
+	int		fd;
+	__int64_t	lr;
+	off64_t		off;
+	off64_t		len;
+	struct stat64	stb;
+	int		v;
+	char		st[1024];
+	int mode = FALLOC_FL_PUNCH_HOLE;
+
+	init_pathname(&f);
+	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
+		if (v)
+			printf("%d/%d: punch hole - no filename\n", procid, opno);
+		free_pathname(&f);
+		return;
+	}
+	fd = open_path(&f, O_RDWR);
+	e = fd < 0 ? errno : 0;
+	check_cwd();
+	if (fd < 0) {
+		if (v)
+			printf("%d/%d: punch hole - open %s failed %d\n",
+				procid, opno, f.path, e);
+		free_pathname(&f);
+		return;
+	}
+	if (fstat64(fd, &stb) < 0) {
+		if (v)
+			printf("%d/%d: punch hole - fstat64 %s failed %d\n",
+				procid, opno, f.path, errno);
+		free_pathname(&f);
+		close(fd);
+		return;
+	}
+	inode_info(st, sizeof(st), &stb, v);
+	lr = ((__int64_t)random() << 32) + random();
+	off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
+	off %= maxfsize;
+	len = (off64_t)(random() % (1024 * 1024));
+	mode |= FALLOC_FL_KEEP_SIZE & random();
+	e = fallocate(fd, mode, (loff_t)off, (loff_t)len) < 0 ? errno : 0;
+	if (v)
+		printf("%d/%d: punch hole(%d) %s %s %lld %lld %d\n",
+		       procid, opno, mode,
+		       f.path, st, (long long)off, (long long)len, e);
+	free_pathname(&f);
+	close(fd);
+#endif
+}
+
+void
 read_f(int opno, long r)
 {
 	char		*buf;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 07/12] xfstests: fsstress add FS_IOC_{SET,GET}FLAGS operations v2
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
                   ` (5 preceding siblings ...)
  2011-11-03 14:24 ` [PATCH 06/12] xfstests: add fallocate support to fsstress Dmitry Monakhov
@ 2011-11-03 14:24 ` Dmitry Monakhov
  2011-11-03 14:24 ` [PATCH 08/12] xfstests: add fiemap operation to fsstress Dmitry Monakhov
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:24 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov

Add two new operations:
- getattr: ioctl(fd, FS_IOC_GETFLAGS, &fl)
- setattr: ioctl(fd, FS_IOC_SETFLAGS, &random_flags)
Attribute mask may be passed via -M opt, by default is (~0).
By default FS_IOC_SETFLAGS has zero probability because
it may produce inodes with APPEND or IMMUTABLE flags which
are not deletable by default. Let's assumes that one who
enable it knows how to delete such inodes.
For example like follows:
find $TEST_PATH -exec chattr -i -a {} \;
rm -rf $TEST_PATH

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 aclocal.m4     |    4 +++
 configure.in   |    1 +
 ltp/fsstress.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 72 insertions(+), 1 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index 5532606..5739004 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -21,6 +21,10 @@ AC_DEFUN([AC_PACKAGE_WANT_LINUX_PRCTL_H],
     AC_SUBST(have_prctl)
   ])
 
+AC_DEFUN([AC_PACKAGE_WANT_LINUX_FS_H],
+  [ AC_CHECK_HEADER([linux/fs.h])
+  ])
+
 AC_DEFUN([AC_PACKAGE_WANT_FALLOCATE],
   [ AC_MSG_CHECKING([for fallocate])
     AC_TRY_LINK([
diff --git a/configure.in b/configure.in
index 76d23e4..3b40e55 100644
--- a/configure.in
+++ b/configure.in
@@ -68,6 +68,7 @@ in
 		AC_PACKAGE_WANT_LINUX_FIEMAP_H
 		AC_PACKAGE_WANT_FALLOCATE
 		AC_PACKAGE_WANT_LINUX_PRCTL_H
+		AC_PACKAGE_WANT_LINUX_FS_H
 		;;
 esac
 
diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index f4c8d81..997f068 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -37,6 +37,15 @@
 #ifdef HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
 #endif
+
+#include <linux/fs.h>
+#ifndef FS_IOC_GETFLAGS
+#define FS_IOC_GETFLAGS                 _IOR('f', 1, long)
+#endif
+#ifndef FS_IOC_SETFLAGS
+#define FS_IOC_SETFLAGS                 _IOW('f', 2, long)
+#endif
+
 #include <math.h>
 #define XFS_ERRTAG_MAX		17
 #define XFS_IDMODULO_MAX	31	/* user/group IDs (1 << x)  */
@@ -58,6 +67,7 @@ typedef enum {
 	OP_FDATASYNC,
 	OP_FREESP,
 	OP_FSYNC,
+	OP_GETATTR,
 	OP_GETDENTS,
 	OP_LINK,
 	OP_MKDIR,
@@ -68,6 +78,7 @@ typedef enum {
 	OP_RENAME,
 	OP_RESVSP,
 	OP_RMDIR,
+	OP_SETATTR,
 	OP_SETXATTR,
 	OP_STAT,
 	OP_SYMLINK,
@@ -140,6 +151,7 @@ void	fallocate_f(int, long);
 void	fdatasync_f(int, long);
 void	freesp_f(int, long);
 void	fsync_f(int, long);
+void	getattr_f(int, long);
 void	getdents_f(int, long);
 void	link_f(int, long);
 void	mkdir_f(int, long);
@@ -150,6 +162,7 @@ void	readlink_f(int, long);
 void	rename_f(int, long);
 void	resvsp_f(int, long);
 void	rmdir_f(int, long);
+void	setattr_f(int, long);
 void	setxattr_f(int, long);
 void	stat_f(int, long);
 void	symlink_f(int, long);
@@ -173,6 +186,7 @@ opdesc_t	ops[] = {
 	{ OP_FDATASYNC, "fdatasync", fdatasync_f, 1, 1 },
 	{ OP_FREESP, "freesp", freesp_f, 1, 1 },
 	{ OP_FSYNC, "fsync", fsync_f, 1, 1 },
+	{ OP_GETATTR, "getattr", getattr_f, 1, 0 },
 	{ OP_GETDENTS, "getdents", getdents_f, 1, 0 },
 	{ OP_LINK, "link", link_f, 1, 1 },
 	{ OP_MKDIR, "mkdir", mkdir_f, 2, 1 },
@@ -183,6 +197,7 @@ opdesc_t	ops[] = {
 	{ OP_RENAME, "rename", rename_f, 2, 1 },
 	{ OP_RESVSP, "resvsp", resvsp_f, 1, 1 },
 	{ OP_RMDIR, "rmdir", rmdir_f, 1, 1 },
+	{ OP_SETATTR, "setattr", setattr_f, 0, 1 },
 	{ OP_SETXATTR, "setxattr", setxattr_f, 1, 1 },
 	{ OP_STAT, "stat", stat_f, 1, 0 },
 	{ OP_SYMLINK, "symlink", symlink_f, 2, 1 },
@@ -218,6 +233,7 @@ int		nops;
 int		nproc = 1;
 int		operations = 1;
 unsigned int	idmodulo = XFS_IDMODULO_MAX;
+unsigned int	attr_mask = ~0;
 int		procid;
 int		rtpct;
 unsigned long	seed = 0;
@@ -296,7 +312,7 @@ int main(int argc, char **argv)
 	nops = sizeof(ops) / sizeof(ops[0]);
 	ops_end = &ops[nops];
 	myprog = argv[0];
-	while ((c = getopt(argc, argv, "d:e:f:i:m:n:o:p:rs:S:vwzH")) != -1) {
+	while ((c = getopt(argc, argv, "d:e:f:i:m:M:n:o:p:rs:S:vwzH")) != -1) {
 		switch (c) {
 		case 'd':
 			dirname = optarg;
@@ -356,6 +372,9 @@ int main(int argc, char **argv)
 		case 'z':
 			zero_freq();
 			break;
+		case 'M':
+		  	attr_mask = strtoul(optarg, NULL, 0);
+			break;
 		case 'S':
 			i = 0;
 			if (optarg[0] == 'c')
@@ -2199,6 +2218,29 @@ fsync_f(int opno, long r)
 }
 
 void
+getattr_f(int opno, long r)
+{
+	int		fd;
+	int		e;
+	pathname_t	f;
+	uint		fl;
+	int		v;
+
+	init_pathname(&f);
+	if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
+		append_pathname(&f, ".");
+	fd = open_path(&f, O_RDWR);
+	e = fd < 0 ? errno : 0;
+	check_cwd();
+
+	e = ioctl(fd, FS_IOC_GETFLAGS, &fl);
+	if (v)
+		printf("%d/%d: getattr %s %u %d\n", procid, opno, f.path, fl, e);
+	free_pathname(&f);
+	close(fd);
+}
+
+void
 getdents_f(int opno, long r)
 {
 	DIR		*dir;
@@ -2644,6 +2686,30 @@ rmdir_f(int opno, long r)
 }
 
 void
+setattr_f(int opno, long r)
+{
+	int		fd;
+	int		e;
+	pathname_t	f;
+	uint		fl;
+	int		v;
+
+	init_pathname(&f);
+	if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
+		append_pathname(&f, ".");
+	fd = open_path(&f, O_RDWR);
+	e = fd < 0 ? errno : 0;
+	check_cwd();
+
+	fl = attr_mask & (uint)random();
+	e = ioctl(fd, FS_IOC_SETFLAGS, &fl);
+	if (v)
+		printf("%d/%d: setattr %s %x %d\n", procid, opno, f.path, fl, e);
+	free_pathname(&f);
+	close(fd);
+}
+
+void
 stat_f(int opno, long r)
 {
 	int		e;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 08/12] xfstests: add fiemap operation to fsstress
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
                   ` (6 preceding siblings ...)
  2011-11-03 14:24 ` [PATCH 07/12] xfstests: fsstress add FS_IOC_{SET,GET}FLAGS operations v2 Dmitry Monakhov
@ 2011-11-03 14:24 ` Dmitry Monakhov
  2011-11-03 14:24 ` [PATCH 09/12] xfstests: add a new test that runs fsstress under ENOSPC conditions Dmitry Monakhov
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:24 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov

Related bug: http://patchwork.ozlabs.org/patch/118863

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 ltp/fsstress.c |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 997f068..cddfe74 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -24,6 +24,9 @@
 #ifdef HAVE_ATTR_ATTRIBUTES_H
 #include <attr/attributes.h>
 #endif
+#ifdef HAVE_LINUX_FIEMAP_H
+#include <linux/fiemap.h>
+#endif
 #ifdef FALLOCATE
 #include <linux/falloc.h>
 #ifndef FALLOC_FL_PUNCH_HOLE
@@ -65,6 +68,7 @@ typedef enum {
 	OP_DWRITE,
 	OP_FALLOCATE,
 	OP_FDATASYNC,
+	OP_FIEMAP,
 	OP_FREESP,
 	OP_FSYNC,
 	OP_GETATTR,
@@ -149,6 +153,7 @@ void	dread_f(int, long);
 void	dwrite_f(int, long);
 void	fallocate_f(int, long);
 void	fdatasync_f(int, long);
+void	fiemap_f(int, long);
 void	freesp_f(int, long);
 void	fsync_f(int, long);
 void	getattr_f(int, long);
@@ -184,6 +189,7 @@ opdesc_t	ops[] = {
 	{ OP_DWRITE, "dwrite", dwrite_f, 4, 1 },
 	{ OP_FALLOCATE, "fallocate", fallocate_f, 1, 1 },
 	{ OP_FDATASYNC, "fdatasync", fdatasync_f, 1, 1 },
+	{ OP_FIEMAP, "fiemap", fiemap_f, 1, 1 },
 	{ OP_FREESP, "freesp", freesp_f, 1, 1 },
 	{ OP_FSYNC, "fsync", fsync_f, 1, 1 },
 	{ OP_GETATTR, "getattr", getattr_f, 1, 0 },
@@ -2131,6 +2137,76 @@ fdatasync_f(int opno, long r)
 	free_pathname(&f);
 	close(fd);
 }
+void
+fiemap_f(int opno, long r)
+{
+#ifdef HAVE_LINUX_FIEMAP_H
+	int		e;
+	pathname_t	f;
+	int		fd;
+	__int64_t	lr;
+	off64_t		off;
+	struct stat64	stb;
+	int		v;
+	char		st[1024];
+	int blocks_to_map;
+	struct fiemap *fiemap;
+
+	init_pathname(&f);
+	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
+		if (v)
+			printf("%d/%d: fiemap - no filename\n", procid, opno);
+		free_pathname(&f);
+		return;
+	}
+	fd = open_path(&f, O_RDWR);
+	e = fd < 0 ? errno : 0;
+	check_cwd();
+	if (fd < 0) {
+		if (v)
+			printf("%d/%d: fiemap - open %s failed %d\n",
+				procid, opno, f.path, e);
+		free_pathname(&f);
+		return;
+	}
+	if (fstat64(fd, &stb) < 0) {
+		if (v)
+			printf("%d/%d: fiemap - fstat64 %s failed %d\n",
+				procid, opno, f.path, errno);
+		free_pathname(&f);
+		close(fd);
+		return;
+	}
+	inode_info(st, sizeof(st), &stb, v);
+	blocks_to_map = random() & 0xffff;
+	fiemap = (struct fiemap *)malloc(sizeof(struct fiemap) +
+			(blocks_to_map * sizeof(struct fiemap_extent)));
+	if (!fiemap) {
+		if (v)
+			printf("%d/%d: malloc failed \n", procid, opno);
+		free_pathname(&f);
+		close(fd);
+		return;
+	}
+	lr = ((__int64_t)random() << 32) + random();
+	off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
+	off %= maxfsize;
+	fiemap->fm_flags = random() & (FIEMAP_FLAGS_COMPAT | 0x10000);
+	fiemap->fm_extent_count = blocks_to_map;
+	fiemap->fm_mapped_extents = random() & 0xffff;
+	fiemap->fm_start = off;
+	fiemap->fm_length = ((__int64_t)random() << 32) + random();
+
+	e = ioctl(fd, FS_IOC_FIEMAP, (unsigned long)fiemap);
+	if (v)
+		printf("%d/%d: ioctl(FIEMAP) %s%s %lld %lld %x %d\n",
+		       procid, opno, f.path, st, (long long)fiemap->fm_start,
+		       (long long) fiemap->fm_length, fiemap->fm_flags, e);
+	free(fiemap);
+	free_pathname(&f);
+	close(fd);
+#endif
+}
 
 void
 freesp_f(int opno, long r)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 09/12] xfstests: add a new test that runs fsstress under ENOSPC conditions
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
                   ` (7 preceding siblings ...)
  2011-11-03 14:24 ` [PATCH 08/12] xfstests: add fiemap operation to fsstress Dmitry Monakhov
@ 2011-11-03 14:24 ` Dmitry Monakhov
  2011-11-07 21:22   ` Dave Chinner
  2011-11-07 21:25   ` Dave Chinner
  2011-11-03 14:24 ` [PATCH 10/12] xfstests: add a new quota " Dmitry Monakhov
                   ` (3 subsequent siblings)
  12 siblings, 2 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:24 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov

During stress testing we want to cover as much code paths as possible
fsstress is very good for this purpose. But it has expandable nature
(disk usage almost continually grow). So once it goes in no ENOSPC
condition it will be where till the end. But by running 'dd' writers
in parallel we can regularly trigger ENOSPC but only for a limited
periods of time because each time it opens the same file with O_TRUNC.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 264     |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 264.out |    5 +++
 group   |    1 +
 3 files changed, 92 insertions(+), 0 deletions(-)
 create mode 100755 264
 create mode 100644 264.out

diff --git a/264 b/264
new file mode 100755
index 0000000..fc6df23
--- /dev/null
+++ b/264
@@ -0,0 +1,86 @@
+#! /bin/bash
+# FSQA Test No. 264
+#
+# Run fsstress and ENSPC hitters in parallel, check fs consistency an the end
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2006 Silicon Graphics, 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
+owner=dmonakhov@openvz.org
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+# Disable all sync operations to get higher load
+FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0"
+_workout()
+{
+	echo ""
+	echo "Run fsstress"
+	echo ""
+	num_iterations=10
+	enospc_time=2
+	out=$SCRATCH_MNT/fsstress.$$
+	args="-p128 -n999999999 -f setattr=1 $FSSTRESS_AVOID -d $out"
+	echo "fsstress $args" >> $here/$seq.full
+	$FSSTRESS_PROG $args > /dev/null 2>&1 &
+	pid=$!
+	echo "Run dd writers in parallel"
+	for ((i=0; i < num_iterations; i++))
+	do
+		# File will be opened with O_TRUNC each time
+		dd if=/dev/zero of=$SCRATCH_MNT/SPACE_CONSUMER bs=1M count=1 \
+			> /dev/null 2>&1
+		sleep $enospc_time
+	done
+	kill $pid
+	wait $pid
+}
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_need_to_be_root
+
+umount $SCRATCH_DEV 2>/dev/null
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seq.full 2>&1
+_scratch_mount
+
+if ! _workout; then
+	umount $SCRATCH_DEV 2>/dev/null
+	exit
+fi
+
+if ! _scratch_unmount; then
+	echo "failed to umount"
+	status=1
+	exit
+fi
+_check_scratch_fs
+status=$?
+exit
diff --git a/264.out b/264.out
new file mode 100644
index 0000000..81b50e5
--- /dev/null
+++ b/264.out
@@ -0,0 +1,5 @@
+QA output created by 264
+
+Run fsstress
+
+Run dd writers in parallel
diff --git a/group b/group
index 2a8970c..e79c29b 100644
--- a/group
+++ b/group
@@ -377,3 +377,4 @@ deprecated
 261 auto quick quota
 262 auto quick quota
 263 rw auto quick
+264 auto rw prealloc ioctl enospc
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 10/12] xfstests: add a new quota test that runs fsstress under ENOSPC conditions
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
                   ` (8 preceding siblings ...)
  2011-11-03 14:24 ` [PATCH 09/12] xfstests: add a new test that runs fsstress under ENOSPC conditions Dmitry Monakhov
@ 2011-11-03 14:24 ` Dmitry Monakhov
  2011-11-03 14:25 ` [PATCH 11/12] xfstress: add regression testcase for d583fb87a3ff0 Dmitry Monakhov
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:24 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov

- Same as 264 but with quota enabled.
- IO performed from $qa_user user
- fsstress granted with CAP_CHOWN capability.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 265     |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 265.out |    8 +++++
 group   |    1 +
 3 files changed, 117 insertions(+), 0 deletions(-)
 create mode 100755 265
 create mode 100644 265.out

diff --git a/265 b/265
new file mode 100755
index 0000000..b568fdd
--- /dev/null
+++ b/265
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FSQA Test No. 265
+#
+# Run fsstress and ENSPC hitters in parallel, check quota and 
+# fs consistency an the end
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2006 Silicon Graphics, 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
+owner=dmonakhov@openvz.org
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+. ./common.quota
+
+# Disable all sync operations to get higher load
+FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0"
+_workout()
+{
+	echo ""
+	echo "Run fsstress"
+	echo ""
+	num_iterations=10
+	enospc_time=2
+	out=$SCRATCH_MNT/fsstress.$$
+	args="-p128 -n999999999 -f setattr=1 $FSSTRESS_AVOID -d $out"
+	echo "fsstress $args" >> $here/$seq.full
+	# Grant chown capability 
+	cp $FSSTRESS_PROG  $tmp.fsstress.bin
+	setcap cap_chown=epi  $tmp.fsstress.bin
+
+	(su $qa_user -c "$tmp.fsstress.bin $args" &) > /dev/null 2>&1
+	pid=$!
+
+	echo "Run dd writers in parallel"
+	for ((i=0; i < num_iterations; i++))
+	do
+		# File will be opened with O_TRUNC each time
+		su $qa_user -c "dd if=/dev/zero \
+			of=$SCRATCH_MNT/SPACE_CONSUMER bs=1M " \
+			> /dev/null 2>&1
+		sleep $enospc_time
+	done
+
+	killall $tmp.fsstress.bin
+	wait $pid
+}
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_quota
+_require_user
+_need_to_be_root
+
+umount $SCRATCH_DEV 2>/dev/null
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seq.full 2>&1
+_scratch_mount "-o usrquota,grpquota"
+chmod 777 $SCRATCH_MNT
+quotacheck -u -g $SCRATCH_MNT 2>/dev/null
+quotaon -u -g $SCRATCH_MNT 2>/dev/null
+
+if ! _workout; then
+	_scratch_unmount 2>/dev/null
+	exit
+fi
+
+if ! _check_quota_usage; then
+	_scratch_unmount 2>/dev/null
+	status=1
+	exit
+fi
+
+echo Comparing filesystem consistency
+if ! _scratch_unmount; then
+	echo "failed to umount"
+	status=1
+	exit
+fi
+_check_scratch_fs
+status=$?
+exit
diff --git a/265.out b/265.out
new file mode 100644
index 0000000..7637291
--- /dev/null
+++ b/265.out
@@ -0,0 +1,8 @@
+QA output created by 265
+
+Run fsstress
+
+Run dd writers in parallel
+Comparing user usage
+Comparing group usage
+Comparing filesystem consistency
diff --git a/group b/group
index e79c29b..487051a 100644
--- a/group
+++ b/group
@@ -378,3 +378,4 @@ deprecated
 262 auto quick quota
 263 rw auto quick
 264 auto rw prealloc ioctl enospc
+265 auto quota rw prealloc ioctl enospc
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 11/12] xfstress: add regression testcase for d583fb87a3ff0
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
                   ` (9 preceding siblings ...)
  2011-11-03 14:24 ` [PATCH 10/12] xfstests: add a new quota " Dmitry Monakhov
@ 2011-11-03 14:25 ` Dmitry Monakhov
  2011-11-03 14:25 ` [PATCH 12/12] xfstress: Test data journaling flag switch for a single file Dmitry Monakhov
  2011-11-03 14:55 ` [PATCH 00/12] Bunch of new stress tests -v4 Christoph Hellwig
  12 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:25 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov

Should be fixed by following patch http://patchwork.ozlabs.org/patch/120883/

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 266     |   69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 266.out |   44 ++++++++++++++++++++++++++++++++++++++++
 group   |    1 +
 3 files changed, 114 insertions(+), 0 deletions(-)
 create mode 100755 266
 create mode 100644 266.out

diff --git a/266 b/266
new file mode 100755
index 0000000..4209532
--- /dev/null
+++ b/266
@@ -0,0 +1,69 @@
+#! /bin/bash
+# FSQA Test No. 266
+#
+# Regression testcase for d583fb87a3ff0 (ext4 extent corruption)
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2006 Silicon Graphics, 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
+owner=dmonakhov@openvz.org
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+_require_scratch
+_need_to_be_root
+
+umount $SCRATCH_DEV 2>/dev/null
+_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seq.full 2>&1
+
+# -onoload and EXT4_SYNC_FL on file is important becase result in
+# metadata sync writes inside ext4_handle_dirty_metadata()
+_scratch_mount -onoload
+touch $SCRATCH_MNT/file
+chattr +S $SCRATCH_MNT/file
+# Create sparse file 
+for ((i = 0; i < 21; i++))
+do
+    dd if=/dev/zero of=$SCRATCH_MNT/file bs=4k count=1 seek=$((i*10))
+done
+# truncate last extent
+truncate $SCRATCH_MNT/file --size $((4096* 200))
+
+if ! _scratch_unmount; then
+	echo "failed to umount"
+	status=1
+	exit
+fi
+echo "Check filesystem"
+_check_scratch_fs
+status=$?
+exit
diff --git a/266.out b/266.out
new file mode 100644
index 0000000..a248232
--- /dev/null
+++ b/266.out
@@ -0,0 +1,44 @@
+QA output created by 266
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+1+0 records in
+1+0 records out
+Check filesystem
diff --git a/group b/group
index 487051a..dfc6fa7 100644
--- a/group
+++ b/group
@@ -379,3 +379,4 @@ deprecated
 263 rw auto quick
 264 auto rw prealloc ioctl enospc
 265 auto quota rw prealloc ioctl enospc
+266 rw auto quick
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 12/12] xfstress: Test data journaling flag switch for a single file
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
                   ` (10 preceding siblings ...)
  2011-11-03 14:25 ` [PATCH 11/12] xfstress: add regression testcase for d583fb87a3ff0 Dmitry Monakhov
@ 2011-11-03 14:25 ` Dmitry Monakhov
  2011-11-03 14:55 ` [PATCH 00/12] Bunch of new stress tests -v4 Christoph Hellwig
  12 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 14:25 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: xfs, hch, aelder, tytso, Dmitry Monakhov


Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 267     |  111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 267.out |   37 +++++++++++++++++++++
 group   |    1 +
 3 files changed, 149 insertions(+), 0 deletions(-)
 create mode 100644 267
 create mode 100644 267.out

diff --git a/267 b/267
new file mode 100644
index 0000000..e2ce347
--- /dev/null
+++ b/267
@@ -0,0 +1,111 @@
+#! /bin/bash
+# FSQA Test No. 267
+#
+# Test data journaling flag switch for a single file  
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2006 Silicon Graphics, 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
+owner=dmonakhov@openvz.org
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+_workout()
+{
+	echo ""
+	echo " Switch data journalling mode"
+	echo ""
+	write_opt_list="iflag=noatime conv=notrunc conv=fsync oflag=direct"
+	chattr_opt_list="+j -j +jS -j"
+	idx=0
+	#
+	for write_opt in $write_opt_list
+	do
+		idx=$((idx + 1))
+		for chattr_opt in $chattr_opt_list
+		do
+		    
+			echo "OP write_opt: $write_opt 4M, \
+chattr_opt: $chattr_opt"
+			dd if=/dev/zero of=$SCRATCH_MNT/file.$idx \
+				bs=1M count=4 $write_opt \
+				> /dev/null 2>&1 || exit
+			chattr $chattr_opt $SCRATCH_MNT/file.$idx \
+				|| exit
+		done
+	done
+	sync
+	# Same as previous test, but for one file,
+	# and with ENOSPC triggering
+	for write_opt in $write_opt_list
+	do
+		idx=$((idx + 1))
+		for chattr_opt in $chattr_opt_list
+		do
+
+			echo "OP write_opt: $write_opt ENOSPC, \
+chattr_opt: $chattr_opt"
+			dd if=/dev/zero of=$SCRATCH_MNT/file.$idx \
+				bs=1M $write_opt > /dev/null 2>&1
+			chattr $chattr_opt $SCRATCH_MNT/file.$idx \
+				|| exit
+		done
+		sync
+		unlink $SCRATCH_MNT/file.$idx
+	done
+}
+
+# real QA test starts here
+_supported_fs ext3 ext4
+_supported_os Linux
+_require_scratch
+_need_to_be_root
+
+umount $SCRATCH_DEV 2>/dev/null
+_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seq.full 2>&1
+
+# -onoload and EXT4_SYNC_FL on file is important becase result in
+# metadata sync writes inside ext4_handle_dirty_metadata()
+_scratch_mount
+
+if ! _workout; then
+	echo "workout failed"
+	_scratch_unmount
+	status=1
+	exit
+fi
+
+if ! _scratch_unmount; then
+	echo "failed to umount"
+	status=1
+	exit
+fi
+echo "Check filesystem"
+_check_scratch_fs
+status=$?
+exit
diff --git a/267.out b/267.out
new file mode 100644
index 0000000..d46b6f4
--- /dev/null
+++ b/267.out
@@ -0,0 +1,37 @@
+QA output created by 267
+
+ Switch data journalling mode
+
+OP write_opt: iflag=noatime 4M, chattr_opt: +j
+OP write_opt: iflag=noatime 4M, chattr_opt: -j
+OP write_opt: iflag=noatime 4M, chattr_opt: +jS
+OP write_opt: iflag=noatime 4M, chattr_opt: -j
+OP write_opt: conv=notrunc 4M, chattr_opt: +j
+OP write_opt: conv=notrunc 4M, chattr_opt: -j
+OP write_opt: conv=notrunc 4M, chattr_opt: +jS
+OP write_opt: conv=notrunc 4M, chattr_opt: -j
+OP write_opt: conv=fsync 4M, chattr_opt: +j
+OP write_opt: conv=fsync 4M, chattr_opt: -j
+OP write_opt: conv=fsync 4M, chattr_opt: +jS
+OP write_opt: conv=fsync 4M, chattr_opt: -j
+OP write_opt: oflag=direct 4M, chattr_opt: +j
+OP write_opt: oflag=direct 4M, chattr_opt: -j
+OP write_opt: oflag=direct 4M, chattr_opt: +jS
+OP write_opt: oflag=direct 4M, chattr_opt: -j
+OP write_opt: iflag=noatime ENOSPC, chattr_opt: +j
+OP write_opt: iflag=noatime ENOSPC, chattr_opt: -j
+OP write_opt: iflag=noatime ENOSPC, chattr_opt: +jS
+OP write_opt: iflag=noatime ENOSPC, chattr_opt: -j
+OP write_opt: conv=notrunc ENOSPC, chattr_opt: +j
+OP write_opt: conv=notrunc ENOSPC, chattr_opt: -j
+OP write_opt: conv=notrunc ENOSPC, chattr_opt: +jS
+OP write_opt: conv=notrunc ENOSPC, chattr_opt: -j
+OP write_opt: conv=fsync ENOSPC, chattr_opt: +j
+OP write_opt: conv=fsync ENOSPC, chattr_opt: -j
+OP write_opt: conv=fsync ENOSPC, chattr_opt: +jS
+OP write_opt: conv=fsync ENOSPC, chattr_opt: -j
+OP write_opt: oflag=direct ENOSPC, chattr_opt: +j
+OP write_opt: oflag=direct ENOSPC, chattr_opt: -j
+OP write_opt: oflag=direct ENOSPC, chattr_opt: +jS
+OP write_opt: oflag=direct ENOSPC, chattr_opt: -j
+Check filesystem
diff --git a/group b/group
index dfc6fa7..5efb43c 100644
--- a/group
+++ b/group
@@ -380,3 +380,4 @@ deprecated
 264 auto rw prealloc ioctl enospc
 265 auto quota rw prealloc ioctl enospc
 266 rw auto quick
+267 rw auto quick
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 00/12] Bunch of new stress tests -v4
  2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
                   ` (11 preceding siblings ...)
  2011-11-03 14:25 ` [PATCH 12/12] xfstress: Test data journaling flag switch for a single file Dmitry Monakhov
@ 2011-11-03 14:55 ` Christoph Hellwig
  2011-11-03 15:21   ` Dmitry Monakhov
  12 siblings, 1 reply; 18+ messages in thread
From: Christoph Hellwig @ 2011-11-03 14:55 UTC (permalink / raw)
  To: Dmitry Monakhov; +Cc: linux-fsdevel, xfs, aelder, tytso

On Thu, Nov 03, 2011 at 06:24:49PM +0400, Dmitry Monakhov wrote:
> Changes from v3 ( in request to  Christoph's comments)
>  - hard code fsstress's options for explicit regression tests
>  - add two new regression tests

I already have commited your first three patches to the kernel.org
repository and various other tests that have used the nubers you're
using.  If you want to get it in ASAP please resend, otherwise I will
do it once I get a bit time.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 00/12] Bunch of new stress tests -v4
  2011-11-03 14:55 ` [PATCH 00/12] Bunch of new stress tests -v4 Christoph Hellwig
@ 2011-11-03 15:21   ` Dmitry Monakhov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-03 15:21 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-fsdevel, xfs, aelder, tytso

On Thu, 3 Nov 2011 15:55:49 +0100, Christoph Hellwig <hch@lst.de> wrote:
> On Thu, Nov 03, 2011 at 06:24:49PM +0400, Dmitry Monakhov wrote:
> > Changes from v3 ( in request to  Christoph's comments)
> >  - hard code fsstress's options for explicit regression tests
> >  - add two new regression tests
> 
> I already have commited your first three patches to the kernel.org
> repository and various other tests that have used the nubers you're
> using.  If you want to get it in ASAP please resend, otherwise I will
> do it once I get a bit time.
Oh.. yes kernel.org, i have just forgot to switch my tree to that repo again.
No problem, Will rebase, test, and resubmit.
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 09/12] xfstests: add a new test that runs fsstress under ENOSPC conditions
  2011-11-03 14:24 ` [PATCH 09/12] xfstests: add a new test that runs fsstress under ENOSPC conditions Dmitry Monakhov
@ 2011-11-07 21:22   ` Dave Chinner
  2011-11-08  8:32     ` Dmitry Monakhov
  2011-11-07 21:25   ` Dave Chinner
  1 sibling, 1 reply; 18+ messages in thread
From: Dave Chinner @ 2011-11-07 21:22 UTC (permalink / raw)
  To: Dmitry Monakhov; +Cc: linux-fsdevel, xfs, hch, aelder, tytso

On Thu, Nov 03, 2011 at 06:24:58PM +0400, Dmitry Monakhov wrote:
> During stress testing we want to cover as much code paths as possible
> fsstress is very good for this purpose. But it has expandable nature
> (disk usage almost continually grow). So once it goes in no ENOSPC
> condition it will be where till the end. But by running 'dd' writers
> in parallel we can regularly trigger ENOSPC but only for a limited
> periods of time because each time it opens the same file with O_TRUNC.

.....

So you have a 512MB filesystem, and you do:

> +# Disable all sync operations to get higher load
> +FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0"
> +_workout()
> +{
> +	echo ""
> +	echo "Run fsstress"
> +	echo ""
> +	num_iterations=10
> +	enospc_time=2
> +	out=$SCRATCH_MNT/fsstress.$$
> +	args="-p128 -n999999999 -f setattr=1 $FSSTRESS_AVOID -d $out"
> +	echo "fsstress $args" >> $here/$seq.full
> +	$FSSTRESS_PROG $args > /dev/null 2>&1 &

run a bunch of fsstress processes

> +	pid=$!
> +	echo "Run dd writers in parallel"
> +	for ((i=0; i < num_iterations; i++))
> +	do
> +		# File will be opened with O_TRUNC each time
> +		dd if=/dev/zero of=$SCRATCH_MNT/SPACE_CONSUMER bs=1M count=1 \
> +			> /dev/null 2>&1
> +		sleep $enospc_time
> +	done

Then write the same 1MB file 10 times, 2 seconds apart, giving a
total space usage of the dd processes of 1MB over 20s.

> +	kill $pid
> +	wait $pid
> +}

Then kill the fsstress.

AFAICT, fsstress won't always fill 511MB in 20s - on my test systems
the fill rate is typically around 5s per 100MB, which would result
in the filesystem not being filled with this test and hence not
exercising ENOSPC.  Perhaps this would be better done like test 083,
which uses a fixed number of write-only operations per fsstress
process that is known to end up at ENOSPC, rather than hoping it
gets there in 20s. 

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 09/12] xfstests: add a new test that runs fsstress under ENOSPC conditions
  2011-11-03 14:24 ` [PATCH 09/12] xfstests: add a new test that runs fsstress under ENOSPC conditions Dmitry Monakhov
  2011-11-07 21:22   ` Dave Chinner
@ 2011-11-07 21:25   ` Dave Chinner
  1 sibling, 0 replies; 18+ messages in thread
From: Dave Chinner @ 2011-11-07 21:25 UTC (permalink / raw)
  To: Dmitry Monakhov; +Cc: linux-fsdevel, xfs, hch, aelder, tytso

On Thu, Nov 03, 2011 at 06:24:58PM +0400, Dmitry Monakhov wrote:
> +# real QA test starts here
> +_supported_fs generic
> +_supported_os Linux
> +_require_scratch
> +_need_to_be_root
> +
> +umount $SCRATCH_DEV 2>/dev/null
> +_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seq.full 2>&1
> +_scratch_mount

_require_scratch unmounts the SCRATCH_DEV. no need to do it
explicitly. Same for the next new test in the series, too.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 09/12] xfstests: add a new test that runs fsstress under ENOSPC conditions
  2011-11-07 21:22   ` Dave Chinner
@ 2011-11-08  8:32     ` Dmitry Monakhov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Monakhov @ 2011-11-08  8:32 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-fsdevel, xfs, hch, aelder, tytso

On Tue, 8 Nov 2011 08:22:35 +1100, Dave Chinner <david@fromorbit.com> wrote:
> On Thu, Nov 03, 2011 at 06:24:58PM +0400, Dmitry Monakhov wrote:
> > During stress testing we want to cover as much code paths as possible
> > fsstress is very good for this purpose. But it has expandable nature
> > (disk usage almost continually grow). So once it goes in no ENOSPC
> > condition it will be where till the end. But by running 'dd' writers
> > in parallel we can regularly trigger ENOSPC but only for a limited
> > periods of time because each time it opens the same file with O_TRUNC.
> 
> .....
> 
> So you have a 512MB filesystem, and you do:
> 
> > +# Disable all sync operations to get higher load
> > +FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0"
> > +_workout()
> > +{
> > +	echo ""
> > +	echo "Run fsstress"
> > +	echo ""
> > +	num_iterations=10
> > +	enospc_time=2
> > +	out=$SCRATCH_MNT/fsstress.$$
> > +	args="-p128 -n999999999 -f setattr=1 $FSSTRESS_AVOID -d $out"
> > +	echo "fsstress $args" >> $here/$seq.full
> > +	$FSSTRESS_PROG $args > /dev/null 2>&1 &
> 
> run a bunch of fsstress processes
> 
> > +	pid=$!
> > +	echo "Run dd writers in parallel"
> > +	for ((i=0; i < num_iterations; i++))
> > +	do
> > +		# File will be opened with O_TRUNC each time
> > +		dd if=/dev/zero of=$SCRATCH_MNT/SPACE_CONSUMER bs=1M count=1 \
> > +			> /dev/null 2>&1
> > +		sleep $enospc_time
> > +	done
> 
> Then write the same 1MB file 10 times, 2 seconds apart, giving a
> total space usage of the dd processes of 1MB over 20s.
Hmm.. definitely it should not have count parameter at all, it
supposed to run until ENOSPC (that's why it's called spaceconsumer),
similar to 270'th testcase.
Patch will be in the list in a minute.
> 
> > +	kill $pid
> > +	wait $pid
> > +}
> 
> Then kill the fsstress.
> 
> AFAICT, fsstress won't always fill 511MB in 20s - on my test systems
> the fill rate is typically around 5s per 100MB, which would result
> in the filesystem not being filled with this test and hence not
> exercising ENOSPC.  Perhaps this would be better done like test 083,
> which uses a fixed number of write-only operations per fsstress
> process that is known to end up at ENOSPC, rather than hoping it
> gets there in 20s. 
> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2011-11-08  8:32 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 01/12] xfstests: fsstress dump inode info when possible Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 02/12] xfstests: add different logging option to fsstress Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 03/12] xfstests: fsstress should kill children tasks before exit Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 04/12] xfstests: fsstress add command line style output for show_opts Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 05/12] xfstests: freeze fsstress options for 117'th Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 06/12] xfstests: add fallocate support to fsstress Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 07/12] xfstests: fsstress add FS_IOC_{SET,GET}FLAGS operations v2 Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 08/12] xfstests: add fiemap operation to fsstress Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 09/12] xfstests: add a new test that runs fsstress under ENOSPC conditions Dmitry Monakhov
2011-11-07 21:22   ` Dave Chinner
2011-11-08  8:32     ` Dmitry Monakhov
2011-11-07 21:25   ` Dave Chinner
2011-11-03 14:24 ` [PATCH 10/12] xfstests: add a new quota " Dmitry Monakhov
2011-11-03 14:25 ` [PATCH 11/12] xfstress: add regression testcase for d583fb87a3ff0 Dmitry Monakhov
2011-11-03 14:25 ` [PATCH 12/12] xfstress: Test data journaling flag switch for a single file Dmitry Monakhov
2011-11-03 14:55 ` [PATCH 00/12] Bunch of new stress tests -v4 Christoph Hellwig
2011-11-03 15:21   ` Dmitry Monakhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).