[pnfs] [PATCH 1/9] layoutrecall: pass layout_segment to pnfs_return_layout

Benny Halevy bhalevy at panasas.com
Thu Aug 30 09:29:59 EDT 2007


pnfs_return_layout always returns layout per file,
fsid and all recall/returns should be handled by its callers
note that the iomode is passed upstream to return_layout in the
layoutrecall callback path.
NULL for the range argument is interpreted in a backward compatible way
as return whole layout for the file <IOMODE_ANY, 0, NFS_LENGTH_EOF>

Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
 fs/nfs/delegation.c |   10 ++++++----
 fs/nfs/inode.c      |    2 +-
 fs/nfs/nfs4proc.c   |    2 +-
 fs/nfs/nfs4state.c  |    7 +++++--
 fs/nfs/pnfs.c       |   14 +++++++++-----
 fs/nfs/pnfs.h       |    2 +-
 6 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 3795280..a046287 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -380,7 +380,7 @@ static int recall_layout_thread(void *data)
 //??? commit the files first ???
 
 	if (args->inode != NULL) {
-		pnfs_return_layout(args->inode, args->rl.cbl_recall_type);
+		pnfs_return_layout(args->inode, &args->rl.cbl_seg);
 		goto out;
 	}
 
@@ -407,6 +407,9 @@ static int recall_layout_thread(void *data)
 	else
 		goto out;
 
+	args->rl.cbl_seg.offset = 0;
+	args->rl.cbl_seg.length = NFS4_LENGTH_EOF;
+
 	/* XXX UGLY UGLY hack alert! */
 	do {
 		found = 0;
@@ -421,7 +424,7 @@ static int recall_layout_thread(void *data)
 
 		if (found) {
 			igrab(inode);
-			pnfs_return_layout(inode, args->rl.cbl_recall_type);
+			pnfs_return_layout(inode, &args->rl.cbl_seg);
 			iput(inode);
 		}
 
@@ -468,8 +471,7 @@ int nfs_async_return_layout(struct nfs4_client *clp, struct inode *inode, void *
 	};
 	int status;
 
-	data.rl.cbl_fsid = rl->cbl_fsid;
-	data.rl.cbl_recall_type = rl->cbl_recall_type;
+	data.rl = *rl;
 	
 	init_completion(&data.started);
 	__module_get(THIS_MODULE);
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 3caae18..207304c 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1074,7 +1074,7 @@ void nfs4_clear_inode(struct inode *inode)
 
 #ifdef CONFIG_PNFS
 	/* Return the layout and free it if this inode has a cached layout */
-	pnfs_return_layout(inode, RETURN_FILE);
+	pnfs_return_layout(inode, NULL);
 #endif
 
 	/* Now clear out any remaining state */
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index fd0a4bd..d8ce185 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2029,7 +2029,7 @@ pnfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
 			if (NFS_I(inode)->layoutcommit_ctx) {
 				pnfs_layoutcommit_inode(inode, 0);
 			}
-			pnfs_return_layout(inode, RETURN_FILE);
+			pnfs_return_layout(inode, NULL);
 		}
 	}
 
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 53ce755..4963454 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -534,10 +534,13 @@ void nfs4_close_state(struct nfs4_state *state, mode_t mode)
 			if (NFS_I(inode)->layoutcommit_ctx) {
 				pnfs_layoutcommit_inode(inode, 0);
 			}
-			/* TODO: make finer grained returns here */
 			if (NFS_I(inode)->current_layout &&
 			    NFS_I(inode)->current_layout->roc_iomode) {
-				pnfs_return_layout(inode, RETURN_FILE);
+				struct nfs4_pnfs_layout_segment range;
+				range.iomode = NFS_I(inode)->current_layout->roc_iomode;
+				range.offset = 0;
+				range.length = NFS4_LENGTH_EOF;
+				pnfs_return_layout(inode, &range);
 			}
 		}
 		if (nfs4_do_close(inode, state) == 0)
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 646db94..e1fcdbf 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -347,7 +347,7 @@ get_layout(struct inode* ino,
 }
 
 int
-pnfs_return_layout(struct inode* ino, int type)
+pnfs_return_layout(struct inode* ino, struct nfs4_pnfs_layout_segment *range)
 {
 	struct nfs4_pnfs_layoutreturn_arg arg;
 	struct nfs4_pnfs_layoutreturn_res res;
@@ -370,10 +370,14 @@ pnfs_return_layout(struct inode* ino, int type)
 
 	arg.reclaim = 0;
 	arg.layout_type = server->pnfs_curr_ld->id;
-	arg.lseg.iomode = IOMODE_ANY /* for now */;
-	arg.return_type = type;
-	arg.lseg.offset = 0;
-	arg.lseg.length = ~0;
+	arg.return_type = RETURN_FILE;
+	if (range)
+		arg.lseg = *range;
+	else {
+		arg.lseg.iomode = IOMODE_ANY /* for now */;
+		arg.lseg.offset = 0;
+		arg.lseg.length = ~0;
+	}
 	arg.inode = ino;
 	arg.minorversion_info = &seqarg;
 	res.minorversion_info = &seqres;
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 528908c..71315cb 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -16,7 +16,7 @@
 int virtual_update_layout(struct inode* ino, struct nfs_open_context* ctx,
 	size_t count, loff_t pos, enum pnfs_iomode access_type);
 
-int pnfs_return_layout(struct inode* ino, int type);
+int pnfs_return_layout(struct inode* ino, struct nfs4_pnfs_layout_segment *range);
 void set_pnfs_layoutdriver(struct super_block *sb, u32 id);
 void unmount_pnfs_layoutdriver(struct super_block *sb);
 ssize_t pnfs_file_write(struct file* filp, const char __user *buf, size_t count, loff_t* pos);
-- 
1.5.2.5



More information about the pNFS mailing list