Skip to contentSkip to conversation

fsstress: add the [-l loops] option

PATCH In review Theodore Ts'o 2 participants 5 messages May 28, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 fsstress: add the [-l loops] option

This feature is in the ltp version of fsstress; port it into xfstests.

---
 ltp/fsstress.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
ltp/fsstress.c +13 -4
index aa3e0c3..ad0c65f 100644
@@ -330,7 +330,8 @@ int main(int argc, char **argv)
 	int             nousage = 0;
 	xfs_error_injection_t	        err_inj;
 	struct sigaction action;
-	const char	*allopts = "d:e:f:i:m:M:n:o:p:rs:S:vVwx:X:zH";
+	int		loops = 1;
+	const char	*allopts = "d:e:f:i:l:m:M:n:o:p:rs:S:vVwx:X:zH";
 
 	errrange = errtag = 0;
 	umask(0);
@@ -372,6 +373,9 @@ int main(int argc, char **argv)
 				exit(1);
 			}
 			break;
+		case 'l':
+			loops = atoi(optarg);
+			break;
 		case 'n':
 			operations = atoi(optarg);
 			break;
@@ -538,7 +542,8 @@ int main(int argc, char **argv)
 				}
 			}
 			procid = i;
-			doproc();
+			for (i = 0; !loops || (i < loops); i++)
+				doproc();
 			return 0;
 		}
 	}
@@ -896,10 +901,12 @@ doproc(void)
 			rval = stat64(".", &statbuf);
 			if (rval == EIO)  {
 				fprintf(stderr, "Detected EIO\n");
-				return;
+				goto errout;
 			}
 		}
 	}
+errout:
+	chdir("..");
 }
 
 /*
@@ -1572,7 +1579,7 @@ void
 usage(void)
 {
 	printf("Usage: %s -H   or\n", myprog);
-	printf("       %s [-d dir][-e errtg][-f op_name=freq][-n nops]\n",
+	printf("       %s [-d dir][-e errtg][-f op_name=freq][-l loops][-n nops]\n",
 		myprog);
 	printf("          [-p nproc][-r len][-s seed][-v][-w][-x cmd][-z][-S][-X ncmd]\n");
 	printf("where\n");
@@ -1582,6 +1589,8 @@ usage(void)
 	printf("                    the valid operation names are:\n");
 	show_ops(-1, "                        ");
 	printf("   -i filenum       get verbose output for this nth file object\n");
+	printf("   -l loops         specifies the no. of times the testrun should loop.\n");
+	printf("                     *use 0 for infinite (default 1)\n");
 	printf("   -m modulo        uid/gid modulo for chown/chgrp (default 32)\n");
 	printf("   -n nops          specifies the no. of operations per process (default 1)\n");
 	printf("   -o logfile       specifies logfile name\n");
Signature · 1 line
2.3.0
#1 lore raw

PATCH 2/2 fsstress: add the -c option

This option causes fsstress to delete the test directory between each run. This is the opposite from the ltp version of fsstress, which deletes the test directory by default, and the -c option caused ltp's fsstress _not_ to delete the test directory.

It can be useful to be able to have the same test behavior as ltp version, and although reversing the sense of the option is unfortunate, it also reserves the -c option, which makes it a bit easier if we want to eventually have one version which is a superset of the xfstest and ltp version of fsstress.

---
 ltp/fsstress.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
ltp/fsstress.c +12 -2
index ad0c65f..1e6c913 100644
@@ -258,6 +258,7 @@ int		procid;
 int		rtpct;
 unsigned long	seed = 0;
 ino_t		top_ino;
+int		cleanup = 0;
 int		verbose = 0;
 int		verifiable_log = 0;
 sig_atomic_t	should_stop = 0;
@@ -331,7 +332,7 @@ int main(int argc, char **argv)
 	xfs_error_injection_t	        err_inj;
 	struct sigaction action;
 	int		loops = 1;
-	const char	*allopts = "d:e:f:i:l:m:M:n:o:p:rs:S:vVwx:X:zH";
+	const char	*allopts = "cd:e:f:i:l:m:M:n:o:p:rs:S:vVwx:X:zH";
 
 	errrange = errtag = 0;
 	umask(0);
@@ -340,6 +341,9 @@ int main(int argc, char **argv)
 	myprog = argv[0];
 	while ((c = getopt(argc, argv, allopts)) != -1) {
 		switch (c) {
+		case 'c':
+			cleanup = 1;
+			break;
 		case 'd':
 			dirname = optarg;
 			break;
@@ -862,6 +866,7 @@ doproc(void)
 {
 	struct stat64	statbuf;
 	char		buf[10];
+	char		cmd[64];
 	int		opno;
 	int		rval;
 	opdesc_t	*p;
@@ -907,6 +912,10 @@ doproc(void)
 	}
 errout:
 	chdir("..");
+	if (cleanup) {
+		sprintf(cmd, "rm -rf %s", buf);
+		system(cmd);
+	}
 }
 
 /*
@@ -1579,10 +1588,11 @@ void
 usage(void)
 {
 	printf("Usage: %s -H   or\n", myprog);
-	printf("       %s [-d dir][-e errtg][-f op_name=freq][-l loops][-n nops]\n",
+	printf("       %s [-c][-d dir][-e errtg][-f op_name=freq][-l loops][-n nops]\n",
 		myprog);
 	printf("          [-p nproc][-r len][-s seed][-v][-w][-x cmd][-z][-S][-X ncmd]\n");
 	printf("where\n");
+	printf("   -c               clean up the test directory after each run\n");
 	printf("   -d dir           specifies the base directory for operations\n");
 	printf("   -e errtg         specifies error injection stuff\n");
 	printf("   -f op_name=freq  changes the frequency of option name to freq\n");
Signature · 1 line
2.3.0
#2 lore raw
In reply to Theodore Ts'o
Quoted 47 lines · Theodore Ts'o

This feature is in the ltp version of fsstress; port it into xfstests.

---
ltp/fsstress.c | 17 +++++++++++++----

1 file changed, 13 insertions(+), 4 deletions(-)
ltp/fsstress.c +7 -2
index aa3e0c3..ad0c65f 100644
@@ -330,7 +330,8 @@ int main(int argc, char **argv)
   int             nousage = 0;
   xfs_error_injection_t            err_inj;
   struct sigaction action;
-    const char    *allopts = "d:e:f:i:m:M:n:o:p:rs:S:vVwx:X:zH";
+    int        loops = 1;
+    const char    *allopts = "d:e:f:i:l:m:M:n:o:p:rs:S:vVwx:X:zH";
 
   errrange = errtag = 0;
   umask(0);
@@ -372,6 +373,9 @@ int main(int argc, char **argv)
               exit(1);
           }
           break;
+        case 'l':
+            loops = atoi(optarg);
+            break;
       case 'n':
           operations = atoi(optarg);
           break;
@@ -538,7 +542,8 @@ int main(int argc, char **argv)
               }
           }
           procid = i;
-            doproc();
+            for (i = 0; !loops || (i < loops); i++)
+                doproc();
           return 0;
       }
   }

ltp/fsstress.c doproc(void) · line 909

Quoted 10 lines
ltp/fsstress.c +3 -1
@@ -896,10 +901,12 @@ doproc(void)
           rval = stat64(".", &statbuf);
           if (rval == EIO)  {
               fprintf(stderr, "Detected EIO\n");
-                return;
+                goto errout;
           }
       }
   }
+errout:
+    chdir("..");

This seems unrelated, no?

Eric

Quoted 29 lines
ltp/fsstress.c +3 -1
 }
 
 /*
@@ -1572,7 +1579,7 @@ void
 usage(void)
 {
   printf("Usage: %s -H   or\n", myprog);
-    printf("       %s [-d dir][-e errtg][-f op_name=freq][-n nops]\n",
+    printf("       %s [-d dir][-e errtg][-f op_name=freq][-l loops][-n nops]\n",
       myprog);
   printf("          [-p nproc][-r len][-s seed][-v][-w][-x cmd][-z][-S][-X ncmd]\n");
   printf("where\n");
@@ -1582,6 +1589,8 @@ usage(void)
   printf("                    the valid operation names are:\n");
   show_ops(-1, "                        ");
   printf("   -i filenum       get verbose output for this nth file object\n");
+    printf("   -l loops         specifies the no. of times the testrun should loop.\n");
+    printf("                     *use 0 for infinite (default 1)\n");
   printf("   -m modulo        uid/gid modulo for chown/chgrp (default 32)\n");
   printf("   -n nops          specifies the no. of operations per process (default 1)\n");
   printf("   -o logfile       specifies logfile name\n");
Signature · 6 lines
2.3.0

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
Quoted 5 lines · Eric Sandeen

ltp/fsstress.c doproc(void) · line 909

Quoted 3 lines
ltp/fsstress.c +2 -0
+errout:
+    chdir("..");

This seems unrelated, no?

This is needed to so that we leave doproc with the same CWD that we entered with. At the beginning of the doproc, we do the eqvuialent of

mkdir -p pN
cd pN

(where N is 0, 1, 2, 3, ..)

previously doproc was only executed once, so it didn't matter what the CWD was when we were doing with doproc(). But since with this patch we are now calling doproc in the loop, the chdir("..") is required or each successive loop will result in a new p0 directory being created, and then at the end of the run, the files will be in

.../p0/p0/p0/p0/p0/p0/p0/p0/p0/...

- Ted

#4 lore raw
Quoted 15 lines · Theodore Ts'o
Quoted 5 lines · Eric Sandeen

ltp/fsstress.c doproc(void) · line 909

Quoted 3 lines
ltp/fsstress.c +2 -0
+errout:
+    chdir("..");

This seems unrelated, no?

This is needed to so that we leave doproc with the same CWD that we entered with. At the beginning of the doproc, we do the eqvuialent of

mkdir -p pN
cd pN

(where N is 0, 1, 2, 3, ..)

Quoted 7 lines

previously doproc was only executed once, so it didn't matter what the CWD was when we were doing with doproc(). But since with this patch we are now calling doproc in the loop, the chdir("..") is required or each successive loop will result in a new p0 directory being created, and then at the end of the run, the files will be in

.../p0/p0/p0/p0/p0/p0/p0/p0/p0/...

Oh, right. I'm sorry, inferred too much from the patch, w/o reading the context around the context.

-Eric