[pnfs] CVS: nfsv4

Benny Halevy Panasas bhalevy at citi.umich.edu
Mon Jan 15 09:38:56 EST 2007


CVSROOT:	/cvs
Module name:	nfsv4
Changes by:	bhalevy at citi.umich.edu	2007/01/15 09:38:56

Modified files:
	cvs/pnfs/fs/nfs: inode.c pnfs.c 

Log message:
Do not update nfs inode when local inode is pending layoutcommit
and server inode is out of date.
Update local change_attr on pnfs write path (similar to write delegation)
Without this patch connectathon lock tests 7 and 14 fail when
read after write returns 0

Signed-off-by: Benny Halevy <bhalevy at panasas.com>

Index: fs/nfs/inode.c
===================================================================
RCS file: /cvs/nfsv4/cvs/pnfs/fs/nfs/inode.c,v
retrieving revision 1.18
diff -d -u -p -r1.18 inode.c
--- fs/nfs/inode.c	25 Dec 2006 00:01:58 -0000	1.18
+++ fs/nfs/inode.c	15 Jan 2007 14:34:03 -0000
@@ -905,6 +905,17 @@ static int nfs_update_inode(struct inode
&& !nfs_fsid_equal(&server->fsid, &fattr->fsid))
server->fsid = fattr->fsid;

+#ifdef CONFIG_NFS_V4 /* XXX CONFIG_PNFS */
+	/*
+	 * file needs layout commit, server attributes may be stale
+	 */
+	if (nfsi->layoutcommit_ctx && nfsi->change_attr >= fattr->change_attr) {
+		dprintk("NFS: %s: layoutcommit is needed for file %s/%ld\n",
+		        __FUNCTION__, inode->i_sb->s_id, inode->i_ino);
+		return 0;
+	}
+#endif /* CONFIG_NFS_V4 */
+
/*
* Update the read time so we don't revalidate too often.
*/
@@ -926,8 +937,16 @@ static int nfs_update_inode(struct inode
if (nfsi->npages == 0) {
/* No, but did we race with nfs_end_data_update()? */
if (data_stable) {
+#ifdef CONFIG_NFS_V4 /* XXX CONFIG_PNFS */
+				/* File could be have been updated by other pnfs clients */
+				if (!nfsi->layoutcommit_ctx || new_isize > cur_isize) {
+					inode->i_size = new_isize;
+					invalid |= NFS_INO_INVALID_DATA;
+				}
+#else /* CONFIG_NFS_V4 */
inode->i_size = new_isize;
invalid |= NFS_INO_INVALID_DATA;
+#endif /* CONFIG_NFS_V4 */
}
invalid |= NFS_INO_INVALID_ATTR;
} else if (new_isize > cur_isize) {
@@ -935,8 +954,13 @@ static int nfs_update_inode(struct inode
invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA;
}
nfsi->cache_change_attribute = jiffies;
-		dprintk("NFS: isize change on server for file %s/%ld\n",
-				inode->i_sb->s_id, inode->i_ino);
+		dprintk("NFS: isize change on server for file %s/%ld "
+		        "new=%lld cur=%lld npages=%d data_stable=%d "
+		        "layoutcommit=%d fattr->change_attr %lld nfsi->change_attr %lld\n",
+		        inode->i_sb->s_id, inode->i_ino,
+		        new_isize, cur_isize, nfsi->npages, data_stable,
+		        nfsi->layoutcommit_ctx != NULL,
+		        fattr->change_attr, nfsi->change_attr);
}

/* Check if the mtime agrees */
Index: fs/nfs/pnfs.c
===================================================================
RCS file: /cvs/nfsv4/cvs/pnfs/fs/nfs/pnfs.c,v
retrieving revision 1.53
diff -d -u -p -r1.53 pnfs.c
--- fs/nfs/pnfs.c	3 Jan 2007 13:18:16 -0000	1.53
+++ fs/nfs/pnfs.c	15 Jan 2007 14:34:04 -0000
@@ -167,7 +167,10 @@ pnfs_need_layoutcommit(struct nfs_inode*
spin_lock(&pnfs_spinlock);
if (nfsi->current_layout && !nfsi->layoutcommit_ctx) {
nfsi->layoutcommit_ctx = get_nfs_open_context(ctx);
+		nfsi->change_attr++;
+		spin_unlock(&pnfs_spinlock);
dprintk("%s: Set layoutcommit_ctx=%p\n",__FUNCTION__, nfsi->layoutcommit_ctx);
+		return;
}
spin_unlock(&pnfs_spinlock);
}



More information about the pNFS mailing list