* [PATCH 1/3] Add support for pwritev2()
@ 2017-09-28 18:54 Goldwyn Rodrigues
2017-09-28 18:54 ` [PATCH 2/3] io/pwrite: Add RWF_NOWAIT to pwritev2() Goldwyn Rodrigues
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Goldwyn Rodrigues @ 2017-09-28 18:54 UTC (permalink / raw)
To: linux-xfs; +Cc: david, Goldwyn Rodrigues
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
io/Makefile | 2 +-
io/pwrite.c | 36 +++++++++++++++++++++++-------------
2 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/io/Makefile b/io/Makefile
index 62bc03b8..87649dc6 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -87,7 +87,7 @@ endif
# Also implies PWRITEV
ifeq ($(HAVE_PREADV),yes)
-LCFLAGS += -DHAVE_PREADV -DHAVE_PWRITEV
+LCFLAGS += -DHAVE_PREADV -DHAVE_PWRITEV -DHAVE_PWRITEV2
endif
ifeq ($(HAVE_READDIR),yes)
diff --git a/io/pwrite.c b/io/pwrite.c
index 67631ce5..82eaf827 100644
--- a/io/pwrite.c
+++ b/io/pwrite.c
@@ -62,7 +62,8 @@ do_pwritev(
int fd,
off64_t offset,
ssize_t count,
- ssize_t buffer_size)
+ ssize_t buffer_size,
+ int pwritev2_flags)
{
int vecs = 0;
ssize_t oldlen = 0;
@@ -81,7 +82,11 @@ do_pwritev(
} else {
vecs = vectors;
}
+#ifdef HAVE_PWRITEV2
+ bytes = pwritev2(fd, iov, vectors, offset, pwritev2_flags);
+#else
bytes = pwritev(fd, iov, vectors, offset);
+#endif
/* restore trimmed iov */
if (oldlen)
@@ -98,12 +103,13 @@ do_pwrite(
int fd,
off64_t offset,
ssize_t count,
- ssize_t buffer_size)
+ ssize_t buffer_size,
+ int pwritev2_flags)
{
if (!vectors)
return pwrite64(fd, buffer, min(count, buffer_size), offset);
- return do_pwritev(fd, offset, count, buffer_size);
+ return do_pwritev(fd, offset, count, buffer_size, pwritev2_flags);
}
static int
@@ -111,7 +117,8 @@ write_random(
off64_t offset,
long long count,
unsigned int seed,
- long long *total)
+ long long *total,
+ int pwritev2_flags)
{
off64_t off, range;
ssize_t bytes;
@@ -133,7 +140,7 @@ write_random(
buffersize;
else
off = offset;
- bytes = do_pwrite(file->fd, off, buffersize, buffersize);
+ bytes = do_pwrite(file->fd, off, buffersize, buffersize, pwritev2_flags);
if (bytes == 0)
break;
if (bytes < 0) {
@@ -153,7 +160,8 @@ static int
write_backward(
off64_t offset,
long long *count,
- long long *total)
+ long long *total,
+ int pwritev2_flags)
{
off64_t end, off = offset;
ssize_t bytes = 0, bytes_requested;
@@ -171,7 +179,7 @@ write_backward(
if ((bytes_requested = (off % buffersize))) {
bytes_requested = min(cnt, bytes_requested);
off -= bytes_requested;
- bytes = do_pwrite(file->fd, off, bytes_requested, buffersize);
+ bytes = do_pwrite(file->fd, off, bytes_requested, buffersize, pwritev2_flags);
if (bytes == 0)
return ops;
if (bytes < 0) {
@@ -189,7 +197,7 @@ write_backward(
while (cnt > end) {
bytes_requested = min(cnt, buffersize);
off -= bytes_requested;
- bytes = do_pwrite(file->fd, off, cnt, buffersize);
+ bytes = do_pwrite(file->fd, off, cnt, buffersize, pwritev2_flags);
if (bytes == 0)
break;
if (bytes < 0) {
@@ -212,7 +220,8 @@ write_buffer(
size_t bs,
int fd,
off64_t skip,
- long long *total)
+ long long *total,
+ int pwritev2_flags)
{
ssize_t bytes;
long long bar = min(bs, count);
@@ -224,7 +233,7 @@ write_buffer(
if (read_buffer(fd, skip + *total, bs, &bar, 0, 1) < 0)
break;
}
- bytes = do_pwrite(file->fd, offset, count, bar);
+ bytes = do_pwrite(file->fd, offset, count, bar, pwritev2_flags);
if (bytes == 0)
break;
if (bytes < 0) {
@@ -258,6 +267,7 @@ pwrite_f(
int Cflag, qflag, uflag, dflag, wflag, Wflag;
int direction = IO_FORWARD;
int c, fd = -1;
+ int pwritev2_flags = 0;
Cflag = qflag = uflag = dflag = wflag = Wflag = 0;
init_cvtnum(&fsblocksize, &fssectsize);
@@ -365,13 +375,13 @@ pwrite_f(
case IO_RANDOM:
if (!zeed) /* srandom seed */
zeed = time(NULL);
- c = write_random(offset, count, zeed, &total);
+ c = write_random(offset, count, zeed, &total, pwritev2_flags);
break;
case IO_FORWARD:
- c = write_buffer(offset, count, bsize, fd, skip, &total);
+ c = write_buffer(offset, count, bsize, fd, skip, &total, pwritev2_flags);
break;
case IO_BACKWARD:
- c = write_backward(offset, &count, &total);
+ c = write_backward(offset, &count, &total, pwritev2_flags);
break;
default:
total = 0;
--
2.14.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] io/pwrite: Add RWF_NOWAIT to pwritev2()
2017-09-28 18:54 [PATCH 1/3] Add support for pwritev2() Goldwyn Rodrigues
@ 2017-09-28 18:54 ` Goldwyn Rodrigues
2017-09-28 19:29 ` Darrick J. Wong
2017-09-28 18:54 ` [PATCH 3/3] Allow partial writes Goldwyn Rodrigues
2017-09-28 19:26 ` [PATCH 1/3] Add support for pwritev2() Darrick J. Wong
2 siblings, 1 reply; 6+ messages in thread
From: Goldwyn Rodrigues @ 2017-09-28 18:54 UTC (permalink / raw)
To: linux-xfs; +Cc: david, Goldwyn Rodrigues
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
This allows to make pwritev2() calls with RWF_NOWAIT,
which would fail in case the call blocks.
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
io/pwrite.c | 8 +++++++-
man/man8/xfs_io.8 | 6 ++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/io/pwrite.c b/io/pwrite.c
index 82eaf827..8289c3ee 100644
--- a/io/pwrite.c
+++ b/io/pwrite.c
@@ -52,6 +52,9 @@ pwrite_help(void)
" (heh, zorry, the -s/-S arguments were already in use in pwrite)\n"
#ifdef HAVE_PWRITEV
" -V N -- use vectored IO with N iovecs of blocksize each (pwritev)\n"
+#ifdef HAVE_PWRITEV2
+" -N -- Perform the pwritev2() with RWF_NOWAIT\n"
+#endif
#endif
"\n"));
}
@@ -273,7 +276,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);
@@ -302,6 +305,9 @@ pwrite_f(
case 'i':
infile = optarg;
break;
+ case 'N':
+ pwritev2_flags |= RWF_NOWAIT;
+ break;
case 's':
skip = cvtnum(fsblocksize, fssectsize, optarg);
if (skip < 0) {
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index 2c56f092..f410ce9a 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -248,6 +248,12 @@ Use the vectored IO write syscall
with a number of blocksize length iovecs. The number of iovecs is set by the
.I vectors
parameter.
+.TP
+.B \-N
+Perform the
+.BR pwritev2 (2)
+call with
+.I RWF_NOWAIT.
.RE
.PD
.TP
--
2.14.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] Allow partial writes
2017-09-28 18:54 [PATCH 1/3] Add support for pwritev2() Goldwyn Rodrigues
2017-09-28 18:54 ` [PATCH 2/3] io/pwrite: Add RWF_NOWAIT to pwritev2() Goldwyn Rodrigues
@ 2017-09-28 18:54 ` Goldwyn Rodrigues
2017-09-28 19:31 ` Darrick J. Wong
2017-09-28 19:26 ` [PATCH 1/3] Add support for pwritev2() Darrick J. Wong
2 siblings, 1 reply; 6+ messages in thread
From: Goldwyn Rodrigues @ 2017-09-28 18:54 UTC (permalink / raw)
To: linux-xfs; +Cc: david, Goldwyn Rodrigues
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
Partial writes are performed when there is an error midway
while performing the I/O. Perform the write exactly once and
return the number of bytes written.
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
io/io.h | 1 +
io/pwrite.c | 25 ++++++++++++++++++++++++-
man/man8/xfs_io.8 | 3 +++
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/io/io.h b/io/io.h
index 2bc7ac4a..5875e85a 100644
--- a/io/io.h
+++ b/io/io.h
@@ -24,6 +24,7 @@
#define IO_RANDOM ( 0)
#define IO_FORWARD ( 1)
#define IO_BACKWARD (-1)
+#define IO_PARTIAL (2)
/*
* File descriptor options
diff --git a/io/pwrite.c b/io/pwrite.c
index 8289c3ee..40f537b3 100644
--- a/io/pwrite.c
+++ b/io/pwrite.c
@@ -47,6 +47,7 @@ pwrite_help(void)
" -W -- call fsync(2) at the end (included in timing results)\n"
" -B -- write backwards through the range from offset (backwards N bytes)\n"
" -F -- write forwards through the range of bytes from offset (default)\n"
+" -P -- return Partial writes, perform one call and return bytes written\n"
" -R -- write at random offsets in the specified range of bytes\n"
" -Z N -- zeed the random number generator (used when writing randomly)\n"
" (heh, zorry, the -s/-S arguments were already in use in pwrite)\n"
@@ -255,6 +256,22 @@ write_buffer(
return ops;
}
+static int
+write_partial(
+ off64_t offset,
+ long long count,
+ long long *total,
+ int pwritev2_flags)
+{
+ size_t bytes;
+ bytes = do_pwrite(file->fd, offset, count, count, pwritev2_flags);
+ if (bytes < 0)
+ return -1;
+ *total = bytes;
+ return 1;
+}
+
+
static int
pwrite_f(
int argc,
@@ -276,7 +293,7 @@ pwrite_f(
init_cvtnum(&fsblocksize, &fssectsize);
bsize = fsblocksize;
- while ((c = getopt(argc, argv, "b:BCdf:Fi:NqRs:S:uV:wWZ:")) != EOF) {
+ while ((c = getopt(argc, argv, "b:BCdf:Fi:NqRs:PS:uV:wWZ:")) != EOF) {
switch (c) {
case 'b':
tmp = cvtnum(fsblocksize, fssectsize, optarg);
@@ -298,6 +315,9 @@ pwrite_f(
case 'R':
direction = IO_RANDOM;
break;
+ case 'P':
+ direction = IO_PARTIAL;
+ break;
case 'd':
dflag = 1;
break;
@@ -389,6 +409,9 @@ pwrite_f(
case IO_BACKWARD:
c = write_backward(offset, &count, &total, pwritev2_flags);
break;
+ case IO_PARTIAL:
+ c = write_partial(offset, count, &total, pwritev2_flags);
+ break;
default:
total = 0;
ASSERT(0);
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index f410ce9a..b21a8145 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -229,6 +229,9 @@ write the buffers in a reserve sequential direction.
.B \-R
write the buffers in the give range in a random order.
.TP
+.B \-P
+return Partial writes, perform one call and return the bytes written.
+.TP
.B \-Z seed
specify the random number seed used for random write
.TP
--
2.14.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] Add support for pwritev2()
2017-09-28 18:54 [PATCH 1/3] Add support for pwritev2() Goldwyn Rodrigues
2017-09-28 18:54 ` [PATCH 2/3] io/pwrite: Add RWF_NOWAIT to pwritev2() Goldwyn Rodrigues
2017-09-28 18:54 ` [PATCH 3/3] Allow partial writes Goldwyn Rodrigues
@ 2017-09-28 19:26 ` Darrick J. Wong
2 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2017-09-28 19:26 UTC (permalink / raw)
To: Goldwyn Rodrigues; +Cc: linux-xfs, david, Goldwyn Rodrigues
On Thu, Sep 28, 2017 at 01:54:24PM -0500, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
>
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> ---
> io/Makefile | 2 +-
> io/pwrite.c | 36 +++++++++++++++++++++++-------------
> 2 files changed, 24 insertions(+), 14 deletions(-)
>
> diff --git a/io/Makefile b/io/Makefile
> index 62bc03b8..87649dc6 100644
> --- a/io/Makefile
> +++ b/io/Makefile
> @@ -87,7 +87,7 @@ endif
>
> # Also implies PWRITEV
> ifeq ($(HAVE_PREADV),yes)
> -LCFLAGS += -DHAVE_PREADV -DHAVE_PWRITEV
> +LCFLAGS += -DHAVE_PREADV -DHAVE_PWRITEV -DHAVE_PWRITEV2
Uh..... preadv doesn't imply pwritev2. Separate configure test, please.
> endif
>
> ifeq ($(HAVE_READDIR),yes)
> diff --git a/io/pwrite.c b/io/pwrite.c
> index 67631ce5..82eaf827 100644
> --- a/io/pwrite.c
> +++ b/io/pwrite.c
> @@ -62,7 +62,8 @@ do_pwritev(
> int fd,
> off64_t offset,
> ssize_t count,
> - ssize_t buffer_size)
> + ssize_t buffer_size,
> + int pwritev2_flags)
> {
> int vecs = 0;
> ssize_t oldlen = 0;
> @@ -81,7 +82,11 @@ do_pwritev(
> } else {
> vecs = vectors;
> }
> +#ifdef HAVE_PWRITEV2
> + bytes = pwritev2(fd, iov, vectors, offset, pwritev2_flags);
If HAVE_PWRITEV2 is defined on the system that built xfs_io but the
system that runs xfs_io doesn't support this syscall, why do we not fall
back to pwritev if !pwritev2_flags?
--D
> +#else
> bytes = pwritev(fd, iov, vectors, offset);
> +#endif
>
> /* restore trimmed iov */
> if (oldlen)
> @@ -98,12 +103,13 @@ do_pwrite(
> int fd,
> off64_t offset,
> ssize_t count,
> - ssize_t buffer_size)
> + ssize_t buffer_size,
> + int pwritev2_flags)
> {
> if (!vectors)
> return pwrite64(fd, buffer, min(count, buffer_size), offset);
>
> - return do_pwritev(fd, offset, count, buffer_size);
> + return do_pwritev(fd, offset, count, buffer_size, pwritev2_flags);
> }
>
> static int
> @@ -111,7 +117,8 @@ write_random(
> off64_t offset,
> long long count,
> unsigned int seed,
> - long long *total)
> + long long *total,
> + int pwritev2_flags)
> {
> off64_t off, range;
> ssize_t bytes;
> @@ -133,7 +140,7 @@ write_random(
> buffersize;
> else
> off = offset;
> - bytes = do_pwrite(file->fd, off, buffersize, buffersize);
> + bytes = do_pwrite(file->fd, off, buffersize, buffersize, pwritev2_flags);
> if (bytes == 0)
> break;
> if (bytes < 0) {
> @@ -153,7 +160,8 @@ static int
> write_backward(
> off64_t offset,
> long long *count,
> - long long *total)
> + long long *total,
> + int pwritev2_flags)
> {
> off64_t end, off = offset;
> ssize_t bytes = 0, bytes_requested;
> @@ -171,7 +179,7 @@ write_backward(
> if ((bytes_requested = (off % buffersize))) {
> bytes_requested = min(cnt, bytes_requested);
> off -= bytes_requested;
> - bytes = do_pwrite(file->fd, off, bytes_requested, buffersize);
> + bytes = do_pwrite(file->fd, off, bytes_requested, buffersize, pwritev2_flags);
> if (bytes == 0)
> return ops;
> if (bytes < 0) {
> @@ -189,7 +197,7 @@ write_backward(
> while (cnt > end) {
> bytes_requested = min(cnt, buffersize);
> off -= bytes_requested;
> - bytes = do_pwrite(file->fd, off, cnt, buffersize);
> + bytes = do_pwrite(file->fd, off, cnt, buffersize, pwritev2_flags);
> if (bytes == 0)
> break;
> if (bytes < 0) {
> @@ -212,7 +220,8 @@ write_buffer(
> size_t bs,
> int fd,
> off64_t skip,
> - long long *total)
> + long long *total,
> + int pwritev2_flags)
> {
> ssize_t bytes;
> long long bar = min(bs, count);
> @@ -224,7 +233,7 @@ write_buffer(
> if (read_buffer(fd, skip + *total, bs, &bar, 0, 1) < 0)
> break;
> }
> - bytes = do_pwrite(file->fd, offset, count, bar);
> + bytes = do_pwrite(file->fd, offset, count, bar, pwritev2_flags);
> if (bytes == 0)
> break;
> if (bytes < 0) {
> @@ -258,6 +267,7 @@ pwrite_f(
> int Cflag, qflag, uflag, dflag, wflag, Wflag;
> int direction = IO_FORWARD;
> int c, fd = -1;
> + int pwritev2_flags = 0;
>
> Cflag = qflag = uflag = dflag = wflag = Wflag = 0;
> init_cvtnum(&fsblocksize, &fssectsize);
> @@ -365,13 +375,13 @@ pwrite_f(
> case IO_RANDOM:
> if (!zeed) /* srandom seed */
> zeed = time(NULL);
> - c = write_random(offset, count, zeed, &total);
> + c = write_random(offset, count, zeed, &total, pwritev2_flags);
> break;
> case IO_FORWARD:
> - c = write_buffer(offset, count, bsize, fd, skip, &total);
> + c = write_buffer(offset, count, bsize, fd, skip, &total, pwritev2_flags);
> break;
> case IO_BACKWARD:
> - c = write_backward(offset, &count, &total);
> + c = write_backward(offset, &count, &total, pwritev2_flags);
> break;
> default:
> total = 0;
> --
> 2.14.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] io/pwrite: Add RWF_NOWAIT to pwritev2()
2017-09-28 18:54 ` [PATCH 2/3] io/pwrite: Add RWF_NOWAIT to pwritev2() Goldwyn Rodrigues
@ 2017-09-28 19:29 ` Darrick J. Wong
0 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2017-09-28 19:29 UTC (permalink / raw)
To: Goldwyn Rodrigues; +Cc: linux-xfs, david, Goldwyn Rodrigues
On Thu, Sep 28, 2017 at 01:54:25PM -0500, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
>
> This allows to make pwritev2() calls with RWF_NOWAIT,
> which would fail in case the call blocks.
>
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> ---
> io/pwrite.c | 8 +++++++-
> man/man8/xfs_io.8 | 6 ++++++
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/io/pwrite.c b/io/pwrite.c
> index 82eaf827..8289c3ee 100644
> --- a/io/pwrite.c
> +++ b/io/pwrite.c
> @@ -52,6 +52,9 @@ pwrite_help(void)
> " (heh, zorry, the -s/-S arguments were already in use in pwrite)\n"
> #ifdef HAVE_PWRITEV
> " -V N -- use vectored IO with N iovecs of blocksize each (pwritev)\n"
> +#ifdef HAVE_PWRITEV2
> +" -N -- Perform the pwritev2() with RWF_NOWAIT\n"
> +#endif
> #endif
> "\n"));
> }
> @@ -273,7 +276,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);
> @@ -302,6 +305,9 @@ pwrite_f(
> case 'i':
> infile = optarg;
> break;
> + case 'N':
> + pwritev2_flags |= RWF_NOWAIT;
> + break;
> case 's':
> skip = cvtnum(fsblocksize, fssectsize, optarg);
> if (skip < 0) {
> diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
> index 2c56f092..f410ce9a 100644
> --- a/man/man8/xfs_io.8
> +++ b/man/man8/xfs_io.8
> @@ -248,6 +248,12 @@ Use the vectored IO write syscall
> with a number of blocksize length iovecs. The number of iovecs is set by the
> .I vectors
> parameter.
> +.TP
> +.B \-N
> +Perform the
> +.BR pwritev2 (2)
> +call with
> +.I RWF_NOWAIT.
Trailing space?
Otherwise looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> .RE
> .PD
> .TP
> --
> 2.14.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] Allow partial writes
2017-09-28 18:54 ` [PATCH 3/3] Allow partial writes Goldwyn Rodrigues
@ 2017-09-28 19:31 ` Darrick J. Wong
0 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2017-09-28 19:31 UTC (permalink / raw)
To: Goldwyn Rodrigues; +Cc: linux-xfs, david, Goldwyn Rodrigues
On Thu, Sep 28, 2017 at 01:54:26PM -0500, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
>
> Partial writes are performed when there is an error midway
> while performing the I/O. Perform the write exactly once and
> return the number of bytes written.
>
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> ---
> io/io.h | 1 +
> io/pwrite.c | 25 ++++++++++++++++++++++++-
> man/man8/xfs_io.8 | 3 +++
> 3 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/io/io.h b/io/io.h
> index 2bc7ac4a..5875e85a 100644
> --- a/io/io.h
> +++ b/io/io.h
> @@ -24,6 +24,7 @@
> #define IO_RANDOM ( 0)
> #define IO_FORWARD ( 1)
> #define IO_BACKWARD (-1)
> +#define IO_PARTIAL (2)
I would name this CALL_ONCE instead of PARTIAL since we don't know
beforehand that the write will return partial results -- it could
succeed at writing the entire buffer.
--D
>
> /*
> * File descriptor options
> diff --git a/io/pwrite.c b/io/pwrite.c
> index 8289c3ee..40f537b3 100644
> --- a/io/pwrite.c
> +++ b/io/pwrite.c
> @@ -47,6 +47,7 @@ pwrite_help(void)
> " -W -- call fsync(2) at the end (included in timing results)\n"
> " -B -- write backwards through the range from offset (backwards N bytes)\n"
> " -F -- write forwards through the range of bytes from offset (default)\n"
> +" -P -- return Partial writes, perform one call and return bytes written\n"
> " -R -- write at random offsets in the specified range of bytes\n"
> " -Z N -- zeed the random number generator (used when writing randomly)\n"
> " (heh, zorry, the -s/-S arguments were already in use in pwrite)\n"
> @@ -255,6 +256,22 @@ write_buffer(
> return ops;
> }
>
> +static int
> +write_partial(
> + off64_t offset,
> + long long count,
> + long long *total,
> + int pwritev2_flags)
> +{
> + size_t bytes;
> + bytes = do_pwrite(file->fd, offset, count, count, pwritev2_flags);
> + if (bytes < 0)
> + return -1;
> + *total = bytes;
> + return 1;
> +}
> +
> +
> static int
> pwrite_f(
> int argc,
> @@ -276,7 +293,7 @@ pwrite_f(
> init_cvtnum(&fsblocksize, &fssectsize);
> bsize = fsblocksize;
>
> - while ((c = getopt(argc, argv, "b:BCdf:Fi:NqRs:S:uV:wWZ:")) != EOF) {
> + while ((c = getopt(argc, argv, "b:BCdf:Fi:NqRs:PS:uV:wWZ:")) != EOF) {
> switch (c) {
> case 'b':
> tmp = cvtnum(fsblocksize, fssectsize, optarg);
> @@ -298,6 +315,9 @@ pwrite_f(
> case 'R':
> direction = IO_RANDOM;
> break;
> + case 'P':
> + direction = IO_PARTIAL;
> + break;
> case 'd':
> dflag = 1;
> break;
> @@ -389,6 +409,9 @@ pwrite_f(
> case IO_BACKWARD:
> c = write_backward(offset, &count, &total, pwritev2_flags);
> break;
> + case IO_PARTIAL:
> + c = write_partial(offset, count, &total, pwritev2_flags);
> + break;
> default:
> total = 0;
> ASSERT(0);
> diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
> index f410ce9a..b21a8145 100644
> --- a/man/man8/xfs_io.8
> +++ b/man/man8/xfs_io.8
> @@ -229,6 +229,9 @@ write the buffers in a reserve sequential direction.
> .B \-R
> write the buffers in the give range in a random order.
> .TP
> +.B \-P
> +return Partial writes, perform one call and return the bytes written.
> +.TP
> .B \-Z seed
> specify the random number seed used for random write
> .TP
> --
> 2.14.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-09-28 19:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-28 18:54 [PATCH 1/3] Add support for pwritev2() Goldwyn Rodrigues
2017-09-28 18:54 ` [PATCH 2/3] io/pwrite: Add RWF_NOWAIT to pwritev2() Goldwyn Rodrigues
2017-09-28 19:29 ` Darrick J. Wong
2017-09-28 18:54 ` [PATCH 3/3] Allow partial writes Goldwyn Rodrigues
2017-09-28 19:31 ` Darrick J. Wong
2017-09-28 19:26 ` [PATCH 1/3] Add support for pwritev2() Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).