Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Nov 2014 14:23:02 +1000
From:      Paul Koch <paul.koch@akips.com>
To:        freebsd-stable@freebsd.org
Subject:   10.1 mmap on zfs not updating mtime
Message-ID:  <20141125142302.1199041c@akips.com>

next in thread | raw e-mail | index | archive | help

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.
-- 
Paul Koch | Founder, CEO
AKIPS Network Monitor
http://www.akips.com
Brisbane, Australia



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