[pnfs] [Fwd: [PATCH 12/13] pnfs: nfs_layoutrecall_find_inode]

Benny Halevy bhalevy at panasas.com
Wed Jan 23 05:49:04 EST 2008


Resending since previous message didn't get to the mailing list.

On Jan. 22, 2008, 21:34 +0200, Benny Halevy <bhalevy at panasas.com> wrote:

lookup an inode based on the recalled layout parameters.

Currently use the clp->cl_lo_inodes.

TODO: In the future a hash table keyed on filehandle
is planned for looking up delegations and RECALL_FILE
layouts.

Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
 fs/nfs/callback_proc.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index e949e63..d12e1d9 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -12,6 +12,10 @@
 #include "delegation.h"
 #include "internal.h"
 
+#if defined(CONFIG_PNFS)
+#include <linux/writeback.h>
+#endif
+
 #define NFSDBG_FACILITY NFSDBG_CALLBACK
  
 __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res)
@@ -87,6 +91,49 @@ out:
 	return res;
 }
 
+#if defined(CONFIG_PNFS)
+
+/*
+ * Retrieve an inode based on layout recall parameters
+ *
+ * Note: caller must iput(inode) to dereference the inode.
+ */
+static struct inode *
+nfs_layoutrecall_find_inode(struct nfs_client *clp,
+			    const struct cb_pnfs_layoutrecallargs *args)
+{
+	struct nfs_inode *nfsi;
+	struct nfs_server *server;
+	struct inode *ino = NULL;
+
+	dprintk("%s: Begin recall_type=%d\n", __func__, args->cbl_recall_type);
+
+	down_read(&clp->cl_sem);
+	list_for_each_entry(nfsi, &clp->cl_lo_inodes, lo_inodes) {
+		if (args->cbl_recall_type == RECALL_FILE) {
+		    if (nfs_compare_fh(&args->cbl_fh, &nfsi->fh))
+			continue;
+		} else if (args->cbl_recall_type == RECALL_FSID) {
+			server = NFS_SERVER(&nfsi->vfs_inode);
+			if (server->fsid.major != args->cbl_fsid.major ||
+			    server->fsid.minor != args->cbl_fsid.minor)
+				continue;
+		}
+
+		ino = &nfsi->vfs_inode;
+		spin_lock(&inode_lock);
+		__iget(ino);
+		spin_unlock(&inode_lock);
+		break;
+	}
+	up_read(&clp->cl_sem);
+
+	dprintk("%s: Return inode=%p\n", __func__, ino);
+	return ino;
+}
+
+#endif /* defined(CONFIG_PNFS) */
+
 #if defined(CONFIG_NFS_V4_1)
 
 /* FIXME: validate args->cbs_{sequence,slot}id */
-- 
1.5.3.3


-- 
Benny Halevy
Software Architect
Tel/Fax: +972-3-647-8340
Mobile: +972-54-802-8340
US:      +1-412-203-3187
bhalevy at panasas.com
 
Panasas, Inc.
The Leader in Parallel Storage
www.panasas.com


More information about the pNFS mailing list