patch-2.1.132 linux/fs/nfs/inode.c

Next file: linux/fs/nfs/read.c
Previous file: linux/fs/nfs/dir.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.131/linux/fs/nfs/inode.c linux/fs/nfs/inode.c
@@ -597,8 +597,10 @@
 		sattr.gid = attr->ia_gid;
 
 	sattr.size = (u32) -1;
-	if ((attr->ia_valid & ATTR_SIZE) && S_ISREG(inode->i_mode))
+	if ((attr->ia_valid & ATTR_SIZE) && S_ISREG(inode->i_mode)) {
 		sattr.size = attr->ia_size;
+		nfs_flush_trunc(inode, sattr.size);
+	}
 
 	sattr.mtime.seconds = sattr.mtime.useconds = (u32) -1;
 	if (attr->ia_valid & ATTR_MTIME) {
@@ -624,7 +626,6 @@
 		if (sattr.size != fattr.size)
 			printk("nfs_notify_change: sattr=%d, fattr=%d??\n",
 				sattr.size, fattr.size);
-		nfs_truncate_dirty_pages(inode, sattr.size);
 		inode->i_size  = sattr.size;
 		inode->i_mtime = fattr.mtime.seconds;
 	}
@@ -749,52 +750,45 @@
 	if ((inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT))
 		goto out_changed;
 
+	inode->i_mode = fattr->mode;
+	inode->i_nlink = fattr->nlink;
+	inode->i_uid = fattr->uid;
+	inode->i_gid = fattr->gid;
+
+	inode->i_blocks = fattr->blocks;
+	inode->i_atime = fattr->atime.seconds;
+	inode->i_ctime = fattr->ctime.seconds;
+
 	/*
-	 * If we have pending write-back entries, we don't want
-	 * to look at the size the server sends us too closely..
-	 * In particular, ignore the server if it tells us that
-	 * the file is smaller or older than we locally think it
-	 * is.. 
+	 * Update the read time so we don't revalidate too often.
 	 */
-	if (NFS_WRITEBACK(inode)) {
-		if (inode->i_size > fattr->size)
-			fattr->size = inode->i_size;
-		if (inode->i_mtime > fattr->mtime.seconds)
-			fattr->mtime.seconds = inode->i_mtime;
-	}
+	NFS_READTIME(inode) = jiffies;
+	error = 0;
 
 	/*
-	 * If the size or mtime changed from outside, we want
-	 * to invalidate the local caches immediately.
+	 * If we have pending write-back entries, we don't want
+	 * to look at the size or the mtime the server sends us
+	 * too closely, as we're in the middle of modifying them.
 	 */
+	if (NFS_WRITEBACK(inode))
+		goto out;
+
 	if (inode->i_size != fattr->size) {
 #ifdef NFS_DEBUG_VERBOSE
 printk("NFS: size change on %x/%ld\n", inode->i_dev, inode->i_ino);
 #endif
+		inode->i_size = fattr->size;
 		invalid = 1;
 	}
+
 	if (inode->i_mtime != fattr->mtime.seconds) {
 #ifdef NFS_DEBUG_VERBOSE
 printk("NFS: mtime change on %x/%ld\n", inode->i_dev, inode->i_ino);
 #endif
+		inode->i_mtime = fattr->mtime.seconds;
 		invalid = 1;
 	}
 
-	inode->i_mode = fattr->mode;
-	inode->i_nlink = fattr->nlink;
-	inode->i_uid = fattr->uid;
-	inode->i_gid = fattr->gid;
-
-	inode->i_size = fattr->size;
-	inode->i_blocks = fattr->blocks;
-	inode->i_atime = fattr->atime.seconds;
-	inode->i_mtime = fattr->mtime.seconds;
-	inode->i_ctime = fattr->ctime.seconds;
-	/*
-	 * Update the read time so we don't revalidate too often.
-	 */
-	NFS_READTIME(inode) = jiffies;
-	error = 0;
 	if (invalid)
 		goto out_invalid;
 out:
@@ -810,6 +804,7 @@
 #endif
 	fattr->mode = inode->i_mode; /* save mode */
 	make_bad_inode(inode);
+	nfs_inval(inode);
 	inode->i_mode = fattr->mode; /* restore mode */
 	/*
 	 * No need to worry about unhashing the dentry, as the
@@ -824,12 +819,9 @@
 #ifdef NFS_DEBUG_VERBOSE
 printk("nfs_refresh_inode: invalidating %ld pages\n", inode->i_nrpages);
 #endif
-	if (!S_ISDIR(inode->i_mode)) {
-		/* This sends off all dirty pages off to the server.
-		 * Note that this function must not sleep. */
-		nfs_inval(inode);
+	if (!S_ISDIR(inode->i_mode))
 		invalidate_inode_pages(inode);
-	} else
+	else
 		nfs_invalidate_dircache(inode);
 	NFS_CACHEINV(inode);
 	NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov