aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/iscsi_tcp.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-01-11 07:16:10 -0500
committerJames Bottomley <jejb@mulgrave.(none)>2006-01-12 12:53:11 -0500
commit0b9506723826c68b50fa33e345700ddcac1bed36 (patch)
treeda3e432ef4517c47ebdc088c6322d0ac51193127 /drivers/scsi/iscsi_tcp.c
parentdacee84b070c4e705a5b6446f1f0a6a6e2f8d7a4 (diff)
[SCSI] turn most scsi semaphores into mutexes
the scsi layer is using semaphores in a mutex way, this patch converts these into using mutexes instead Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/iscsi_tcp.c')
-rw-r--r--drivers/scsi/iscsi_tcp.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 10bcf42cb65c..1067d77da10e 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -33,6 +33,7 @@
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/kfifo.h> 34#include <linux/kfifo.h>
35#include <linux/scatterlist.h> 35#include <linux/scatterlist.h>
36#include <linux/mutex.h>
36#include <net/tcp.h> 37#include <net/tcp.h>
37#include <scsi/scsi_cmnd.h> 38#include <scsi/scsi_cmnd.h>
38#include <scsi/scsi_device.h> 39#include <scsi/scsi_device.h>
@@ -2300,10 +2301,10 @@ iscsi_xmitworker(void *data)
2300 /* 2301 /*
2301 * serialize Xmit worker on a per-connection basis. 2302 * serialize Xmit worker on a per-connection basis.
2302 */ 2303 */
2303 down(&conn->xmitsema); 2304 mutex_lock(&conn->xmitmutex);
2304 if (iscsi_data_xmit(conn)) 2305 if (iscsi_data_xmit(conn))
2305 schedule_work(&conn->xmitwork); 2306 schedule_work(&conn->xmitwork);
2306 up(&conn->xmitsema); 2307 mutex_unlock(&conn->xmitmutex);
2307} 2308}
2308 2309
2309#define FAILURE_BAD_HOST 1 2310#define FAILURE_BAD_HOST 1
@@ -2367,11 +2368,11 @@ iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
2367 session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1); 2368 session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1);
2368 spin_unlock(&session->lock); 2369 spin_unlock(&session->lock);
2369 2370
2370 if (!in_interrupt() && !down_trylock(&conn->xmitsema)) { 2371 if (!in_interrupt() && mutex_trylock(&conn->xmitmutex)) {
2371 spin_unlock_irq(host->host_lock); 2372 spin_unlock_irq(host->host_lock);
2372 if (iscsi_data_xmit(conn)) 2373 if (iscsi_data_xmit(conn))
2373 schedule_work(&conn->xmitwork); 2374 schedule_work(&conn->xmitwork);
2374 up(&conn->xmitsema); 2375 mutex_unlock(&conn->xmitmutex);
2375 spin_lock_irq(host->host_lock); 2376 spin_lock_irq(host->host_lock);
2376 } else 2377 } else
2377 schedule_work(&conn->xmitwork); 2378 schedule_work(&conn->xmitwork);
@@ -2531,7 +2532,7 @@ iscsi_conn_create(iscsi_sessionh_t sessionh, uint32_t conn_idx)
2531 goto max_recv_dlenght_alloc_fail; 2532 goto max_recv_dlenght_alloc_fail;
2532 2533
2533 init_timer(&conn->tmabort_timer); 2534 init_timer(&conn->tmabort_timer);
2534 init_MUTEX(&conn->xmitsema); 2535 mutex_init(&conn->xmitmutex);
2535 init_waitqueue_head(&conn->ehwait); 2536 init_waitqueue_head(&conn->ehwait);
2536 2537
2537 return iscsi_handle(conn); 2538 return iscsi_handle(conn);
@@ -2561,7 +2562,7 @@ iscsi_conn_destroy(iscsi_connh_t connh)
2561 struct iscsi_conn *conn = iscsi_ptr(connh); 2562 struct iscsi_conn *conn = iscsi_ptr(connh);
2562 struct iscsi_session *session = conn->session; 2563 struct iscsi_session *session = conn->session;
2563 2564
2564 down(&conn->xmitsema); 2565 mutex_lock(&conn->xmitmutex);
2565 set_bit(SUSPEND_BIT, &conn->suspend_tx); 2566 set_bit(SUSPEND_BIT, &conn->suspend_tx);
2566 if (conn->c_stage == ISCSI_CONN_INITIAL_STAGE && conn->sock) { 2567 if (conn->c_stage == ISCSI_CONN_INITIAL_STAGE && conn->sock) {
2567 struct sock *sk = conn->sock->sk; 2568 struct sock *sk = conn->sock->sk;
@@ -2592,7 +2593,7 @@ iscsi_conn_destroy(iscsi_connh_t connh)
2592 } 2593 }
2593 spin_unlock_bh(&session->lock); 2594 spin_unlock_bh(&session->lock);
2594 2595
2595 up(&conn->xmitsema); 2596 mutex_unlock(&conn->xmitmutex);
2596 2597
2597 /* 2598 /*
2598 * Block until all in-progress commands for this connection 2599 * Block until all in-progress commands for this connection
@@ -2796,7 +2797,7 @@ iscsi_conn_stop(iscsi_connh_t connh, int flag)
2796 set_bit(SUSPEND_BIT, &conn->suspend_rx); 2797 set_bit(SUSPEND_BIT, &conn->suspend_rx);
2797 write_unlock_bh(&sk->sk_callback_lock); 2798 write_unlock_bh(&sk->sk_callback_lock);
2798 2799
2799 down(&conn->xmitsema); 2800 mutex_lock(&conn->xmitmutex);
2800 2801
2801 spin_lock_irqsave(session->host->host_lock, flags); 2802 spin_lock_irqsave(session->host->host_lock, flags);
2802 spin_lock(&session->lock); 2803 spin_lock(&session->lock);
@@ -2878,7 +2879,7 @@ iscsi_conn_stop(iscsi_connh_t connh, int flag)
2878 conn->datadgst_en = 0; 2879 conn->datadgst_en = 0;
2879 } 2880 }
2880 } 2881 }
2881 up(&conn->xmitsema); 2882 mutex_unlock(&conn->xmitmutex);
2882} 2883}
2883 2884
2884static int 2885static int
@@ -3029,12 +3030,12 @@ iscsi_eh_abort(struct scsi_cmnd *sc)
3029 * 1) connection-level failure; 3030 * 1) connection-level failure;
3030 * 2) recovery due protocol error; 3031 * 2) recovery due protocol error;
3031 */ 3032 */
3032 down(&conn->xmitsema); 3033 mutex_lock(&conn->xmitmutex);
3033 spin_lock_bh(&session->lock); 3034 spin_lock_bh(&session->lock);
3034 if (session->state != ISCSI_STATE_LOGGED_IN) { 3035 if (session->state != ISCSI_STATE_LOGGED_IN) {
3035 if (session->state == ISCSI_STATE_TERMINATE) { 3036 if (session->state == ISCSI_STATE_TERMINATE) {
3036 spin_unlock_bh(&session->lock); 3037 spin_unlock_bh(&session->lock);
3037 up(&conn->xmitsema); 3038 mutex_unlock(&conn->xmitmutex);
3038 goto failed; 3039 goto failed;
3039 } 3040 }
3040 spin_unlock_bh(&session->lock); 3041 spin_unlock_bh(&session->lock);
@@ -3052,7 +3053,7 @@ iscsi_eh_abort(struct scsi_cmnd *sc)
3052 * 2) session was re-open during time out of ctask. 3053 * 2) session was re-open during time out of ctask.
3053 */ 3054 */
3054 spin_unlock_bh(&session->lock); 3055 spin_unlock_bh(&session->lock);
3055 up(&conn->xmitsema); 3056 mutex_unlock(&conn->xmitmutex);
3056 goto success; 3057 goto success;
3057 } 3058 }
3058 conn->tmabort_state = TMABORT_INITIAL; 3059 conn->tmabort_state = TMABORT_INITIAL;
@@ -3107,7 +3108,7 @@ iscsi_eh_abort(struct scsi_cmnd *sc)
3107 conn->tmabort_state == TMABORT_SUCCESS) { 3108 conn->tmabort_state == TMABORT_SUCCESS) {
3108 conn->tmabort_state = TMABORT_INITIAL; 3109 conn->tmabort_state = TMABORT_INITIAL;
3109 spin_unlock_bh(&session->lock); 3110 spin_unlock_bh(&session->lock);
3110 up(&conn->xmitsema); 3111 mutex_unlock(&conn->xmitmutex);
3111 goto success; 3112 goto success;
3112 } 3113 }
3113 conn->tmabort_state = TMABORT_INITIAL; 3114 conn->tmabort_state = TMABORT_INITIAL;
@@ -3116,7 +3117,7 @@ iscsi_eh_abort(struct scsi_cmnd *sc)
3116 spin_unlock_bh(&session->lock); 3117 spin_unlock_bh(&session->lock);
3117 } 3118 }
3118 } 3119 }
3119 up(&conn->xmitsema); 3120 mutex_unlock(&conn->xmitmutex);
3120 3121
3121 3122
3122 /* 3123 /*
@@ -3182,7 +3183,7 @@ failed:
3182exit: 3183exit:
3183 del_timer_sync(&conn->tmabort_timer); 3184 del_timer_sync(&conn->tmabort_timer);
3184 3185
3185 down(&conn->xmitsema); 3186 mutex_lock(&conn->xmitmutex);
3186 if (conn->sock) { 3187 if (conn->sock) {
3187 struct sock *sk = conn->sock->sk; 3188 struct sock *sk = conn->sock->sk;
3188 3189
@@ -3190,7 +3191,7 @@ exit:
3190 iscsi_ctask_cleanup(conn, ctask); 3191 iscsi_ctask_cleanup(conn, ctask);
3191 write_unlock_bh(&sk->sk_callback_lock); 3192 write_unlock_bh(&sk->sk_callback_lock);
3192 } 3193 }
3193 up(&conn->xmitsema); 3194 mutex_unlock(&conn->xmitmutex);
3194 return rc; 3195 return rc;
3195} 3196}
3196 3197
@@ -3601,9 +3602,9 @@ iscsi_conn_send_pdu(iscsi_connh_t connh, struct iscsi_hdr *hdr, char *data,
3601 struct iscsi_conn *conn = iscsi_ptr(connh); 3602 struct iscsi_conn *conn = iscsi_ptr(connh);
3602 int rc; 3603 int rc;
3603 3604
3604 down(&conn->xmitsema); 3605 mutex_lock(&conn->xmitmutex);
3605 rc = iscsi_conn_send_generic(conn, hdr, data, data_size); 3606 rc = iscsi_conn_send_generic(conn, hdr, data, data_size);
3606 up(&conn->xmitsema); 3607 mutex_unlock(&conn->xmitmutex);
3607 3608
3608 return rc; 3609 return rc;
3609} 3610}