未验证 提交 140dbb75 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!422 iscsi bugfixes backport

Merge Pull Request from: @LiuYongQiang0816 
 
two iscsi bugfixes backport from Zhong Jinghua 
 
Link:https://gitee.com/openeuler/kernel/pulls/422 

Reviewed-by: Zheng Zengkai <zhengzengkai@huawei.com> 
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com> 
......@@ -783,7 +783,7 @@ static int iscsi_sw_tcp_host_get_param(struct Scsi_Host *shost,
enum iscsi_host_param param, char *buf)
{
struct iscsi_sw_tcp_host *tcp_sw_host = iscsi_host_priv(shost);
struct iscsi_session *session = tcp_sw_host->session;
struct iscsi_session *session;
struct iscsi_conn *conn;
struct iscsi_tcp_conn *tcp_conn;
struct iscsi_sw_tcp_conn *tcp_sw_conn;
......@@ -792,6 +792,7 @@ static int iscsi_sw_tcp_host_get_param(struct Scsi_Host *shost,
switch (param) {
case ISCSI_HOST_PARAM_IPADDRESS:
session = tcp_sw_host->session;
if (!session)
return -ENOTCONN;
......@@ -886,11 +887,13 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max,
if (!cls_session)
goto remove_host;
session = cls_session->dd_data;
tcp_sw_host = iscsi_host_priv(shost);
tcp_sw_host->session = session;
if (iscsi_tcp_r2tpool_alloc(session))
goto remove_session;
/* We are now fully setup so expose the session to sysfs. */
tcp_sw_host = iscsi_host_priv(shost);
tcp_sw_host->session = session;
return cls_session;
remove_session:
......@@ -910,10 +913,17 @@ static void iscsi_sw_tcp_session_destroy(struct iscsi_cls_session *cls_session)
if (WARN_ON_ONCE(session->leadconn))
return;
iscsi_session_remove(cls_session);
/*
* Our get_host_param needs to access the session, so remove the
* host from sysfs before freeing the session to make sure userspace
* is no longer accessing the callout.
*/
iscsi_host_remove(shost);
iscsi_tcp_r2tpool_free(cls_session->dd_data);
iscsi_session_teardown(cls_session);
iscsi_host_remove(shost);
iscsi_session_free(cls_session);
iscsi_host_free(shost);
}
......
......@@ -3018,20 +3018,34 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,
}
EXPORT_SYMBOL_GPL(iscsi_session_setup);
/*
* issi_session_remove - Remove session from iSCSI class.
*/
void iscsi_session_remove(struct iscsi_cls_session *cls_session)
{
struct iscsi_session *session = cls_session->dd_data;
struct Scsi_Host *shost = session->host;
iscsi_remove_session(cls_session);
/*
* host removal only has to wait for its children to be removed from
* sysfs, and iscsi_tcp needs to do iscsi_host_remove before freeing
* the session, so drop the session count here.
*/
iscsi_host_dec_session_cnt(shost);
}
EXPORT_SYMBOL_GPL(iscsi_session_remove);
/**
* iscsi_session_teardown - destroy session, host, and cls_session
* iscsi_session_free - Free iscsi session and it's resources
* @cls_session: iscsi session
*/
void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
void iscsi_session_free(struct iscsi_cls_session *cls_session)
{
struct iscsi_session *session = cls_session->dd_data;
struct module *owner = cls_session->transport->owner;
struct Scsi_Host *shost = session->host;
iscsi_pool_free(&session->cmdpool);
iscsi_remove_session(cls_session);
kfree(session->password);
kfree(session->password_in);
kfree(session->username);
......@@ -3047,10 +3061,19 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
kfree(session->discovery_parent_type);
iscsi_free_session(cls_session);
iscsi_host_dec_session_cnt(shost);
module_put(owner);
}
EXPORT_SYMBOL_GPL(iscsi_session_free);
/**
* iscsi_session_teardown - destroy session and cls_session
* @cls_session: iscsi session
*/
void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
{
iscsi_session_remove(cls_session);
iscsi_session_free(cls_session);
}
EXPORT_SYMBOL_GPL(iscsi_session_teardown);
/**
......
......@@ -425,6 +425,8 @@ extern int iscsi_host_get_max_scsi_cmds(struct Scsi_Host *shost,
extern struct iscsi_cls_session *
iscsi_session_setup(struct iscsi_transport *, struct Scsi_Host *shost,
uint16_t, int, int, uint32_t, unsigned int);
void iscsi_session_remove(struct iscsi_cls_session *cls_session);
void iscsi_session_free(struct iscsi_cls_session *cls_session);
extern void iscsi_session_teardown(struct iscsi_cls_session *);
extern void iscsi_session_recovery_timedout(struct iscsi_cls_session *);
extern int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册