No subject


Wed Jul 16 14:05:21 EDT 2008


For RETURN_FILE, we need to pass the stateid we received by
CB_LAYOUTRECALL down to LAYOUTRETURN.

This patch adds an optional stateid pointer on the pnfs return_layout.

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

This should be it, but it's not tested yet...

Benny

 fs/nfs/callback_proc.c |    7 ++++---
 fs/nfs/inode.c         |    2 +-
 fs/nfs/nfs4proc.c      |    2 +-
 fs/nfs/nfs4state.c     |    2 +-
 fs/nfs/pnfs.c          |    9 +++++++--
 fs/nfs/pnfs.h          |    4 +++-
 6 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 0957a2f..537d4f3 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -192,7 +192,8 @@ static int pnfs_recall_layout(void *data)
  */
 
 	if (rl.cbl_recall_type == RECALL_FILE) {
-		status = pnfs_return_layout(inode, &rl.cbl_seg, RECALL_FILE);
+		status = pnfs_return_layout(inode, &rl.cbl_seg, &rl.cbl_stateid, 
+					    RECALL_FILE);
 		if (status)
 			dprintk("%s RECALL_FILE error: %d\n", __func__, status);
 		goto out;
@@ -204,12 +205,12 @@ static int pnfs_recall_layout(void *data)
 	/* FIXME: This loop is inefficient, running in O(|s_inodes|^2) */
 	while ((ino = nfs_layoutrecall_find_inode(clp, &rl)) != NULL) {
 		/* XXX need to check status on pnfs_return_layout */
-		pnfs_return_layout(ino, &rl.cbl_seg, RECALL_FILE);
+		pnfs_return_layout(ino, &rl.cbl_seg, NULL, RECALL_FILE);
 		iput(ino);
 	}
 
 	/* send final layoutreturn */
-	status = pnfs_return_layout(inode, &rl.cbl_seg, rl.cbl_recall_type);
+	status = pnfs_return_layout(inode, &rl.cbl_seg, NULL, rl.cbl_recall_type);
 	if (status)
 		printk(KERN_INFO "%s: ignoring pnfs_return_layout status=%d\n",
 				__func__, status);
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index ff74aec..83855dc 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1170,7 +1170,7 @@ void nfs4_clear_inode(struct inode *inode)
 	/* First call standard NFS clear_inode() code */
 	nfs_clear_inode(inode);
 #ifdef CONFIG_PNFS
-	pnfs_return_layout(inode, NULL, RECALL_FILE);
+	pnfs_return_layout(inode, NULL, NULL, RECALL_FILE);
 #endif /* CONFIG_PNFS */
 }
 #endif
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 973c8f5..bc17cc4 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2157,7 +2157,7 @@ pnfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
 		if (p_ops && p_ops->layoutret_on_setattr) {
 			if (nfsi->layoutcommit_ctx)
 				pnfs_layoutcommit_inode(inode, 0);
-			pnfs_return_layout(inode, NULL, RECALL_FILE);
+			pnfs_return_layout(inode, NULL, NULL, RECALL_FILE);
 		}
 	}
 	return nfs4_proc_setattr(dentry, fattr, sattr);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 8e5d9ae..a4235b9 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -533,7 +533,7 @@ static void __nfs4_close(struct path *path, struct nfs4_state *state, mode_t mod
 		range.iomode = nfsi->current_layout->roc_iomode;
 		range.offset = 0;
 		range.length = NFS4_LENGTH_EOF;
-		pnfs_return_layout(state->inode, &range, RECALL_FILE);
+		pnfs_return_layout(state->inode, &range, NULL, RECALL_FILE);
 	}
 #endif /* CONFIG_PNFS */
 		nfs4_do_close(path, state, wait);
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 8d1b213..1021c01 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -591,6 +591,7 @@ pnfs_free_layout(struct pnfs_layout_type *lo,
 
 static int
 return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range,
+	      const nfs4_stateid *stateid, /* optional */
 	      enum pnfs_layoutrecall_type type, struct pnfs_layout_type *lo)
 {
 	struct nfs4_pnfs_layoutreturn *lrp;
@@ -609,7 +610,10 @@ return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range,
 	lrp->args.inode = ino;
 
 	if (lo) {
-		pnfs_get_layout_stateid(&lrp->args.stateid, lo);
+		if (stateid)
+			lrp->args.stateid = *stateid;
+		else
+			pnfs_get_layout_stateid(&lrp->args.stateid, lo);
 		lrp->lo = lo;
 	}
 
@@ -621,6 +625,7 @@ out:
 
 int
 _pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range,
+		    const nfs4_stateid *stateid, /* optional */
 		    enum pnfs_layoutrecall_type type)
 {
 	struct pnfs_layout_type *lo = NULL;
@@ -650,7 +655,7 @@ _pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range,
 		spin_unlock(&nfsi->lo_lock);
 	}
 
-	status = return_layout(ino, &arg, type, lo);
+	status = return_layout(ino, &arg, stateid, type, lo);
 out:
 	dprintk("<-- %s status: %d\n", __func__, status);
 	return status;
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index a93b248..8433db9 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -30,6 +30,7 @@ int pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx,
 	struct pnfs_layout_segment **lsegpp);
 
 int _pnfs_return_layout(struct inode *, struct nfs4_pnfs_layout_segment *,
+			const nfs4_stateid *stateid, /* optional */
 			enum pnfs_layoutrecall_type);
 void set_pnfs_layoutdriver(struct super_block *sb, struct nfs_fh *fh, u32 id);
 void unmount_pnfs_layoutdriver(struct super_block *sb);
@@ -196,6 +197,7 @@ static inline void pnfs_modify_new_request(struct nfs_page *req,
 
 static inline int pnfs_return_layout(struct inode *ino,
 				     struct nfs4_pnfs_layout_segment *lseg,
+				     const nfs4_stateid *stateid, /* optional */
 				     enum pnfs_layoutrecall_type type)
 {
 	struct nfs_inode *nfsi = NFS_I(ino);
@@ -203,7 +205,7 @@ static inline int pnfs_return_layout(struct inode *ino,
 
 	if (pnfs_enabled_sb(nfss) &&
 	    (nfsi->current_layout || type != RECALL_FILE))
-		return _pnfs_return_layout(ino, lseg, type);
+		return _pnfs_return_layout(ino, lseg, stateid, type);
 
 	return 0;
 }
-- 
1.5.6.4



More information about the pNFS mailing list