public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* 2.4.18 no timestamp update on modified mmapped files
@ 2002-06-11  5:33 Keith Owens
  2002-06-11  6:17 ` Andrew Morton
  0 siblings, 1 reply; 25+ messages in thread
From: Keith Owens @ 2002-06-11  5:33 UTC (permalink / raw)
  To: linux-kernel

fd = open("foo", O_RDWR);
map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
... modify the mapped pages ...
munmap(map, size);
close(fd);

The timestamp on foo is not updated, even though the contents have
changed.  Adding msync(map, size, MS_[A]SYNC) before munmap makes no
difference.  2.4.19-pre10 has no obvious fixes for this problem.

I was tearing my hair out wondering why some files were not being
rsynced.  No change on size or timestamp tells rsync that the file is
"unchanged".  I had to add a dummy write(map, fd, 1) to force a
timestamp update.


^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: 2.4.18 no timestamp update on modified mmapped files
@ 2002-06-15  5:24 Kevin Easton
  2002-06-15  8:10 ` Hugh Dickins
  0 siblings, 1 reply; 25+ messages in thread
From: Kevin Easton @ 2002-06-15  5:24 UTC (permalink / raw)
  To: hugh; +Cc: linux-kernel


> On Wed, 12 Jun 2002, Andrew Morton wrote: 
> > 
> > A more serious form of data loss occurs when an application has a shared 
> > mapping over a sparse file. If the filesystem is out of space when 
> > the VM decides to write back some pages, your data simply gets dropped 
> > on the floor. Even a subsequent msync() won't tell you that you have 
> > a shiny new bunch of zeroes in your file. 
> > 
> > It's not simple to fix. Approaches might be: 
> > 
> > 1: Map the page to disk at fault time, generate SIGBUS on 
> > ENOSPC (the standards don't seem to address this issue, and 
> > this is a non-standard overload of SIGBUS). 
> 
> 
> I've looked at this issue in the past: it's a familiar problem 
> for various filesystems on various flavours of UNIX. Some of the 
> strangeness in tmpfs (shmem_recalc_inode, or ac's shmem_removepage) 
> can be traced to this issue, I believe. The filesystem does not 
> know when a clean page is dirtied, and somehow has to cope afterwards. 
> 
> 
> I believe your option 1 is closest to the right direction; and SIGBUS 
> is entirely appropriate, I don't see it as a non-standard overload. 
> 
> 
> But you didn't spell out the worst news on that option: read faults 
> into a read-only shared mapping of a file which the application had 
> open for read-write when it mmapped: the page must be mapped to disk 
> at read fault time (because the mapping just might be mprotected for 
> read-write later on, and the page then dirtied). 
> 

Can't the page be mapped to disk at the page-dirtying-fault time? I 
was under the impression that even after the mapping has been mprotected
for read-write, the first write to each page will still cause a page
fault that results in the page being marked dirty.

	- Kevin.


^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: 2.4.18 no timestamp update on modified mmapped files
@ 2002-06-16  4:35 Kevin Easton
  2002-06-16 16:35 ` Hugh Dickins
  0 siblings, 1 reply; 25+ messages in thread
From: Kevin Easton @ 2002-06-16  4:35 UTC (permalink / raw)
  To: hugh; +Cc: linux-kernel, rmk


On Sat, 15 Jun 2002, Hugh Dickins wrote:
> On Sat, 15 Jun 2002, Russell King wrote:
> > On Sat, Jun 15, 2002 at 07:12:30PM +1000, Kevin Easton wrote:
> > > Hmm.. so how do such pages get marked dirty on architectures that don't
> > > do it in hardware ("most RISC architectures" according to a comment in
> > > memory.c)? Is the entire mapping made dirty when the write permissions
> > > are added?
> > 
> > No.  You only give user space write access when the write access _and_
> > "Linux dirty bit" are set.  This means you fault when user space tries
> > to write to the page, which means you can set the dirty bit.  This is
> > what the following code is doing (if write_access is required and the
> > pte already has write permission, then set the dirty bit):
> > 
> >         if (write_access) {
> >                 if (!pte_write(entry))
> >                         return do_wp_page(mm, vma, address, pte, pmd, entry);
> > 
> >                 entry = pte_mkdirty(entry);
> > }
> 
> Thanks, Russell.  Sorry, Kevin: I wasn't even thinking about
> non-i86 cases, add that to the list of disclaimers I put in.
> 
> Hugh

So... the difference on i386 is just the definitions of the protection_map
entries that are used.. specifically that PAGE_SHARED in asm-i386/pgtable.h
includes _PAGE_RW? Changing this definition to be the same as the PAGE_COPY
definition would be one fix?

	- Kevin.


^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: 2.4.18 no timestamp update on modified mmapped files
@ 2002-06-19 17:57 Randy.Dunlap
  0 siblings, 0 replies; 25+ messages in thread
From: Randy.Dunlap @ 2002-06-19 17:57 UTC (permalink / raw)
  To: linux-kernel

n Tue, 2002-06-11 at 00:28, Andrew Morton wrote:

> That'll be a left-brain/write-brain thing.

Illegal instruction!

I hope everyone else saw this and just refrained from comment.  Thanks
for making my morning ;-)

        Robert Love
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

or as Douglas Hofstadter would say
(as I found while re-reading "GEB" last weekend):
	"left brain/right mind"

-- 
~Randy


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2002-06-19 18:02 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-11  5:33 2.4.18 no timestamp update on modified mmapped files Keith Owens
2002-06-11  6:17 ` Andrew Morton
2002-06-11  6:29   ` Keith Owens
2002-06-11  6:49     ` Andrew Morton
2002-06-11  7:07       ` Keith Owens
2002-06-11  7:28         ` Andrew Morton
2002-06-11  9:10           ` Hugh Dickins
2002-06-11  9:33             ` Andrew Morton
2002-06-11  9:51               ` Hugh Dickins
2002-06-12  7:40             ` Alan Cox
2002-06-12  7:56               ` Andrew Morton
2002-06-12 14:52                 ` Hugh Dickins
2002-06-13  2:25                   ` jw schultz
2002-06-13  9:58                     ` Hugh Dickins
2002-06-13 10:40                       ` jw schultz
2002-06-11 18:09           ` Robert Love
2002-06-12 17:17           ` Pavel Machek
2002-06-11  6:39   ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2002-06-15  5:24 Kevin Easton
2002-06-15  8:10 ` Hugh Dickins
2002-06-15  9:12   ` Kevin Easton
2002-06-15  9:23     ` Russell King
2002-06-16  4:35 Kevin Easton
2002-06-16 16:35 ` Hugh Dickins
2002-06-19 17:57 Randy.Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox