diff options
Diffstat (limited to 'drivers/scsi/iscsi_tcp.c')
-rw-r--r-- | drivers/scsi/iscsi_tcp.c | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 780bfcc67096..d07d309ac026 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c | |||
@@ -146,7 +146,7 @@ iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err) | |||
146 | spin_unlock_irqrestore(&session->lock, flags); | 146 | spin_unlock_irqrestore(&session->lock, flags); |
147 | set_bit(SUSPEND_BIT, &conn->suspend_tx); | 147 | set_bit(SUSPEND_BIT, &conn->suspend_tx); |
148 | set_bit(SUSPEND_BIT, &conn->suspend_rx); | 148 | set_bit(SUSPEND_BIT, &conn->suspend_rx); |
149 | iscsi_conn_error(iscsi_handle(conn), err); | 149 | iscsi_conn_error(conn->cls_conn, err); |
150 | } | 150 | } |
151 | 151 | ||
152 | static inline int | 152 | static inline int |
@@ -689,7 +689,7 @@ iscsi_hdr_recv(struct iscsi_conn *conn) | |||
689 | break; | 689 | break; |
690 | 690 | ||
691 | if (!conn->in.datalen) { | 691 | if (!conn->in.datalen) { |
692 | rc = iscsi_recv_pdu(iscsi_handle(conn), hdr, | 692 | rc = iscsi_recv_pdu(conn->cls_conn, hdr, |
693 | NULL, 0); | 693 | NULL, 0); |
694 | if (conn->login_mtask != mtask) { | 694 | if (conn->login_mtask != mtask) { |
695 | spin_lock(&session->lock); | 695 | spin_lock(&session->lock); |
@@ -737,7 +737,7 @@ iscsi_hdr_recv(struct iscsi_conn *conn) | |||
737 | if (!conn->in.datalen) { | 737 | if (!conn->in.datalen) { |
738 | struct iscsi_mgmt_task *mtask; | 738 | struct iscsi_mgmt_task *mtask; |
739 | 739 | ||
740 | rc = iscsi_recv_pdu(iscsi_handle(conn), hdr, | 740 | rc = iscsi_recv_pdu(conn->cls_conn, hdr, |
741 | NULL, 0); | 741 | NULL, 0); |
742 | mtask = (struct iscsi_mgmt_task *) | 742 | mtask = (struct iscsi_mgmt_task *) |
743 | session->mgmt_cmds[conn->in.itt - | 743 | session->mgmt_cmds[conn->in.itt - |
@@ -761,7 +761,7 @@ iscsi_hdr_recv(struct iscsi_conn *conn) | |||
761 | rc = iscsi_check_assign_cmdsn(session, | 761 | rc = iscsi_check_assign_cmdsn(session, |
762 | (struct iscsi_nopin*)hdr); | 762 | (struct iscsi_nopin*)hdr); |
763 | if (!rc && hdr->ttt != ISCSI_RESERVED_TAG) | 763 | if (!rc && hdr->ttt != ISCSI_RESERVED_TAG) |
764 | rc = iscsi_recv_pdu(iscsi_handle(conn), | 764 | rc = iscsi_recv_pdu(conn->cls_conn, |
765 | hdr, NULL, 0); | 765 | hdr, NULL, 0); |
766 | } else | 766 | } else |
767 | rc = ISCSI_ERR_PROTO; | 767 | rc = ISCSI_ERR_PROTO; |
@@ -1044,7 +1044,7 @@ iscsi_data_recv(struct iscsi_conn *conn) | |||
1044 | goto exit; | 1044 | goto exit; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | rc = iscsi_recv_pdu(iscsi_handle(conn), conn->in.hdr, | 1047 | rc = iscsi_recv_pdu(conn->cls_conn, conn->in.hdr, |
1048 | conn->data, conn->in.datalen); | 1048 | conn->data, conn->in.datalen); |
1049 | 1049 | ||
1050 | if (!rc && conn->datadgst_en && | 1050 | if (!rc && conn->datadgst_en && |
@@ -2428,19 +2428,20 @@ iscsi_pool_free(struct iscsi_queue *q, void **items) | |||
2428 | } | 2428 | } |
2429 | 2429 | ||
2430 | static struct iscsi_cls_conn * | 2430 | static struct iscsi_cls_conn * |
2431 | iscsi_conn_create(struct Scsi_Host *shost, uint32_t conn_idx) | 2431 | iscsi_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx) |
2432 | { | 2432 | { |
2433 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); | ||
2433 | struct iscsi_session *session = iscsi_hostdata(shost->hostdata); | 2434 | struct iscsi_session *session = iscsi_hostdata(shost->hostdata); |
2434 | struct iscsi_conn *conn; | 2435 | struct iscsi_conn *conn; |
2435 | struct iscsi_cls_conn *cls_conn; | 2436 | struct iscsi_cls_conn *cls_conn; |
2436 | 2437 | ||
2437 | cls_conn = iscsi_create_conn(hostdata_session(shost->hostdata), | 2438 | cls_conn = iscsi_create_conn(cls_session, conn_idx); |
2438 | conn_idx); | ||
2439 | if (!cls_conn) | 2439 | if (!cls_conn) |
2440 | return NULL; | 2440 | return NULL; |
2441 | conn = cls_conn->dd_data; | 2441 | conn = cls_conn->dd_data; |
2442 | memset(conn, 0, sizeof(*conn)); | ||
2442 | 2443 | ||
2443 | memset(conn, 0, sizeof(struct iscsi_conn)); | 2444 | conn->cls_conn = cls_conn; |
2444 | conn->c_stage = ISCSI_CONN_INITIAL_STAGE; | 2445 | conn->c_stage = ISCSI_CONN_INITIAL_STAGE; |
2445 | conn->in_progress = IN_PROGRESS_WAIT_HEADER; | 2446 | conn->in_progress = IN_PROGRESS_WAIT_HEADER; |
2446 | conn->id = conn_idx; | 2447 | conn->id = conn_idx; |
@@ -2625,11 +2626,13 @@ iscsi_conn_destroy(struct iscsi_cls_conn *cls_conn) | |||
2625 | } | 2626 | } |
2626 | 2627 | ||
2627 | static int | 2628 | static int |
2628 | iscsi_conn_bind(iscsi_sessionh_t sessionh, iscsi_connh_t connh, | 2629 | iscsi_conn_bind(struct iscsi_cls_session *cls_session, |
2629 | uint32_t transport_fd, int is_leading) | 2630 | struct iscsi_cls_conn *cls_conn, uint32_t transport_fd, |
2631 | int is_leading) | ||
2630 | { | 2632 | { |
2631 | struct iscsi_session *session = iscsi_ptr(sessionh); | 2633 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); |
2632 | struct iscsi_conn *tmp = ERR_PTR(-EEXIST), *conn = iscsi_ptr(connh); | 2634 | struct iscsi_session *session = iscsi_hostdata(shost->hostdata); |
2635 | struct iscsi_conn *tmp = ERR_PTR(-EEXIST), *conn = cls_conn->dd_data; | ||
2633 | struct sock *sk; | 2636 | struct sock *sk; |
2634 | struct socket *sock; | 2637 | struct socket *sock; |
2635 | int err; | 2638 | int err; |
@@ -2703,9 +2706,9 @@ iscsi_conn_bind(iscsi_sessionh_t sessionh, iscsi_connh_t connh, | |||
2703 | } | 2706 | } |
2704 | 2707 | ||
2705 | static int | 2708 | static int |
2706 | iscsi_conn_start(iscsi_connh_t connh) | 2709 | iscsi_conn_start(struct iscsi_cls_conn *cls_conn) |
2707 | { | 2710 | { |
2708 | struct iscsi_conn *conn = iscsi_ptr(connh); | 2711 | struct iscsi_conn *conn = cls_conn->dd_data; |
2709 | struct iscsi_session *session = conn->session; | 2712 | struct iscsi_session *session = conn->session; |
2710 | struct sock *sk; | 2713 | struct sock *sk; |
2711 | 2714 | ||
@@ -2754,9 +2757,9 @@ iscsi_conn_start(iscsi_connh_t connh) | |||
2754 | } | 2757 | } |
2755 | 2758 | ||
2756 | static void | 2759 | static void |
2757 | iscsi_conn_stop(iscsi_connh_t connh, int flag) | 2760 | iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) |
2758 | { | 2761 | { |
2759 | struct iscsi_conn *conn = iscsi_ptr(connh); | 2762 | struct iscsi_conn *conn = cls_conn->dd_data; |
2760 | struct iscsi_session *session = conn->session; | 2763 | struct iscsi_session *session = conn->session; |
2761 | struct sock *sk; | 2764 | struct sock *sk; |
2762 | unsigned long flags; | 2765 | unsigned long flags; |
@@ -3253,9 +3256,9 @@ static struct scsi_host_template iscsi_sht = { | |||
3253 | 3256 | ||
3254 | static struct iscsi_transport iscsi_tcp_transport; | 3257 | static struct iscsi_transport iscsi_tcp_transport; |
3255 | 3258 | ||
3256 | static struct Scsi_Host * | 3259 | static struct iscsi_cls_session * |
3257 | iscsi_session_create(struct scsi_transport_template *scsit, | 3260 | iscsi_session_create(struct scsi_transport_template *scsit, |
3258 | uint32_t initial_cmdsn) | 3261 | uint32_t initial_cmdsn, uint32_t *sid) |
3259 | { | 3262 | { |
3260 | struct Scsi_Host *shost; | 3263 | struct Scsi_Host *shost; |
3261 | struct iscsi_session *session; | 3264 | struct iscsi_session *session; |
@@ -3275,6 +3278,7 @@ iscsi_session_create(struct scsi_transport_template *scsit, | |||
3275 | session->exp_cmdsn = initial_cmdsn + 1; | 3278 | session->exp_cmdsn = initial_cmdsn + 1; |
3276 | session->max_cmdsn = initial_cmdsn + 1; | 3279 | session->max_cmdsn = initial_cmdsn + 1; |
3277 | session->max_r2t = 1; | 3280 | session->max_r2t = 1; |
3281 | *sid = shost->host_no; | ||
3278 | 3282 | ||
3279 | /* initialize SCSI PDU commands pool */ | 3283 | /* initialize SCSI PDU commands pool */ |
3280 | if (iscsi_pool_init(&session->cmdpool, session->cmds_max, | 3284 | if (iscsi_pool_init(&session->cmdpool, session->cmds_max, |
@@ -3311,7 +3315,7 @@ iscsi_session_create(struct scsi_transport_template *scsit, | |||
3311 | if (iscsi_r2tpool_alloc(session)) | 3315 | if (iscsi_r2tpool_alloc(session)) |
3312 | goto r2tpool_alloc_fail; | 3316 | goto r2tpool_alloc_fail; |
3313 | 3317 | ||
3314 | return shost; | 3318 | return hostdata_session(shost->hostdata); |
3315 | 3319 | ||
3316 | r2tpool_alloc_fail: | 3320 | r2tpool_alloc_fail: |
3317 | for (cmd_i = 0; cmd_i < session->mgmtpool_max; cmd_i++) | 3321 | for (cmd_i = 0; cmd_i < session->mgmtpool_max; cmd_i++) |
@@ -3321,12 +3325,14 @@ immdata_alloc_fail: | |||
3321 | mgmtpool_alloc_fail: | 3325 | mgmtpool_alloc_fail: |
3322 | iscsi_pool_free(&session->cmdpool, (void**)session->cmds); | 3326 | iscsi_pool_free(&session->cmdpool, (void**)session->cmds); |
3323 | cmdpool_alloc_fail: | 3327 | cmdpool_alloc_fail: |
3328 | iscsi_transport_destroy_session(shost); | ||
3324 | return NULL; | 3329 | return NULL; |
3325 | } | 3330 | } |
3326 | 3331 | ||
3327 | static void | 3332 | static void |
3328 | iscsi_session_destroy(struct Scsi_Host *shost) | 3333 | iscsi_session_destroy(struct iscsi_cls_session *cls_session) |
3329 | { | 3334 | { |
3335 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); | ||
3330 | struct iscsi_session *session = iscsi_hostdata(shost->hostdata); | 3336 | struct iscsi_session *session = iscsi_hostdata(shost->hostdata); |
3331 | int cmd_i; | 3337 | int cmd_i; |
3332 | struct iscsi_data_task *dtask, *n; | 3338 | struct iscsi_data_task *dtask, *n; |
@@ -3350,10 +3356,10 @@ iscsi_session_destroy(struct Scsi_Host *shost) | |||
3350 | } | 3356 | } |
3351 | 3357 | ||
3352 | static int | 3358 | static int |
3353 | iscsi_conn_set_param(iscsi_connh_t connh, enum iscsi_param param, | 3359 | iscsi_conn_set_param(struct iscsi_cls_conn *cls_conn, enum iscsi_param param, |
3354 | uint32_t value) | 3360 | uint32_t value) |
3355 | { | 3361 | { |
3356 | struct iscsi_conn *conn = iscsi_ptr(connh); | 3362 | struct iscsi_conn *conn = cls_conn->dd_data; |
3357 | struct iscsi_session *session = conn->session; | 3363 | struct iscsi_session *session = conn->session; |
3358 | 3364 | ||
3359 | spin_lock_bh(&session->lock); | 3365 | spin_lock_bh(&session->lock); |
@@ -3495,9 +3501,10 @@ iscsi_conn_set_param(iscsi_connh_t connh, enum iscsi_param param, | |||
3495 | } | 3501 | } |
3496 | 3502 | ||
3497 | static int | 3503 | static int |
3498 | iscsi_session_get_param(struct Scsi_Host *shost, | 3504 | iscsi_session_get_param(struct iscsi_cls_session *cls_session, |
3499 | enum iscsi_param param, uint32_t *value) | 3505 | enum iscsi_param param, uint32_t *value) |
3500 | { | 3506 | { |
3507 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); | ||
3501 | struct iscsi_session *session = iscsi_hostdata(shost->hostdata); | 3508 | struct iscsi_session *session = iscsi_hostdata(shost->hostdata); |
3502 | 3509 | ||
3503 | switch(param) { | 3510 | switch(param) { |
@@ -3539,9 +3546,10 @@ iscsi_session_get_param(struct Scsi_Host *shost, | |||
3539 | } | 3546 | } |
3540 | 3547 | ||
3541 | static int | 3548 | static int |
3542 | iscsi_conn_get_param(void *data, enum iscsi_param param, uint32_t *value) | 3549 | iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, |
3550 | enum iscsi_param param, uint32_t *value) | ||
3543 | { | 3551 | { |
3544 | struct iscsi_conn *conn = data; | 3552 | struct iscsi_conn *conn = cls_conn->dd_data; |
3545 | 3553 | ||
3546 | switch(param) { | 3554 | switch(param) { |
3547 | case ISCSI_PARAM_MAX_RECV_DLENGTH: | 3555 | case ISCSI_PARAM_MAX_RECV_DLENGTH: |
@@ -3564,9 +3572,9 @@ iscsi_conn_get_param(void *data, enum iscsi_param param, uint32_t *value) | |||
3564 | } | 3572 | } |
3565 | 3573 | ||
3566 | static void | 3574 | static void |
3567 | iscsi_conn_get_stats(iscsi_connh_t connh, struct iscsi_stats *stats) | 3575 | iscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats) |
3568 | { | 3576 | { |
3569 | struct iscsi_conn *conn = iscsi_ptr(connh); | 3577 | struct iscsi_conn *conn = cls_conn->dd_data; |
3570 | 3578 | ||
3571 | stats->txdata_octets = conn->txdata_octets; | 3579 | stats->txdata_octets = conn->txdata_octets; |
3572 | stats->rxdata_octets = conn->rxdata_octets; | 3580 | stats->rxdata_octets = conn->rxdata_octets; |
@@ -3587,10 +3595,10 @@ iscsi_conn_get_stats(iscsi_connh_t connh, struct iscsi_stats *stats) | |||
3587 | } | 3595 | } |
3588 | 3596 | ||
3589 | static int | 3597 | static int |
3590 | iscsi_conn_send_pdu(iscsi_connh_t connh, struct iscsi_hdr *hdr, char *data, | 3598 | iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr, |
3591 | uint32_t data_size) | 3599 | char *data, uint32_t data_size) |
3592 | { | 3600 | { |
3593 | struct iscsi_conn *conn = iscsi_ptr(connh); | 3601 | struct iscsi_conn *conn = cls_conn->dd_data; |
3594 | int rc; | 3602 | int rc; |
3595 | 3603 | ||
3596 | mutex_lock(&conn->xmitmutex); | 3604 | mutex_lock(&conn->xmitmutex); |