nfsd41: refactor nfs4_open_deleg_none_ext logic out of nfs4_open_delegation
authorBenny Halevy <benny@tonian.com>
Tue, 21 Feb 2012 22:16:44 +0000 (14:16 -0800)
committerJ. Bruce Fields <bfields@redhat.com>
Tue, 6 Mar 2012 23:13:34 +0000 (18:13 -0500)
When a 4.1 client asks for a delegation and the server returns none
op_delegate_type is set to NFS4_OPEN_DELEGATE_NONE_EXT
and op_why_no_deleg is set to either WND4_CONTENTION or WND4_RESOURCE.
Or, if the client sent a NFS4_SHARE_WANT_CANCEL (which it is not supposed
to ever do until our server supports delegations signaling),
op_why_no_deleg is set to WND4_CANCELLED.

Note that for WND4_CONTENTION and WND4_RESOURCE, the xdr layer is hard coded
at this time to encode boolean FALSE for ond_server_will_push_deleg /
ond_server_will_signal_avail.

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4state.c

index 90c7e06ea2e8137b9741ad690cc7581f35dba558..1b3e2bd82568e717d876909c282208035a09eed8 100644 (file)
@@ -2862,6 +2862,27 @@ static int nfs4_set_delegation(struct nfs4_delegation *dp, int flag)
        return 0;
 }
 
+static void nfsd4_open_deleg_none_ext(struct nfsd4_open *open, int status)
+{
+       open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT;
+       if (status == -EAGAIN)
+               open->op_why_no_deleg = WND4_CONTENTION;
+       else {
+               open->op_why_no_deleg = WND4_RESOURCE;
+               switch (open->op_deleg_want) {
+               case NFS4_SHARE_WANT_READ_DELEG:
+               case NFS4_SHARE_WANT_WRITE_DELEG:
+               case NFS4_SHARE_WANT_ANY_DELEG:
+                       break;
+               case NFS4_SHARE_WANT_CANCEL:
+                       open->op_why_no_deleg = WND4_CANCELLED;
+                       break;
+               case NFS4_SHARE_WANT_NO_DELEG:
+                       BUG();  /* not supposed to get here */
+               }
+       }
+}
+
 /*
  * Attempt to hand out a delegation.
  */
@@ -2918,25 +2939,9 @@ out:
                    open->op_delegate_type != NFS4_OPEN_DELEGATE_NONE)
                        dprintk("NFSD: WARNING: refusing delegation reclaim\n");
 
-               if (open->op_deleg_want) {
-                       open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT;
-                       if (status == -EAGAIN)
-                               open->op_why_no_deleg = WND4_CONTENTION;
-                       else {
-                               open->op_why_no_deleg = WND4_RESOURCE;
-                               switch (open->op_deleg_want) {
-                               case NFS4_SHARE_WANT_READ_DELEG:
-                               case NFS4_SHARE_WANT_WRITE_DELEG:
-                               case NFS4_SHARE_WANT_ANY_DELEG:
-                                       break;
-                               case NFS4_SHARE_WANT_CANCEL:
-                                       open->op_why_no_deleg = WND4_CANCELLED;
-                                       break;
-                               case NFS4_SHARE_WANT_NO_DELEG:
-                                       BUG();  /* not supposed to get here */
-                               }
-                       }
-               }
+               /* 4.1 client asking for a delegation? */
+               if (open->op_deleg_want)
+                       nfsd4_open_deleg_none_ext(open, status);
        }
        return;
 out_free: