Skip to contentSkip to conversation

nfsd: update mtime on truncate

PATCH In review Christoph Hellwig 2 participants 2 messages Sep 7, 2014 – Sep 8, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsd: update mtime on truncate

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.

---
 fs/nfsd/vfs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
fs/nfsd/vfs.c +10 -0
index f501a9b..60ed117 100644
@@ -445,6 +445,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;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 3 lines · Christoph Hellwig

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.

Thanks, Intending just to queue up for 3.18 unless you see a reason it's more urgent.

--b.

Quoted 34 lines
---
 fs/nfsd/vfs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
fs/nfsd/vfs.c +10 -0
index f501a9b..60ed117 100644
@@ -445,6 +445,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;
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html