Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 101517
b: refs/heads/master
c: b40977d
h: refs/heads/master
i:
  101515: 5dd5243
v: v3
  • Loading branch information
Mike Christie authored and James Bottomley committed Jul 12, 2008
1 parent 79b1ec0 commit 8109042
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5af3e91d232b7e022f258202f72ebb79b8b0c706
refs/heads/master: b40977d95fb3a1898ace6a7d97e4ed1a33a440a4
42 changes: 39 additions & 3 deletions trunk/drivers/infiniband/ulp/iser/iscsi_iser.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,18 @@ iscsi_iser_conn_destroy(struct iscsi_cls_conn *cls_conn)
{
struct iscsi_conn *conn = cls_conn->dd_data;
struct iscsi_iser_conn *iser_conn = conn->dd_data;
struct iser_conn *ib_conn = iser_conn->ib_conn;

if (iser_conn->ib_conn)
iser_conn->ib_conn->iser_conn = NULL;
iscsi_conn_teardown(cls_conn);
/*
* Userspace will normally call the stop callback and
* already have freed the ib_conn, but if it goofed up then
* we free it here.
*/
if (ib_conn) {
ib_conn->iser_conn = NULL;
iser_conn_put(ib_conn);
}
}

static int
Expand Down Expand Up @@ -340,12 +348,29 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,
iser_conn = conn->dd_data;
ib_conn->iser_conn = iser_conn;
iser_conn->ib_conn = ib_conn;
iser_conn_get(ib_conn);

conn->recv_lock = &iser_conn->lock;

return 0;
}

static void
iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
{
struct iscsi_conn *conn = cls_conn->dd_data;
struct iscsi_iser_conn *iser_conn = conn->dd_data;
struct iser_conn *ib_conn = iser_conn->ib_conn;

iscsi_conn_stop(cls_conn, flag);
/*
* There is no unbind event so the stop callback
* must release the ref from the bind.
*/
iser_conn_put(ib_conn);
iser_conn->ib_conn = NULL;
}

static int
iscsi_iser_conn_start(struct iscsi_cls_conn *cls_conn)
{
Expand Down Expand Up @@ -564,6 +589,17 @@ iscsi_iser_ep_disconnect(__u64 ep_handle)
if (!ib_conn)
return;

if (ib_conn->iser_conn)
/*
* Must suspend xmit path if the ep is bound to the
* iscsi_conn, so we know we are not accessing the ib_conn
* when we free it.
*
* This may not be bound if the ep poll failed.
*/
iscsi_suspend_tx(ib_conn->iser_conn->iscsi_conn);


iser_err("ib conn %p state %d\n",ib_conn, ib_conn->state);
iser_conn_terminate(ib_conn);
}
Expand Down Expand Up @@ -622,7 +658,7 @@ static struct iscsi_transport iscsi_iser_transport = {
.get_conn_param = iscsi_conn_get_param,
.get_session_param = iscsi_session_get_param,
.start_conn = iscsi_iser_conn_start,
.stop_conn = iscsi_conn_stop,
.stop_conn = iscsi_iser_conn_stop,
/* iscsi host params */
.get_host_param = iscsi_host_get_param,
.set_host_param = iscsi_host_set_param,
Expand Down
5 changes: 5 additions & 0 deletions trunk/drivers/infiniband/ulp/iser/iscsi_iser.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ struct iser_device {
struct iser_conn {
struct iscsi_iser_conn *iser_conn; /* iser conn for upcalls */
enum iser_ib_conn_state state; /* rdma connection state */
atomic_t refcount;
spinlock_t lock; /* used for state changes */
struct iser_device *device; /* device context */
struct rdma_cm_id *cma_id; /* CMA ID */
Expand Down Expand Up @@ -314,6 +315,10 @@ void iscsi_iser_recv(struct iscsi_conn *conn,

int iser_conn_init(struct iser_conn **ib_conn);

void iser_conn_get(struct iser_conn *ib_conn);

void iser_conn_put(struct iser_conn *ib_conn);

void iser_conn_terminate(struct iser_conn *ib_conn);

void iser_rcv_completion(struct iser_desc *desc,
Expand Down
14 changes: 13 additions & 1 deletion trunk/drivers/infiniband/ulp/iser/iser_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ static void iser_conn_release(struct iser_conn *ib_conn)
kfree(ib_conn);
}

void iser_conn_get(struct iser_conn *ib_conn)
{
atomic_inc(&ib_conn->refcount);
}

void iser_conn_put(struct iser_conn *ib_conn)
{
if (atomic_dec_and_test(&ib_conn->refcount))
iser_conn_release(ib_conn);
}

/**
* triggers start of the disconnect procedures and wait for them to be done
*/
Expand All @@ -349,7 +360,7 @@ void iser_conn_terminate(struct iser_conn *ib_conn)
wait_event_interruptible(ib_conn->wait,
ib_conn->state == ISER_CONN_DOWN);

iser_conn_release(ib_conn);
iser_conn_put(ib_conn);
}

static void iser_connect_error(struct rdma_cm_id *cma_id)
Expand Down Expand Up @@ -496,6 +507,7 @@ int iser_conn_init(struct iser_conn **ibconn)
init_waitqueue_head(&ib_conn->wait);
atomic_set(&ib_conn->post_recv_buf_count, 0);
atomic_set(&ib_conn->post_send_buf_count, 0);
atomic_set(&ib_conn->refcount, 1);
INIT_LIST_HEAD(&ib_conn->conn_list);
spin_lock_init(&ib_conn->lock);

Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/scsi/libiscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,11 +1383,12 @@ static void fail_all_commands(struct iscsi_conn *conn, unsigned lun,
}
}

static void iscsi_suspend_tx(struct iscsi_conn *conn)
void iscsi_suspend_tx(struct iscsi_conn *conn)
{
set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
scsi_flush_work(conn->session->host);
}
EXPORT_SYMBOL_GPL(iscsi_suspend_tx);

static void iscsi_start_tx(struct iscsi_conn *conn)
{
Expand Down

0 comments on commit 8109042

Please sign in to comment.