Commit 0a880a28 authored by Trond Myklebust's avatar Trond Myklebust Committed by J. Bruce Fields

nfsd: Add lockdep assertions to document the nfs4_client/session locking

Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: default avatarJeff Layton <jlayton@primarydata.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 3e339f96
...@@ -139,6 +139,10 @@ static __be32 mark_client_expired_locked(struct nfs4_client *clp) ...@@ -139,6 +139,10 @@ static __be32 mark_client_expired_locked(struct nfs4_client *clp)
static __be32 get_client_locked(struct nfs4_client *clp) static __be32 get_client_locked(struct nfs4_client *clp)
{ {
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
lockdep_assert_held(&nn->client_lock);
if (is_client_expired(clp)) if (is_client_expired(clp))
return nfserr_expired; return nfserr_expired;
atomic_inc(&clp->cl_refcount); atomic_inc(&clp->cl_refcount);
...@@ -179,6 +183,10 @@ renew_client(struct nfs4_client *clp) ...@@ -179,6 +183,10 @@ renew_client(struct nfs4_client *clp)
static void put_client_renew_locked(struct nfs4_client *clp) static void put_client_renew_locked(struct nfs4_client *clp)
{ {
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
lockdep_assert_held(&nn->client_lock);
if (!atomic_dec_and_test(&clp->cl_refcount)) if (!atomic_dec_and_test(&clp->cl_refcount))
return; return;
if (!is_client_expired(clp)) if (!is_client_expired(clp))
...@@ -212,6 +220,9 @@ static __be32 nfsd4_get_session_locked(struct nfsd4_session *ses) ...@@ -212,6 +220,9 @@ static __be32 nfsd4_get_session_locked(struct nfsd4_session *ses)
static void nfsd4_put_session_locked(struct nfsd4_session *ses) static void nfsd4_put_session_locked(struct nfsd4_session *ses)
{ {
struct nfs4_client *clp = ses->se_client; struct nfs4_client *clp = ses->se_client;
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
lockdep_assert_held(&nn->client_lock);
if (atomic_dec_and_test(&ses->se_ref) && is_session_dead(ses)) if (atomic_dec_and_test(&ses->se_ref) && is_session_dead(ses))
free_session(ses); free_session(ses);
...@@ -1453,6 +1464,8 @@ __find_in_sessionid_hashtbl(struct nfs4_sessionid *sessionid, struct net *net) ...@@ -1453,6 +1464,8 @@ __find_in_sessionid_hashtbl(struct nfs4_sessionid *sessionid, struct net *net)
int idx; int idx;
struct nfsd_net *nn = net_generic(net, nfsd_net_id); struct nfsd_net *nn = net_generic(net, nfsd_net_id);
lockdep_assert_held(&nn->client_lock);
dump_sessionid(__func__, sessionid); dump_sessionid(__func__, sessionid);
idx = hash_sessionid(sessionid); idx = hash_sessionid(sessionid);
/* Search in the appropriate list */ /* Search in the appropriate list */
...@@ -1489,6 +1502,11 @@ find_in_sessionid_hashtbl(struct nfs4_sessionid *sessionid, struct net *net, ...@@ -1489,6 +1502,11 @@ find_in_sessionid_hashtbl(struct nfs4_sessionid *sessionid, struct net *net,
static void static void
unhash_session(struct nfsd4_session *ses) unhash_session(struct nfsd4_session *ses)
{ {
struct nfs4_client *clp = ses->se_client;
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
lockdep_assert_held(&nn->client_lock);
list_del(&ses->se_hash); list_del(&ses->se_hash);
spin_lock(&ses->se_client->cl_lock); spin_lock(&ses->se_client->cl_lock);
list_del(&ses->se_perclnt); list_del(&ses->se_perclnt);
...@@ -1575,6 +1593,8 @@ unhash_client_locked(struct nfs4_client *clp) ...@@ -1575,6 +1593,8 @@ unhash_client_locked(struct nfs4_client *clp)
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
struct nfsd4_session *ses; struct nfsd4_session *ses;
lockdep_assert_held(&nn->client_lock);
/* Mark the client as expired! */ /* Mark the client as expired! */
clp->cl_time = 0; clp->cl_time = 0;
/* Make it invisible */ /* Make it invisible */
...@@ -1906,6 +1926,8 @@ add_to_unconfirmed(struct nfs4_client *clp) ...@@ -1906,6 +1926,8 @@ add_to_unconfirmed(struct nfs4_client *clp)
unsigned int idhashval; unsigned int idhashval;
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
lockdep_assert_held(&nn->client_lock);
clear_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags); clear_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags);
add_clp_to_name_tree(clp, &nn->unconf_name_tree); add_clp_to_name_tree(clp, &nn->unconf_name_tree);
idhashval = clientid_hashval(clp->cl_clientid.cl_id); idhashval = clientid_hashval(clp->cl_clientid.cl_id);
...@@ -1919,6 +1941,8 @@ move_to_confirmed(struct nfs4_client *clp) ...@@ -1919,6 +1941,8 @@ move_to_confirmed(struct nfs4_client *clp)
unsigned int idhashval = clientid_hashval(clp->cl_clientid.cl_id); unsigned int idhashval = clientid_hashval(clp->cl_clientid.cl_id);
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
lockdep_assert_held(&nn->client_lock);
dprintk("NFSD: move_to_confirm nfs4_client %p\n", clp); dprintk("NFSD: move_to_confirm nfs4_client %p\n", clp);
list_move(&clp->cl_idhash, &nn->conf_id_hashtbl[idhashval]); list_move(&clp->cl_idhash, &nn->conf_id_hashtbl[idhashval]);
rb_erase(&clp->cl_namenode, &nn->unconf_name_tree); rb_erase(&clp->cl_namenode, &nn->unconf_name_tree);
...@@ -1949,6 +1973,7 @@ find_confirmed_client(clientid_t *clid, bool sessions, struct nfsd_net *nn) ...@@ -1949,6 +1973,7 @@ find_confirmed_client(clientid_t *clid, bool sessions, struct nfsd_net *nn)
{ {
struct list_head *tbl = nn->conf_id_hashtbl; struct list_head *tbl = nn->conf_id_hashtbl;
lockdep_assert_held(&nn->client_lock);
return find_client_in_id_table(tbl, clid, sessions); return find_client_in_id_table(tbl, clid, sessions);
} }
...@@ -1957,6 +1982,7 @@ find_unconfirmed_client(clientid_t *clid, bool sessions, struct nfsd_net *nn) ...@@ -1957,6 +1982,7 @@ find_unconfirmed_client(clientid_t *clid, bool sessions, struct nfsd_net *nn)
{ {
struct list_head *tbl = nn->unconf_id_hashtbl; struct list_head *tbl = nn->unconf_id_hashtbl;
lockdep_assert_held(&nn->client_lock);
return find_client_in_id_table(tbl, clid, sessions); return find_client_in_id_table(tbl, clid, sessions);
} }
...@@ -1968,12 +1994,14 @@ static bool clp_used_exchangeid(struct nfs4_client *clp) ...@@ -1968,12 +1994,14 @@ static bool clp_used_exchangeid(struct nfs4_client *clp)
static struct nfs4_client * static struct nfs4_client *
find_confirmed_client_by_name(struct xdr_netobj *name, struct nfsd_net *nn) find_confirmed_client_by_name(struct xdr_netobj *name, struct nfsd_net *nn)
{ {
lockdep_assert_held(&nn->client_lock);
return find_clp_in_name_tree(name, &nn->conf_name_tree); return find_clp_in_name_tree(name, &nn->conf_name_tree);
} }
static struct nfs4_client * static struct nfs4_client *
find_unconfirmed_client_by_name(struct xdr_netobj *name, struct nfsd_net *nn) find_unconfirmed_client_by_name(struct xdr_netobj *name, struct nfsd_net *nn)
{ {
lockdep_assert_held(&nn->client_lock);
return find_clp_in_name_tree(name, &nn->unconf_name_tree); return find_clp_in_name_tree(name, &nn->unconf_name_tree);
} }
...@@ -4907,6 +4935,8 @@ find_lockowner_str_locked(clientid_t *clid, struct xdr_netobj *owner, ...@@ -4907,6 +4935,8 @@ find_lockowner_str_locked(clientid_t *clid, struct xdr_netobj *owner,
unsigned int strhashval = ownerstr_hashval(owner); unsigned int strhashval = ownerstr_hashval(owner);
struct nfs4_stateowner *so; struct nfs4_stateowner *so;
lockdep_assert_held(&clp->cl_lock);
list_for_each_entry(so, &clp->cl_ownerstr_hashtbl[strhashval], list_for_each_entry(so, &clp->cl_ownerstr_hashtbl[strhashval],
so_strhash) { so_strhash) {
if (so->so_is_open_owner) if (so->so_is_open_owner)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment