PCI: tegra: Add debugfs support
[firefly-linux-kernel-4.4.55.git] / fs / nfsd / nfs4state.c
index 9a77a5a21557c4e16740196c16d7f4f218ce2643..c0d45cec9958ec185b975e1653a78b3c722b6f34 100644 (file)
@@ -81,13 +81,13 @@ static DEFINE_MUTEX(client_mutex);
  * effort to decrease the scope of the client_mutex, this spinlock may
  * eventually cover more:
  */
-static DEFINE_SPINLOCK(recall_lock);
+static DEFINE_SPINLOCK(state_lock);
 
-static struct kmem_cache *openowner_slab = NULL;
-static struct kmem_cache *lockowner_slab = NULL;
-static struct kmem_cache *file_slab = NULL;
-static struct kmem_cache *stateid_slab = NULL;
-static struct kmem_cache *deleg_slab = NULL;
+static struct kmem_cache *openowner_slab;
+static struct kmem_cache *lockowner_slab;
+static struct kmem_cache *file_slab;
+static struct kmem_cache *stateid_slab;
+static struct kmem_cache *deleg_slab;
 
 void
 nfs4_lock_state(void)
@@ -235,9 +235,9 @@ static void nfsd4_free_file(struct nfs4_file *f)
 static inline void
 put_nfs4_file(struct nfs4_file *fi)
 {
-       if (atomic_dec_and_lock(&fi->fi_ref, &recall_lock)) {
+       if (atomic_dec_and_lock(&fi->fi_ref, &state_lock)) {
                hlist_del(&fi->fi_hash);
-               spin_unlock(&recall_lock);
+               spin_unlock(&state_lock);
                iput(fi->fi_inode);
                nfsd4_free_file(fi);
        }
@@ -375,7 +375,6 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_ol_stateid *stp, struct sv
        dp = delegstateid(nfs4_alloc_stid(clp, deleg_slab));
        if (dp == NULL)
                return dp;
-       dp->dl_stid.sc_type = NFS4_DELEG_STID;
        /*
         * delegation seqid's are never incremented.  The 4.1 special
         * meaning of seqid 0 isn't meaningful, really, but let's avoid
@@ -418,6 +417,8 @@ nfs4_put_delegation(struct nfs4_delegation *dp)
 
 static void nfs4_put_deleg_lease(struct nfs4_file *fp)
 {
+       if (!fp->fi_lease)
+               return;
        if (atomic_dec_and_test(&fp->fi_delegees)) {
                vfs_setlease(fp->fi_deleg_file, F_UNLCK, &fp->fi_lease);
                fp->fi_lease = NULL;
@@ -431,18 +432,30 @@ static void unhash_stid(struct nfs4_stid *s)
        s->sc_type = 0;
 }
 
+static void
+hash_delegation_locked(struct nfs4_delegation *dp, struct nfs4_file *fp)
+{
+       lockdep_assert_held(&state_lock);
+
+       dp->dl_stid.sc_type = NFS4_DELEG_STID;
+       list_add(&dp->dl_perfile, &fp->fi_delegations);
+       list_add(&dp->dl_perclnt, &dp->dl_stid.sc_client->cl_delegations);
+}
+
 /* Called under the state lock. */
 static void
 unhash_delegation(struct nfs4_delegation *dp)
 {
+       spin_lock(&state_lock);
        list_del_init(&dp->dl_perclnt);
-       spin_lock(&recall_lock);
        list_del_init(&dp->dl_perfile);
        list_del_init(&dp->dl_recall_lru);
-       spin_unlock(&recall_lock);
-       nfs4_put_deleg_lease(dp->dl_file);
-       put_nfs4_file(dp->dl_file);
-       dp->dl_file = NULL;
+       spin_unlock(&state_lock);
+       if (dp->dl_file) {
+               nfs4_put_deleg_lease(dp->dl_file);
+               put_nfs4_file(dp->dl_file);
+               dp->dl_file = NULL;
+       }
 }
 
 
@@ -645,6 +658,12 @@ static void unhash_lockowner(struct nfs4_lockowner *lo)
        }
 }
 
