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

login
register
mail settings
Submitter Curt Wohlgemuth
Date Feb. 7, 2012, 7:16 p.m.
Message ID <1328642166-389-1-git-send-email-curtw@google.com>
Download mbox | patch
Permalink /patch/139995/
State Not Applicable
Headers show

Comments

Curt Wohlgemuth - Feb. 7, 2012, 7:16 p.m.
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.

Signed-off-by: Curt Wohlgemuth <curtw@google.com>
---
 ltp/fsx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Christoph Hellwig - Feb. 12, 2012, 11:48 p.m.
On Tue, Feb 07, 2012 at 11:16:06AM -0800, Curt Wohlgemuth wrote:
> 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.

Reviewed-by: Christoph Hellwig <hch@lst.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christoph Hellwig - March 31, 2012, 8:12 p.m.
Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/ltp/fsx.c b/ltp/fsx.c
index b36c201..2f1e3e8 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -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);
 	}