Message ID | e071c0bf9acdd826f9aa96a7c2617df8aa262f8e.1741170031.git.ritesh.list@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | xfsprogs: Add support for preadv2() and RWF_DONTCACHE | expand |
On Wed, Mar 05, 2025 at 03:57:48PM +0530, Ritesh Harjani (IBM) wrote: > Add per-io RWF_DONTCACHE support flag to preadv2(). > This enables xfs_io to perform uncached buffered-io reads. > > e.g. xfs_io -c "pread -U -V 1 0 16K" /mnt/f1 > > Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> > --- > io/pread.c | 17 +++++++++++++++-- > man/man8/xfs_io.8 | 8 +++++++- > 2 files changed, 22 insertions(+), 3 deletions(-) > > diff --git a/io/pread.c b/io/pread.c > index b314fbc7..79e6570e 100644 > --- a/io/pread.c > +++ b/io/pread.c > @@ -38,6 +38,9 @@ pread_help(void) > " -Z N -- zeed the random number generator (used when reading randomly)\n" > " (heh, zorry, the -s/-S arguments were already in use in pwrite)\n" > " -V N -- use vectored IO with N iovecs of blocksize each (preadv)\n" > +#ifdef HAVE_PREADV2 > +" -U -- Perform the preadv2() with Uncached/RWF_DONTCACHE\n" Same comment as the last patch, but otherwise this looks good; Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > +#endif > "\n" > " When in \"random\" mode, the number of read operations will equal the\n" > " number required to do a complete forward/backward scan of the range.\n" > @@ -388,7 +391,7 @@ pread_f( > init_cvtnum(&fsblocksize, &fssectsize); > bsize = fsblocksize; > > - while ((c = getopt(argc, argv, "b:BCFRquvV:Z:")) != EOF) { > + while ((c = getopt(argc, argv, "b:BCFRquUvV:Z:")) != EOF) { > switch (c) { > case 'b': > tmp = cvtnum(fsblocksize, fssectsize, optarg); > @@ -417,6 +420,11 @@ pread_f( > case 'u': > uflag = 1; > break; > +#ifdef HAVE_PREADV2 > + case 'U': > + preadv2_flags |= RWF_DONTCACHE; > + break; > +#endif > case 'v': > vflag = 1; > break; > @@ -446,6 +454,11 @@ pread_f( > exitcode = 1; > return command_usage(&pread_cmd); > } > + if (preadv2_flags != 0 && vectors == 0) { > + printf(_("preadv2 flags require vectored I/O (-V)\n")); > + exitcode = 1; > + return command_usage(&pread_cmd); > + } > > offset = cvtnum(fsblocksize, fssectsize, argv[optind]); > if (offset < 0 && (direction & (IO_RANDOM|IO_BACKWARD))) { > @@ -514,7 +527,7 @@ pread_init(void) > pread_cmd.argmin = 2; > pread_cmd.argmax = -1; > pread_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; > - pread_cmd.args = _("[-b bs] [-qv] [-i N] [-FBR [-Z N]] off len"); > + pread_cmd.args = _("[-b bs] [-qUv] [-i N] [-FBR [-Z N]] off len"); > pread_cmd.oneline = _("reads a number of bytes at a specified offset"); > pread_cmd.help = pread_help; > > diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8 > index 47af5232..df508054 100644 > --- a/man/man8/xfs_io.8 > +++ b/man/man8/xfs_io.8 > @@ -200,7 +200,7 @@ option will set the file permissions to read-write (0644). This allows xfs_io to > set up mismatches between the file permissions and the open file descriptor > read/write mode to exercise permission checks inside various syscalls. > .TP > -.BI "pread [ \-b " bsize " ] [ \-qv ] [ \-FBR [ \-Z " seed " ] ] [ \-V " vectors " ] " "offset length" > +.BI "pread [ \-b " bsize " ] [ \-qUv ] [ \-FBR [ \-Z " seed " ] ] [ \-V " vectors " ] " "offset length" > Reads a range of bytes in a specified blocksize from the given > .IR offset . > .RS 1.0i > @@ -214,6 +214,12 @@ requests will be split. The default blocksize is 4096 bytes. > .B \-q > quiet mode, do not write anything to standard output. > .TP > +.B \-U > +Perform the > +.BR preadv2 (2) > +call with > +.IR RWF_DONTCACHE . > +.TP > .B \-v > dump the contents of the buffer after reading, > by default only the count of bytes actually read is dumped. > -- > 2.48.1 > >
"Darrick J. Wong" <djwong@kernel.org> writes: > On Wed, Mar 05, 2025 at 03:57:48PM +0530, Ritesh Harjani (IBM) wrote: >> Add per-io RWF_DONTCACHE support flag to preadv2(). >> This enables xfs_io to perform uncached buffered-io reads. >> >> e.g. xfs_io -c "pread -U -V 1 0 16K" /mnt/f1 >> >> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> >> --- >> io/pread.c | 17 +++++++++++++++-- >> man/man8/xfs_io.8 | 8 +++++++- >> 2 files changed, 22 insertions(+), 3 deletions(-) >> >> diff --git a/io/pread.c b/io/pread.c >> index b314fbc7..79e6570e 100644 >> --- a/io/pread.c >> +++ b/io/pread.c >> @@ -38,6 +38,9 @@ pread_help(void) >> " -Z N -- zeed the random number generator (used when reading randomly)\n" >> " (heh, zorry, the -s/-S arguments were already in use in pwrite)\n" >> " -V N -- use vectored IO with N iovecs of blocksize each (preadv)\n" >> +#ifdef HAVE_PREADV2 >> +" -U -- Perform the preadv2() with Uncached/RWF_DONTCACHE\n" > > Same comment as the last patch, but otherwise this looks good; Sure will do in v3. > Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Thanks! -ritesh > > --D > >> +#endif >> "\n" >> " When in \"random\" mode, the number of read operations will equal the\n" >> " number required to do a complete forward/backward scan of the range.\n" >> @@ -388,7 +391,7 @@ pread_f( >> init_cvtnum(&fsblocksize, &fssectsize); >> bsize = fsblocksize; >> >> - while ((c = getopt(argc, argv, "b:BCFRquvV:Z:")) != EOF) { >> + while ((c = getopt(argc, argv, "b:BCFRquUvV:Z:")) != EOF) { >> switch (c) { >> case 'b': >> tmp = cvtnum(fsblocksize, fssectsize, optarg); >> @@ -417,6 +420,11 @@ pread_f( >> case 'u': >> uflag = 1; >> break; >> +#ifdef HAVE_PREADV2 >> + case 'U': >> + preadv2_flags |= RWF_DONTCACHE; >> + break; >> +#endif >> case 'v': >> vflag = 1; >> break; >> @@ -446,6 +454,11 @@ pread_f( >> exitcode = 1; >> return command_usage(&pread_cmd); >> } >> + if (preadv2_flags != 0 && vectors == 0) { >> + printf(_("preadv2 flags require vectored I/O (-V)\n")); >> + exitcode = 1; >> + return command_usage(&pread_cmd); >> + } >> >> offset = cvtnum(fsblocksize, fssectsize, argv[optind]); >> if (offset < 0 && (direction & (IO_RANDOM|IO_BACKWARD))) { >> @@ -514,7 +527,7 @@ pread_init(void) >> pread_cmd.argmin = 2; >> pread_cmd.argmax = -1; >> pread_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; >> - pread_cmd.args = _("[-b bs] [-qv] [-i N] [-FBR [-Z N]] off len"); >> + pread_cmd.args = _("[-b bs] [-qUv] [-i N] [-FBR [-Z N]] off len"); >> pread_cmd.oneline = _("reads a number of bytes at a specified offset"); >> pread_cmd.help = pread_help; >> >> diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8 >> index 47af5232..df508054 100644 >> --- a/man/man8/xfs_io.8 >> +++ b/man/man8/xfs_io.8 >> @@ -200,7 +200,7 @@ option will set the file permissions to read-write (0644). This allows xfs_io to >> set up mismatches between the file permissions and the open file descriptor >> read/write mode to exercise permission checks inside various syscalls. >> .TP >> -.BI "pread [ \-b " bsize " ] [ \-qv ] [ \-FBR [ \-Z " seed " ] ] [ \-V " vectors " ] " "offset length" >> +.BI "pread [ \-b " bsize " ] [ \-qUv ] [ \-FBR [ \-Z " seed " ] ] [ \-V " vectors " ] " "offset length" >> Reads a range of bytes in a specified blocksize from the given >> .IR offset . >> .RS 1.0i >> @@ -214,6 +214,12 @@ requests will be split. The default blocksize is 4096 bytes. >> .B \-q >> quiet mode, do not write anything to standard output. >> .TP >> +.B \-U >> +Perform the >> +.BR preadv2 (2) >> +call with >> +.IR RWF_DONTCACHE . >> +.TP >> .B \-v >> dump the contents of the buffer after reading, >> by default only the count of bytes actually read is dumped. >> -- >> 2.48.1 >> >>
diff --git a/io/pread.c b/io/pread.c index b314fbc7..79e6570e 100644 --- a/io/pread.c +++ b/io/pread.c @@ -38,6 +38,9 @@ pread_help(void) " -Z N -- zeed the random number generator (used when reading randomly)\n" " (heh, zorry, the -s/-S arguments were already in use in pwrite)\n" " -V N -- use vectored IO with N iovecs of blocksize each (preadv)\n" +#ifdef HAVE_PREADV2 +" -U -- Perform the preadv2() with Uncached/RWF_DONTCACHE\n" +#endif "\n" " When in \"random\" mode, the number of read operations will equal the\n" " number required to do a complete forward/backward scan of the range.\n" @@ -388,7 +391,7 @@ pread_f( init_cvtnum(&fsblocksize, &fssectsize); bsize = fsblocksize; - while ((c = getopt(argc, argv, "b:BCFRquvV:Z:")) != EOF) { + while ((c = getopt(argc, argv, "b:BCFRquUvV:Z:")) != EOF) { switch (c) { case 'b': tmp = cvtnum(fsblocksize, fssectsize, optarg); @@ -417,6 +420,11 @@ pread_f( case 'u': uflag = 1; break; +#ifdef HAVE_PREADV2 + case 'U': + preadv2_flags |= RWF_DONTCACHE; + break; +#endif case 'v': vflag = 1; break; @@ -446,6 +454,11 @@ pread_f( exitcode = 1; return command_usage(&pread_cmd); } + if (preadv2_flags != 0 && vectors == 0) { + printf(_("preadv2 flags require vectored I/O (-V)\n")); + exitcode = 1; + return command_usage(&pread_cmd); + } offset = cvtnum(fsblocksize, fssectsize, argv[optind]); if (offset < 0 && (direction & (IO_RANDOM|IO_BACKWARD))) { @@ -514,7 +527,7 @@ pread_init(void) pread_cmd.argmin = 2; pread_cmd.argmax = -1; pread_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; - pread_cmd.args = _("[-b bs] [-qv] [-i N] [-FBR [-Z N]] off len"); + pread_cmd.args = _("[-b bs] [-qUv] [-i N] [-FBR [-Z N]] off len"); pread_cmd.oneline = _("reads a number of bytes at a specified offset"); pread_cmd.help = pread_help; diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8 index 47af5232..df508054 100644 --- a/man/man8/xfs_io.8 +++ b/man/man8/xfs_io.8 @@ -200,7 +200,7 @@ option will set the file permissions to read-write (0644). This allows xfs_io to set up mismatches between the file permissions and the open file descriptor read/write mode to exercise permission checks inside various syscalls. .TP -.BI "pread [ \-b " bsize " ] [ \-qv ] [ \-FBR [ \-Z " seed " ] ] [ \-V " vectors " ] " "offset length" +.BI "pread [ \-b " bsize " ] [ \-qUv ] [ \-FBR [ \-Z " seed " ] ] [ \-V " vectors " ] " "offset length" Reads a range of bytes in a specified blocksize from the given .IR offset . .RS 1.0i @@ -214,6 +214,12 @@ requests will be split. The default blocksize is 4096 bytes. .B \-q quiet mode, do not write anything to standard output. .TP +.B \-U +Perform the +.BR preadv2 (2) +call with +.IR RWF_DONTCACHE . +.TP .B \-v dump the contents of the buffer after reading, by default only the count of bytes actually read is dumped.
Add per-io RWF_DONTCACHE support flag to preadv2(). This enables xfs_io to perform uncached buffered-io reads. e.g. xfs_io -c "pread -U -V 1 0 16K" /mnt/f1 Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> --- io/pread.c | 17 +++++++++++++++-- man/man8/xfs_io.8 | 8 +++++++- 2 files changed, 22 insertions(+), 3 deletions(-)