Skip to contentSkip to conversation

xfstests: fix msync() call in fsx.c:domapwrite()

PATCH Applied Curt Wohlgemuth 2 participants 3 messages Feb 7, 2012 – Mar 31, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests: fix msync() call in fsx.c:domapwrite()

This explicitly sends MS_SYNC as the flag to msync() in fsx.c, in domapwrite(). Without this flag, the memory written to the mmap'ed region will not be flushed to disk; in fact, on Linux, calling msync() with a '0' or MS_ASYNC flag is a no-op.

---
 ltp/fsx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ltp/fsx.c +1 -1
index b36c201..2f1e3e8 100644
@@ -779,7 +779,7 @@ domapwrite(unsigned offset, unsigned size)
 		report_failure(202);
 	}
 	memcpy(p + pg_offset, good_buf + offset, size);
-	if (msync(p, map_size, 0) != 0) {
+	if (msync(p, map_size, MS_SYNC) != 0) {
 		prterr("domapwrite: msync");
 		report_failure(203);
 	}
Signature · 1 line
1.7.7.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Curt Wohlgemuth

This explicitly sends MS_SYNC as the flag to msync() in fsx.c, in domapwrite(). Without this flag, the memory written to the mmap'ed region will not be flushed to disk; in fact, on Linux, calling msync() with a '0' or MS_ASYNC flag is a no-op.

Looks sensible to me - what exactly msync did has always been grossly different for different operating systems, including changing meaning on Linux a few times, so let's be explicit.