Skip to content

Commit

Permalink
[SCSI] iscsi: add sysfs attrs for uspace sync up
Browse files Browse the repository at this point in the history
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 <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
  • Loading branch information
Mike Christie authored and James Bottomley committed Apr 14, 2006
1 parent b5c7a12 commit fd7255f
Show file tree
Hide file tree
Showing 4 changed files with 342 additions and 76 deletions.
68 changes: 66 additions & 2 deletions drivers/scsi/iscsi_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3536,7 +3536,7 @@ iscsi_session_get_param(struct iscsi_cls_session *cls_session,
*value = session->ofmarker_en;
break;
default:
return ISCSI_ERR_PARAM_NOT_FOUND;
return -EINVAL;
}

return 0;
Expand All @@ -3547,6 +3547,7 @@ iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
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:
Expand All @@ -3561,13 +3562,61 @@ iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
case 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)
{
Expand Down Expand Up @@ -3610,6 +3659,20 @@ static struct iscsi_transport iscsi_tcp_transport = {
.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),
Expand All @@ -3622,6 +3685,7 @@ static struct iscsi_transport iscsi_tcp_transport = {
.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,
Expand Down
Loading

0 comments on commit fd7255f

Please sign in to comment.