Skip to contentSkip to conversation

Add necessary items for MAP_SYNC testing

PATCH In review Ross Zwisler 2 participants 4 messages Dec 21, 2017 libnvdimm: non-volatile memory device

lore
Share & tools
lore
#0 lore raw

v4 cover Add necessary items for MAP_SYNC testing

This is the fourth revision of my MAP_SYNC + dm-log-writes support for xfsprogs. The previous revision can be found here:

https://lists.01.org/pipermail/linux-nvdimm/2017-December/013473.html

Changes since v3:

- Fixed indentation of variable declarations (Darrick).

- Added a comment for the case where MAP_SYNC and MAP_SHARED_VALIDATE aren't defined in system headers and we fail an msync command (Darrick).

- Dropped patch 1 of the previous series which fixed compiler warnings. A fix for this issue was already submitted by Dave.

---

As suggested by Dave Chinner:

As I say to all these sorts of one-off test prgrams: please add the new MAP_SYNC flag to xfs_io rather than writing a one-off test program to set it and write some data.

And if we're going to be adding special custom tests just because we need to insert dm-log marks, add that functionality to xfs_io, too.

That way we can create complex custom dm logwrite tests without needing one-off test programs for them all...

This series enhances xfs_io by adding support for the MAP_SYNC mmap() flag and for dm-log-writes marks. This allows the resulting xfstest for MAP_SYNC to be much simpler and have no custom C programs.

Ross Zwisler (2):
xfs_io: add MAP_SYNC support to mmap()
xfs_io: add a new 'log_writes' command

 configure.ac            |   2 +
 debian/control          |   2 +-
 include/builddefs.in    |   3 ++
 include/linux.h         |   8 ++++
 io/Makefile             |  10 +++++
 io/init.c               |   1 +
 io/io.h                 |   7 ++++
 io/log_writes.c         | 106 ++++++++++++++++++++++++++++++++++++++++++++++++
 io/mmap.c               |  29 ++++++++++---
 m4/Makefile             |   1 +
 m4/package_devmapper.m4 |  11 +++++
 m4/package_libcdev.m4   |  16 ++++++++
 man/man8/xfs_io.8       |  29 ++++++++++++-
 13 files changed, 217 insertions(+), 8 deletions(-)
 create mode 100644 io/log_writes.c
 create mode 100644 m4/package_devmapper.m4
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw

PATCH v4 1/2 xfs_io: add MAP_SYNC support to mmap()

Add support for a new -S flag to xfs_io's mmap command. This opens the mapping with the (MAP_SYNC | MAP_SHARED_VALIDATE) flags instead of the standard MAP_SHARED flag.

---
 configure.ac          |  1 +
 include/builddefs.in  |  1 +
 include/linux.h       |  8 ++++++++
 io/Makefile           |  4 ++++
 io/io.h               |  1 +
 io/mmap.c             | 29 ++++++++++++++++++++++++-----
 m4/package_libcdev.m4 | 16 ++++++++++++++++
 man/man8/xfs_io.8     |  6 +++++-
 8 files changed, 60 insertions(+), 6 deletions(-)
configure.ac +1 -0
index e5d0309f..f3325aa0 100644
@@ -163,6 +163,7 @@ AC_HAVE_MREMAP
 AC_NEED_INTERNAL_FSXATTR
 AC_HAVE_GETFSMAP
 AC_HAVE_STATFS_FLAGS
+AC_HAVE_MAP_SYNC
 
 if test "$enable_blkid" = yes; then
 AC_HAVE_BLKID_TOPO
include/builddefs.in +1 -0
index fd274ddc..126f7e95 100644
@@ -115,6 +115,7 @@ HAVE_MREMAP = @have_mremap@
 NEED_INTERNAL_FSXATTR = @need_internal_fsxattr@
 HAVE_GETFSMAP = @have_getfsmap@
 HAVE_STATFS_FLAGS = @have_statfs_flags@
