]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: iscsi: Add iscsi_cls_conn refcount helpers
authorMike Christie <michael.christie@oracle.com>
Tue, 25 May 2021 18:18:03 +0000 (13:18 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:10:43 +0000 (16:10 +0200)
[ Upstream commit b1d19e8c92cfb0ded180ef3376c20e130414e067 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/libiscsi.c
drivers/scsi/scsi_transport_iscsi.c
include/scsi/scsi_transport_iscsi.h

index c5b7d18513b66b045011674a597799098e971513..b9981078375df12e3e40ad0824bdcc0b0d7c3f61 100644 (file)
@@ -1348,7 +1348,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;
@@ -1357,10 +1356,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
@@ -1370,7 +1367,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);
 
index a26df7d6d5d18fa659f92b3a9cdf70c82057da88..2f1553d0a10ed29b37bae02447d24a597b753a2f 100644 (file)
@@ -2308,6 +2308,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
  */
index 325ae731d9ad87878577df10d2071b0d179280e4..71c78410e6ab3f28d5d63caa3642f216f8d4dce0 100644 (file)
@@ -423,6 +423,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);