提交 6484c945 编写于 作者: M Mike Christie 提交者: Zheng Zengkai

scsi: iscsi: Add iscsi_cls_conn refcount helpers

stable inclusion
from stable-5.10.52
commit 21962a5dd6b4021567a12f7b431217a0ee8323d8
bugzilla: 175542 https://gitee.com/openeuler/kernel/issues/I4DTKU

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=21962a5dd6b4021567a12f7b431217a0ee8323d8

--------------------------------

[ Upstream commit b1d19e8c ]

There are a couple places where we could free the iscsi_cls_conn while it's
still in use. This adds some helpers to get/put a refcount on the struct
and converts an exiting user. Subsequent commits will then use the helpers
to fix 2 bugs in the eh code.

Link: https://lore.kernel.org/r/20210525181821.7617-11-michael.christie@oracle.comReviewed-by: NLee Duncan <lduncan@suse.com>
Signed-off-by: NMike Christie <michael.christie@oracle.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 62f109ec
......@@ -1361,7 +1361,6 @@ void iscsi_session_failure(struct iscsi_session *session,
enum iscsi_err err)
{
struct iscsi_conn *conn;
struct device *dev;
spin_lock_bh(&session->frwd_lock);
conn = session->leadconn;
......@@ -1370,10 +1369,8 @@ void iscsi_session_failure(struct iscsi_session *session,
return;
}
dev = get_device(&conn->cls_conn->dev);
iscsi_get_conn(conn->cls_conn);
spin_unlock_bh(&session->frwd_lock);
if (!dev)
return;
/*
* if the host is being removed bypass the connection
* recovery initialization because we are going to kill
......@@ -1383,7 +1380,7 @@ void iscsi_session_failure(struct iscsi_session *session,
iscsi_conn_error_event(conn->cls_conn, err);
else
iscsi_conn_failure(conn, err);
put_device(dev);
iscsi_put_conn(conn->cls_conn);
}
EXPORT_SYMBOL_GPL(iscsi_session_failure);
......
......@@ -2353,6 +2353,18 @@ int iscsi_destroy_conn(struct iscsi_cls_conn *conn)
}
EXPORT_SYMBOL_GPL(iscsi_destroy_conn);
void iscsi_put_conn(struct iscsi_cls_conn *conn)
{
put_device(&conn->dev);
}
EXPORT_SYMBOL_GPL(iscsi_put_conn);
void iscsi_get_conn(struct iscsi_cls_conn *conn)
{
get_device(&conn->dev);
}
EXPORT_SYMBOL_GPL(iscsi_get_conn);
/*
* iscsi interface functions
*/
......
......@@ -434,6 +434,8 @@ extern void iscsi_remove_session(struct iscsi_cls_session *session);
extern void iscsi_free_session(struct iscsi_cls_session *session);
extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess,
int dd_size, uint32_t cid);
extern void iscsi_put_conn(struct iscsi_cls_conn *conn);
extern void iscsi_get_conn(struct iscsi_cls_conn *conn);
extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn);
extern void iscsi_unblock_session(struct iscsi_cls_session *session);
extern void iscsi_block_session(struct iscsi_cls_session *session);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册