lkml.org 
[lkml]   [2006]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patches in this message
/
Date
From
Subject[PATCH] NFS server does not update mtime on setattr request
Hi.

Attached aer two patches to address two halves of a problem where NFS does
not update the mtime when an existing file is opened with O_TRUNC. The
mtime does not get updated when the file is already zero length, although
it should.

On the NFS client side, there was an optimization added which attempted
to avoid an over the wire call if the size of the file was not going to
change. This would be great, except for the side effect of the mtime
on the file needing to change anyway. The solution is just to issue the
over the wire call anyway, which, as a side effect, updates the mtime and
ctime fields.

On the NFS server side, there was a change to the routine, inode_setattr(),
which now relies upon the caller to set the ATTR_MTIME and ATTR_CTIME
flags in ia_valid in addition to the ATTR_SIZE. Previously, this routine
would force these bits on if the size of the file was not changing. Now,
this routine relies upon the caller to specify all of the fields which need
to be updated.

Comments?

Thanx...

ps

Signed-off-by: Peter Staubach <staubach@redhat.com>
--- linux-2.6.16.x86_64/fs/nfs/inode.c.org
+++ linux-2.6.16.x86_64/fs/nfs/inode.c
@@ -947,11 +947,6 @@ nfs_setattr(struct dentry *dentry, struc

nfs_inc_stats(inode, NFSIOS_VFSSETATTR);

- if (attr->ia_valid & ATTR_SIZE) {
- if (!S_ISREG(inode->i_mode) || attr->ia_size == i_size_read(inode))
- attr->ia_valid &= ~ATTR_SIZE;
- }
-
/* Optimization: if the end result is no change, don't RPC */
attr->ia_valid &= NFS_VALID_ATTRS;
if (attr->ia_valid == 0)--- linux-2.6.16.x86_64/fs/nfsd/vfs.c.org
+++ linux-2.6.16.x86_64/fs/nfsd/vfs.c
@@ -327,6 +327,11 @@ nfsd_setattr(struct svc_rqst *rqstp, str
goto out_nfserr;
}
DQUOT_INIT(inode);
+ /*
+ * Make sure that the mtime changes even if the file
+ * size doesn't actually change.
+ */
+ iap->ia_valid |= ATTR_MTIME | ATTR_CTIME;
}

imode = inode->i_mode;
\
 
 \ /
  Last update: 2006-06-06 20:08    [W:0.069 / U:9.972 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site