diff mbox series

fsx: add missing -K in usage() and cleanup

Message ID 20230804054003.936263-1-ruansy.fnst@fujitsu.com (mailing list archive)
State New, archived
Headers show
Series fsx: add missing -K in usage() and cleanup | expand

Commit Message

Shiyang Ruan Aug. 4, 2023, 5:40 a.m. UTC
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
---
 ltp/fsx.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

Comments

Darrick J. Wong Aug. 4, 2023, 9:17 p.m. UTC | #1
On Fri, Aug 04, 2023 at 01:40:03PM +0800, Shiyang Ruan wrote:
> Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>

Yes, thank you, this is much more readable.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  ltp/fsx.c | 27 +++++++++++++++++----------
>  1 file changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/ltp/fsx.c b/ltp/fsx.c
> index ffa64cfa0..753c472f4 100644
> --- a/ltp/fsx.c
> +++ b/ltp/fsx.c
> @@ -2393,11 +2393,17 @@ void
>  usage(void)
>  {
>  	fprintf(stdout, "usage: %s",
> -		"fsx [-dknqxBEFJLOWZ][-A|-U] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
> +		"fsx [-dfknqxyzBEFHIJKLORWXZ0]\n\
> +	   [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid]\n\
> +	   [-l flen] [-m start:end] [-o oplen] [-p progressinterval]\n\
> +	   [-r readbdy] [-s style] [-t truncbdy] [-w writebdy]\n\
> +	   [-A|-U] [-D startingop] [-N numops] [-P dirpath] [-S seed]\n\
> +	   [--replay-ops opsfile] [--record-ops[=opsfile]] [--duration seconds]\n\
> +	   ... fname\n\
>  	-b opnum: beginning operation number (default 1)\n\
>  	-c P: 1 in P chance of file close+open at each op (default infinity)\n\
>  	-d: debug output for all operations\n\
> -	-f flush and invalidate cache after I/O\n\
> +	-f: flush and invalidate cache after I/O\n\
>  	-g X: write character X instead of random generated data\n\
>  	-i logdev: do integrity testing, logdev is the dm log writes device\n\
>  	-j logid: prefix debug log messsages with this id\n\
> @@ -2412,15 +2418,15 @@ usage(void)
>  	-s style: 1 gives smaller truncates (default 0)\n\
>  	-t truncbdy: 4096 would make truncates page aligned (default 1)\n\
>  	-w writebdy: 4096 would make writes page aligned (default 1)\n\
> -	-x: preallocate file space before starting, XFS only (default 0)\n\
> -	-y synchronize changes to a file\n"
> +	-x: preallocate file space before starting, XFS only\n\
> +	-y: synchronize changes to a file\n"
>  
>  #ifdef AIO
>  "	-A: Use the AIO system calls, -A excludes -U\n"
>  #endif
>  #ifdef URING
>  "	-U: Use the IO_URING system calls, -U excludes -A\n"
> - #endif
> +#endif
>  "	-D startingop: debug output starting at specified operation\n"
>  #ifdef HAVE_LINUX_FALLOC_H
>  "	-F: Do not use fallocate (preallocation) calls\n"
> @@ -2449,18 +2455,19 @@ usage(void)
>  #ifdef FIEXCHANGE_RANGE
>  "	-0: Do not use exchange range calls\n"
>  #endif
> -"	-L: fsxLite - no file creations & no file size changes\n\
> +"	-K: Do not use keep size\n\
> +	-L: fsxLite - no file creations & no file size changes\n\
>  	-N numops: total # operations to do (default infinity)\n\
>  	-O: use oplen (see -o flag) for every op (default random)\n\
> -	-P: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
> +	-P dirpath: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
>  	-S seed: for random # generator (default 1) 0 gets timestamp\n\
>  	-W: mapped write operations DISabled\n\
>  	-X: Read file and compare to good buffer after every operation.\n\
> -        -R: read() system calls only (mapped reads disabled)\n\
> -        -Z: O_DIRECT (use -R, -W, -r and -w too)\n\
> +	-R: read() system calls only (mapped reads disabled)\n\
> +	-Z: O_DIRECT (use -R, -W, -r and -w too)\n\
>  	--replay-ops opsfile: replay ops from recorded .fsxops file\n\
>  	--record-ops[=opsfile]: dump ops file also on success. optionally specify ops file name\n\
> -	--duration=seconds: ignore any -N setting and run for this many seconds\n\
> +	--duration seconds: ignore any -N setting and run for this many seconds\n\
>  	fname: this filename is REQUIRED (no default)\n");
>  	exit(90);
>  }
> -- 
> 2.41.0
>
Zorro Lang Aug. 5, 2023, 9:50 a.m. UTC | #2
On Fri, Aug 04, 2023 at 02:17:04PM -0700, Darrick J. Wong wrote:
> On Fri, Aug 04, 2023 at 01:40:03PM +0800, Shiyang Ruan wrote:
> > Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
> 
> Yes, thank you, this is much more readable.
> 
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> 
> --D
> 
> > ---
> >  ltp/fsx.c | 27 +++++++++++++++++----------
> >  1 file changed, 17 insertions(+), 10 deletions(-)
> > 
> > diff --git a/ltp/fsx.c b/ltp/fsx.c
> > index ffa64cfa0..753c472f4 100644
> > --- a/ltp/fsx.c
> > +++ b/ltp/fsx.c
> > @@ -2393,11 +2393,17 @@ void
> >  usage(void)
> >  {
> >  	fprintf(stdout, "usage: %s",
> > -		"fsx [-dknqxBEFJLOWZ][-A|-U] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
> > +		"fsx [-dfknqxyzBEFHIJKLORWXZ0]\n\
> > +	   [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid]\n\
> > +	   [-l flen] [-m start:end] [-o oplen] [-p progressinterval]\n\
> > +	   [-r readbdy] [-s style] [-t truncbdy] [-w writebdy]\n\
> > +	   [-A|-U] [-D startingop] [-N numops] [-P dirpath] [-S seed]\n\
> > +	   [--replay-ops opsfile] [--record-ops[=opsfile]] [--duration seconds]\n\

"--duration seconds"

> > +	   ... fname\n\
> >  	-b opnum: beginning operation number (default 1)\n\
> >  	-c P: 1 in P chance of file close+open at each op (default infinity)\n\
> >  	-d: debug output for all operations\n\
> > -	-f flush and invalidate cache after I/O\n\
> > +	-f: flush and invalidate cache after I/O\n\
> >  	-g X: write character X instead of random generated data\n\
> >  	-i logdev: do integrity testing, logdev is the dm log writes device\n\
> >  	-j logid: prefix debug log messsages with this id\n\
> > @@ -2412,15 +2418,15 @@ usage(void)
> >  	-s style: 1 gives smaller truncates (default 0)\n\
> >  	-t truncbdy: 4096 would make truncates page aligned (default 1)\n\
> >  	-w writebdy: 4096 would make writes page aligned (default 1)\n\
> > -	-x: preallocate file space before starting, XFS only (default 0)\n\
> > -	-y synchronize changes to a file\n"
> > +	-x: preallocate file space before starting, XFS only\n\
> > +	-y: synchronize changes to a file\n"
> >  
> >  #ifdef AIO
> >  "	-A: Use the AIO system calls, -A excludes -U\n"
> >  #endif
> >  #ifdef URING
> >  "	-U: Use the IO_URING system calls, -U excludes -A\n"
> > - #endif
> > +#endif
> >  "	-D startingop: debug output starting at specified operation\n"
> >  #ifdef HAVE_LINUX_FALLOC_H
> >  "	-F: Do not use fallocate (preallocation) calls\n"
> > @@ -2449,18 +2455,19 @@ usage(void)
> >  #ifdef FIEXCHANGE_RANGE
> >  "	-0: Do not use exchange range calls\n"
> >  #endif
> > -"	-L: fsxLite - no file creations & no file size changes\n\
> > +"	-K: Do not use keep size\n\
> > +	-L: fsxLite - no file creations & no file size changes\n\
> >  	-N numops: total # operations to do (default infinity)\n\
> >  	-O: use oplen (see -o flag) for every op (default random)\n\
> > -	-P: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
> > +	-P dirpath: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
> >  	-S seed: for random # generator (default 1) 0 gets timestamp\n\
> >  	-W: mapped write operations DISabled\n\
> >  	-X: Read file and compare to good buffer after every operation.\n\
> > -        -R: read() system calls only (mapped reads disabled)\n\
> > -        -Z: O_DIRECT (use -R, -W, -r and -w too)\n\
> > +	-R: read() system calls only (mapped reads disabled)\n\
> > +	-Z: O_DIRECT (use -R, -W, -r and -w too)\n\
> >  	--replay-ops opsfile: replay ops from recorded .fsxops file\n\
> >  	--record-ops[=opsfile]: dump ops file also on success. optionally specify ops file name\n\
> > -	--duration=seconds: ignore any -N setting and run for this many seconds\n\
> > +	--duration seconds: ignore any -N setting and run for this many seconds\n\

I'm wondering does "--duration" need the "=" or not, or either?

Looks like fsstress.c and fsx.c recommend using "--duration=xxx":
fsstress.c:
                case 256:  /* --duration */
                        if (!optarg) {
                                fprintf(stderr, "Specify time with --duration=\n");

fsx.c:
                case 254:  /* --duration */
                        if (!optarg) {
                                fprintf(stderr, "Specify time with --duration=\n");


And each case contains "--duration" tends to use the "=" too:

  $ grep -rsn -- "--duration" tests/
  tests/generic/642:52:test -n "$DURATION" && args+=(--duration="$DURATION")
  tests/generic/521:38:test -n "$SOAK_DURATION" && fsx_args+=(--duration="$SOAK_DURATION")
  tests/generic/476:37:test -n "$SOAK_DURATION" && fsstress_args+=(--duration="$SOAK_DURATION")
  tests/generic/522:32:test -n "$SOAK_DURATION" && fsx_args+=(--duration="$SOAK_DURATION")


As this patch hopes to tidy the fsx options, maybe we can clear that, better to
have a  consistent usage?

Thanks,
Zorro

> >  	fname: this filename is REQUIRED (no default)\n");
> >  	exit(90);
> >  }
> > -- 
> > 2.41.0
> > 
>
Zorro Lang Aug. 5, 2023, 10:01 a.m. UTC | #3
On Sat, Aug 05, 2023 at 05:50:40PM +0800, Zorro Lang wrote:
> On Fri, Aug 04, 2023 at 02:17:04PM -0700, Darrick J. Wong wrote:
> > On Fri, Aug 04, 2023 at 01:40:03PM +0800, Shiyang Ruan wrote:

BTW, as this patch trys to tidy the fsx's options usage mostly, and "add
missing option usage" is part of this job. So I'd like to change the subject
of to  "fsx: tidy options usage and format" (or other description which
can reflect the main job you did in this patch.) Then you can describe more
details in commit log, likes adding missing -K option and so on.

Thanks,
Zorro

> > > Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
> > 
> > Yes, thank you, this is much more readable.
> > 
> > Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> > 
> > --D
> > 
> > > ---
> > >  ltp/fsx.c | 27 +++++++++++++++++----------
> > >  1 file changed, 17 insertions(+), 10 deletions(-)
> > > 
> > > diff --git a/ltp/fsx.c b/ltp/fsx.c
> > > index ffa64cfa0..753c472f4 100644
> > > --- a/ltp/fsx.c
> > > +++ b/ltp/fsx.c
> > > @@ -2393,11 +2393,17 @@ void
> > >  usage(void)
> > >  {
> > >  	fprintf(stdout, "usage: %s",
> > > -		"fsx [-dknqxBEFJLOWZ][-A|-U] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
> > > +		"fsx [-dfknqxyzBEFHIJKLORWXZ0]\n\
> > > +	   [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid]\n\
> > > +	   [-l flen] [-m start:end] [-o oplen] [-p progressinterval]\n\
> > > +	   [-r readbdy] [-s style] [-t truncbdy] [-w writebdy]\n\
> > > +	   [-A|-U] [-D startingop] [-N numops] [-P dirpath] [-S seed]\n\
> > > +	   [--replay-ops opsfile] [--record-ops[=opsfile]] [--duration seconds]\n\
> 
> "--duration seconds"
> 
> > > +	   ... fname\n\
> > >  	-b opnum: beginning operation number (default 1)\n\
> > >  	-c P: 1 in P chance of file close+open at each op (default infinity)\n\
> > >  	-d: debug output for all operations\n\
> > > -	-f flush and invalidate cache after I/O\n\
> > > +	-f: flush and invalidate cache after I/O\n\
> > >  	-g X: write character X instead of random generated data\n\
> > >  	-i logdev: do integrity testing, logdev is the dm log writes device\n\
> > >  	-j logid: prefix debug log messsages with this id\n\
> > > @@ -2412,15 +2418,15 @@ usage(void)
> > >  	-s style: 1 gives smaller truncates (default 0)\n\
> > >  	-t truncbdy: 4096 would make truncates page aligned (default 1)\n\
> > >  	-w writebdy: 4096 would make writes page aligned (default 1)\n\
> > > -	-x: preallocate file space before starting, XFS only (default 0)\n\
> > > -	-y synchronize changes to a file\n"
> > > +	-x: preallocate file space before starting, XFS only\n\
> > > +	-y: synchronize changes to a file\n"
> > >  
> > >  #ifdef AIO
> > >  "	-A: Use the AIO system calls, -A excludes -U\n"
> > >  #endif
> > >  #ifdef URING
> > >  "	-U: Use the IO_URING system calls, -U excludes -A\n"
> > > - #endif
> > > +#endif
> > >  "	-D startingop: debug output starting at specified operation\n"
> > >  #ifdef HAVE_LINUX_FALLOC_H
> > >  "	-F: Do not use fallocate (preallocation) calls\n"
> > > @@ -2449,18 +2455,19 @@ usage(void)
> > >  #ifdef FIEXCHANGE_RANGE
> > >  "	-0: Do not use exchange range calls\n"
> > >  #endif
> > > -"	-L: fsxLite - no file creations & no file size changes\n\
> > > +"	-K: Do not use keep size\n\
> > > +	-L: fsxLite - no file creations & no file size changes\n\
> > >  	-N numops: total # operations to do (default infinity)\n\
> > >  	-O: use oplen (see -o flag) for every op (default random)\n\
> > > -	-P: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
> > > +	-P dirpath: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
> > >  	-S seed: for random # generator (default 1) 0 gets timestamp\n\
> > >  	-W: mapped write operations DISabled\n\
> > >  	-X: Read file and compare to good buffer after every operation.\n\
> > > -        -R: read() system calls only (mapped reads disabled)\n\
> > > -        -Z: O_DIRECT (use -R, -W, -r and -w too)\n\
> > > +	-R: read() system calls only (mapped reads disabled)\n\
> > > +	-Z: O_DIRECT (use -R, -W, -r and -w too)\n\
> > >  	--replay-ops opsfile: replay ops from recorded .fsxops file\n\
> > >  	--record-ops[=opsfile]: dump ops file also on success. optionally specify ops file name\n\
> > > -	--duration=seconds: ignore any -N setting and run for this many seconds\n\
> > > +	--duration seconds: ignore any -N setting and run for this many seconds\n\
> 
> I'm wondering does "--duration" need the "=" or not, or either?
> 
> Looks like fsstress.c and fsx.c recommend using "--duration=xxx":
> fsstress.c:
>                 case 256:  /* --duration */
>                         if (!optarg) {
>                                 fprintf(stderr, "Specify time with --duration=\n");
> 
> fsx.c:
>                 case 254:  /* --duration */
>                         if (!optarg) {
>                                 fprintf(stderr, "Specify time with --duration=\n");
> 
> 
> And each case contains "--duration" tends to use the "=" too:
> 
>   $ grep -rsn -- "--duration" tests/
>   tests/generic/642:52:test -n "$DURATION" && args+=(--duration="$DURATION")
>   tests/generic/521:38:test -n "$SOAK_DURATION" && fsx_args+=(--duration="$SOAK_DURATION")
>   tests/generic/476:37:test -n "$SOAK_DURATION" && fsstress_args+=(--duration="$SOAK_DURATION")
>   tests/generic/522:32:test -n "$SOAK_DURATION" && fsx_args+=(--duration="$SOAK_DURATION")
> 
> 
> As this patch hopes to tidy the fsx options, maybe we can clear that, better to
> have a  consistent usage?
> 
> Thanks,
> Zorro
> 
> > >  	fname: this filename is REQUIRED (no default)\n");
> > >  	exit(90);
> > >  }
> > > -- 
> > > 2.41.0
> > > 
> >
Darrick J. Wong Aug. 5, 2023, 4:20 p.m. UTC | #4
On Sat, Aug 05, 2023 at 05:50:40PM +0800, Zorro Lang wrote:
> On Fri, Aug 04, 2023 at 02:17:04PM -0700, Darrick J. Wong wrote:
> > On Fri, Aug 04, 2023 at 01:40:03PM +0800, Shiyang Ruan wrote:
> > > Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
> > 
> > Yes, thank you, this is much more readable.
> > 
> > Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> > 
> > --D
> > 
> > > ---
> > >  ltp/fsx.c | 27 +++++++++++++++++----------
> > >  1 file changed, 17 insertions(+), 10 deletions(-)
> > > 
> > > diff --git a/ltp/fsx.c b/ltp/fsx.c
> > > index ffa64cfa0..753c472f4 100644
> > > --- a/ltp/fsx.c
> > > +++ b/ltp/fsx.c
> > > @@ -2393,11 +2393,17 @@ void
> > >  usage(void)
> > >  {
> > >  	fprintf(stdout, "usage: %s",
> > > -		"fsx [-dknqxBEFJLOWZ][-A|-U] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
> > > +		"fsx [-dfknqxyzBEFHIJKLORWXZ0]\n\
> > > +	   [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid]\n\
> > > +	   [-l flen] [-m start:end] [-o oplen] [-p progressinterval]\n\
> > > +	   [-r readbdy] [-s style] [-t truncbdy] [-w writebdy]\n\
> > > +	   [-A|-U] [-D startingop] [-N numops] [-P dirpath] [-S seed]\n\
> > > +	   [--replay-ops opsfile] [--record-ops[=opsfile]] [--duration seconds]\n\
> 
> "--duration seconds"
> 
> > > +	   ... fname\n\
> > >  	-b opnum: beginning operation number (default 1)\n\
> > >  	-c P: 1 in P chance of file close+open at each op (default infinity)\n\
> > >  	-d: debug output for all operations\n\
> > > -	-f flush and invalidate cache after I/O\n\
> > > +	-f: flush and invalidate cache after I/O\n\
> > >  	-g X: write character X instead of random generated data\n\
> > >  	-i logdev: do integrity testing, logdev is the dm log writes device\n\
> > >  	-j logid: prefix debug log messsages with this id\n\
> > > @@ -2412,15 +2418,15 @@ usage(void)
> > >  	-s style: 1 gives smaller truncates (default 0)\n\
> > >  	-t truncbdy: 4096 would make truncates page aligned (default 1)\n\
> > >  	-w writebdy: 4096 would make writes page aligned (default 1)\n\
> > > -	-x: preallocate file space before starting, XFS only (default 0)\n\
> > > -	-y synchronize changes to a file\n"
> > > +	-x: preallocate file space before starting, XFS only\n\
> > > +	-y: synchronize changes to a file\n"
> > >  
> > >  #ifdef AIO
> > >  "	-A: Use the AIO system calls, -A excludes -U\n"
> > >  #endif
> > >  #ifdef URING
> > >  "	-U: Use the IO_URING system calls, -U excludes -A\n"
> > > - #endif
> > > +#endif
> > >  "	-D startingop: debug output starting at specified operation\n"
> > >  #ifdef HAVE_LINUX_FALLOC_H
> > >  "	-F: Do not use fallocate (preallocation) calls\n"
> > > @@ -2449,18 +2455,19 @@ usage(void)
> > >  #ifdef FIEXCHANGE_RANGE
> > >  "	-0: Do not use exchange range calls\n"
> > >  #endif
> > > -"	-L: fsxLite - no file creations & no file size changes\n\
> > > +"	-K: Do not use keep size\n\
> > > +	-L: fsxLite - no file creations & no file size changes\n\
> > >  	-N numops: total # operations to do (default infinity)\n\
> > >  	-O: use oplen (see -o flag) for every op (default random)\n\
> > > -	-P: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
> > > +	-P dirpath: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
> > >  	-S seed: for random # generator (default 1) 0 gets timestamp\n\
> > >  	-W: mapped write operations DISabled\n\
> > >  	-X: Read file and compare to good buffer after every operation.\n\
> > > -        -R: read() system calls only (mapped reads disabled)\n\
> > > -        -Z: O_DIRECT (use -R, -W, -r and -w too)\n\
> > > +	-R: read() system calls only (mapped reads disabled)\n\
> > > +	-Z: O_DIRECT (use -R, -W, -r and -w too)\n\
> > >  	--replay-ops opsfile: replay ops from recorded .fsxops file\n\
> > >  	--record-ops[=opsfile]: dump ops file also on success. optionally specify ops file name\n\
> > > -	--duration=seconds: ignore any -N setting and run for this many seconds\n\
> > > +	--duration seconds: ignore any -N setting and run for this many seconds\n\
> 
> I'm wondering does "--duration" need the "=" or not, or either?

glibc getopt_long doesn't care either way, but I suppose we ought to be
consistent about the equals.  Perhaps leave it the way it was?

--D

> Looks like fsstress.c and fsx.c recommend using "--duration=xxx":
> fsstress.c:
>                 case 256:  /* --duration */
>                         if (!optarg) {
>                                 fprintf(stderr, "Specify time with --duration=\n");
> 
> fsx.c:
>                 case 254:  /* --duration */
>                         if (!optarg) {
>                                 fprintf(stderr, "Specify time with --duration=\n");
> 
> 
> And each case contains "--duration" tends to use the "=" too:
> 
>   $ grep -rsn -- "--duration" tests/
>   tests/generic/642:52:test -n "$DURATION" && args+=(--duration="$DURATION")
>   tests/generic/521:38:test -n "$SOAK_DURATION" && fsx_args+=(--duration="$SOAK_DURATION")
>   tests/generic/476:37:test -n "$SOAK_DURATION" && fsstress_args+=(--duration="$SOAK_DURATION")
>   tests/generic/522:32:test -n "$SOAK_DURATION" && fsx_args+=(--duration="$SOAK_DURATION")
> 
> 
> As this patch hopes to tidy the fsx options, maybe we can clear that, better to
> have a  consistent usage?
> 
> Thanks,
> Zorro
> 
> > >  	fname: this filename is REQUIRED (no default)\n");
> > >  	exit(90);
> > >  }
> > > -- 
> > > 2.41.0
> > > 
> > 
>
Zorro Lang Aug. 6, 2023, 4:35 a.m. UTC | #5
On Sat, Aug 05, 2023 at 09:20:29AM -0700, Darrick J. Wong wrote:
> On Sat, Aug 05, 2023 at 05:50:40PM +0800, Zorro Lang wrote:
> > On Fri, Aug 04, 2023 at 02:17:04PM -0700, Darrick J. Wong wrote:
> > > On Fri, Aug 04, 2023 at 01:40:03PM +0800, Shiyang Ruan wrote:
> > > > Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
> > > 
> > > Yes, thank you, this is much more readable.
> > > 
> > > Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> > > 
> > > --D
> > > 
> > > > ---
> > > >  ltp/fsx.c | 27 +++++++++++++++++----------
> > > >  1 file changed, 17 insertions(+), 10 deletions(-)
> > > > 
> > > > diff --git a/ltp/fsx.c b/ltp/fsx.c
> > > > index ffa64cfa0..753c472f4 100644
> > > > --- a/ltp/fsx.c
> > > > +++ b/ltp/fsx.c
> > > > @@ -2393,11 +2393,17 @@ void
> > > >  usage(void)
> > > >  {
> > > >  	fprintf(stdout, "usage: %s",
> > > > -		"fsx [-dknqxBEFJLOWZ][-A|-U] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
> > > > +		"fsx [-dfknqxyzBEFHIJKLORWXZ0]\n\
> > > > +	   [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid]\n\
> > > > +	   [-l flen] [-m start:end] [-o oplen] [-p progressinterval]\n\
> > > > +	   [-r readbdy] [-s style] [-t truncbdy] [-w writebdy]\n\
> > > > +	   [-A|-U] [-D startingop] [-N numops] [-P dirpath] [-S seed]\n\
> > > > +	   [--replay-ops opsfile] [--record-ops[=opsfile]] [--duration seconds]\n\
> > 
> > "--duration seconds"
> > 
> > > > +	   ... fname\n\
> > > >  	-b opnum: beginning operation number (default 1)\n\
> > > >  	-c P: 1 in P chance of file close+open at each op (default infinity)\n\
> > > >  	-d: debug output for all operations\n\
> > > > -	-f flush and invalidate cache after I/O\n\
> > > > +	-f: flush and invalidate cache after I/O\n\
> > > >  	-g X: write character X instead of random generated data\n\
> > > >  	-i logdev: do integrity testing, logdev is the dm log writes device\n\
> > > >  	-j logid: prefix debug log messsages with this id\n\
> > > > @@ -2412,15 +2418,15 @@ usage(void)
> > > >  	-s style: 1 gives smaller truncates (default 0)\n\
> > > >  	-t truncbdy: 4096 would make truncates page aligned (default 1)\n\
> > > >  	-w writebdy: 4096 would make writes page aligned (default 1)\n\
> > > > -	-x: preallocate file space before starting, XFS only (default 0)\n\
> > > > -	-y synchronize changes to a file\n"
> > > > +	-x: preallocate file space before starting, XFS only\n\
> > > > +	-y: synchronize changes to a file\n"
> > > >  
> > > >  #ifdef AIO
> > > >  "	-A: Use the AIO system calls, -A excludes -U\n"
> > > >  #endif
> > > >  #ifdef URING
> > > >  "	-U: Use the IO_URING system calls, -U excludes -A\n"
> > > > - #endif
> > > > +#endif
> > > >  "	-D startingop: debug output starting at specified operation\n"
> > > >  #ifdef HAVE_LINUX_FALLOC_H
> > > >  "	-F: Do not use fallocate (preallocation) calls\n"
> > > > @@ -2449,18 +2455,19 @@ usage(void)
> > > >  #ifdef FIEXCHANGE_RANGE
> > > >  "	-0: Do not use exchange range calls\n"
> > > >  #endif
> > > > -"	-L: fsxLite - no file creations & no file size changes\n\
> > > > +"	-K: Do not use keep size\n\
> > > > +	-L: fsxLite - no file creations & no file size changes\n\
> > > >  	-N numops: total # operations to do (default infinity)\n\
> > > >  	-O: use oplen (see -o flag) for every op (default random)\n\
> > > > -	-P: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
> > > > +	-P dirpath: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
> > > >  	-S seed: for random # generator (default 1) 0 gets timestamp\n\
> > > >  	-W: mapped write operations DISabled\n\
> > > >  	-X: Read file and compare to good buffer after every operation.\n\
> > > > -        -R: read() system calls only (mapped reads disabled)\n\
> > > > -        -Z: O_DIRECT (use -R, -W, -r and -w too)\n\
> > > > +	-R: read() system calls only (mapped reads disabled)\n\
> > > > +	-Z: O_DIRECT (use -R, -W, -r and -w too)\n\
> > > >  	--replay-ops opsfile: replay ops from recorded .fsxops file\n\
> > > >  	--record-ops[=opsfile]: dump ops file also on success. optionally specify ops file name\n\
> > > > -	--duration=seconds: ignore any -N setting and run for this many seconds\n\
> > > > +	--duration seconds: ignore any -N setting and run for this many seconds\n\
> > 
> > I'm wondering does "--duration" need the "=" or not, or either?
> 
> glibc getopt_long doesn't care either way, but I suppose we ought to be
> consistent about the equals.  Perhaps leave it the way it was?

Yeah, likes `grubby --set-default /boot/xxx` also can be "--set-default=/boot/xxx".
But looks like mostly one "hyphen" option uses space (between option name and
value), two "hyphens" option uses "=". (correct me if it's wrong)

So I think we'd better to keep consistent in fstests, especially for fsstress
and fsx. As this patch is trying to tidy to usage, we can change to
"--replay-ops=opsfile", "--duration=seconds".

Thanks,
Zorro

> 
> --D
> 
> > Looks like fsstress.c and fsx.c recommend using "--duration=xxx":
> > fsstress.c:
> >                 case 256:  /* --duration */
> >                         if (!optarg) {
> >                                 fprintf(stderr, "Specify time with --duration=\n");
> > 
> > fsx.c:
> >                 case 254:  /* --duration */
> >                         if (!optarg) {
> >                                 fprintf(stderr, "Specify time with --duration=\n");
> > 
> > 
> > And each case contains "--duration" tends to use the "=" too:
> > 
> >   $ grep -rsn -- "--duration" tests/
> >   tests/generic/642:52:test -n "$DURATION" && args+=(--duration="$DURATION")
> >   tests/generic/521:38:test -n "$SOAK_DURATION" && fsx_args+=(--duration="$SOAK_DURATION")
> >   tests/generic/476:37:test -n "$SOAK_DURATION" && fsstress_args+=(--duration="$SOAK_DURATION")
> >   tests/generic/522:32:test -n "$SOAK_DURATION" && fsx_args+=(--duration="$SOAK_DURATION")
> > 
> > 
> > As this patch hopes to tidy the fsx options, maybe we can clear that, better to
> > have a  consistent usage?
> > 
> > Thanks,
> > Zorro
> > 
> > > >  	fname: this filename is REQUIRED (no default)\n");
> > > >  	exit(90);
> > > >  }
> > > > -- 
> > > > 2.41.0
> > > > 
> > > 
> > 
>
diff mbox series

Patch

diff --git a/ltp/fsx.c b/ltp/fsx.c
index ffa64cfa0..753c472f4 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -2393,11 +2393,17 @@  void
 usage(void)
 {
 	fprintf(stdout, "usage: %s",
-		"fsx [-dknqxBEFJLOWZ][-A|-U] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
+		"fsx [-dfknqxyzBEFHIJKLORWXZ0]\n\
+	   [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid]\n\
+	   [-l flen] [-m start:end] [-o oplen] [-p progressinterval]\n\
+	   [-r readbdy] [-s style] [-t truncbdy] [-w writebdy]\n\
+	   [-A|-U] [-D startingop] [-N numops] [-P dirpath] [-S seed]\n\
+	   [--replay-ops opsfile] [--record-ops[=opsfile]] [--duration seconds]\n\
+	   ... fname\n\
 	-b opnum: beginning operation number (default 1)\n\
 	-c P: 1 in P chance of file close+open at each op (default infinity)\n\
 	-d: debug output for all operations\n\
-	-f flush and invalidate cache after I/O\n\
+	-f: flush and invalidate cache after I/O\n\
 	-g X: write character X instead of random generated data\n\
 	-i logdev: do integrity testing, logdev is the dm log writes device\n\
 	-j logid: prefix debug log messsages with this id\n\
@@ -2412,15 +2418,15 @@  usage(void)
 	-s style: 1 gives smaller truncates (default 0)\n\
 	-t truncbdy: 4096 would make truncates page aligned (default 1)\n\
 	-w writebdy: 4096 would make writes page aligned (default 1)\n\
-	-x: preallocate file space before starting, XFS only (default 0)\n\
-	-y synchronize changes to a file\n"
+	-x: preallocate file space before starting, XFS only\n\
+	-y: synchronize changes to a file\n"
 
 #ifdef AIO
 "	-A: Use the AIO system calls, -A excludes -U\n"
 #endif
 #ifdef URING
 "	-U: Use the IO_URING system calls, -U excludes -A\n"
- #endif
+#endif
 "	-D startingop: debug output starting at specified operation\n"
 #ifdef HAVE_LINUX_FALLOC_H
 "	-F: Do not use fallocate (preallocation) calls\n"
@@ -2449,18 +2455,19 @@  usage(void)
 #ifdef FIEXCHANGE_RANGE
 "	-0: Do not use exchange range calls\n"
 #endif
-"	-L: fsxLite - no file creations & no file size changes\n\
+"	-K: Do not use keep size\n\
+	-L: fsxLite - no file creations & no file size changes\n\
 	-N numops: total # operations to do (default infinity)\n\
 	-O: use oplen (see -o flag) for every op (default random)\n\
-	-P: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
+	-P dirpath: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
 	-S seed: for random # generator (default 1) 0 gets timestamp\n\
 	-W: mapped write operations DISabled\n\
 	-X: Read file and compare to good buffer after every operation.\n\
-        -R: read() system calls only (mapped reads disabled)\n\
-        -Z: O_DIRECT (use -R, -W, -r and -w too)\n\
+	-R: read() system calls only (mapped reads disabled)\n\
+	-Z: O_DIRECT (use -R, -W, -r and -w too)\n\
 	--replay-ops opsfile: replay ops from recorded .fsxops file\n\
 	--record-ops[=opsfile]: dump ops file also on success. optionally specify ops file name\n\
-	--duration=seconds: ignore any -N setting and run for this many seconds\n\
+	--duration seconds: ignore any -N setting and run for this many seconds\n\
 	fname: this filename is REQUIRED (no default)\n");
 	exit(90);
 }