mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
nfsd4: use callbacks on svc_xprt_deletion
Remove connections from the list when they go down. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
This commit is contained in:
parent
edc7a89403
commit
19cf5c026f
2 changed files with 45 additions and 9 deletions
|
@ -625,6 +625,25 @@ static void init_forechannel_attrs(struct nfsd4_channel_attrs *new, struct nfsd4
|
||||||
new->maxops = min_t(u32, req->maxops, NFSD_MAX_OPS_PER_COMPOUND);
|
new->maxops = min_t(u32, req->maxops, NFSD_MAX_OPS_PER_COMPOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void free_conn(struct nfsd4_conn *c)
|
||||||
|
{
|
||||||
|
svc_xprt_put(c->cn_xprt);
|
||||||
|
kfree(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void nfsd4_conn_lost(struct svc_xpt_user *u)
|
||||||
|
{
|
||||||
|
struct nfsd4_conn *c = container_of(u, struct nfsd4_conn, cn_xpt_user);
|
||||||
|
struct nfs4_client *clp = c->cn_session->se_client;
|
||||||
|
|
||||||
|
spin_lock(&clp->cl_lock);
|
||||||
|
if (!list_empty(&c->cn_persession)) {
|
||||||
|
list_del(&c->cn_persession);
|
||||||
|
free_conn(c);
|
||||||
|
}
|
||||||
|
spin_unlock(&clp->cl_lock);
|
||||||
|
}
|
||||||
|
|
||||||
static __be32 nfsd4_new_conn(struct svc_rqst *rqstp, struct nfsd4_session *ses)
|
static __be32 nfsd4_new_conn(struct svc_rqst *rqstp, struct nfsd4_session *ses)
|
||||||
{
|
{
|
||||||
struct nfs4_client *clp = ses->se_client;
|
struct nfs4_client *clp = ses->se_client;
|
||||||
|
@ -636,18 +655,34 @@ static __be32 nfsd4_new_conn(struct svc_rqst *rqstp, struct nfsd4_session *ses)
|
||||||
conn->cn_flags = NFS4_CDFC4_FORE;
|
conn->cn_flags = NFS4_CDFC4_FORE;
|
||||||
svc_xprt_get(rqstp->rq_xprt);
|
svc_xprt_get(rqstp->rq_xprt);
|
||||||
conn->cn_xprt = rqstp->rq_xprt;
|
conn->cn_xprt = rqstp->rq_xprt;
|
||||||
|
conn->cn_session = ses;
|
||||||
|
|
||||||
spin_lock(&clp->cl_lock);
|
spin_lock(&clp->cl_lock);
|
||||||
list_add(&conn->cn_persession, &ses->se_conns);
|
list_add(&conn->cn_persession, &ses->se_conns);
|
||||||
spin_unlock(&clp->cl_lock);
|
spin_unlock(&clp->cl_lock);
|
||||||
|
|
||||||
|
conn->cn_xpt_user.callback = nfsd4_conn_lost;
|
||||||
|
register_xpt_user(rqstp->rq_xprt, &conn->cn_xpt_user);
|
||||||
return nfs_ok;
|
return nfs_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_conn(struct nfsd4_conn *c)
|
static void nfsd4_del_conns(struct nfsd4_session *s)
|
||||||
{
|
{
|
||||||
svc_xprt_put(c->cn_xprt);
|
struct nfs4_client *clp = s->se_client;
|
||||||
kfree(c);
|
struct nfsd4_conn *c;
|
||||||
|
|
||||||
|
spin_lock(&clp->cl_lock);
|
||||||
|
while (!list_empty(&s->se_conns)) {
|
||||||
|
c = list_first_entry(&s->se_conns, struct nfsd4_conn, cn_persession);
|
||||||
|
list_del_init(&c->cn_persession);
|
||||||
|
spin_unlock(&clp->cl_lock);
|
||||||
|
|
||||||
|
unregister_xpt_user(c->cn_xprt, &c->cn_xpt_user);
|
||||||
|
free_conn(c);
|
||||||
|
|
||||||
|
spin_lock(&clp->cl_lock);
|
||||||
|
}
|
||||||
|
spin_unlock(&clp->cl_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_session(struct kref *kref)
|
void free_session(struct kref *kref)
|
||||||
|
@ -656,12 +691,7 @@ void free_session(struct kref *kref)
|
||||||
int mem;
|
int mem;
|
||||||
|
|
||||||
ses = container_of(kref, struct nfsd4_session, se_ref);
|
ses = container_of(kref, struct nfsd4_session, se_ref);
|
||||||
while (!list_empty(&ses->se_conns)) {
|
nfsd4_del_conns(ses);
|
||||||
struct nfsd4_conn *c;
|
|
||||||
c = list_first_entry(&ses->se_conns, struct nfsd4_conn, cn_persession);
|
|
||||||
list_del(&c->cn_persession);
|
|
||||||
free_conn(c);
|
|
||||||
}
|
|
||||||
spin_lock(&nfsd_drc_lock);
|
spin_lock(&nfsd_drc_lock);
|
||||||
mem = ses->se_fchannel.maxreqs * slot_bytes(&ses->se_fchannel);
|
mem = ses->se_fchannel.maxreqs * slot_bytes(&ses->se_fchannel);
|
||||||
nfsd_drc_mem_used -= mem;
|
nfsd_drc_mem_used -= mem;
|
||||||
|
@ -1552,6 +1582,9 @@ nfsd4_destroy_session(struct svc_rqst *r,
|
||||||
/* wait for callbacks */
|
/* wait for callbacks */
|
||||||
nfsd4_shutdown_callback(ses->se_client);
|
nfsd4_shutdown_callback(ses->se_client);
|
||||||
nfs4_unlock_state();
|
nfs4_unlock_state();
|
||||||
|
|
||||||
|
nfsd4_del_conns(ses);
|
||||||
|
|
||||||
nfsd4_put_session(ses);
|
nfsd4_put_session(ses);
|
||||||
status = nfs_ok;
|
status = nfs_ok;
|
||||||
out:
|
out:
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#ifndef _NFSD4_STATE_H
|
#ifndef _NFSD4_STATE_H
|
||||||
#define _NFSD4_STATE_H
|
#define _NFSD4_STATE_H
|
||||||
|
|
||||||
|
#include <linux/sunrpc/svc_xprt.h>
|
||||||
#include <linux/nfsd/nfsfh.h>
|
#include <linux/nfsd/nfsfh.h>
|
||||||
#include "nfsfh.h"
|
#include "nfsfh.h"
|
||||||
|
|
||||||
|
@ -155,6 +156,8 @@ struct nfsd4_clid_slot {
|
||||||
struct nfsd4_conn {
|
struct nfsd4_conn {
|
||||||
struct list_head cn_persession;
|
struct list_head cn_persession;
|
||||||
struct svc_xprt *cn_xprt;
|
struct svc_xprt *cn_xprt;
|
||||||
|
struct svc_xpt_user cn_xpt_user;
|
||||||
|
struct nfsd4_session *cn_session;
|
||||||
/* CDFC4_FORE, CDFC4_BACK: */
|
/* CDFC4_FORE, CDFC4_BACK: */
|
||||||
unsigned char cn_flags;
|
unsigned char cn_flags;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue