10.1 mmap on zfs not updating mtime

Paul Koch paul.koch137 at gmail.com
Sun Nov 30 00:08:04 UTC 2014


Can probably ignore this.  We changed our application so it always calls
futimes() on the file descriptor after a fsync() or munmap().

	Paul.

On Tue, 25 Nov 2014 14:23:02 +1000
Paul Koch <paul.koch at akips.com> wrote:

> 
> Hi,
> 
> we have observed some odd behaviour with the mtime of a mmap'ed file
> when it has been updated on a zfs pool.  The mtime does not appear to
> be updated.  Seems to work ok on UFS.
> 
> Test program below...
> 
> On 10.0, the following works ok:
> 
>  dd bs=1k if=/dev/zero of=mdata count=1
>  ls -lT mdata; /tmp/mmap-mtime mdata; ls -lT mdata
> 
> but on 10.1 the mtime stays at its creation time.
> 
> 
> 
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <sys/mman.h>
> 
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <string.h>
> #include <errno.h>
> 
> 
> int
> main (int argc, char **argv)
> {
>    int   fd,
>          i;
>    char *data,
>         *filename;
>    struct stat s;
> 
>    if (argc != 2)
>       exit (1);
> 
>    filename =argv[1];
> 
>    if (stat (filename, &s) != 0) {
>       fprintf (stderr, "stat: %s\n", strerror (errno));
>       exit (1);
>    }
>    else if ((fd = open (filename, O_RDWR, 0644)) == -1) {
>       fprintf (stderr, "open: %s\n", strerror (errno));
>       exit (1);
>    }
>    else if ((data = mmap (NULL, (size_t) s.st_size, 
>                           PROT_READ | PROT_WRITE, 
>                           MAP_SHARED,
>                           fd, (off_t) 0)) == MAP_FAILED) {
>       fprintf (stderr, "mmap: %s\n", strerror (errno));
>       exit (1);
>    }
> 
>    for (i = 0; i < s.st_size; i++) {
>       data[i] = 1;
>    }
> 
>    munmap (data, s.st_size);
>    close (fd);
> 
>    exit (0);
> }
> 
> 	Paul.


More information about the freebsd-stable mailing list