]> git.hungrycats.org Git - linux/commitdiff
nfsd: update mtime on truncate
authorChristoph Hellwig <hch@lst.de>
Sun, 7 Sep 2014 19:15:52 +0000 (12:15 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 5 Jun 2017 20:17:11 +0000 (21:17 +0100)
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 <hch@lst.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/nfsd/vfs.c

index 521f717b4a99215393412a287494f2ae368962ac..3137a98233ab18fcbef0f7a2246b8b84dc29a7fb 100644 (file)
@@ -448,6 +448,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;