Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20210525181821.7617-11-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Mike Christie and committed by
Martin K. Petersen
b1d19e8c 788b71c5

+16 -5
+2 -5
drivers/scsi/libiscsi.c
··· 1361 1361 enum iscsi_err err) 1362 1362 { 1363 1363 struct iscsi_conn *conn; 1364 - struct device *dev; 1365 1364 1366 1365 spin_lock_bh(&session->frwd_lock); 1367 1366 conn = session->leadconn; ··· 1369 1370 return; 1370 1371 } 1371 1372 1372 - dev = get_device(&conn->cls_conn->dev); 1373 + iscsi_get_conn(conn->cls_conn); 1373 1374 spin_unlock_bh(&session->frwd_lock); 1374 - if (!dev) 1375 - return; 1376 1375 /* 1377 1376 * if the host is being removed bypass the connection 1378 1377 * recovery initialization because we are going to kill ··· 1380 1383 iscsi_conn_error_event(conn->cls_conn, err); 1381 1384 else 1382 1385 iscsi_conn_failure(conn, err); 1383 - put_device(dev); 1386 + iscsi_put_conn(conn->cls_conn); 1384 1387 } 1385 1388 EXPORT_SYMBOL_GPL(iscsi_session_failure); 1386 1389
+12
drivers/scsi/scsi_transport_iscsi.c
··· 2457 2457 } 2458 2458 EXPORT_SYMBOL_GPL(iscsi_destroy_conn); 2459 2459 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 + 2460 2472 /* 2461 2473 * iscsi interface functions 2462 2474 */
+2
include/scsi/scsi_transport_iscsi.h
··· 443 443 extern void iscsi_free_session(struct iscsi_cls_session *session); 444 444 extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess, 445 445 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); 446 448 extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn); 447 449 extern void iscsi_unblock_session(struct iscsi_cls_session *session); 448 450 extern void iscsi_block_session(struct iscsi_cls_session *session);