]> git.karo-electronics.de Git - karo-tx-linux.git/commit
knfsd: Fix a race in closing NFSd connections.
authorNeilBrown <neilb@suse.de>
Wed, 7 Feb 2007 00:10:26 +0000 (11:10 +1100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 9 Mar 2007 18:50:18 +0000 (10:50 -0800)
commitb3725e12ab2cf9e0f1254506baef3f9206520d3e
treea6017d4ff34399b4e77d3ff3ad9cb8a0a79aaf81
parente3844c2df6b122e494e77ab507ae96553160c006
knfsd: Fix a race in closing NFSd connections.

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

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
include/linux/sunrpc/svcsock.h
net/sunrpc/svc.c
net/sunrpc/svcsock.c