iscsi: add sysfs attrs for uspace sync up
PATCH 2/5 iscsi: add sysfs attrs for uspace sync up
For iscsi boot when going from initramfs to the real root we need to stop the userpsace iscsi daemon. To later restart it iscsid needs to be able to rebuild itself and part of that process is matching a session running the kernel with the iscsid representation. To do this the attached patch adds several required iscsi values. If the LLD does not provide them becuase, login is done in userspace, then the transport class and userspace set ths up for the LLD.
Signed-off-by Mike Christie <[email protected]>
drivers/scsi/iscsi_tcp.c +66 -2
@@ -3536,7 +3536,7 @@ iscsi_session_get_param(struct iscsi_cls *value = session->ofmarker_en;break ;default : -return ISCSI_ERR_PARAM_NOT_FOUND ; +return -EINVAL ; }return 0 ;
@@ -3547,6 +3547,7 @@ iscsi_conn_get_param(struct iscsi_cls_co enum iscsi_param param, uint32_t *value) { struct iscsi_conn *conn = cls_conn->dd_data; +struct inet_sock *inet;switch (param) {case ISCSI_PARAM_MAX_RECV_DLENGTH :
@@ -3561,13 +3562,61 @@ iscsi_conn_get_param(struct iscsi_cls_cocase ISCSI_PARAM_DATADGST_EN : *value = conn->datadgst_en;break ; +case ISCSI_PARAM_CONN_PORT : +mutex_lock (&conn->xmitmutex); +if (!conn->sock) { +mutex_unlock (&conn->xmitmutex); +return -EINVAL ; + } + + inet =inet_sk (conn->sock->sk); + *value =be16_to_cpu (inet->dport); +mutex_unlock (&conn->xmitmutex);default : -return ISCSI_ERR_PARAM_NOT_FOUND ; +return -EINVAL ; }return 0 ; } +static int +iscsi_conn_get_str_param (struct iscsi_cls_conn *cls_conn, +enum iscsi_param param,char *buf) +{ +struct iscsi_conn *conn = cls_conn->dd_data; +struct sock *sk; +struct inet_sock *inet; +struct ipv6_pinfo *np; +int len =0 ; + +switch (param) { +case ISCSI_PARAM_CONN_ADDRESS : +mutex_lock (&conn->xmitmutex); +if (!conn->sock) { +mutex_unlock (&conn->xmitmutex); +return -EINVAL ; + } + + sk = conn->sock->sk; +if (sk->sk_family ==PF_INET ) { + inet =inet_sk (sk); + len =sprintf (buf,"%u.%u.%u.%u\n" , +NIPQUAD (inet->daddr)); + }else { + np =inet6_sk (sk); + len =sprintf (buf, +"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n" , +NIP6 (np->daddr)); + } +mutex_unlock (&conn->xmitmutex); +break ; +default : +return -EINVAL ; + } + +return len; +} +static void iscsi_conn_get_stats (struct iscsi_cls_conn *cls_conn,struct iscsi_stats *stats) {
@@ -3610,6 +3659,20 @@ static struct iscsi_transport iscsi_tcp_ .name = "tcp", .caps =CAP_RECOVERY_L0 |CAP_MULTI_R2T |CAP_HDRDGST | CAP_DATADGST, + .param_mask =ISCSI_MAX_RECV_DLENGTH | +ISCSI_MAX_XMIT_DLENGTH | +ISCSI_HDRDGST_EN | +ISCSI_DATADGST_EN | +ISCSI_INITIAL_R2T_EN | +ISCSI_MAX_R2T | +ISCSI_IMM_DATA_EN | +ISCSI_FIRST_BURST | +ISCSI_MAX_BURST | +ISCSI_PDU_INORDER_EN | +ISCSI_DATASEQ_INORDER_EN | +ISCSI_ERL | +ISCSI_CONN_PORT | + ISCSI_CONN_ADDRESS, .host_template = &iscsi_sht, .hostdata_size = sizeof(struct iscsi_session), .conndata_size = sizeof(struct iscsi_conn),
@@ -3622,6 +3685,7 @@ static struct iscsi_transport iscsi_tcp_ .destroy_conn = iscsi_conn_destroy, .set_param = iscsi_conn_set_param, .get_conn_param = iscsi_conn_get_param, + .get_conn_str_param = iscsi_conn_get_str_param, .get_session_param = iscsi_session_get_param, .start_conn = iscsi_conn_start, .stop_conn = iscsi_conn_stop,
drivers/scsi/scsi_transport_iscsi.c +207 -53
347 lines not on this page · raw message
include/scsi/iscsi_if.h +48 -16
77 lines not on this page · raw message
include/scsi/scsi_transport_iscsi.h +20 -4
@@ -53,11 +53,11 @@ struct iscsi_transport {struct module *owner;char *name;unsigned int caps; +/* LLD sets this to indicate what values it can export to sysfs */ +unsigned int param_mask;struct scsi_host_template *host_template;/* LLD session/scsi_host data size */ int hostdata_size; -/* LLD iscsi_host data size */ -int ihostdata_size;/* LLD connection data size */ int conndata_size;/* LLD session data size */
@@ -79,10 +79,13 @@ struct iscsi_transport {int (*set_param) (struct iscsi_cls_conn *conn,enum iscsi_param param,uint32_t value);int (*get_conn_param) (struct iscsi_cls_conn *conn, -enum iscsi_param param, -uint32_t *value); +enum iscsi_param param,uint32_t *value);int (*get_session_param) (struct iscsi_cls_session *session,enum iscsi_param param,uint32_t *value); +int (*get_conn_str_param) (struct iscsi_cls_conn *conn, +enum iscsi_param param,char *buf); +int (*get_session_str_param) (struct iscsi_cls_session *session, +enum iscsi_param param,char *buf);int (*send_pdu) (struct iscsi_cls_conn *conn,struct iscsi_hdr *hdr,char *data,uint32_t data_size); void (*get_stats) (struct iscsi_cls_conn *conn,
@@ -107,6 +110,14 @@ struct iscsi_cls_conn {void *dd_data;/* LLD private data */ struct iscsi_transport *transport;uint32_t cid;/* connection id */ + +/* portal/group values we got during discovery */ +char *persistent_address; +int persistent_port; +/* portal/group values we are currently using */ +char *address; +int port; +int active;/* must be accessed with the connlock */ struct device dev;/* sysfs transport/container device */ struct mempool_zone *z_error;
@@ -120,6 +131,11 @@ struct iscsi_cls_conn {struct iscsi_cls_session {struct list_head sess_list;/* item in session_list */ struct iscsi_transport *transport; + +/* iSCSI values used as unique id by userspace. */ +char *targetname; +int tpgt; +int sid;/* session id */ void *dd_data;/* LLD private data */ struct device dev;/* sysfs transport/container device */