knfsd: Fix a race in closing NFSd connections.
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): 20070207110636.9166.patches@notabene
PATCH 1/1 knfsd: Fix a race in closing NFSd connections.
There is a bug introduced in 2.6.19 that can cause badness in the NFS server, particularly if you get clients closing connections while the server is trying to write a reply.
This patch fixed the bug and improves the handling of socket closing.
The patch was made against -mm, and applies correctly with a little bit of fuzz to 2.6.19 and 2.6.20. It should be considered at least for 2.6.20.1.
Thanks,
NeilBrown
### Comments for Changeset
If you lose this race, it can iput a socket inode twice and you get a BUG in fs/inode.c
When I added the option for user-space to close a socket, I added some cruft to svc_delete_socket so that I could call that function when closing a socket per user-space request.
This was the wrong thing to do. I should have just set SK_CLOSE and let normal mechanisms do the work.
Not only wrong, but buggy. The locking is all wrong and it openned up a race where-by a socket could be closed twice.
So this patch:
Introduces svc_close_socket which sets SK_CLOSE then either leave the close up to a thread, or calls svc_delete_socket if it can get SK_BUSY.
Adds a bias to sk_busy which is removed when SK_DEAD is set, This avoid races around shutting down the socket.
Changes several 'spin_lock' to 'spin_lock_bh' where the _bh was missing.
Bugzilla-url: http://bugzilla.kernel.org/show_bug.cgi?id=7916
### Diffstat output
./include/linux/sunrpc/svcsock.h | 2 - ./net/sunrpc/svc.c | 4 +-- ./net/sunrpc/svcsock.c | 52 ++++++++++++++++++++++++++++----------- 3 files changed, 41 insertions(+), 17 deletions(-)
include/linux/sunrpc/svcsock.h +1 -1
@@ -66,7 +66,7 @@ struct svc_sock {* Function prototypes. */ int svc_makesock (struct svc_serv *,int ,unsigned short ,int flags); -void svc_delete_socket (struct svc_sock *); +void svc_close_socket (struct svc_sock *);int svc_recv (struct svc_rqst *,long );int svc_send (struct svc_rqst *);void svc_drop (struct svc_rqst *);
net/sunrpc/svc.c +2 -2
@@ -386,7 +386,7 @@ svc_destroy(struct svc_serv *serv) svsk =list_entry (serv->sv_tempsocks.next, struct svc_sock, sk_list); -svc_delete_socket (svsk); +svc_close_socket (svsk); }if (serv->sv_shutdown) serv->sv_shutdown (serv);
@@ -395,7 +395,7 @@ svc_destroy(struct svc_serv *serv) svsk =list_entry (serv->sv_permsocks.next, struct svc_sock, sk_list); -svc_delete_socket (svsk); +svc_close_socket (svsk); }cache_clean_deferred (serv);
net/sunrpc/svcsock.c +38 -14
120 lines not on this page · raw message
Quoted 18 lines · On Wed, 7 Feb 2007 11:10:26 +1100 NeilBrown <[email protected]> wrote:
If you lose this race, it can iput a socket inode twice and you get a BUG in
fs/inode.cWhen I added the option for user-space to close a socket, I added some cruft to
svc_delete_socketso that I could call that function when closing a socket per user-space request.This was the wrong thing to do. I should have just set
SK_CLOSEand let normal mechanisms do the work.Not only wrong, but buggy. The locking is all wrong and it openned up a race where-by a socket could be closed twice.
So this patch:
Introducessvc_close_socketwhich setsSK_CLOSEthen either leave the close up to a thread, or callssvc_delete_socketif it can getSK_BUSY.
Quoted 6 lines
Adds a bias to
sk_busywhich is removed whenSK_DEADis set, This avoid races around shutting down the socket.Changes several '
spin_lock' to 'spin_lock_bh' where the_bhwas missing.
This patch assumes the presence of knfsd-sunrpc-allow-creating-an-rpc-service-without-registering-with-portmapper.patch which obviously isn't appropriate for -stable.
Please confirm that the patch which I merged is still OK, thanks.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 4 lines · On Tuesday February 6, [email protected] wrote:
This patch assumes the presence of knfsd-sunrpc-allow-creating-an-rpc-service-without-registering-with-portmapper.patch which obviously isn't appropriate for -stable.
Only because they change adjacent lines. There is no semantic dependency.
The patch I sent will apply *correctly* against -stable with "--fuzz=3".
I cannot send a fuzz-free patch if that would make Mr Stable happy.
Quoted 2 lines
Please confirm that the patch which I merged is still OK, thanks.
Yes, the patch which you merged is OK.
Thanks,
NeilBrown