Skip to content

Commit

Permalink
NFSv4.1: nfs4_destroy_session must call rpc_destroy_waitqueue
Browse files Browse the repository at this point in the history
There may still be timers active on the session waitqueues. Make sure
that we kill them before freeing the memory.

Cc: stable@vger.kernel.org # 3.12+
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
Trond Myklebust committed Feb 1, 2014
1 parent 17ead6c commit 20b9a90
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fs/nfs/nfs4client.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void nfs41_shutdown_client(struct nfs_client *clp)
void nfs40_shutdown_client(struct nfs_client *clp)
{
if (clp->cl_slot_tbl) {
nfs4_release_slot_table(clp->cl_slot_tbl);
nfs4_shutdown_slot_table(clp->cl_slot_tbl);
kfree(clp->cl_slot_tbl);
}
}
Expand Down
25 changes: 20 additions & 5 deletions fs/nfs/nfs4session.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,23 @@ static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl,
return ret;
}

/*
* nfs4_release_slot_table - release all slot table entries
*/
static void nfs4_release_slot_table(struct nfs4_slot_table *tbl)
{
nfs4_shrink_slot_table(tbl, 0);
}

/**
* nfs4_release_slot_table - release resources attached to a slot table
* nfs4_shutdown_slot_table - release resources attached to a slot table
* @tbl: slot table to shut down
*
*/
void nfs4_release_slot_table(struct nfs4_slot_table *tbl)
void nfs4_shutdown_slot_table(struct nfs4_slot_table *tbl)
{
nfs4_shrink_slot_table(tbl, 0);
nfs4_release_slot_table(tbl);
rpc_destroy_wait_queue(&tbl->slot_tbl_waitq);
}

/**
Expand Down Expand Up @@ -422,7 +431,7 @@ void nfs41_update_target_slotid(struct nfs4_slot_table *tbl,
spin_unlock(&tbl->slot_tbl_lock);
}

static void nfs4_destroy_session_slot_tables(struct nfs4_session *session)
static void nfs4_release_session_slot_tables(struct nfs4_session *session)
{
nfs4_release_slot_table(&session->fc_slot_table);
nfs4_release_slot_table(&session->bc_slot_table);
Expand Down Expand Up @@ -450,7 +459,7 @@ int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
if (status && tbl->slots == NULL)
/* Fore and back channel share a connection so get
* both slot tables or neither */
nfs4_destroy_session_slot_tables(ses);
nfs4_release_session_slot_tables(ses);
return status;
}

Expand All @@ -470,6 +479,12 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
return session;
}

static void nfs4_destroy_session_slot_tables(struct nfs4_session *session)
{
nfs4_shutdown_slot_table(&session->fc_slot_table);
nfs4_shutdown_slot_table(&session->bc_slot_table);
}

void nfs4_destroy_session(struct nfs4_session *session)
{
struct rpc_xprt *xprt;
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/nfs4session.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ enum nfs4_session_state {

extern int nfs4_setup_slot_table(struct nfs4_slot_table *tbl,
unsigned int max_reqs, const char *queue);
extern void nfs4_release_slot_table(struct nfs4_slot_table *tbl);
extern void nfs4_shutdown_slot_table(struct nfs4_slot_table *tbl);
extern struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl);
extern void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot);
extern void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl);
Expand Down

0 comments on commit 20b9a90

Please sign in to comment.