diff mbox series

[15/17] iscsi target: hook iscsi target into sysfs API

Message ID 1591562164-9766-16-git-send-email-michael.christie@oracle.com (mailing list archive)
State Changes Requested
Headers show
Series [01/17] target: check enforce_pr_isids during registration | expand

Commit Message

Mike Christie June 7, 2020, 8:36 p.m. UTC
Have the iscsi target export it's sessions in sysfs.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/target/iscsi/iscsi_target.c      | 2 ++
 drivers/target/iscsi/iscsi_target_nego.c | 9 +++++++++
 2 files changed, 11 insertions(+)

Comments

Hannes Reinecke June 8, 2020, 6:20 a.m. UTC | #1
On 6/7/20 10:36 PM, Mike Christie wrote:
> Have the iscsi target export it's sessions in sysfs.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/target/iscsi/iscsi_target.c      | 2 ++
>   drivers/target/iscsi/iscsi_target_nego.c | 9 +++++++++
>   2 files changed, 11 insertions(+)
> 
> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 4c73374..f26d364 100644
> --- a/drivers/target/iscsi/iscsi_target.c
> +++ b/drivers/target/iscsi/iscsi_target.c
> @@ -4383,6 +4383,8 @@ int iscsit_close_session(struct iscsi_session *sess)
>   		}
>   	}
>   
> +	target_sysfs_remove_session(sess->se_sess);
> +
>   	if (sess->sess_ops->ErrorRecoveryLevel == 2)
>   		iscsit_free_connection_recovery_entries(sess);
>   
> diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c
> index c44613a2..6dcb8ff 100644
> --- a/drivers/target/iscsi/iscsi_target_nego.c
> +++ b/drivers/target/iscsi/iscsi_target_nego.c
> @@ -359,6 +359,13 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log
>   					    ISCSI_LOGIN_STATUS_NO_RESOURCES);
>   			return -1;
>   		}
> +
> +		if (target_sysfs_add_session(&conn->tpg->tpg_se_tpg,
> +					     conn->sess->se_sess)) {
> +			iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
> +					    ISCSI_LOGIN_STATUS_NO_RESOURCES);
> +			return -1;
> +		}
>   	}
>   
>   	if (conn->conn_transport->iscsit_put_login_tx(conn, login,
> @@ -371,6 +378,8 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log
>   
>   err:
>   	if (login->login_complete) {
> +		target_sysfs_remove_session(conn->sess->se_sess);
> +
>   		if (conn->rx_thread && conn->rx_thread_active) {
>   			send_sig(SIGINT, conn->rx_thread, 1);
>   			complete(&conn->rx_login_comp);
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
diff mbox series

Patch

diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 4c73374..f26d364 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -4383,6 +4383,8 @@  int iscsit_close_session(struct iscsi_session *sess)
 		}
 	}
 
+	target_sysfs_remove_session(sess->se_sess);
+
 	if (sess->sess_ops->ErrorRecoveryLevel == 2)
 		iscsit_free_connection_recovery_entries(sess);
 
diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c
index c44613a2..6dcb8ff 100644
--- a/drivers/target/iscsi/iscsi_target_nego.c
+++ b/drivers/target/iscsi/iscsi_target_nego.c
@@ -359,6 +359,13 @@  static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log
 					    ISCSI_LOGIN_STATUS_NO_RESOURCES);
 			return -1;
 		}
+
+		if (target_sysfs_add_session(&conn->tpg->tpg_se_tpg,
+					     conn->sess->se_sess)) {
+			iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
+					    ISCSI_LOGIN_STATUS_NO_RESOURCES);
+			return -1;
+		}
 	}
 
 	if (conn->conn_transport->iscsit_put_login_tx(conn, login,
@@ -371,6 +378,8 @@  static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log
 
 err:
 	if (login->login_complete) {
+		target_sysfs_remove_session(conn->sess->se_sess);
+
 		if (conn->rx_thread && conn->rx_thread_active) {
 			send_sig(SIGINT, conn->rx_thread, 1);
 			complete(&conn->rx_login_comp);