[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20070326232214.ee92d8c4.akpm@linux-foundation.org>
Date: Mon, 26 Mar 2007 23:22:14 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Miklos Szeredi <miklos@...redi.hu>
Cc: a.p.zijlstra@...llo.nl, linux-kernel@...r.kernel.org,
linux-mm@...ck.org
Subject: Re: [patch resend v4] update ctime and mtime for mmaped write
On Tue, 27 Mar 2007 08:55:40 +0200 Miklos Szeredi <miklos@...redi.hu> wrote:
> > > > > This patch makes writing to shared memory mappings update st_ctime and
> > > > > st_mtime as defined by SUSv3:
> > > >
> > > > Boy this is complicated.
> > >
> > > You tell me?
> > >
> > > > Is there a simpler way of doing all this? Say, we define a new page flag
> > > > PG_dirtiedbywrite and we do SetPageDirtiedByWrite() inside write() and
> > > > ClearPageDirtiedByWrite() whenever we propagate pte-dirtiness into
> > > > page-dirtiness. Then, when performing writeback we look to see if any of
> > > > the dirty pages are !PageDirtiedByWrite() and, if so, we update [mc]time to
> > > > current-time.
> > >
> > > I don't think a page flag gains anything over the address_space flag
> > > that this patch already has.
> > >
> > > The complexity is not about keeping track of the "data modified
> > > through mmap" state, but about msync() guarantees, that POSIX wants.
> > >
> > > And these requirements do in fact make some sense: msync() basically
> > > means:
> > >
> > > "I want the data written through mmaps to be visible to the world"
> > >
> > > And that obviously includes updating the timestamps.
> > >
> > > So how do we know if the data was modified between two msync()
> > > invocations? The only sane way I can think of is to walk the page
> > > tables in msync() and test/clear the pte dirty bit.
> >
> > clear_page_dirty_for_io() already does that.
> >
> > So we should be able to test PageDirtiedByWrite() after running
> > clear_page_dirty_for_io() to discover whether this page was dirtied via
> > MAP_SHARED, and then update the inode times if so.
>
> What do you need the page flag for?
To work out whether the page was dirtied via write (in which case the
timestamps were updated) or via mmap (in which case they were not).
> The "modified through mmap" info
> is there in the ptes.
It might not be there any more - the ptes could have got taken down by, for
example, reclaim.
I dunno - I'm not trying very hard. I'm trying to encourage you to come up
with something less costly and less complex than this thing, but you appear
to be resisting.
> And from the ptes it can be transfered to a
> per-address_space flag. Nobody is interested through which page was
> the file modified.
>
> Anyway, that's just MS_SYNC. MS_ASYNC doesn't walk the pages, yet it
> should update the timestamp. That's the difficult one.
>
We can treat MS_ASYNC as we treat MS_SYNC. Then, MS_ASYNC *does* walk the
pages. Is does it in generic_writepages(). It also even walks the ptes
for you, in clear_page_dirty_for_io().
There is surely no need to duplicate all that.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists