diff mbox

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

Message ID 1432774726-26824-1-git-send-email-tytso@mit.edu (mailing list archive)
State New, archived
Headers show

Commit Message

Theodore Ts'o May 28, 2015, 12:58 a.m. UTC
This feature is in the ltp version of fsstress; port it into
xfstests.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 ltp/fsstress.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

Comments

Eric Sandeen May 28, 2015, 1:32 a.m. UTC | #1
> On May 27, 2015, at 7:58 PM, Theodore Ts'o <tytso@mit.edu> wrote:
> 
> This feature is in the ltp version of fsstress; port it into
> xfstests.
> 
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
> ---
> ltp/fsstress.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/ltp/fsstress.c b/ltp/fsstress.c
> index aa3e0c3..ad0c65f 100644
> --- a/ltp/fsstress.c
> +++ b/ltp/fsstress.c
> @@ -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("..");

This seems unrelated, no?

Eric


> }
> 
> /*
> @@ -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");
> -- 
> 2.3.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o May 28, 2015, 6:25 p.m. UTC | #2
On Wed, May 27, 2015 at 08:32:23PM -0500, Eric Sandeen wrote:
> 
> > +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
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Sandeen May 28, 2015, 6:49 p.m. UTC | #3
On 5/28/15 1:25 PM, Theodore Ts'o wrote:
> On Wed, May 27, 2015 at 08:32:23PM -0500, Eric Sandeen wrote:
>>
>>> +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/...

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

-Eric

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index aa3e0c3..ad0c65f 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -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");