+static void nfs4_free_lockowner(struct nfs4_lockowner *lo)
+{
+       kfree(lo->lo_owner.so_owner.data);
+       kmem_cache_free(lockowner_slab, lo);
+}
+
 static void release_lockowner(struct nfs4_lockowner *lo)
 {
        unhash_lockowner(lo);
@@ -699,6 +718,12 @@ static void release_last_closed_stateid(struct nfs4_openowner *oo)
        }
 }
 
+static void nfs4_free_openowner(struct nfs4_openowner *oo)
+{
+       kfree(oo->oo_owner.so_owner.data);
+       kmem_cache_free(openowner_slab, oo);
+}
+
 static void release_openowner(struct nfs4_openowner *oo)
 {
        unhash_openowner(oo);
@@ -1093,7 +1118,7 @@ static struct nfs4_client *alloc_client(struct xdr_netobj name)
        return clp;
 }
 
-static inline void
+static void
 free_client(struct nfs4_client *clp)
 {
        struct nfsd_net __maybe_unused *nn = net_generic(clp->net, nfsd_net_id);
@@ -1136,13 +1161,13 @@ destroy_client(struct nfs4_client *clp)
        struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
 
        INIT_LIST_HEAD(&reaplist);
-       spin_lock(&recall_lock);
+       spin_lock(&state_lock);
        while (!list_empty(&clp->cl_delegations)) {
                dp = list_entry(clp->cl_delegations.next, struct nfs4_delegation, dl_perclnt);
                list_del_init(&dp->dl_perclnt);
                list_move(&dp->dl_recall_lru, &reaplist);
        }
-       spin_unlock(&recall_lock);
+       spin_unlock(&state_lock);
        while (!list_empty(&reaplist)) {
                dp = list_entry(reaplist.next, struct nfs4_delegation, dl_recall_lru);
                destroy_delegation(dp);
@@ -1544,6 +1569,7 @@ out_err:
 void
 nfsd4_store_cache_entry(struct nfsd4_compoundres *resp)
 {
+       struct xdr_buf *buf = resp->xdr.buf;
        struct nfsd4_slot *slot = resp->cstate.slot;
        unsigned int base;
 
@@ -1557,11 +1583,9 @@ nfsd4_store_cache_entry(struct nfsd4_compoundres *resp)
                slot->sl_datalen = 0;
                return;
        }
-       slot->sl_datalen = (char *)resp->p - (char *)resp->cstate.datap;
-       base = (char *)resp->cstate.datap -
-                                       (char *)resp->xbuf->head[0].iov_base;
-       if (read_bytes_from_xdr_buf(resp->xbuf, base, slot->sl_data,
-                                   slot->sl_datalen))
+       base = resp->cstate.data_offset;
+       slot->sl_datalen = buf->len - base;
+       if (read_bytes_from_xdr_buf(buf, base, slot->sl_data, slot->sl_datalen))
                WARN("%s: sessions DRC could not cache compound\n", __func__);
        return;
 }
@@ -1602,6 +1626,8 @@ nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp,
                         struct nfsd4_sequence *seq)
 {
        struct nfsd4_slot *slot = resp->cstate.slot;
+       struct xdr_stream *xdr = &resp->xdr;
+       __be32 *p;
        __be32 status;
 
        dprintk("--> %s slot %p\n", __func__, slot);
@@ -1610,14 +1636,16 @@ nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp,
        if (status)
                return status;
 
-       /* The sequence operation has been encoded, cstate->datap set. */
-       memcpy(resp->cstate.datap, slot->sl_data, slot->sl_datalen);
+       p = xdr_reserve_space(xdr, slot->sl_datalen);
+       if (!p) {
+               WARN_ON_ONCE(1);
+               return nfserr_serverfault;
+       }
+       xdr_encode_opaque_fixed(p, slot->sl_data, slot->sl_datalen);
+       xdr_commit_encode(xdr);
 
        resp->opcnt = slot->sl_opcnt;
-       resp->p = resp->cstate.datap + XDR_QUADLEN(slot->sl_datalen);
-       status = slot->sl_status;
-
-       return status;
+       return slot->sl_status;
 }
 
 /*
@@ -2189,11 +2217,13 @@ nfsd4_sequence(struct svc_rqst *rqstp,
               struct nfsd4_sequence *seq)
 {
        struct nfsd4_compoundres *resp = rqstp->rq_resp;
+       struct xdr_stream *xdr = &resp->xdr;
        struct nfsd4_session *session;
        struct nfs4_client *clp;
        struct nfsd4_slot *slot;
        struct nfsd4_conn *conn;
        __be32 status;
+       int buflen;
        struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
 
        if (resp->opcnt != 1)
@@ -2262,6 +2292,16 @@ nfsd4_sequence(struct svc_rqst *rqstp,
        if (status)
                goto out_put_session;
 
+       buflen = (seq->cachethis) ?
+                       session->se_fchannel.maxresp_cached :
+                       session->se_fchannel.maxresp_sz;
+       status = (seq->cachethis) ? nfserr_rep_too_big_to_cache :
+                                   nfserr_rep_too_big;
+       if (xdr_restrict_buflen(xdr, buflen - rqstp->rq_auth_slack))
+               goto out_put_session;
+       svc_reserve(rqstp, buflen);
+
+       status = nfs_ok;
        /* Success! bump slot seqid */
        slot->sl_seqid = seq->seqid;
        slot->sl_flags |= NFSD4_SLOT_INUSE;
