public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NFS server does not update mtime on setattr request
@ 2006-06-06 18:05 Peter Staubach
  2006-06-07  5:38 ` Trond Myklebust
  0 siblings, 1 reply; 15+ messages in thread
From: Peter Staubach @ 2006-06-06 18:05 UTC (permalink / raw)
  To: Trond Myklebust, Neil Brown; +Cc: NFS List, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 1088 bytes --]

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>

[-- Attachment #2: nfs_client_mtime.devel --]
[-- Type: text/plain, Size: 466 bytes --]

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

[-- Attachment #3: nfs_server_mtime.devel --]
[-- Type: text/plain, Size: 371 bytes --]

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2006-06-09 13:10 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-06 18:05 [PATCH] NFS server does not update mtime on setattr request Peter Staubach
2006-06-07  5:38 ` Trond Myklebust
2006-06-07 14:44   ` Peter Staubach
2006-06-07 15:17     ` [NFS] " J. Bruce Fields
2006-06-07 15:26       ` Peter Staubach
2006-06-07 15:39         ` Trond Myklebust
2006-06-07 15:44           ` Peter Staubach
2006-06-07 17:17             ` Trond Myklebust
2006-06-07 17:41               ` Peter Staubach
2006-06-07 15:42         ` J. Bruce Fields
2006-06-07 15:50           ` Peter Staubach
2006-06-07 16:03             ` J. Bruce Fields
2006-06-07 16:56               ` Peter Staubach
2006-06-09  0:40     ` Neil Brown
2006-06-09 13:10       ` Peter Staubach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox