public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fsync-err: write to different offset on each fd
@ 2017-09-13 13:06 Jeff Layton
  2017-09-14  6:24 ` Eryu Guan
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Layton @ 2017-09-13 13:06 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests, neilb

From: Jeff Layton <jlayton@redhat.com>

NFS currently has slightly different semantics from other fs' and
fails this test due to the fact that the same range is overwritten
via each fd.

Change it so that each fd overwrites a different region, which is
more representative of a real workload anyway.

Reported-by: Neil Brown <neilb@suse.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 src/fsync-err.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/fsync-err.c b/src/fsync-err.c
index 4b0205cf2fd4..146688ddb01e 100644
--- a/src/fsync-err.c
+++ b/src/fsync-err.c
@@ -106,7 +106,7 @@ int main(int argc, char **argv)
 	memset(buf, 0x7c, bufsize);
 
 	for (i = 0; i < numfds; ++i) {
-		ret = write(fd[i], buf, bufsize);
+		ret = pwrite(fd[i], buf, bufsize, i * bufsize);
 		if (ret < 0) {
 			printf("First write on fd[%d] failed: %m\n", i);
 			return 1;
@@ -149,7 +149,7 @@ int main(int argc, char **argv)
 	}
 
 	for (i = 0; i < numfds; ++i) {
-		ret = write(fd[i], buf, bufsize);
+		ret = pwrite(fd[i], buf, bufsize, i * bufsize);
 		if (ret < 0) {
 			printf("Second write on fd[%d] failed: %m\n", i);
 			return 1;
-- 
2.13.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fsync-err: write to different offset on each fd
  2017-09-13 13:06 [PATCH] fsync-err: write to different offset on each fd Jeff Layton
@ 2017-09-14  6:24 ` Eryu Guan
  0 siblings, 0 replies; 2+ messages in thread
From: Eryu Guan @ 2017-09-14  6:24 UTC (permalink / raw)
  To: Jeff Layton; +Cc: fstests, neilb

On Wed, Sep 13, 2017 at 09:06:24AM -0400, Jeff Layton wrote:
> From: Jeff Layton <jlayton@redhat.com>
> 
> NFS currently has slightly different semantics from other fs' and
> fails this test due to the fact that the same range is overwritten
> via each fd.

generic/441 and generic/442 require the SCRATCH_DEV to be a real block
device, tests should be skipped as _notrun on NFS, and I didn't expect a
test failure on NFS..

> 
> Change it so that each fd overwrites a different region, which is
> more representative of a real workload anyway.
> 
> Reported-by: Neil Brown <neilb@suse.com>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>

But the change looks fine to me.

Thanks,
Eryu
> ---
>  src/fsync-err.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/fsync-err.c b/src/fsync-err.c
> index 4b0205cf2fd4..146688ddb01e 100644
> --- a/src/fsync-err.c
> +++ b/src/fsync-err.c
> @@ -106,7 +106,7 @@ int main(int argc, char **argv)
>  	memset(buf, 0x7c, bufsize);
>  
>  	for (i = 0; i < numfds; ++i) {
> -		ret = write(fd[i], buf, bufsize);
> +		ret = pwrite(fd[i], buf, bufsize, i * bufsize);
>  		if (ret < 0) {
>  			printf("First write on fd[%d] failed: %m\n", i);
>  			return 1;
> @@ -149,7 +149,7 @@ int main(int argc, char **argv)
>  	}
>  
>  	for (i = 0; i < numfds; ++i) {
> -		ret = write(fd[i], buf, bufsize);
> +		ret = pwrite(fd[i], buf, bufsize, i * bufsize);
>  		if (ret < 0) {
>  			printf("Second write on fd[%d] failed: %m\n", i);
>  			return 1;
> -- 
> 2.13.5
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-14  6:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-13 13:06 [PATCH] fsync-err: write to different offset on each fd Jeff Layton
2017-09-14  6:24 ` Eryu Guan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox