diff options
author | Erez Zilber <erezz@voltaire.com> | 2007-04-01 06:53:43 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2007-04-05 12:46:04 -0400 |
commit | 1d426d6418d1914b592c9c307c02e488d9182fa8 (patch) | |
tree | 488d9f534a5496975a36b33237f05b127c42ec23 /drivers/infiniband | |
parent | 58e949139014a852a83b5ef071136b1f50c86ad1 (diff) |
IB/iser: Don't defer connection failure notification to workqueue
When a connection is terminated asynchronously from the iSCSI layer's
perspective, iSER needs to notify the iSCSI layer that the connection
has failed. This is done using a workqueue (switched to from the iSER
tasklet context). Meanwhile, the connection object (that holds the
work struct) is released. If the workqueue function wasn't called
yet, it will be called later with a NULL pointer, which will crash the
kernel.
The context switch (tasklet to workqueue) is not required, and
everything can be done from the iSER tasklet. This eliminates the NULL
work struct bug (and simplifies the code).
Signed-off-by: Erez Zilber <erezz@voltaire.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/ulp/iser/iscsi_iser.h | 1 | ||||
-rw-r--r-- | drivers/infiniband/ulp/iser/iser_verbs.c | 40 |
2 files changed, 16 insertions, 25 deletions
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h index cae8c96a55f8..8960196ffb0f 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.h +++ b/drivers/infiniband/ulp/iser/iscsi_iser.h | |||
@@ -245,7 +245,6 @@ struct iser_conn { | |||
245 | wait_queue_head_t wait; /* waitq for conn/disconn */ | 245 | wait_queue_head_t wait; /* waitq for conn/disconn */ |
246 | atomic_t post_recv_buf_count; /* posted rx count */ | 246 | atomic_t post_recv_buf_count; /* posted rx count */ |
247 | atomic_t post_send_buf_count; /* posted tx count */ | 247 | atomic_t post_send_buf_count; /* posted tx count */ |
248 | struct work_struct comperror_work; /* conn term sleepable ctx*/ | ||
249 | char name[ISER_OBJECT_NAME_SIZE]; | 248 | char name[ISER_OBJECT_NAME_SIZE]; |
250 | struct iser_page_vec *page_vec; /* represents SG to fmr maps* | 249 | struct iser_page_vec *page_vec; /* represents SG to fmr maps* |
251 | * maps serialized as tx is*/ | 250 | * maps serialized as tx is*/ |
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index 693b77002897..1fc967464a28 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c | |||
@@ -48,7 +48,6 @@ | |||
48 | 48 | ||
49 | static void iser_cq_tasklet_fn(unsigned long data); | 49 | static void iser_cq_tasklet_fn(unsigned long data); |
50 | static void iser_cq_callback(struct ib_cq *cq, void *cq_context); | 50 | static void iser_cq_callback(struct ib_cq *cq, void *cq_context); |
51 | static void iser_comp_error_worker(struct work_struct *work); | ||
52 | 51 | ||
53 | static void iser_cq_event_callback(struct ib_event *cause, void *context) | 52 | static void iser_cq_event_callback(struct ib_event *cause, void *context) |
54 | { | 53 | { |
@@ -480,7 +479,6 @@ int iser_conn_init(struct iser_conn **ibconn) | |||
480 | init_waitqueue_head(&ib_conn->wait); | 479 | init_waitqueue_head(&ib_conn->wait); |
481 | atomic_set(&ib_conn->post_recv_buf_count, 0); | 480 | atomic_set(&ib_conn->post_recv_buf_count, 0); |
482 | atomic_set(&ib_conn->post_send_buf_count, 0); | 481 | atomic_set(&ib_conn->post_send_buf_count, 0); |
483 | INIT_WORK(&ib_conn->comperror_work, iser_comp_error_worker); | ||
484 | INIT_LIST_HEAD(&ib_conn->conn_list); | 482 | INIT_LIST_HEAD(&ib_conn->conn_list); |
485 | spin_lock_init(&ib_conn->lock); | 483 | spin_lock_init(&ib_conn->lock); |
486 | 484 | ||
@@ -753,26 +751,6 @@ int iser_post_send(struct iser_desc *tx_desc) | |||
753 | return ret_val; | 751 | return ret_val; |
754 | } | 752 | } |
755 | 753 | ||
756 | static void iser_comp_error_worker(struct work_struct *work) | ||
757 | { | ||
758 | struct iser_conn *ib_conn = | ||
759 | container_of(work, struct iser_conn, comperror_work); | ||
760 | |||
761 | /* getting here when the state is UP means that the conn is being * | ||
762 | * terminated asynchronously from the iSCSI layer's perspective. */ | ||
763 | if (iser_conn_state_comp_exch(ib_conn, ISER_CONN_UP, | ||
764 | ISER_CONN_TERMINATING)) | ||
765 | iscsi_conn_failure(ib_conn->iser_conn->iscsi_conn, | ||
766 | ISCSI_ERR_CONN_FAILED); | ||
767 | |||
768 | /* complete the termination process if disconnect event was delivered * | ||
769 | * note there are no more non completed posts to the QP */ | ||
770 | if (ib_conn->disc_evt_flag) { | ||
771 | ib_conn->state = ISER_CONN_DOWN; | ||
772 | wake_up_interruptible(&ib_conn->wait); | ||
773 | } | ||
774 | } | ||
775 | |||
776 | static void iser_handle_comp_error(struct iser_desc *desc) | 754 | static void iser_handle_comp_error(struct iser_desc *desc) |
777 | { | 755 | { |
778 | struct iser_dto *dto = &desc->dto; | 756 | struct iser_dto *dto = &desc->dto; |
@@ -791,8 +769,22 @@ static void iser_handle_comp_error(struct iser_desc *desc) | |||
791 | } | 769 | } |
792 | 770 | ||
793 | if (atomic_read(&ib_conn->post_recv_buf_count) == 0 && | 771 | if (atomic_read(&ib_conn->post_recv_buf_count) == 0 && |
794 | atomic_read(&ib_conn->post_send_buf_count) == 0) | 772 | atomic_read(&ib_conn->post_send_buf_count) == 0) { |
795 | schedule_work(&ib_conn->comperror_work); | 773 | /* getting here when the state is UP means that the conn is * |
774 | * being terminated asynchronously from the iSCSI layer's * | ||
775 | * perspective. */ | ||
776 | if (iser_conn_state_comp_exch(ib_conn, ISER_CONN_UP, | ||
777 | ISER_CONN_TERMINATING)) | ||
778 | iscsi_conn_failure(ib_conn->iser_conn->iscsi_conn, | ||
779 | ISCSI_ERR_CONN_FAILED); | ||
780 | |||
781 | /* complete the termination process if disconnect event was delivered * | ||
782 | * note there are no more non completed posts to the QP */ | ||
783 | if (ib_conn->disc_evt_flag) { | ||
784 | ib_conn->state = ISER_CONN_DOWN; | ||
785 | wake_up_interruptible(&ib_conn->wait); | ||
786 | } | ||
787 | } | ||
796 | } | 788 | } |
797 | 789 | ||
798 | static void iser_cq_tasklet_fn(unsigned long data) | 790 | static void iser_cq_tasklet_fn(unsigned long data) |