+HAVE_MAP_SYNC = @have_map_sync@
 
 GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
include/linux.h +8 -0
index 6ce344c5..1998941a 100644
@@ -327,4 +327,12 @@ fsmap_advance(
 #define HAVE_GETFSMAP
 #endif /* HAVE_GETFSMAP */
 
+#ifndef HAVE_MAP_SYNC
+#define MAP_SYNC 0
+#define MAP_SHARED_VALIDATE 0
+#else
+#include <asm-generic/mman.h>
+#include <asm-generic/mman-common.h>
+#endif /* HAVE_MAP_SYNC */
+
 #endif	/* __XFS_LINUX_H__ */
io/Makefile +4 -0
index 6725936d..2987ee11 100644
@@ -103,6 +103,10 @@ ifeq ($(HAVE_MREMAP),yes)
 LCFLAGS += -DHAVE_MREMAP
 endif
 
+ifeq ($(HAVE_MAP_SYNC),yes)
+LCFLAGS += -DHAVE_MAP_SYNC
+endif
+
 # On linux we get fsmap from the system or define it ourselves
 # so include this based on platform type.  If this reverts to only
 # the autoconf check w/o local definition, change to testing HAVE_GETFSMAP
io/io.h +1 -0
index 3862985f..8b2753b3 100644
@@ -65,6 +65,7 @@ typedef struct mmap_region {
 	size_t		length;		/* length of mapping */
 	off64_t		offset;		/* start offset into backing file */
 	int		prot;		/* protection mode of the mapping */
+	bool		map_sync;	/* is this a MAP_SYNC mapping? */
 	char		*name;		/* name of backing file */
 } mmap_region_t;
 
io/mmap.c +24 -5
index b0c1f764..04a828a4 100644
@@ -42,7 +42,7 @@ print_mapping(
 	int		index,
 	int		braces)
 {
-	unsigned char	buffer[8] = { 0 };
+	char		buffer[8] = { 0 };
 	int		i;
 
 	static struct {
@@ -57,6 +57,10 @@ print_mapping(
 
 	for (i = 0, p = pflags; p->prot != PROT_NONE; i++, p++)
 		buffer[i] = (map->prot & p->prot) ? p->mode : '-';
+
+	if (map->map_sync)
+		sprintf(&buffer[i], " S");
+
 	printf("%c%03d%c 0x%lx - 0x%lx %s  %14s (%lld : %ld)\n",
 		braces? '[' : ' ', index, braces? ']' : ' ',
 		(unsigned long)map->addr,
@@ -147,6 +151,7 @@ mmap_help(void)
 " -r -- map with PROT_READ protection\n"
 " -w -- map with PROT_WRITE protection\n"
 " -x -- map with PROT_EXEC protection\n"
+" -S -- map with MAP_SYNC and MAP_SHARED_VALIDATE flags\n"
 " -s <size> -- first do mmap(size)/munmap(size), try to reserve some free space\n"
 " If no protection mode is specified, all are used by default.\n"
 "\n"));
@@ -162,7 +167,7 @@ mmap_f(
 	void		*address = NULL;
 	char		*filename;
 	size_t		blocksize, sectsize;
-	int		c, prot = 0;
+	int		c, prot = 0, flags = MAP_SHARED;
 
 	exitcode = 1;
 	if (argc == 1) {
@@ -186,7 +191,7 @@ mmap_f(
 
 	init_cvtnum(&blocksize, &sectsize);
 
-	while ((c = getopt(argc, argv, "rwxs:")) != EOF) {
+	while ((c = getopt(argc, argv, "rwxSs:")) != EOF) {
 		switch (c) {
 		case 'r':
 			prot |= PROT_READ;
@@ -197,6 +202,19 @@ mmap_f(
 		case 'x':
 			prot |= PROT_EXEC;
 			break;
+		case 'S':
+			flags = MAP_SYNC | MAP_SHARED_VALIDATE;
+
+			/*
+			 * If MAP_SYNC and MAP_SHARED_VALIDATE aren't defined
+			 * in the system headers we will have defined them
+			 * both as 0.
+			 */
+			if (!flags) {
+				printf("MAP_SYNC not supported\n");
+				return 0;
+			}
+			break;
 		case 's':
 			length2 = cvtnum(blocksize, sectsize, optarg);
 			break;
@@ -240,7 +258,7 @@ mmap_f(
 		               MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 		munmap(address, length2);
 	}
-	address = mmap(address, length, prot, MAP_SHARED, file->fd, offset);
+	address = mmap(address, length, prot, flags, file->fd, offset);
 	if (address == MAP_FAILED) {
 		perror("mmap");
 		free(filename);
@@ -265,6 +283,7 @@ mmap_f(
 	mapping->offset = offset;
 	mapping->name = filename;
 	mapping->prot = prot;
+	mapping->map_sync = (flags == (MAP_SYNC | MAP_SHARED_VALIDATE));
 	exitcode = 0;
 	return 0;
 }
@@ -691,7 +710,7 @@ mmap_init(void)
 	mmap_cmd.argmax = -1;
 	mmap_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK |
 			 CMD_FOREIGN_OK | CMD_FLAG_ONESHOT;
-	mmap_cmd.args = _("[N] | [-rwx] [-s size] [off len]");
+	mmap_cmd.args = _("[N] | [-rwxS] [-s size] [off len]");
 	mmap_cmd.oneline =
 		_("mmap a range in the current file, show mappings");
 	mmap_cmd.help = mmap_help;
m4/package_libcdev.m4 +16 -0
index 7b4dfc85..71cedc5c 100644
@@ -328,3 +328,19 @@ AC_DEFUN([AC_HAVE_STATFS_FLAGS],
     )
     AC_SUBST(have_statfs_flags)
   ])
+
+#
+# Check if we have MAP_SYNC defines (Linux)
+#
+AC_DEFUN([AC_HAVE_MAP_SYNC],
+  [ AC_MSG_CHECKING([for MAP_SYNC])
+    AC_TRY_COMPILE([
+#include <asm-generic/mman.h>
+#include <asm-generic/mman-common.h>
+    ], [
+        int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
+    ], have_map_sync=yes
+	AC_MSG_RESULT(yes),
+	AC_MSG_RESULT(no))
+    AC_SUBST(have_map_sync)
+  ])
man/man8/xfs_io.8 +5 -1
index 9bf1a478..1693f7f1 100644
@@ -764,7 +764,7 @@ Each (sec, nsec) pair constitutes a single timestamp value.
 
 .SH MEMORY MAPPED I/O COMMANDS
 .TP
-.BI "mmap [ " N " | [[ \-rwx ] [\-s " size " ] " "offset length " ]]
+.BI "mmap [ " N " | [[ \-rwxS ] [\-s " size " ] " "offset length " ]]
 With no arguments,
 .B mmap
 shows the current mappings. Specifying a single numeric argument
@@ -780,6 +780,10 @@ PROT_WRITE
 .RB ( \-w ),
 and PROT_EXEC
 .RB ( \-x ).
+The mapping will be created with the MAP_SHARED flag by default, or with the
+Linux specific (MAP_SYNC | MAP_SHARED_VALIDATE) flags if
+.B -S
+is given.
 .BI \-s " size"
 is used to do a mmap(size) && munmap(size) operation at first, try to reserve some
 extendible free memory space, if
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#3 lore raw

PATCH v4 2/2 xfs_io: add a new 'log_writes' command

In reply to Ross Zwisler

Add a new 'log_writes' command to xfs_io so that we can add dm-log-writes log marks. It's helpful to allow users of xfs_io to adds these marks from within xfs_io instead of waiting until after xfs_io exits because then they are able to replay the dm-log-writes log up to immediately after another xfs_io operation such as mwrite. This isolates the log replay from other operations that happen as part of xfs_io exiting (file handles being closed, mmaps being torn down, etc.). This also allows users to insert multiple marks between different xfs_io commands.

---
 configure.ac            |   1 +
 debian/control          |   2 +-
 include/builddefs.in    |   2 +
 io/Makefile             |   6 +++
 io/init.c               |   1 +
 io/io.h                 |   6 +++
 io/log_writes.c         | 106 ++++++++++++++++++++++++++++++++++++++++++++++++
 m4/Makefile             |   1 +
 m4/package_devmapper.m4 |  11 +++++
 man/man8/xfs_io.8       |  23 ++++++++++-
 10 files changed, 157 insertions(+), 2 deletions(-)
 create mode 100644 io/log_writes.c
 create mode 100644 m4/package_devmapper.m4
configure.ac +1 -0
index f3325aa0..f83d5817 100644
@@ -164,6 +164,7 @@ AC_NEED_INTERNAL_FSXATTR
 AC_HAVE_GETFSMAP
 AC_HAVE_STATFS_FLAGS
 AC_HAVE_MAP_SYNC
+AC_HAVE_DEVMAPPER
 
 if test "$enable_blkid" = yes; then
 AC_HAVE_BLKID_TOPO
debian/control +1 -1
index ad816622..5c26e3d7 100644
@@ -3,7 +3,7 @@ Section: admin
 Priority: optional
 Maintainer: XFS Development Team <[email protected]>
 Uploaders: Nathan Scott <[email protected]>, Anibal Monsalve Salazar <[email protected]>
-Build-Depends: uuid-dev, dh-autoreconf, debhelper (>= 5), gettext, libtool, libreadline-gplv2-dev | libreadline5-dev, libblkid-dev (>= 2.17), linux-libc-dev
+Build-Depends: uuid-dev, dh-autoreconf, debhelper (>= 5), gettext, libtool, libreadline-gplv2-dev | libreadline5-dev, libblkid-dev (>= 2.17), linux-libc-dev, libdevmapper-dev
 Standards-Version: 3.9.1
 Homepage: http://xfs.org/
 
include/builddefs.in +2 -0
index 126f7e95..66bdbfa2 100644
@@ -35,6 +35,7 @@ LIBTERMCAP = @libtermcap@
 LIBEDITLINE = @libeditline@
 LIBREADLINE = @libreadline@
 LIBBLKID = @libblkid@
+LIBDEVMAPPER = @libdevmapper@
 LIBXFS = $(TOPDIR)/libxfs/libxfs.la
 LIBXCMD = $(TOPDIR)/libxcmd/libxcmd.la
 LIBXLOG = $(TOPDIR)/libxlog/libxlog.la
@@ -116,6 +117,7 @@ NEED_INTERNAL_FSXATTR = @need_internal_fsxattr@
 HAVE_GETFSMAP = @have_getfsmap@
 HAVE_STATFS_FLAGS = @have_statfs_flags@
 HAVE_MAP_SYNC = @have_map_sync@
+HAVE_DEVMAPPER = @have_devmapper@
 
 GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
io/Makefile +6 -0
index 2987ee11..b7585a1b 100644
@@ -107,6 +107,12 @@ ifeq ($(HAVE_MAP_SYNC),yes)
 LCFLAGS += -DHAVE_MAP_SYNC
 endif
 
+ifeq ($(HAVE_DEVMAPPER),yes)
+CFILES += log_writes.c
+LLDLIBS += $(LIBDEVMAPPER)
+LCFLAGS += -DHAVE_DEVMAPPER
+endif
+
 # On linux we get fsmap from the system or define it ourselves
 # so include this based on platform type.  If this reverts to only
 # the autoconf check w/o local definition, change to testing HAVE_GETFSMAP
io/init.c +1 -0
index 20d5f80d..34d87b5f 100644
@@ -72,6 +72,7 @@ init_commands(void)
 	help_init();
 	imap_init();
 	inject_init();
+	log_writes_init();
 	madvise_init();
 	mincore_init();
 	mmap_init();
io/io.h +6 -0
index 8b2753b3..9349cc75 100644
@@ -186,3 +186,9 @@ extern void		fsmap_init(void);
 #else
 # define fsmap_init()	do { } while (0)
 #endif
+
+#ifdef HAVE_DEVMAPPER
+extern void		log_writes_init(void);
+#else
+#define log_writes_init()	do { } while (0)
+#endif
io/log_writes.c new file +106 -0

106 lines not on this page · raw message

m4/Makefile +1 -0
index 4706121b..77f2edda 100644
@@ -15,6 +15,7 @@ CONFIGURE = \
 LSRCFILES = \
 	manual_format.m4 \
 	package_blkid.m4 \
+	package_devmapper.m4 \
 	package_globals.m4 \
 	package_libcdev.m4 \
 	package_pthread.m4 \
m4/package_devmapper.m4 new file +11 -0
new file mode 100644
index 00000000..821f283c
@@ -0,0 +1,11 @@
+#
+# See if libdevmapper is available on the system.
+#
+AC_DEFUN([AC_HAVE_DEVMAPPER],
+[ AC_SEARCH_LIBS([dm_task_create], [devmapper],
+        libdevmapper="-ldevmapper"
+        have_devmapper=yes,
+        have_devmapper=no,)
+    AC_SUBST(have_devmapper)
+    AC_SUBST(libdevmapper)
+])
man/man8/xfs_io.8 +22 -1
index 1693f7f1..4fce6d39 100644
@@ -1123,7 +1123,27 @@ version of policy structure (numeric)
 .BR get_encpolicy
 On filesystems that support encryption, display the encryption policy of the
 current file.
+.RE
+.PD
+.TP
+.BI "log_writes \-d " device " \-m "  mark
+Create a mark named
+.I mark
+in the dm-log-writes log specified by
+.I device.
+This is intended to be equivalent to the shell command:
 
+.B dmsetup message
+.I device
+.B 0 mark
+.I mark
+.PD
+.RE
+.TP
+.B lw
+See the
+.B log_writes
+command.
 .SH SEE ALSO
 .BR mkfs.xfs (8),
 .BR xfsctl (3),
@@ -1141,4 +1161,5 @@ current file.
 .BR open (2),
 .BR pread (2),
 .BR pwrite (2),
-.BR readdir (3).
+.BR readdir (3),
+.BR dmsetup (8).
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Reviewed-by on v4 1/2
#2 lore raw

Re: [xfsprogs PATCH v4 1/2] xfs_io: add MAP_SYNC support to mmap()

In reply to Ross Zwisler
Quoted 6 lines · Ross Zwisler

Add support for a new -S flag to xfs_io's mmap command. This opens the mapping with the (MAP_SYNC | MAP_SHARED_VALIDATE) flags instead of the standard MAP_SHARED flag.

Looks ok,

Quoted 230 lines
---
 configure.ac          |  1 +
 include/builddefs.in  |  1 +
 include/linux.h       |  8 ++++++++
 io/Makefile           |  4 ++++
 io/io.h               |  1 +
 io/mmap.c             | 29 ++++++++++++++++++++++++-----
 m4/package_libcdev.m4 | 16 ++++++++++++++++
 man/man8/xfs_io.8     |  6 +++++-
 8 files changed, 60 insertions(+), 6 deletions(-)
configure.ac +1 -0
index e5d0309f..f3325aa0 100644
@@ -163,6 +163,7 @@ AC_HAVE_MREMAP
 AC_NEED_INTERNAL_FSXATTR
 AC_HAVE_GETFSMAP
 AC_HAVE_STATFS_FLAGS
+AC_HAVE_MAP_SYNC
 
 if test "$enable_blkid" = yes; then
 AC_HAVE_BLKID_TOPO
include/builddefs.in +1 -0
index fd274ddc..126f7e95 100644
@@ -115,6 +115,7 @@ HAVE_MREMAP = @have_mremap@
 NEED_INTERNAL_FSXATTR = @need_internal_fsxattr@
 HAVE_GETFSMAP = @have_getfsmap@
 HAVE_STATFS_FLAGS = @have_statfs_flags@
+HAVE_MAP_SYNC = @have_map_sync@
 
 GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
include/linux.h +8 -0
index 6ce344c5..1998941a 100644
@@ -327,4 +327,12 @@ fsmap_advance(
 #define HAVE_GETFSMAP
 #endif /* HAVE_GETFSMAP */
 
+#ifndef HAVE_MAP_SYNC
+#define MAP_SYNC 0
+#define MAP_SHARED_VALIDATE 0
+#else
+#include <asm-generic/mman.h>
+#include <asm-generic/mman-common.h>
+#endif /* HAVE_MAP_SYNC */
+
 #endif	/* __XFS_LINUX_H__ */
io/Makefile +4 -0
index 6725936d..2987ee11 100644
@@ -103,6 +103,10 @@ ifeq ($(HAVE_MREMAP),yes)
 LCFLAGS += -DHAVE_MREMAP
 endif
 
+ifeq ($(HAVE_MAP_SYNC),yes)
+LCFLAGS += -DHAVE_MAP_SYNC
+endif
+
 # On linux we get fsmap from the system or define it ourselves
 # so include this based on platform type.  If this reverts to only
 # the autoconf check w/o local definition, change to testing HAVE_GETFSMAP
io/io.h +1 -0
index 3862985f..8b2753b3 100644
@@ -65,6 +65,7 @@ typedef struct mmap_region {
 	size_t		length;		/* length of mapping */
 	off64_t		offset;		/* start offset into backing file */
 	int		prot;		/* protection mode of the mapping */
+	bool		map_sync;	/* is this a MAP_SYNC mapping? */
 	char		*name;		/* name of backing file */
 } mmap_region_t;
 
io/mmap.c +24 -5
index b0c1f764..04a828a4 100644
@@ -42,7 +42,7 @@ print_mapping(
 	int		index,
 	int		braces)
 {
-	unsigned char	buffer[8] = { 0 };
+	char		buffer[8] = { 0 };
 	int		i;
 
 	static struct {
@@ -57,6 +57,10 @@ print_mapping(
 
 	for (i = 0, p = pflags; p->prot != PROT_NONE; i++, p++)
 		buffer[i] = (map->prot & p->prot) ? p->mode : '-';
+
+	if (map->map_sync)
+		sprintf(&buffer[i], " S");
+
 	printf("%c%03d%c 0x%lx - 0x%lx %s  %14s (%lld : %ld)\n",
 		braces? '[' : ' ', index, braces? ']' : ' ',
 		(unsigned long)map->addr,
@@ -147,6 +151,7 @@ mmap_help(void)
 " -r -- map with PROT_READ protection\n"
 " -w -- map with PROT_WRITE protection\n"
 " -x -- map with PROT_EXEC protection\n"
+" -S -- map with MAP_SYNC and MAP_SHARED_VALIDATE flags\n"
 " -s <size> -- first do mmap(size)/munmap(size), try to reserve some free space\n"
 " If no protection mode is specified, all are used by default.\n"
 "\n"));
@@ -162,7 +167,7 @@ mmap_f(
 	void		*address = NULL;
 	char		*filename;
 	size_t		blocksize, sectsize;
-	int		c, prot = 0;
+	int		c, prot = 0, flags = MAP_SHARED;
 
 	exitcode = 1;
 	if (argc == 1) {
@@ -186,7 +191,7 @@ mmap_f(
 
 	init_cvtnum(&blocksize, &sectsize);
 
-	while ((c = getopt(argc, argv, "rwxs:")) != EOF) {
+	while ((c = getopt(argc, argv, "rwxSs:")) != EOF) {
 		switch (c) {
 		case 'r':
 			prot |= PROT_READ;
@@ -197,6 +202,19 @@ mmap_f(
 		case 'x':
 			prot |= PROT_EXEC;
 			break;
+		case 'S':
+			flags = MAP_SYNC | MAP_SHARED_VALIDATE;
+
+			/*
+			 * If MAP_SYNC and MAP_SHARED_VALIDATE aren't defined
+			 * in the system headers we will have defined them
+			 * both as 0.
+			 */
+			if (!flags) {
+				printf("MAP_SYNC not supported\n");
+				return 0;
+			}
+			break;
 		case 's':
 			length2 = cvtnum(blocksize, sectsize, optarg);
 			break;
@@ -240,7 +258,7 @@ mmap_f(
 		               MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 		munmap(address, length2);
 	}
-	address = mmap(address, length, prot, MAP_SHARED, file->fd, offset);
+	address = mmap(address, length, prot, flags, file->fd, offset);
 	if (address == MAP_FAILED) {
 		perror("mmap");
 		free(filename);
@@ -265,6 +283,7 @@ mmap_f(
 	mapping->offset = offset;
 	mapping->name = filename;
 	mapping->prot = prot;
+	mapping->map_sync = (flags == (MAP_SYNC | MAP_SHARED_VALIDATE));
 	exitcode = 0;
 	return 0;
 }
@@ -691,7 +710,7 @@ mmap_init(void)
 	mmap_cmd.argmax = -1;
 	mmap_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK |
 			 CMD_FOREIGN_OK | CMD_FLAG_ONESHOT;
-	mmap_cmd.args = _("[N] | [-rwx] [-s size] [off len]");
+	mmap_cmd.args = _("[N] | [-rwxS] [-s size] [off len]");
 	mmap_cmd.oneline =
 		_("mmap a range in the current file, show mappings");
 	mmap_cmd.help = mmap_help;
m4/package_libcdev.m4 +16 -0
index 7b4dfc85..71cedc5c 100644
@@ -328,3 +328,19 @@ AC_DEFUN([AC_HAVE_STATFS_FLAGS],
     )
     AC_SUBST(have_statfs_flags)
   ])
+
+#
+# Check if we have MAP_SYNC defines (Linux)
+#
+AC_DEFUN([AC_HAVE_MAP_SYNC],
+  [ AC_MSG_CHECKING([for MAP_SYNC])
+    AC_TRY_COMPILE([
+#include <asm-generic/mman.h>
+#include <asm-generic/mman-common.h>
+    ], [
+        int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
+    ], have_map_sync=yes
+	AC_MSG_RESULT(yes),
+	AC_MSG_RESULT(no))
+    AC_SUBST(have_map_sync)
+  ])
man/man8/xfs_io.8 +5 -1
index 9bf1a478..1693f7f1 100644
@@ -764,7 +764,7 @@ Each (sec, nsec) pair constitutes a single timestamp value.
 
 .SH MEMORY MAPPED I/O COMMANDS
 .TP
-.BI "mmap [ " N " | [[ \-rwx ] [\-s " size " ] " "offset length " ]]
+.BI "mmap [ " N " | [[ \-rwxS ] [\-s " size " ] " "offset length " ]]
 With no arguments,
 .B mmap
 shows the current mappings. Specifying a single numeric argument
@@ -780,6 +780,10 @@ PROT_WRITE
 .RB ( \-w ),
 and PROT_EXEC
 .RB ( \-x ).
+The mapping will be created with the MAP_SHARED flag by default, or with the
+Linux specific (MAP_SYNC | MAP_SHARED_VALIDATE) flags if
+.B -S
+is given.
 .BI \-s " size"
 is used to do a mmap(size) && munmap(size) operation at first, try to reserve some
 extendible free memory space, if
Signature · 6 lines
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm