Commit 72ca545b authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

cifs: convert tcpSem to a mutex

Mutexes are preferred for single-holder semaphores...
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 0468a2cf
...@@ -151,7 +151,7 @@ struct TCP_Server_Info { ...@@ -151,7 +151,7 @@ struct TCP_Server_Info {
atomic_t num_waiters; /* blocked waiting to get in sendrecv */ atomic_t num_waiters; /* blocked waiting to get in sendrecv */
#endif #endif
enum statusEnum tcpStatus; /* what we think the status is */ enum statusEnum tcpStatus; /* what we think the status is */
struct semaphore tcpSem; struct mutex srv_mutex;
struct task_struct *tsk; struct task_struct *tsk;
char server_GUID[16]; char server_GUID[16];
char secMode; char secMode;
......
...@@ -156,7 +156,7 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -156,7 +156,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
} }
read_unlock(&cifs_tcp_ses_lock); read_unlock(&cifs_tcp_ses_lock);
/* do not want to be sending data on a socket we are freeing */ /* do not want to be sending data on a socket we are freeing */
down(&server->tcpSem); mutex_lock(&server->srv_mutex);
if (server->ssocket) { if (server->ssocket) {
cFYI(1, ("State: 0x%x Flags: 0x%lx", server->ssocket->state, cFYI(1, ("State: 0x%x Flags: 0x%lx", server->ssocket->state,
server->ssocket->flags)); server->ssocket->flags));
...@@ -182,7 +182,7 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -182,7 +182,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
} }
} }
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
up(&server->tcpSem); mutex_unlock(&server->srv_mutex);
while ((server->tcpStatus != CifsExiting) && while ((server->tcpStatus != CifsExiting) &&
(server->tcpStatus != CifsGood)) { (server->tcpStatus != CifsGood)) {
...@@ -2175,7 +2175,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -2175,7 +2175,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
to the struct since the kernel thread not created yet to the struct since the kernel thread not created yet
so no need to spinlock this init of tcpStatus */ so no need to spinlock this init of tcpStatus */
srvTcp->tcpStatus = CifsNew; srvTcp->tcpStatus = CifsNew;
init_MUTEX(&srvTcp->tcpSem); mutex_init(&srvTcp->srv_mutex);
/* /*
* since we're in a cifs function already, we know that * since we're in a cifs function already, we know that
......
...@@ -516,11 +516,11 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses, ...@@ -516,11 +516,11 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
and avoid races inside tcp sendmsg code that could cause corruption and avoid races inside tcp sendmsg code that could cause corruption
of smb data */ of smb data */
down(&ses->server->tcpSem); mutex_lock(&ses->server->srv_mutex);
rc = allocate_mid(ses, in_buf, &midQ); rc = allocate_mid(ses, in_buf, &midQ);
if (rc) { if (rc) {
up(&ses->server->tcpSem); mutex_unlock(&ses->server->srv_mutex);
cifs_small_buf_release(in_buf); cifs_small_buf_release(in_buf);
/* Update # of requests on wire to server */ /* Update # of requests on wire to server */
atomic_dec(&ses->server->inFlight); atomic_dec(&ses->server->inFlight);
...@@ -541,7 +541,7 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses, ...@@ -541,7 +541,7 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
midQ->when_sent = jiffies; midQ->when_sent = jiffies;
#endif #endif
up(&ses->server->tcpSem); mutex_unlock(&ses->server->srv_mutex);
cifs_small_buf_release(in_buf); cifs_small_buf_release(in_buf);
if (rc < 0) if (rc < 0)
...@@ -698,11 +698,11 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses, ...@@ -698,11 +698,11 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
and avoid races inside tcp sendmsg code that could cause corruption and avoid races inside tcp sendmsg code that could cause corruption
of smb data */ of smb data */
down(&ses->server->tcpSem); mutex_lock(&ses->server->srv_mutex);
rc = allocate_mid(ses, in_buf, &midQ); rc = allocate_mid(ses, in_buf, &midQ);
if (rc) { if (rc) {
up(&ses->server->tcpSem); mutex_unlock(&ses->server->srv_mutex);
/* Update # of requests on wire to server */ /* Update # of requests on wire to server */
atomic_dec(&ses->server->inFlight); atomic_dec(&ses->server->inFlight);
wake_up(&ses->server->request_q); wake_up(&ses->server->request_q);
...@@ -713,7 +713,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses, ...@@ -713,7 +713,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
cERROR(1, ("Illegal length, greater than maximum frame, %d", cERROR(1, ("Illegal length, greater than maximum frame, %d",
in_buf->smb_buf_length)); in_buf->smb_buf_length));
DeleteMidQEntry(midQ); DeleteMidQEntry(midQ);
up(&ses->server->tcpSem); mutex_unlock(&ses->server->srv_mutex);
/* Update # of requests on wire to server */ /* Update # of requests on wire to server */
atomic_dec(&ses->server->inFlight); atomic_dec(&ses->server->inFlight);
wake_up(&ses->server->request_q); wake_up(&ses->server->request_q);
...@@ -733,7 +733,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses, ...@@ -733,7 +733,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
atomic_dec(&ses->server->inSend); atomic_dec(&ses->server->inSend);
midQ->when_sent = jiffies; midQ->when_sent = jiffies;
#endif #endif
up(&ses->server->tcpSem); mutex_unlock(&ses->server->srv_mutex);
if (rc < 0) if (rc < 0)
goto out; goto out;
...@@ -861,16 +861,16 @@ send_nt_cancel(struct cifsTconInfo *tcon, struct smb_hdr *in_buf, ...@@ -861,16 +861,16 @@ send_nt_cancel(struct cifsTconInfo *tcon, struct smb_hdr *in_buf,
header_assemble(in_buf, SMB_COM_NT_CANCEL, tcon, 0); header_assemble(in_buf, SMB_COM_NT_CANCEL, tcon, 0);
in_buf->Mid = mid; in_buf->Mid = mid;
down(&ses->server->tcpSem); mutex_lock(&ses->server->srv_mutex);
rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number); rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
if (rc) { if (rc) {
up(&ses->server->tcpSem); mutex_unlock(&ses->server->srv_mutex);
return rc; return rc;
} }
rc = smb_send(ses->server->ssocket, in_buf, in_buf->smb_buf_length, rc = smb_send(ses->server->ssocket, in_buf, in_buf->smb_buf_length,
(struct sockaddr *) &(ses->server->addr.sockAddr), (struct sockaddr *) &(ses->server->addr.sockAddr),
ses->server->noblocksnd); ses->server->noblocksnd);
up(&ses->server->tcpSem); mutex_unlock(&ses->server->srv_mutex);
return rc; return rc;
} }
...@@ -936,16 +936,16 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon, ...@@ -936,16 +936,16 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon,
and avoid races inside tcp sendmsg code that could cause corruption and avoid races inside tcp sendmsg code that could cause corruption
of smb data */ of smb data */
down(&ses->server->tcpSem); mutex_lock(&ses->server->srv_mutex);
rc = allocate_mid(ses, in_buf, &midQ); rc = allocate_mid(ses, in_buf, &midQ);
if (rc) { if (rc) {
up(&ses->server->tcpSem); mutex_unlock(&ses->server->srv_mutex);
return rc; return rc;
} }
if (in_buf->smb_buf_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { if (in_buf->smb_buf_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
up(&ses->server->tcpSem); mutex_unlock(&ses->server->srv_mutex);
cERROR(1, ("Illegal length, greater than maximum frame, %d", cERROR(1, ("Illegal length, greater than maximum frame, %d",
in_buf->smb_buf_length)); in_buf->smb_buf_length));
DeleteMidQEntry(midQ); DeleteMidQEntry(midQ);
...@@ -965,7 +965,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon, ...@@ -965,7 +965,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon,
atomic_dec(&ses->server->inSend); atomic_dec(&ses->server->inSend);
midQ->when_sent = jiffies; midQ->when_sent = jiffies;
#endif #endif
up(&ses->server->tcpSem); mutex_unlock(&ses->server->srv_mutex);
if (rc < 0) { if (rc < 0) {
DeleteMidQEntry(midQ); DeleteMidQEntry(midQ);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment