Skip to contentSkip to conversation

fsync-err: write to different offset on each fd

PATCH In review Jeff Layton 2 participants 2 messages Sep 13, 2017 – Sep 14, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsync-err: write to different offset on each fd

From: Jeff Layton <[email protected]>

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.

---
 src/fsync-err.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/fsync-err.c +2 -2
index 4b0205cf2fd4..146688ddb01e 100644
@@ -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;
Signature · 1 line
2.13.5
#1 lore raw
Quoted 5 lines · Jeff Layton

From: Jeff Layton <[email protected]>

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..

Quoted 6 lines

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

But the change looks fine to me.

Thanks,
Eryu

Quoted 29 lines
---
 src/fsync-err.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/fsync-err.c +2 -2
index 4b0205cf2fd4..146688ddb01e 100644
@@ -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;
Signature · 1 line
2.13.5