[stgt] Limiting the number of ISCSI-Sessions per target

Martin Klapproth martin.klapproth at inqbus.de
Thu Oct 23 14:37:59 CEST 2008


>
> Oops, can you try this patch (please ignore the previous patch)?
>
> This can be applied to tgt-20080805 (0.90, and the latest git tree
> too).
>
> diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
> index cb2ba0b..c22a6f6 100644
> --- a/usr/iscsi/iscsid.c
> +++ b/usr/iscsi/iscsid.c
> @@ -498,6 +498,7 @@ static void login_finish(struct iscsi_connection *conn)
>  {
>  	struct iscsi_login_rsp *rsp = (struct iscsi_login_rsp *) &conn->rsp.bhs;
>  	int ret;
> +	uint8_t class, detail;
>  
>  	switch (conn->session_type) {
>  	case SESSION_NORMAL:
> @@ -513,25 +514,25 @@ static void login_finish(struct iscsi_connection *conn)
>  		 */
>  		ret = conn->tp->ep_login_complete(conn);
>  		if (ret) {
> -			rsp->flags = 0;
> -			rsp->status_class = ISCSI_STATUS_CLS_TARGET_ERR;
> -			rsp->status_detail = ISCSI_LOGIN_STATUS_NO_RESOURCES;
> -			conn->state = STATE_EXIT;
> -			break;
> +			class = ISCSI_STATUS_CLS_TARGET_ERR;
> +			detail = ISCSI_LOGIN_STATUS_NO_RESOURCES;
> +			goto fail;
>  		}
>  		if (!conn->session) {
> -			session_create(conn);
> +			ret = session_create(conn);
> +			if (ret) {
> +				class = ISCSI_STATUS_CLS_TARGET_ERR;
> +				detail = ISCSI_LOGIN_STATUS_TARGET_ERROR;
> +				goto fail;
> +			}
>  		} else {
>  			if (conn->tp->rdma ^ conn->session->rdma) {
>  				eprintf("new conn rdma %d, but session %d\n",
>  					conn->tp->rdma, conn->session->rdma);
> -				rsp->flags = 0;
> -				rsp->status_class =
> -					ISCSI_STATUS_CLS_INITIATOR_ERR;
> -				rsp->status_detail =
> -					ISCSI_LOGIN_STATUS_INVALID_REQUEST;
> -				conn->state = STATE_EXIT;
> -				break;
> +
> +				class = ISCSI_STATUS_CLS_INITIATOR_ERR;
> +				detail =ISCSI_LOGIN_STATUS_INVALID_REQUEST;
> +				goto fail;
>  			}
>  		}
>  		memcpy(conn->isid, conn->session->isid, sizeof(conn->isid));
> @@ -542,6 +543,14 @@ static void login_finish(struct iscsi_connection *conn)
>  		conn->tsih = 1;
>  		break;
>  	}
> +
> +	return;
> +fail:
> +	rsp->flags = 0;
> +	rsp->status_class = class;
> +	rsp->status_detail = detail;
> +	conn->state = STATE_EXIT;
> +	return;
>  }
>  
>  static int cmnd_exec_auth(struct iscsi_connection *conn)
> diff --git a/usr/target.c b/usr/target.c
> index dc30c87..91085dc 100644
> --- a/usr/target.c
> +++ b/usr/target.c
> @@ -248,6 +248,9 @@ int it_nexus_create(int tid, uint64_t itn_id, int host_no, char *info)
>  
>  	target = target_lookup(tid);
>  
> +	if (!list_empty(&target->it_nexus_list))
> +		return -EEXIST;
> +
>  	itn = zalloc(sizeof(*itn));
>  	if (!itn)
>  		return -ENOMEM;
>
>
>   
Thank you for the patch.

Now tgtd doesn't die when a seconds session should be started. The
second client which wants to get a session runs in a timout and after
about 60 seconds an error will be raised.

Best regards

Martin Klapproth

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list