Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 297451
b: refs/heads/master
c: 508dc6e
h: refs/heads/master
i:
  297449: 5a6d3b0
  297447: 37a22eb
v: v3
  • Loading branch information
Benny Halevy authored and J. Bruce Fields committed Mar 6, 2012
1 parent 2f43eb0 commit 2267757
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e27f49c33b7410f4db065bc4382a8e03769eecc3
refs/heads/master: 508dc6e110c6dbdc0bbe84298ccfe22de7538486
35 changes: 31 additions & 4 deletions trunk/fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ nfs4_lock_state(void)
mutex_lock(&client_mutex);
}

static void free_session(struct kref *);

/* Must be called under the client_lock */
static void nfsd4_put_session_locked(struct nfsd4_session *ses)
{
kref_put(&ses->se_ref, free_session);
}

static void nfsd4_get_session(struct nfsd4_session *ses)
{
kref_get(&ses->se_ref);
}

void
nfs4_unlock_state(void)
{
Expand Down Expand Up @@ -836,11 +849,12 @@ static void nfsd4_del_conns(struct nfsd4_session *s)
spin_unlock(&clp->cl_lock);
}

void free_session(struct kref *kref)
static void free_session(struct kref *kref)
{
struct nfsd4_session *ses;
int mem;

BUG_ON(!spin_is_locked(&client_lock));
ses = container_of(kref, struct nfsd4_session, se_ref);
nfsd4_del_conns(ses);
spin_lock(&nfsd_drc_lock);
Expand All @@ -851,6 +865,13 @@ void free_session(struct kref *kref)
kfree(ses);
}

void nfsd4_put_session(struct nfsd4_session *ses)
{
spin_lock(&client_lock);
nfsd4_put_session_locked(ses);
spin_unlock(&client_lock);
}

static struct nfsd4_session *alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp, struct nfsd4_create_session *cses)
{
struct nfsd4_session *new;
Expand Down Expand Up @@ -898,7 +919,9 @@ static struct nfsd4_session *alloc_init_session(struct svc_rqst *rqstp, struct n
status = nfsd4_new_conn_from_crses(rqstp, new);
/* whoops: benny points out, status is ignored! (err, or bogus) */
if (status) {
spin_lock(&client_lock);
free_session(&new->se_ref);
spin_unlock(&client_lock);
return NULL;
}
if (cses->flags & SESSION4_BACK_CHAN) {
Expand Down Expand Up @@ -1010,12 +1033,13 @@ static struct nfs4_client *alloc_client(struct xdr_netobj name)
static inline void
free_client(struct nfs4_client *clp)
{
BUG_ON(!spin_is_locked(&client_lock));
while (!list_empty(&clp->cl_sessions)) {
struct nfsd4_session *ses;
ses = list_entry(clp->cl_sessions.next, struct nfsd4_session,
se_perclnt);
list_del(&ses->se_perclnt);
nfsd4_put_session(ses);
nfsd4_put_session_locked(ses);
}
if (clp->cl_cred.cr_group_info)
put_group_info(clp->cl_cred.cr_group_info);
Expand Down Expand Up @@ -1184,7 +1208,9 @@ static struct nfs4_client *create_client(struct xdr_netobj name, char *recdir,
if (princ) {
clp->cl_principal = kstrdup(princ, GFP_KERNEL);
if (clp->cl_principal == NULL) {
spin_lock(&client_lock);
free_client(clp);
spin_unlock(&client_lock);
return NULL;
}
}
Expand Down Expand Up @@ -1812,9 +1838,10 @@ nfsd4_destroy_session(struct svc_rqst *r,
nfsd4_probe_callback_sync(ses->se_client);
nfs4_unlock_state();

spin_lock(&client_lock);
nfsd4_del_conns(ses);

nfsd4_put_session(ses);
nfsd4_put_session_locked(ses);
spin_unlock(&client_lock);
status = nfs_ok;
out:
dprintk("%s returns %d\n", __func__, ntohl(status));
Expand Down
13 changes: 1 addition & 12 deletions trunk/fs/nfsd/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,7 @@ struct nfsd4_session {
struct nfsd4_slot *se_slots[]; /* forward channel slots */
};

static inline void
nfsd4_put_session(struct nfsd4_session *ses)
{
extern void free_session(struct kref *kref);
kref_put(&ses->se_ref, free_session);
}

static inline void
nfsd4_get_session(struct nfsd4_session *ses)
{
kref_get(&ses->se_ref);
}
extern void nfsd4_put_session(struct nfsd4_session *ses);

/* formatted contents of nfs4_sessionid */
struct nfsd4_sessionid {
Expand Down

0 comments on commit 2267757

Please sign in to comment.