Skip to content

Commit b1d19e8

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: iscsi: Add iscsi_cls_conn refcount helpers
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/[email protected] Reviewed-by: Lee Duncan <[email protected]> Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 788b71c commit b1d19e8

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

drivers/scsi/libiscsi.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,6 @@ void iscsi_session_failure(struct iscsi_session *session,
13611361
enum iscsi_err err)
13621362
{
13631363
struct iscsi_conn *conn;
1364-
struct device *dev;
13651364

13661365
spin_lock_bh(&session->frwd_lock);
13671366
conn = session->leadconn;
@@ -1370,10 +1369,8 @@ void iscsi_session_failure(struct iscsi_session *session,
13701369
return;
13711370
}
13721371

1373-
dev = get_device(&conn->cls_conn->dev);
1372+
iscsi_get_conn(conn->cls_conn);
13741373
spin_unlock_bh(&session->frwd_lock);
1375-
if (!dev)
1376-
return;
13771374
/*
13781375
* if the host is being removed bypass the connection
13791376
* recovery initialization because we are going to kill
@@ -1383,7 +1380,7 @@ void iscsi_session_failure(struct iscsi_session *session,
13831380
iscsi_conn_error_event(conn->cls_conn, err);
13841381
else
13851382
iscsi_conn_failure(conn, err);
1386-
put_device(dev);
1383+
iscsi_put_conn(conn->cls_conn);
13871384
}
13881385
EXPORT_SYMBOL_GPL(iscsi_session_failure);
13891386

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,18 @@ int iscsi_destroy_conn(struct iscsi_cls_conn *conn)
24572457
}
24582458
EXPORT_SYMBOL_GPL(iscsi_destroy_conn);
24592459

2460+
void iscsi_put_conn(struct iscsi_cls_conn *conn)
2461+
{
2462+
put_device(&conn->dev);
2463+
}
2464+
EXPORT_SYMBOL_GPL(iscsi_put_conn);
2465+
2466+
void iscsi_get_conn(struct iscsi_cls_conn *conn)
2467+
{
2468+
get_device(&conn->dev);
2469+
}
2470+
EXPORT_SYMBOL_GPL(iscsi_get_conn);
2471+
24602472
/*
24612473
* iscsi interface functions
24622474
*/

include/scsi/scsi_transport_iscsi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ extern void iscsi_remove_session(struct iscsi_cls_session *session);
443443
extern void iscsi_free_session(struct iscsi_cls_session *session);
444444
extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess,
445445
int dd_size, uint32_t cid);
446+
extern void iscsi_put_conn(struct iscsi_cls_conn *conn);
447+
extern void iscsi_get_conn(struct iscsi_cls_conn *conn);
446448
extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn);
447449
extern void iscsi_unblock_session(struct iscsi_cls_session *session);
448450
extern void iscsi_block_session(struct iscsi_cls_session *session);

0 commit comments

Comments
 (0)