Skip to content

Commit fd7255f

Browse files
Mike ChristieJames Bottomley
authored andcommitted
[SCSI] 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 <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
1 parent b5c7a12 commit fd7255f

File tree

4 files changed

+342
-76
lines changed

4 files changed

+342
-76
lines changed

drivers/scsi/iscsi_tcp.c

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3536,7 +3536,7 @@ iscsi_session_get_param(struct iscsi_cls_session *cls_session,
35363536
*value = session->ofmarker_en;
35373537
break;
35383538
default:
3539-
return ISCSI_ERR_PARAM_NOT_FOUND;
3539+
return -EINVAL;
35403540
}
35413541

35423542
return 0;
@@ -3547,6 +3547,7 @@ iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
35473547
enum iscsi_param param, uint32_t *value)
35483548
{
35493549
struct iscsi_conn *conn = cls_conn->dd_data;
3550+
struct inet_sock *inet;
35503551

35513552
switch(param) {
35523553
case ISCSI_PARAM_MAX_RECV_DLENGTH:
@@ -3561,13 +3562,61 @@ iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
35613562
case ISCSI_PARAM_DATADGST_EN:
35623563
*value = conn->datadgst_en;
35633564
break;
3565+
case ISCSI_PARAM_CONN_PORT:
3566+
mutex_lock(&conn->xmitmutex);
3567+
if (!conn->sock) {
3568+
mutex_unlock(&conn->xmitmutex);
3569+
return -EINVAL;
3570+
}
3571+
3572+
inet = inet_sk(conn->sock->sk);
3573+
*value = be16_to_cpu(inet->dport);
3574+
mutex_unlock(&conn->xmitmutex);
35643575
default:
3565-
return ISCSI_ERR_PARAM_NOT_FOUND;
3576+
return -EINVAL;
35663577
}
35673578

35683579
return 0;
35693580
}
35703581

3582+
static int
3583+
iscsi_conn_get_str_param(struct iscsi_cls_conn *cls_conn,
3584+
enum iscsi_param param, char *buf)
3585+
{
3586+
struct iscsi_conn *conn = cls_conn->dd_data;
3587+
struct sock *sk;
3588+
struct inet_sock *inet;
3589+
struct ipv6_pinfo *np;
3590+
int len = 0;
3591+
3592+
switch (param) {
3593+
case ISCSI_PARAM_CONN_ADDRESS:
3594+
mutex_lock(&conn->xmitmutex);
3595+
if (!conn->sock) {
3596+
mutex_unlock(&conn->xmitmutex);
3597+
return -EINVAL;
3598+
}
3599+
3600+
sk = conn->sock->sk;
3601+
if (sk->sk_family == PF_INET) {
3602+
inet = inet_sk(sk);
3603+
len = sprintf(buf, "%u.%u.%u.%u\n",
3604+
NIPQUAD(inet->daddr));
3605+
} else {
3606+
np = inet6_sk(sk);
3607+
len = sprintf(buf,
3608+
"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
3609+
NIP6(np->daddr));
3610+
}
3611+
mutex_unlock(&conn->xmitmutex);
3612+
break;
3613+
default:
3614+
return -EINVAL;
3615+
}
3616+
3617+
return len;
3618+
}
3619+
35713620
static void
35723621
iscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats)
35733622
{
@@ -3610,6 +3659,20 @@ static struct iscsi_transport iscsi_tcp_transport = {
36103659
.name = "tcp",
36113660
.caps = CAP_RECOVERY_L0 | CAP_MULTI_R2T | CAP_HDRDGST
36123661
| CAP_DATADGST,
3662+
.param_mask = ISCSI_MAX_RECV_DLENGTH |
3663+
ISCSI_MAX_XMIT_DLENGTH |
3664+
ISCSI_HDRDGST_EN |
3665+
ISCSI_DATADGST_EN |
3666+
ISCSI_INITIAL_R2T_EN |
3667+
ISCSI_MAX_R2T |
3668+
ISCSI_IMM_DATA_EN |
3669+
ISCSI_FIRST_BURST |
3670+
ISCSI_MAX_BURST |
3671+
ISCSI_PDU_INORDER_EN |
3672+
ISCSI_DATASEQ_INORDER_EN |
3673+
ISCSI_ERL |
3674+
ISCSI_CONN_PORT |
3675+
ISCSI_CONN_ADDRESS,
36133676
.host_template = &iscsi_sht,
36143677
.hostdata_size = sizeof(struct iscsi_session),
36153678
.conndata_size = sizeof(struct iscsi_conn),
@@ -3622,6 +3685,7 @@ static struct iscsi_transport iscsi_tcp_transport = {
36223685
.destroy_conn = iscsi_conn_destroy,
36233686
.set_param = iscsi_conn_set_param,
36243687
.get_conn_param = iscsi_conn_get_param,
3688+
.get_conn_str_param = iscsi_conn_get_str_param,
36253689
.get_session_param = iscsi_session_get_param,
36263690
.start_conn = iscsi_conn_start,
36273691
.stop_conn = iscsi_conn_stop,

0 commit comments

Comments
 (0)