Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Nov 2014 10:07:20 +1000
From:      Paul Koch <paul.koch137@gmail.com>
To:        freebsd-stable@freebsd.org
Subject:   Re: 10.1 mmap on zfs not updating mtime
Message-ID:  <20141130100720.5b0bead7@splash.akips.com>
In-Reply-To: <20141125142302.1199041c@akips.com>
References:  <20141125142302.1199041c@akips.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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@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.



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