diff options
author | Jeff Layton <jlayton@redhat.com> | 2008-11-14 13:53:46 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2008-11-14 18:56:55 -0500 |
commit | 14fbf50d695207754daeb96270b3027a3821121f (patch) | |
tree | 05e80aa7e5e6a6bc07a9354f744ba9c599699569 /fs/cifs/cifssmb.c | |
parent | e7ddee9037e7dd43de1ad08b51727e552aedd836 (diff) |
cifs: reinstate sharing of SMB sessions sans races
We do this by abandoning the global list of SMB sessions and instead
moving to a per-server list. This entails adding a new list head to the
TCP_Server_Info struct. The refcounting for the cifsSesInfo is moved to
a non-atomic variable. We have to protect it by a lock anyway, so there's
no benefit to making it an atomic. The list and refcount are protected
by the global cifs_tcp_ses_lock.
The patch also adds a new routines to find and put SMB sessions and
that properly take and put references under the lock.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/cifssmb.c')
-rw-r--r-- | fs/cifs/cifssmb.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index cd9e9a145e4d..9c95617baa4d 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -799,20 +799,16 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses) | |||
799 | int rc = 0; | 799 | int rc = 0; |
800 | 800 | ||
801 | cFYI(1, ("In SMBLogoff for session disconnect")); | 801 | cFYI(1, ("In SMBLogoff for session disconnect")); |
802 | if (ses) | ||
803 | down(&ses->sesSem); | ||
804 | else | ||
805 | return -EIO; | ||
806 | |||
807 | atomic_dec(&ses->inUse); | ||
808 | if (atomic_read(&ses->inUse) > 0) { | ||
809 | up(&ses->sesSem); | ||
810 | return -EBUSY; | ||
811 | } | ||
812 | 802 | ||
813 | if (ses->server == NULL) | 803 | /* |
804 | * BB: do we need to check validity of ses and server? They should | ||
805 | * always be valid since we have an active reference. If not, that | ||
806 | * should probably be a BUG() | ||
807 | */ | ||
808 | if (!ses || !ses->server) | ||
814 | return -EIO; | 809 | return -EIO; |
815 | 810 | ||
811 | down(&ses->sesSem); | ||
816 | if (ses->need_reconnect) | 812 | if (ses->need_reconnect) |
817 | goto session_already_dead; /* no need to send SMBlogoff if uid | 813 | goto session_already_dead; /* no need to send SMBlogoff if uid |
818 | already closed due to reconnect */ | 814 | already closed due to reconnect */ |
@@ -833,10 +829,6 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses) | |||
833 | pSMB->AndXCommand = 0xFF; | 829 | pSMB->AndXCommand = 0xFF; |
834 | rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0); | 830 | rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0); |
835 | session_already_dead: | 831 | session_already_dead: |
836 | if (ses->server) { | ||
837 | cifs_put_tcp_session(ses->server); | ||
838 | rc = 0; | ||
839 | } | ||
840 | up(&ses->sesSem); | 832 | up(&ses->sesSem); |
841 | 833 | ||
842 | /* if session dead then we do not need to do ulogoff, | 834 | /* if session dead then we do not need to do ulogoff, |