On Wed, 18 Aug 2010 13:32:03 -0400 "J. Bruce Fields" <bfields@xxxxxxxxxxxx> wrote: > On Wed, Aug 18, 2010 at 03:53:59PM +1000, Neil Brown wrote: > > I'm not sure you even want to pay for a per-filesystem atomic access when > > updating mtime. mnt_want_write - called at the same time - seems to go to > > some lengths to avoid an atomic operation. > > > > I think that nfsd should be the only place that has to pay the atomic > > penalty, as it is where the need is. > > > > I imagine something like this: > > - Create a global struct timespec which is protected by a seqlock > > Call it current_nfsd_time or similar. > > - file_update_time reads this and uses it if it is newer than > > current_fs_time. > > - nfsd updates it whenever it reads an mtime out of an inode that matches > > current_fs_time to the granularity of 1/HZ. > > We can also skip the update whenever current_nfsd_time is greater than > the inode's mtime--that's enough to ensure that the next > file_update_time() call will get a time different from the inode's > current mtime. Yes, I agree with you and Patrick - very sensible optimisation. > > Would the extra expense rule out treating sys_stat() the same as nfsd? > It would be nice to be able to solve the same problem for userspace > nfsd's (or any other application that might be using mtime to save > rereading data). It would be nice, but I would be loathe to add any cost to 'stat' unless we knew it was needed. If we had an xstat() which could explicitly ask for high-precision-time-stamps, then yes - otherwise maybe not. (or maybe define a system:linux.xxxx xattr which would read as a high-precision time stamp... I seem to be warming to the idea of using the xattr interface for enhancing stat). NeilBrown -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html