Re: [patch resend v4] update ctime and mtime for mmaped write

From: Miklos Szeredi
Date: Tue Mar 27 2007 - 03:37:37 EST


> > > 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.

Yes, but then the "modified through mmap" is transferred to the
per-address_space flag. All this is already done by this patch.

> 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.

No, I'm just arguing that your suggestion is actually a complication,
not a simplification ;)

> > 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().

Yes. But that's not very useful semantic for MS_ASYNC vs. file time
update.

It would basically say:

"if you cann MS_ASYNC, and the file was modified then sometime in
the future you will get an updated c/mtime".

But this is not what POSIX says, and it's not what applications want.

For example "make" would want to know if a file was modified or not,
and with your suggestion only msync(MS_SYNC) would reliably provide
that info. But msync(MS_SYNC) is unnecessary in many cases.

> There is surely no need to duplicate all that.

Yeah, we could teach generic_writepages() to conditionally not submit
for io just test/clear pte dirtyness.

Maybe that would be somewhat cleaner, dunno.

Then there are the ram backed filesystems, which don't have dirty
accounting and radix trees, and for which this pte walking is still
needed to provide semantics consistent with normal filesystems.

Miklos
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/