Messages in this thread Patches in this message | | | Date | Tue, 06 Jun 2006 14:05:50 -0400 | From | Peter Staubach <> | 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; | |