
From: NeilBrown <neilb@cse.unsw.edu.au>

Simplify logic in nfs4_open_delegation, fix a small bug on allocation failure.

Signed-off-by: Andy Adamson <andros@citi.umich.edu>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/fs/nfsd/nfs4state.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff -puN fs/nfsd/nfs4state.c~nfsd4-simplify-open_delegation-2 fs/nfsd/nfs4state.c
--- 25/fs/nfsd/nfs4state.c~nfsd4-simplify-open_delegation-2	2005-03-07 23:55:30.000000000 -0800
+++ 25-akpm/fs/nfsd/nfs4state.c	2005-03-07 23:55:30.000000000 -0800
@@ -1664,20 +1664,21 @@ nfs4_open_delegation(struct svc_fh *fh, 
 	if (*flag == NFS4_OPEN_DELEGATE_NONE)
 		return;
 
-	/* set flag */
 	*flag = NFS4_OPEN_DELEGATE_NONE;
 	if (open->op_claim_type != NFS4_OPEN_CLAIM_NULL
 	     || !atomic_read(&cb->cb_set) || !sop->so_confirmed)
 		return;
 
-	if (!(open->op_share_access & NFS4_SHARE_ACCESS_WRITE))
-		*flag = NFS4_OPEN_DELEGATE_READ;
-
-	else if (!(open->op_share_access & NFS4_SHARE_ACCESS_READ))
+	if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE)
 		*flag = NFS4_OPEN_DELEGATE_WRITE;
+	else
+		*flag = NFS4_OPEN_DELEGATE_READ;
 
-	if (!(dp = alloc_init_deleg(sop->so_client, stp->st_file, fh, *flag)))
+	dp = alloc_init_deleg(sop->so_client, stp->st_file, fh, *flag);
+	if (dp == NULL) {
+		*flag = NFS4_OPEN_DELEGATE_NONE;
 		return;
+	}
 	locks_init_lock(&fl);
 	fl.fl_lmops = &nfsd_lease_mng_ops;
 	fl.fl_flags = FL_LEASE;
_
