/*
  * Return all delegations that have been marked for return
  */
-static void nfs_client_return_marked_delegations(struct nfs_client *clp)
+void nfs_client_return_marked_delegations(struct nfs_client *clp)
 {
        struct nfs_delegation *delegation;
        struct inode *inode;
        nfs_client_return_marked_delegations(clp);
 }
 
-static void nfs_client_return_all_delegations(struct nfs_client *clp)
+static void nfs_client_mark_return_all_delegations(struct nfs_client *clp)
 {
        struct nfs_delegation *delegation;
 
        rcu_read_lock();
-       list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list)
+       list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) {
                set_bit(NFS_DELEGATION_RETURN, &delegation->flags);
+               set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state);
+       }
        rcu_read_unlock();
-       nfs_client_return_marked_delegations(clp);
 }
 
 static int nfs_do_expire_all_delegations(void *ptr)
                goto out;
        if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) == 0)
                goto out;
-       nfs_client_return_all_delegations(clp);
+       nfs_client_mark_return_all_delegations(clp);
+       nfs_client_return_marked_delegations(clp);
 out:
        nfs_put_client(clp);
        module_put_and_exit(0);
 {
        if (clp == NULL)
                return;
-       nfs_client_return_all_delegations(clp);
+       nfs_client_mark_return_all_delegations(clp);
 }
 
 struct recall_threadargs {
 
 void nfs_super_return_all_delegations(struct super_block *sb);
 void nfs_expire_all_delegations(struct nfs_client *clp);
 void nfs_handle_cb_pathdown(struct nfs_client *clp);
+void nfs_client_return_marked_delegations(struct nfs_client *clp);
 
 void nfs_delegation_mark_reclaim(struct nfs_client *clp);
 void nfs_delegation_reap_unclaimed(struct nfs_client *clp);
 
 {
        switch (error) {
                case -NFS4ERR_CB_PATH_DOWN:
-                       set_bit(NFS4CLNT_CB_PATH_DOWN, &clp->cl_state);
+                       nfs_handle_cb_pathdown(clp);
                        break;
                case -NFS4ERR_STALE_CLIENTID:
                case -NFS4ERR_LEASE_MOVED:
                                nfs4_state_end_reclaim_nograce(clp);
                        continue;
                }
+
+               if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) {
+                       nfs_client_return_marked_delegations(clp);
+                       continue;
+               }
                break;
        }
 out:
-       if (test_and_clear_bit(NFS4CLNT_CB_PATH_DOWN, &clp->cl_state))
-               nfs_handle_cb_pathdown(clp);
        nfs4_clear_recover_bit(clp);
        nfs_put_client(clp);
        module_put_and_exit(0);