Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Nov 2013 18:35:01 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r258351 - head/tools/regression/fsx
Message-ID:  <201311191835.rAJIZ1Z8023905@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Tue Nov 19 18:35:01 2013
New Revision: 258351
URL: http://svnweb.freebsd.org/changeset/base/258351

Log:
  fsx: new option to disable msync(MS_SYNC) after each write via mmaped region
  
  This option should be useful for testing if a filesystem uses the
  unified buffer / page cache.
  Or, if filesystem's emulation of the unified cache works as expected.
  This should be the case for e.g. ZFS.
  
  MFC after:	1 week

Modified:
  head/tools/regression/fsx/fsx.c

Modified: head/tools/regression/fsx/fsx.c
==============================================================================
--- head/tools/regression/fsx/fsx.c	Tue Nov 19 17:53:19 2013	(r258350)
+++ head/tools/regression/fsx/fsx.c	Tue Nov 19 18:35:01 2013	(r258351)
@@ -126,6 +126,7 @@ int	randomoplen = 1;		/* -O flag disable
 int	seed = 1;			/* -S flag */
 int     mapped_writes = 1;	      /* -W flag disables */
 int 	mapped_reads = 1;		/* -R flag disables it */
+int     mapped_msync = 1;	      /* -U flag disables */
 int	fsxgoodfd = 0;
 FILE *	fsxlogf = NULL;
 int badoff = -1;
@@ -679,12 +680,12 @@ domapwrite(unsigned offset, unsigned siz
 
 	if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE,
 			      MAP_FILE | MAP_SHARED, fd,
-			      (off_t)(offset - pg_offset))) == (char *)-1) {
+			      (off_t)(offset - pg_offset))) == MAP_FAILED) {
 		prterr("domapwrite: mmap");
 		report_failure(202);
 	}
 	memcpy(p + pg_offset, good_buf + offset, size);
-	if (msync(p, map_size, 0) != 0) {
+	if (mapped_msync && msync(p, map_size, MS_SYNC) != 0) {
 		prterr("domapwrite: msync");
 		report_failure(203);
 	}
@@ -886,6 +887,7 @@ usage(void)
 	-S seed: for random # generator (default 1) 0 gets timestamp\n\
 	-W: mapped write operations DISabled\n\
 	-R: mapped read operations DISabled)\n\
+	-U: msync after mapped write operations DISabled\n\
 	fname: this filename is REQUIRED (no default)\n");
 	exit(90);
 }
@@ -941,8 +943,8 @@ main(int argc, char **argv)
 
 	setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
 
-	while ((ch = getopt(argc, argv, "b:c:dl:m:no:p:qr:s:t:w:D:LN:OP:RS:W"))
-	       != -1)
+	while ((ch = getopt(argc, argv,
+	    "b:c:dl:m:no:p:qr:s:t:w:D:LN:OP:RS:UW")) != -1)
 		switch (ch) {
 		case 'b':
 			simulatedopcount = getnum(optarg, &endp);
@@ -1057,6 +1059,11 @@ main(int argc, char **argv)
 			if (!quiet)
 				fprintf(stdout, "mapped writes DISABLED\n");
 			break;
+		case 'U':
+			mapped_msync = 0;
+			if (!quiet)
+				fprintf(stdout, "mapped msync DISABLED\n");
+			break;
 
 		default:
 			usage();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311191835.rAJIZ1Z8023905>