diff options
author | Sagi Grimberg <sagig@mellanox.com> | 2014-10-01 07:02:04 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2014-10-09 03:06:06 -0400 |
commit | 3a940daf6fa105d28b69cf3b7a3739a3777f4185 (patch) | |
tree | b83d909745453657054b31cb0924fc60b2f6a727 | |
parent | ec370e2b63526931a65f4668626dbb43896788c6 (diff) |
IB/iser: Protect tasks cleanup in case IB device was already released
Bailout in case a task cleanup (iscsi_iser_cleanup_task) is called
after the IB device was removed (DEVICE_REMOVAL CM event). We also
call iscsi_conn_stop with a lock taken to prevent DEVICE_REMOVAL and
tasks cleanup from racing.
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Ariel Nahum <arieln@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r-- | drivers/infiniband/ulp/iser/iscsi_iser.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index 7298e696c6cf..81d69a30bcca 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c | |||
@@ -293,6 +293,10 @@ static void iscsi_iser_cleanup_task(struct iscsi_task *task) | |||
293 | struct iser_conn *iser_conn = task->conn->dd_data; | 293 | struct iser_conn *iser_conn = task->conn->dd_data; |
294 | struct iser_device *device = iser_conn->ib_conn.device; | 294 | struct iser_device *device = iser_conn->ib_conn.device; |
295 | 295 | ||
296 | /* DEVICE_REMOVAL event might have already released the device */ | ||
297 | if (!device) | ||
298 | return; | ||
299 | |||
296 | ib_dma_unmap_single(device->ib_device, | 300 | ib_dma_unmap_single(device->ib_device, |
297 | tx_desc->dma_addr, ISER_HEADERS_LEN, DMA_TO_DEVICE); | 301 | tx_desc->dma_addr, ISER_HEADERS_LEN, DMA_TO_DEVICE); |
298 | 302 | ||
@@ -407,7 +411,6 @@ iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) | |||
407 | struct iser_conn *iser_conn = conn->dd_data; | 411 | struct iser_conn *iser_conn = conn->dd_data; |
408 | 412 | ||
409 | iser_dbg("stopping iscsi_conn: %p, iser_conn: %p\n", conn, iser_conn); | 413 | iser_dbg("stopping iscsi_conn: %p, iser_conn: %p\n", conn, iser_conn); |
410 | iscsi_conn_stop(cls_conn, flag); | ||
411 | 414 | ||
412 | /* | 415 | /* |
413 | * Userspace may have goofed up and not bound the connection or | 416 | * Userspace may have goofed up and not bound the connection or |
@@ -415,6 +418,7 @@ iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) | |||
415 | */ | 418 | */ |
416 | if (iser_conn) { | 419 | if (iser_conn) { |
417 | mutex_lock(&iser_conn->state_mutex); | 420 | mutex_lock(&iser_conn->state_mutex); |
421 | iscsi_conn_stop(cls_conn, flag); | ||
418 | iser_conn_terminate(iser_conn); | 422 | iser_conn_terminate(iser_conn); |
419 | 423 | ||
420 | /* unbind */ | 424 | /* unbind */ |
@@ -423,6 +427,8 @@ iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) | |||
423 | 427 | ||
424 | complete(&iser_conn->stop_completion); | 428 | complete(&iser_conn->stop_completion); |
425 | mutex_unlock(&iser_conn->state_mutex); | 429 | mutex_unlock(&iser_conn->state_mutex); |
430 | } else { | ||
431 | iscsi_conn_stop(cls_conn, flag); | ||
426 | } | 432 | } |
427 | } | 433 | } |
428 | 434 | ||