Skip to content

Commit

Permalink
lockd: Add nlm_destroy_host_locked()
Browse files Browse the repository at this point in the history
Refactor the tail of nlm_gc_hosts() into nlm_destroy_host() so that
this logic can be used separately from garbage collection.

Rename it _locked() to document that it must be called with the hosts
cache mutex held.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Dec 16, 2010
1 parent a7952f4 commit 723bb5b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions fs/lockd/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,23 +231,30 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni)
}

/*
* Destroy a host
* Destroy an nlm_host and free associated resources
*
* Caller must hold nlm_host_mutex.
*/
static void
nlm_destroy_host(struct nlm_host *host)
static void nlm_destroy_host_locked(struct nlm_host *host)
{
struct rpc_clnt *clnt;

dprintk("lockd: destroy host %s\n", host->h_name);

BUG_ON(!list_empty(&host->h_lockowners));
BUG_ON(atomic_read(&host->h_count));

hlist_del_init(&host->h_hash);

nsm_unmonitor(host);
nsm_release(host->h_nsmhandle);

clnt = host->h_rpcclnt;
if (clnt != NULL)
rpc_shutdown_client(clnt);
kfree(host);

nrhosts--;
}

/**
Expand Down Expand Up @@ -589,11 +596,7 @@ nlm_gc_hosts(void)
host->h_inuse, host->h_expires);
continue;
}
dprintk("lockd: delete host %s\n", host->h_name);
hlist_del_init(&host->h_hash);

nlm_destroy_host(host);
nrhosts--;
nlm_destroy_host_locked(host);
}

next_gc = jiffies + NLM_HOST_COLLECT;
Expand Down

0 comments on commit 723bb5b

Please sign in to comment.