@@ -2499,28 +2539,19 @@ static void nfsd4_init_file(struct nfs4_file *fp, struct inode *ino)
        fp->fi_lease = NULL;
        memset(fp->fi_fds, 0, sizeof(fp->fi_fds));
        memset(fp->fi_access, 0, sizeof(fp->fi_access));
-       spin_lock(&recall_lock);
+       spin_lock(&state_lock);
        hlist_add_head(&fp->fi_hash, &file_hashtbl[hashval]);
-       spin_unlock(&recall_lock);
-}
-
-static void
-nfsd4_free_slab(struct kmem_cache **slab)
-{
-       if (*slab == NULL)
-               return;
-       kmem_cache_destroy(*slab);
-       *slab = NULL;
+       spin_unlock(&state_lock);
 }
 
 void
 nfsd4_free_slabs(void)
 {
-       nfsd4_free_slab(&openowner_slab);
-       nfsd4_free_slab(&lockowner_slab);
-       nfsd4_free_slab(&file_slab);
-       nfsd4_free_slab(&stateid_slab);
-       nfsd4_free_slab(&deleg_slab);
+       kmem_cache_destroy(openowner_slab);
+       kmem_cache_destroy(lockowner_slab);
+       kmem_cache_destroy(file_slab);
+       kmem_cache_destroy(stateid_slab);
+       kmem_cache_destroy(deleg_slab);
 }
 
 int
@@ -2529,42 +2560,38 @@ nfsd4_init_slabs(void)
        openowner_slab = kmem_cache_create("nfsd4_openowners",
                        sizeof(struct nfs4_openowner), 0, 0, NULL);
        if (openowner_slab == NULL)
-               goto out_nomem;
+               goto out;
        lockowner_slab = kmem_cache_create("nfsd4_lockowners",
                        sizeof(struct nfs4_lockowner), 0, 0, NULL);
        if (lockowner_slab == NULL)
-               goto out_nomem;
+               goto out_free_openowner_slab;
        file_slab = kmem_cache_create("nfsd4_files",
                        sizeof(struct nfs4_file), 0, 0, NULL);
        if (file_slab == NULL)
-               goto out_nomem;
+               goto out_free_lockowner_slab;
        stateid_slab = kmem_cache_create("nfsd4_stateids",
                        sizeof(struct nfs4_ol_stateid), 0, 0, NULL);
        if (stateid_slab == NULL)
-               goto out_nomem;
+               goto out_free_file_slab;
        deleg_slab = kmem_cache_create("nfsd4_delegations",
                        sizeof(struct nfs4_delegation), 0, 0, NULL);
        if (deleg_slab == NULL)
-               goto out_nomem;
+               goto out_free_stateid_slab;
        return 0;
-out_nomem:
-       nfsd4_free_slabs();
+
+out_free_stateid_slab:
+       kmem_cache_destroy(stateid_slab);
+out_free_file_slab:
+       kmem_cache_destroy(file_slab);
+out_free_lockowner_slab:
+       kmem_cache_destroy(lockowner_slab);
+out_free_openowner_slab:
+       kmem_cache_destroy(openowner_slab);
+out:
        dprintk("nfsd4: out of memory while initializing nfsv4\n");
        return -ENOMEM;
 }
 
-void nfs4_free_openowner(struct nfs4_openowner *oo)
-{
-       kfree(oo->oo_owner.so_owner.data);
-       kmem_cache_free(openowner_slab, oo);
-}
-
-void nfs4_free_lockowner(struct nfs4_lockowner *lo)
-{
-       kfree(lo->lo_owner.so_owner.data);
-       kmem_cache_free(lockowner_slab, lo);
-}
-
 static void init_nfs4_replay(struct nfs4_replay *rp)
 {
        rp->rp_status = nfserr_serverfault;
@@ -2685,15 +2712,15 @@ find_file(struct inode *ino)
        unsigned int hashval = file_hashval(ino);
        struct nfs4_file *fp;
 
-       spin_lock(&recall_lock);
+       spin_lock(&state_lock);
        hlist_for_each_entry(fp, &file_hashtbl[hashval], fi_hash) {
                if (fp->fi_inode == ino) {
                        get_nfs4_file(fp);
-                       spin_unlock(&recall_lock);
+                       spin_unlock(&state_lock);
                        return fp;
                }
        }
-       spin_unlock(&recall_lock);
+       spin_unlock(&state_lock);
        return NULL;
 }
 
@@ -2730,6 +2757,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp)
        struct nfs4_client *clp = dp->dl_stid.sc_client;
        struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
 
+       lockdep_assert_held(&state_lock);
        /* We're assuming the state code never drops its reference
         * without first removing the lease.  Since we're in this lease
         * callback (and since the lease code is serialized by the kernel
@@ -2766,11 +2794,11 @@ static void nfsd_break_deleg_cb(struct file_lock *fl)
         */
        fl->fl_break_time = 0;
 
-       spin_lock(&recall_lock);
+       spin_lock(&state_lock);
        fp->fi_had_conflict = true;
        list_for_each_entry(dp, &fp->fi_delegations, dl_perfile)
                nfsd_break_one_deleg(dp);
-       spin_unlock(&recall_lock);
+       spin_unlock(&state_lock);
 }
 
 static
@@ -3047,11 +3075,12 @@ static int nfs4_setlease(struct nfs4_delegation *dp)
        status = vfs_setlease(fl->fl_file, fl->fl_type, &fl);
        if (status)
                goto out_free;
-       list_add(&dp->dl_perclnt, &dp->dl_stid.sc_client->cl_delegations);
        fp->fi_lease = fl;
        fp->fi_deleg_file = get_file(fl->fl_file);
        atomic_set(&fp->fi_delegees, 1);
-       list_add(&dp->dl_perfile, &fp->fi_delegations);
+       spin_lock(&state_lock);
+       hash_delegation_locked(dp, fp);
+       spin_unlock(&state_lock);
        return 0;
 out_free:
        locks_free_lock(fl);
@@ -3060,33 +3089,21 @@ out_free:
 
 static int nfs4_set_delegation(struct nfs4_delegation *dp, struct nfs4_file *fp)
 {
-       int status;
-
        if (fp->fi_had_conflict)
                return -EAGAIN;
        get_nfs4_file(fp);
        dp->dl_file = fp;
-       if (!fp->fi_lease) {
-               status = nfs4_setlease(dp);
-               if (status)
-                       goto out_free;
-               return 0;
-       }
-       spin_lock(&recall_lock);
+       if (!fp->fi_lease)
+               return nfs4_setlease(dp);
+       spin_lock(&state_lock);
+       atomic_inc(&fp->fi_delegees);
        if (fp->fi_had_conflict) {
-               spin_unlock(&recall_lock);
-               status = -EAGAIN;
-               goto out_free;
+               spin_unlock(&state_lock);
+               return -EAGAIN;
        }
-       atomic_inc(&fp->fi_delegees);
-       list_add(&dp->dl_perfile, &fp->fi_delegations);
-       spin_unlock(&recall_lock);
-       list_add(&dp->dl_perclnt, &dp->dl_stid.sc_client->cl_delegations);
+       hash_delegation_locked(dp, fp);
+       spin_unlock(&state_lock);
        return 0;
-out_free:
-       put_nfs4_file(fp);
-       dp->dl_file = fp;
-       return status;
 }
 
 static void nfsd4_open_deleg_none_ext(struct nfsd4_open *open, int status)
