nfsd4: fix 4.1 connection registration race
If a connection is closed just after a sequence or create_session is sent over it, we could end up trying to register a callback that will never get called since the xprt is already marked dead. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
c8ddb2713c
commit
21b75b0199
2 changed files with 29 additions and 11 deletions
|
|
@ -82,13 +82,6 @@ struct svc_xprt {
|
|||
struct net *xpt_net;
|
||||
};
|
||||
|
||||
static inline void register_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user *u)
|
||||
{
|
||||
spin_lock(&xpt->xpt_lock);
|
||||
list_add(&u->list, &xpt->xpt_users);
|
||||
spin_unlock(&xpt->xpt_lock);
|
||||
}
|
||||
|
||||
static inline void unregister_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user *u)
|
||||
{
|
||||
spin_lock(&xpt->xpt_lock);
|
||||
|
|
@ -96,6 +89,23 @@ static inline void unregister_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user
|
|||
spin_unlock(&xpt->xpt_lock);
|
||||
}
|
||||
|
||||
static inline int register_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user *u)
|
||||
{
|
||||
spin_lock(&xpt->xpt_lock);
|
||||
if (test_bit(XPT_CLOSE, &xpt->xpt_flags)) {
|
||||
/*
|
||||
* The connection is about to be deleted soon (or,
|
||||
* worse, may already be deleted--in which case we've
|
||||
* already notified the xpt_users).
|
||||
*/
|
||||
spin_unlock(&xpt->xpt_lock);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
list_add(&u->list, &xpt->xpt_users);
|
||||
spin_unlock(&xpt->xpt_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int svc_reg_xprt_class(struct svc_xprt_class *);
|
||||
void svc_unreg_xprt_class(struct svc_xprt_class *);
|
||||
void svc_xprt_init(struct svc_xprt_class *, struct svc_xprt *,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue