[PATCH 07/22] SQUASHME: pnfs-submit: fixups for nfsv4.1 callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Benny Halevy <bhalevy@xxxxxxxxxxx>

Signed-off-by: Benny Halevy <bhalevy@xxxxxxxxxxx>
---
 fs/nfs/callback_proc.c |   52 +++++++++++++++++++++--------------------------
 1 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 53a85648..2e62155 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -21,6 +21,12 @@
 #define NFSDBG_FACILITY NFSDBG_CALLBACK
 #endif
 
+static struct nfs_client *
+find_client_from_cps(struct cb_process_state *cps, struct sockaddr *addr)
+{
+	return cps->session ? cps->session->clp : nfs_find_client(addr, 4);
+}
+
 __be32 nfs4_callback_getattr(struct cb_getattrargs *args,
 			     struct cb_getattrres *res,
 			     struct cb_process_state *cps)
@@ -32,13 +38,9 @@ __be32 nfs4_callback_getattr(struct cb_getattrargs *args,
 
 	res->bitmap[0] = res->bitmap[1] = 0;
 	res->status = htonl(NFS4ERR_BADHANDLE);
-	if (cps->session) { /* set in cb_sequence */
-		clp = cps->session->clp;
-	} else {
-		clp = nfs_find_client(args->addr, 4);
-		if (clp == NULL)
-			goto out;
-	}
+	clp = find_client_from_cps(cps, args->addr);
+	if (clp == NULL)
+		goto out;
 
 	dprintk("NFS: GETATTR callback request from %s\n",
 		rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
@@ -81,13 +83,9 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy,
 	__be32 res;
 	
 	res = htonl(NFS4ERR_BADHANDLE);
-	if (cps->session) { /* set in cb_sequence */
-		clp = cps->session->clp;
-	} else {
-		clp = nfs_find_client(args->addr, 4);
-		if (clp == NULL)
-			goto out;
-	}
+	clp = find_client_from_cps(cps, args->addr);
+	if (clp == NULL)
+		goto out;
 
 	dprintk("NFS: RECALL callback request from %s\n",
 		rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
@@ -111,11 +109,11 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy,
 			}
 			iput(inode);
 		}
-		if (!cps->session) {
-			clp = nfs_find_client_next(prev);
-			nfs_put_client(prev);
-		}
-	} while (!cps->session && clp != NULL);
+		if (cps->session)
+			break;
+		clp = nfs_find_client_next(prev);
+		nfs_put_client(prev);
+	} while (clp != NULL);
 out:
 	dprintk("%s: exit with status = %d\n", __func__, ntohl(res));
 	return res;
@@ -376,11 +374,6 @@ __be32 nfs4_callback_layoutrecall(struct cb_layoutrecallargs *args,
 	else
 		goto out;
 
-	/* the callback must come from the MDS personality */
-	res = cpu_to_be32(NFS4ERR_NOTSUPP);
-	if (!(clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_MDS))
-		goto out;
-
 	res = cpu_to_be32(NFS4ERR_NOMATCHING_LAYOUT);
 	/*
 	 * In the _ALL or _FSID case, we need the inode to get
@@ -579,6 +572,12 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
 	if (status)
 		goto out_putclient;
 
+	/* The callback must come from the MDS personality */
+	if (!(clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_MDS)) {
+		status = htonl(NFS4ERR_INVAL);
+		goto out_putclient;
+	}
+
 	/*
 	 * Check for pending referring calls.  If a match is found, a
 	 * related callback was received before the response to the original
@@ -658,11 +657,6 @@ __be32 nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy,
 	dprintk("NFS: RECALL_ANY callback request from %s\n",
 		rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
 
-	/* the callback must come from the MDS personality */
-	status = cpu_to_be32(NFS4ERR_NOTSUPP);
-	if (!(clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_MDS))
-		goto out;
-
 	status = cpu_to_be32(NFS4ERR_INVAL);
 	if (!validate_bitmap_values((const unsigned long *)
 				    &args->craa_type_mask))
-- 
1.7.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux