static void isert_send_data_rsp(struct iscsi_cmnd *req, u8 *sense, int sense_len, u8 status, int is_send_status) { struct iscsi_cmnd *rsp; TRACE_ENTRY(); sBUG_ON(!is_send_status); rsp = create_status_rsp(req, status, sense, sense_len); isert_update_len_sn(rsp); conn_get(rsp->conn); if (status != SAM_STAT_CHECK_CONDITION) isert_send_data_in(req, rsp); else isert_pdu_tx(rsp); TRACE_EXIT(); }
int isert_conn_alloc(struct iscsi_session *session, struct iscsi_kern_conn_info *info, struct iscsi_conn **new_conn, struct iscsit_transport *t) { int res = 0; struct isert_conn_dev *dev; struct iscsi_conn *conn; struct iscsi_cmnd *cmnd; struct file *filp = fget(info->fd); TRACE_ENTRY(); lockdep_assert_held(&session->target->target_mutex); if (unlikely(!filp)) { res = -EBADF; goto out; } dev = filp->private_data; cmnd = dev->login_rsp; sBUG_ON(cmnd == NULL); dev->login_rsp = NULL; *new_conn = dev->conn; res = isert_set_session_params(dev->conn, &session->sess_params, &session->tgt_params); if (!res) set_bit(ISERT_CONN_PASSED, &dev->flags); fput(filp); conn = *new_conn; if (unlikely(res)) goto cleanup_conn; conn->transport = t; res = iscsi_init_conn(session, info, conn); if (unlikely(res)) goto cleanup_conn; conn->rd_state = 1; isert_del_timer(dev); isert_dev_release(dev); isert_set_priv(conn, NULL); res = isert_login_rsp_tx(cmnd, true, false); vunmap(dev->sg_virt); dev->sg_virt = NULL; if (unlikely(res)) goto cleanup_iscsi_conn; #ifndef CONFIG_SCST_PROC res = conn_sysfs_add(conn); if (unlikely(res)) goto cleanup_iscsi_conn; #endif list_add_tail(&conn->conn_list_entry, &session->conn_list); goto out; cleanup_iscsi_conn: conn->rd_state = 0; if (conn->nop_in_interval > 0) cancel_delayed_work_sync(&conn->nop_in_delayed_work); cleanup_conn: conn->session = NULL; isert_close_connection(conn); out: TRACE_EXIT_RES(res); return res; }
/* * This function converts transport_id in a string form into internal per-CPU * static buffer. This buffer isn't anyhow protected, because it's acceptable * if the name corrupted in the debug logs because of the race for this buffer. * * Note! You can't call this function 2 or more times in a single logging * (printk) statement, because then each new call of this function will override * data written in this buffer by the previous call. You should instead split * that logging statement on smaller statements each calling * debug_transport_id_to_initiator_name() only once. */ const char *debug_transport_id_to_initiator_name(const uint8_t *transport_id) { /* * No external protection, because it's acceptable if the name * corrupted in the debug logs because of the race for this * buffer. */ #define SIZEOF_NAME_BUF 256 static char name_bufs[NR_CPUS][SIZEOF_NAME_BUF]; char *name_buf; unsigned long flags; sBUG_ON(transport_id == NULL); /* better to catch it not under lock */ spin_lock_irqsave(&trace_buf_lock, flags); name_buf = name_bufs[smp_processor_id()]; /* * To prevent external racing with us users from accidentally * missing their NULL terminator. */ memset(name_buf, 0, SIZEOF_NAME_BUF); smp_mb(); switch (transport_id[0] & 0x0f) { case SCSI_TRANSPORTID_PROTOCOLID_ISCSI: scnprintf(name_buf, SIZEOF_NAME_BUF, "%s", &transport_id[4]); break; case SCSI_TRANSPORTID_PROTOCOLID_FCP2: scnprintf(name_buf, SIZEOF_NAME_BUF, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", transport_id[8], transport_id[9], transport_id[10], transport_id[11], transport_id[12], transport_id[13], transport_id[14], transport_id[15]); break; case SCSI_TRANSPORTID_PROTOCOLID_SPI5: scnprintf(name_buf, SIZEOF_NAME_BUF, "%x:%x", be16_to_cpu((__force __be16)transport_id[2]), be16_to_cpu((__force __be16)transport_id[6])); break; case SCSI_TRANSPORTID_PROTOCOLID_SRP: scnprintf(name_buf, SIZEOF_NAME_BUF, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" ":%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", transport_id[8], transport_id[9], transport_id[10], transport_id[11], transport_id[12], transport_id[13], transport_id[14], transport_id[15], transport_id[16], transport_id[17], transport_id[18], transport_id[19], transport_id[20], transport_id[21], transport_id[22], transport_id[23]); break; case SCSI_TRANSPORTID_PROTOCOLID_SAS: scnprintf(name_buf, SIZEOF_NAME_BUF, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", transport_id[4], transport_id[5], transport_id[6], transport_id[7], transport_id[8], transport_id[9], transport_id[10], transport_id[11]); break; default: scnprintf(name_buf, SIZEOF_NAME_BUF, "(Not known protocol ID %x)", transport_id[0] & 0x0f); break; } spin_unlock_irqrestore(&trace_buf_lock, flags); return name_buf; #undef SIZEOF_NAME_BUF }