[pnfs] CVS: nfsv4

Benny Halevy Panasas bhalevy at citi.umich.edu
Sat Jan 13 07:02:22 EST 2007


CVSROOT:	/cvs
Module name:	nfsv4
Changes by:	bhalevy at citi.umich.edu	2007/01/13 07:02:22

Modified files:
	cvs/pnfs/fs/nfsd: nfs4state.c 

Log message:
fix bug when searching for a layout, after list_for_each_entry
cursor ptr is equal to list head, not null...

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

Index: fs/nfsd/nfs4state.c
===================================================================
RCS file: /cvs/nfsv4/cvs/pnfs/fs/nfsd/nfs4state.c,v
retrieving revision 1.27
diff -d -u -p -r1.27 nfs4state.c
--- fs/nfsd/nfs4state.c	28 Dec 2006 09:21:19 -0000	1.27
+++ fs/nfsd/nfs4state.c	13 Jan 2007 11:59:41 -0000
@@ -3526,15 +3526,27 @@ nfs4_add_pnfs_ds_dev(struct nfs4_stateid
return 0;
}

+static struct nfs4_layout *
+find_layout(struct nfs4_file *fp, struct nfs4_client *clp)
+{
+	struct nfs4_layout *lp;
+
+	list_for_each_entry (lp, &fp->fi_layouts, lo_perfile) {
+	        //??? if the right layout
+		if (lp->lo_client == clp)
+			return lp;
+	}
+	return NULL;
+}

int nfs4_pnfs_get_layout(struct super_block *sb, struct svc_fh *current_fh,
struct nfsd4_pnfs_layoutget *lgp)
{
int status = -ENOENT;
struct inode *ino = current_fh->fh_dentry->d_inode;
-	struct nfs4_file *fp = NULL;
-	struct nfs4_client *clp = NULL;
-	struct nfs4_layout *lp = NULL;
+	struct nfs4_file *fp;
+	struct nfs4_client *clp;
+	struct nfs4_layout *lp;
struct nfsd4_pnfs_layoutreturn lr;

dprintk("NFSD: nfs4_pnfs_get_layout\n");
@@ -3551,13 +3563,9 @@ int nfs4_pnfs_get_layout(struct super_bl
goto out;

lgp->lg_flags = 0;
-	list_for_each_entry (lp, &fp->fi_layouts, lo_perfile) {
-	        //??? if the right layout
-		if (lp->lo_client == clp) {
-			lgp->lg_flags = 1; /* update layout */
-	        	break;
-		}
-	}
+	lp = find_layout(fp, clp);
+	if (lp)
+		lgp->lg_flags = 1; /* update layout */
if (sb->s_export_op->layout_get) {
status = sb->s_export_op->layout_get(current_fh->fh_dentry->d_inode,
(void *)lgp);
@@ -3621,8 +3629,8 @@ int nfs4_pnfs_return_layout(struct super
int status = -ENOENT;
struct inode *ino = current_fh->fh_dentry->d_inode;
struct nfs4_file *fp;
-	struct nfs4_client *clp = NULL;
-	struct nfs4_layout *lp = NULL;
+	struct nfs4_client *clp;
+	struct nfs4_layout *lp;

dprintk("NFSD: nfs4_pnfs_return_layout\n");

@@ -3637,11 +3645,7 @@ int nfs4_pnfs_return_layout(struct super
if (!clp)
goto out;

-	list_for_each_entry (lp, &fp->fi_layouts, lo_perfile) {
-		//??? if the right layout
-		if (lp->lo_client == clp)
-			break;
-	}
+	lp = find_layout(fp, clp);
dprintk("pNFS %s: lp %p\n", __FUNCTION__, lp);

if (lp) {



More information about the pNFS mailing list