@@ -3173,8 +3190,7 @@ nfs4_open_delegation(struct net *net, struct svc_fh *fh,
        open->op_delegate_type = NFS4_OPEN_DELEGATE_READ;
        return;
 out_free:
-       remove_stid(&dp->dl_stid);
-       nfs4_put_delegation(dp);
+       destroy_delegation(dp);
 out_no_deleg:
        open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE;
        if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS &&
@@ -3391,8 +3407,7 @@ nfs4_laundromat(struct nfsd_net *nn)
        struct nfs4_delegation *dp;
        struct list_head *pos, *next, reaplist;
        time_t cutoff = get_seconds() - nn->nfsd4_lease;
-       time_t t, clientid_val = nn->nfsd4_lease;
-       time_t u, test_val = nn->nfsd4_lease;
+       time_t t, new_timeo = nn->nfsd4_lease;
 
        nfs4_lock_state();
 
@@ -3404,8 +3419,7 @@ nfs4_laundromat(struct nfsd_net *nn)
                clp = list_entry(pos, struct nfs4_client, cl_lru);
                if (time_after((unsigned long)clp->cl_time, (unsigned long)cutoff)) {
                        t = clp->cl_time - cutoff;
-                       if (clientid_val > t)
-                               clientid_val = t;
+                       new_timeo = min(new_timeo, t);
                        break;
                }
                if (mark_client_expired_locked(clp)) {
@@ -3422,39 +3436,35 @@ nfs4_laundromat(struct nfsd_net *nn)
                        clp->cl_clientid.cl_id);
                expire_client(clp);
        }
-       spin_lock(&recall_lock);
+       spin_lock(&state_lock);
        list_for_each_safe(pos, next, &nn->del_recall_lru) {
                dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);
                if (net_generic(dp->dl_stid.sc_client->net, nfsd_net_id) != nn)
                        continue;
                if (time_after((unsigned long)dp->dl_time, (unsigned long)cutoff)) {
-                       u = dp->dl_time - cutoff;
-                       if (test_val > u)
-                               test_val = u;
+                       t = dp->dl_time - cutoff;
+                       new_timeo = min(new_timeo, t);
                        break;
                }
                list_move(&dp->dl_recall_lru, &reaplist);
        }
-       spin_unlock(&recall_lock);
+       spin_unlock(&state_lock);
        list_for_each_safe(pos, next, &reaplist) {
                dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);
                revoke_delegation(dp);
        }
-       test_val = nn->nfsd4_lease;
        list_for_each_safe(pos, next, &nn->close_lru) {
                oo = container_of(pos, struct nfs4_openowner, oo_close_lru);
                if (time_after((unsigned long)oo->oo_time, (unsigned long)cutoff)) {
-                       u = oo->oo_time - cutoff;
-                       if (test_val > u)
-                               test_val = u;
+                       t = oo->oo_time - cutoff;
+                       new_timeo = min(new_timeo, t);
                        break;
                }
                release_openowner(oo);
        }
-       if (clientid_val < NFSD_LAUNDROMAT_MINTIMEOUT)
-               clientid_val = NFSD_LAUNDROMAT_MINTIMEOUT;
+       new_timeo = max_t(time_t, new_timeo, NFSD_LAUNDROMAT_MINTIMEOUT);
        nfs4_unlock_state();
-       return clientid_val;
+       return new_timeo;
 }
 
 static struct workqueue_struct *laundry_wq;
@@ -3654,6 +3664,7 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
        struct svc_fh *current_fh = &cstate->current_fh;
        struct inode *ino = current_fh->fh_dentry->d_inode;
        struct nfsd_net *nn = net_generic(net, nfsd_net_id);
+       struct file *file = NULL;
        __be32 status;
 
        if (filpp)
@@ -3665,10 +3676,12 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
        if (ZERO_STATEID(stateid) || ONE_STATEID(stateid))
                return check_special_stateids(net, current_fh, stateid, flags);
 
+       nfs4_lock_state();
+
        status = nfsd4_lookup_stateid(stateid, NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID,
                                      &s, cstate->minorversion, nn);
        if (status)
-               return status;
+               goto out;
        status = check_stateid_generation(stateid, &s->sc_stateid, nfsd4_has_session(cstate));
        if (status)
                goto out;
