diff options
author | J. Bruce Fields <bfields@redhat.com> | 2010-10-26 10:07:17 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2010-11-02 17:13:52 -0400 |
commit | 21b75b019983dfa5c2dda588f4b60b4ca69844a4 (patch) | |
tree | c1e0a8c4e136a0de35fc996a7ed6c5db1e6bb9cc /include/linux/sunrpc | |
parent | c8ddb2713c624f432fa5fe3c7ecffcdda46ea0d4 (diff) | |
download | kernel_samsung_tuna-21b75b019983dfa5c2dda588f4b60b4ca69844a4.zip kernel_samsung_tuna-21b75b019983dfa5c2dda588f4b60b4ca69844a4.tar.gz kernel_samsung_tuna-21b75b019983dfa5c2dda588f4b60b4ca69844a4.tar.bz2 |
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>
Diffstat (limited to 'include/linux/sunrpc')
-rw-r--r-- | include/linux/sunrpc/svc_xprt.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h index bbdb680..aea0d438 100644 --- a/include/linux/sunrpc/svc_xprt.h +++ b/include/linux/sunrpc/svc_xprt.h @@ -82,18 +82,28 @@ struct svc_xprt { struct net *xpt_net; }; -static inline void register_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user *u) +static inline void unregister_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user *u) { spin_lock(&xpt->xpt_lock); - list_add(&u->list, &xpt->xpt_users); + list_del_init(&u->list); spin_unlock(&xpt->xpt_lock); } -static inline void unregister_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user *u) +static inline int register_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user *u) { spin_lock(&xpt->xpt_lock); - list_del_init(&u->list); + 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 *); |