From 0799d5cf54dcfe9579268b644c6f5706fc341e93 Mon Sep 17 00:00:00 2001 From: Goldwyn Rodrigues Date: Thu, 9 Nov 2017 14:56:28 -0600 Subject: [PATCH] xfs_io: Add RWF_NOWAIT to pwritev2() This allows to make pwritev2() calls with RWF_NOWAIT, which would fail in case the call blocks. Signed-off-by: Goldwyn Rodrigues Reviewed-by: Brian Foster [sandeen@sandeen.net: combine all optional args in short help] Signed-off-by: Eric Sandeen --- io/pwrite.c | 12 ++++++++++-- man/man8/xfs_io.8 | 28 +++++++++++++++++----------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/io/pwrite.c b/io/pwrite.c index abd3a184d..c36a661a8 100644 --- a/io/pwrite.c +++ b/io/pwrite.c @@ -53,6 +53,9 @@ pwrite_help(void) #ifdef HAVE_PWRITEV " -V N -- use vectored IO with N iovecs of blocksize each (pwritev)\n" #endif +#ifdef HAVE_PWRITEV2 +" -N -- Perform the pwritev2() with RWF_NOWAIT\n" +#endif "\n")); } @@ -279,7 +282,7 @@ pwrite_f( init_cvtnum(&fsblocksize, &fssectsize); bsize = fsblocksize; - while ((c = getopt(argc, argv, "b:BCdf:Fi:qRs:S:uV:wWZ:")) != EOF) { + while ((c = getopt(argc, argv, "b:BCdf:Fi:NqRs:S:uV:wWZ:")) != EOF) { switch (c) { case 'b': tmp = cvtnum(fsblocksize, fssectsize, optarg); @@ -308,6 +311,11 @@ pwrite_f( case 'i': infile = optarg; break; +#ifdef HAVE_PWRITEV2 + case 'N': + pwritev2_flags |= RWF_NOWAIT; + break; +#endif case 's': skip = cvtnum(fsblocksize, fssectsize, optarg); if (skip < 0) { @@ -438,7 +446,7 @@ pwrite_init(void) pwrite_cmd.argmax = -1; pwrite_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; pwrite_cmd.args = -_("[-i infile [-d] [-s skip]] [-b bs] [-S seed] [-wW] [-FBR [-Z N]] [-V N] off len"); +_("[-i infile [-dwNW] [-s skip]] [-b bs] [-S seed] [-FBR [-Z N]] [-V N] off len"); pwrite_cmd.oneline = _("writes a number of bytes at a specified offset"); pwrite_cmd.help = pwrite_help; diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8 index 0fd9b9511..c2fe6aae7 100644 --- a/man/man8/xfs_io.8 +++ b/man/man8/xfs_io.8 @@ -222,7 +222,7 @@ See the .B pread command. .TP -.BI "pwrite [ \-i " file " ] [ \-d ] [ \-s " skip " ] [ \-b " size " ] [ \-S " seed " ] [ \-FBR [ \-Z " zeed " ] ] [ \-wW ] [ \-V " vectors " ] " "offset length" +.BI "pwrite [ \-i " file " ] [ \-dwNW ] [ \-s " skip " ] [ \-b " size " ] [ \-S " seed " ] [ \-FBR [ \-Z " zeed " ] ] [ \-V " vectors " ] " "offset length" Writes a range of bytes in a specified blocksize from the given .IR offset . The bytes written can be either a set pattern or read in from another @@ -239,6 +239,22 @@ to be specified as the source of the data to be written. causes direct I/O, rather than the usual buffered I/O, to be used when reading the input file. .TP +.B \-w +call +.BR fdatasync (2) +once all writes are complete (included in timing results) +.TP +.B \-N +Perform the +.BR pwritev2 (2) +call with +.I RWF_NOWAIT. +.TP +.B \-W +call +.BR fsync (2) +once all writes are complete (included in timing results) +.TP .B \-s specifies the number of bytes to .I skip @@ -266,16 +282,6 @@ write the buffers in the give range in a random order. .B \-Z seed specify the random number seed used for random write .TP -.B \-w -call -.BR fdatasync (2) -once all writes are complete (included in timing results) -.TP -.B \-W -call -.BR fsync (2) -once all writes are complete (included in timing results) -.TP .B \-V vectors Use the vectored IO write syscall .BR pwritev (2) -- 2.47.2