@@ -3679,8 +3692,8 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
                if (status)
                        goto out;
                if (filpp) {
-                       *filpp = dp->dl_file->fi_deleg_file;
-                       if (!*filpp) {
+                       file = dp->dl_file->fi_deleg_file;
+                       if (!file) {
                                WARN_ON_ONCE(1);
                                status = nfserr_serverfault;
                                goto out;
@@ -3701,16 +3714,20 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
                        goto out;
                if (filpp) {
                        if (flags & RD_STATE)
-                               *filpp = find_readable_file(stp->st_file);
+                               file = find_readable_file(stp->st_file);
                        else
-                               *filpp = find_writeable_file(stp->st_file);
+                               file = find_writeable_file(stp->st_file);
                }
                break;
        default:
-               return nfserr_bad_stateid;
+               status = nfserr_bad_stateid;
+               goto out;
        }
        status = nfs_ok;
+       if (file)
+               *filpp = get_file(file);
 out:
+       nfs4_unlock_state();
        return status;
 }
 
@@ -3726,7 +3743,7 @@ nfsd4_free_lock_stateid(struct nfs4_ol_stateid *stp)
         * correspondance, and we have to delete the lockowner when we
         * delete the lock stateid:
         */
-       unhash_lockowner(lo);
+       release_lockowner(lo);
        return nfs_ok;
 }
 
@@ -4896,6 +4913,7 @@ static u64 nfsd_find_all_delegations(struct nfs4_client *clp, u64 max,
        struct nfs4_delegation *dp, *next;
        u64 count = 0;
 
+       lockdep_assert_held(&state_lock);
        list_for_each_entry_safe(dp, next, &clp->cl_delegations, dl_perclnt) {
                if (victims)
                        list_move(&dp->dl_recall_lru, victims);
@@ -4911,9 +4929,9 @@ u64 nfsd_forget_client_delegations(struct nfs4_client *clp, u64 max)
        LIST_HEAD(victims);
        u64 count;
 
-       spin_lock(&recall_lock);
+       spin_lock(&state_lock);
        count = nfsd_find_all_delegations(clp, max, &victims);
-       spin_unlock(&recall_lock);
+       spin_unlock(&state_lock);
 
        list_for_each_entry_safe(dp, next, &victims, dl_recall_lru)
                revoke_delegation(dp);
@@ -4927,11 +4945,11 @@ u64 nfsd_recall_client_delegations(struct nfs4_client *clp, u64 max)
        LIST_HEAD(victims);
        u64 count;
 
-       spin_lock(&recall_lock);
+       spin_lock(&state_lock);
        count = nfsd_find_all_delegations(clp, max, &victims);
        list_for_each_entry_safe(dp, next, &victims, dl_recall_lru)
                nfsd_break_one_deleg(dp);
-       spin_unlock(&recall_lock);
+       spin_unlock(&state_lock);
 
        return count;
 }
@@ -4940,9 +4958,9 @@ u64 nfsd_print_client_delegations(struct nfs4_client *clp, u64 max)
 {
        u64 count = 0;
 
-       spin_lock(&recall_lock);
+       spin_lock(&state_lock);
        count = nfsd_find_all_delegations(clp, max, NULL);
-       spin_unlock(&recall_lock);
+       spin_unlock(&state_lock);
 
        nfsd_print_count(clp, count, "delegations");
        return count;
@@ -4983,13 +5001,6 @@ struct nfs4_client *nfsd_find_client(struct sockaddr_storage *addr, size_t addr_
 
 #endif /* CONFIG_NFSD_FAULT_INJECTION */
 
-/* initialization to perform at module load time: */
-
-void
-nfs4_state_init(void)
-{
-}
-
 /*
  * Since the lifetime of a delegation isn't limited to that of an open, a
  * client may quite reasonably hang on to a delegation as long as it has
@@ -5160,12 +5171,12 @@ nfs4_state_shutdown_net(struct net *net)
 
        nfs4_lock_state();
        INIT_LIST_HEAD(&reaplist);
-       spin_lock(&recall_lock);
+       spin_lock(&state_lock);
        list_for_each_safe(pos, next, &nn->del_recall_lru) {
                dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);
                list_move(&dp->dl_recall_lru, &reaplist);
        }
-       spin_unlock(&recall_lock);
+       spin_unlock(&state_lock);
        list_for_each_safe(pos, next, &reaplist) {
                dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);
                destroy_delegation(dp);