From: Christoph Hellwig Date: Sun, 7 Sep 2014 19:15:52 +0000 (-0700) Subject: nfsd: update mtime on truncate X-Git-Tag: v3.2.89~48 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=commitdiff_plain;h=62138927a56551fe5f3bb675e3e78709e396296e;ds=sidebyside nfsd: update mtime on truncate commit f0c63124a6165792f6e37e4b5983792d009e1ce8 upstream. This fixes a failure in xfstests generic/313 because nfs doesn't update mtime on a truncate. The protocol requires this to be done implicity for a size changing setattr. Signed-off-by: Christoph Hellwig Signed-off-by: J. Bruce Fields Signed-off-by: Ben Hutchings --- diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 855e3f80e4e1..babe7f998da4 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -450,6 +450,16 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, if (err) goto out; size_change = 1; + + /* + * RFC5661, Section 18.30.4: + * Changing the size of a file with SETATTR indirectly + * changes the time_modify and change attributes. + * + * (and similar for the older RFCs) + */ + if (iap->ia_size != i_size_read(inode)) + iap->ia_valid |= ATTR_MTIME; } iap->ia_valid |= ATTR_CTIME;