iscsi-target: remove usage of ->shutdown_session
authorChristoph Hellwig <hch@lst.de>
Mon, 2 May 2016 13:45:24 +0000 (15:45 +0200)
committerNicholas Bellinger <nab@linux-iscsi.org>
Tue, 10 May 2016 08:19:41 +0000 (01:19 -0700)
->shutdown session only decideŃ• if the target core calls ->close_session
directly, or if the fabrics drivers calls it manually later through
target_put_session, which at this point will always close the session as
it has been removed from the lookup list and thus no new references will
be acquired from the core.

So instead remove ->shutdown and have the core call ->close_session
directly, and replace all calls to target_put_session in the iSCSI target
with direct calls to iscsit_close_session.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/iscsi/iscsi_target.c
drivers/target/iscsi/iscsi_target_configfs.c
drivers/target/iscsi/iscsi_target_erl0.c
drivers/target/iscsi/iscsi_target_login.c

index 487d8f37b23ad65268deef2ef9c21fef04f22c7a..9a4f8957725b7d4ed216ae27be2e2472a40bad36 100644 (file)
@@ -4270,7 +4270,7 @@ int iscsit_close_connection(
        if (!atomic_read(&sess->session_reinstatement) &&
             atomic_read(&sess->session_fall_back_to_erl0)) {
                spin_unlock_bh(&sess->conn_lock);
-               target_put_session(sess->se_sess);
+               iscsit_close_session(sess);
 
                return 0;
        } else if (atomic_read(&sess->session_logout)) {
@@ -4299,6 +4299,10 @@ int iscsit_close_connection(
        }
 }
 
+/*
+ * If the iSCSI Session for the iSCSI Initiator Node exists,
+ * forcefully shutdown the iSCSI NEXUS.
+ */
 int iscsit_close_session(struct iscsi_session *sess)
 {
        struct iscsi_portal_group *tpg = sess->tpg;
@@ -4398,7 +4402,7 @@ static void iscsit_logout_post_handler_closesession(
        iscsit_dec_conn_usage_count(conn);
        iscsit_stop_session(sess, sleep, sleep);
        iscsit_dec_session_usage_count(sess);
-       target_put_session(sess->se_sess);
+       iscsit_close_session(sess);
 }
 
 static void iscsit_logout_post_handler_samecid(
@@ -4570,7 +4574,7 @@ int iscsit_free_session(struct iscsi_session *sess)
        } else
                spin_unlock_bh(&sess->conn_lock);
 
-       target_put_session(sess->se_sess);
+       iscsit_close_session(sess);
        return 0;
 }
 
index 3565e07ad8a6c47bf4d03ac621d6f74bffd5c5da..1b8f885dbfebec033f9b04755041787bd73fa552 100644 (file)
@@ -1630,7 +1630,7 @@ static int lio_tpg_check_prot_fabric_only(
  * This function calls iscsit_inc_session_usage_count() on the
  * struct iscsi_session in question.
  */
-static int lio_tpg_shutdown_session(struct se_session *se_sess)
+static void lio_tpg_close_session(struct se_session *se_sess)
 {
        struct iscsi_session *sess = se_sess->fabric_sess_ptr;
        struct se_portal_group *se_tpg = &sess->tpg->tpg_se_tpg;
@@ -1642,7 +1642,7 @@ static int lio_tpg_shutdown_session(struct se_session *se_sess)
            (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
                spin_unlock(&sess->conn_lock);
                spin_unlock_bh(&se_tpg->session_lock);
-               return 0;
+               return;
        }
        atomic_set(&sess->session_reinstatement, 1);
        spin_unlock(&sess->conn_lock);
@@ -1651,20 +1651,6 @@ static int lio_tpg_shutdown_session(struct se_session *se_sess)
        spin_unlock_bh(&se_tpg->session_lock);
 
        iscsit_stop_session(sess, 1, 1);
-       return 1;
-}
-
-/*
- * Calls iscsit_dec_session_usage_count() as inverse of
- * lio_tpg_shutdown_session()
- */
-static void lio_tpg_close_session(struct se_session *se_sess)
-{
-       struct iscsi_session *sess = se_sess->fabric_sess_ptr;
-       /*
-        * If the iSCSI Session for the iSCSI Initiator Node exists,
-        * forcefully shutdown the iSCSI NEXUS.
-        */
        iscsit_close_session(sess);
 }
 
@@ -1716,7 +1702,6 @@ const struct target_core_fabric_ops iscsi_ops = {
        .tpg_get_inst_index             = lio_tpg_get_inst_index,
        .check_stop_free                = lio_check_stop_free,
        .release_cmd                    = lio_release_cmd,
-       .shutdown_session               = lio_tpg_shutdown_session,
        .close_session                  = lio_tpg_close_session,
        .sess_get_index                 = lio_sess_get_index,
        .sess_get_initiator_sid         = lio_sess_get_initiator_sid,
index 210f6e4830e37a4341fd5e611a87168521932b7a..b54e72c7ab0fa5f4ddf501b27b6e46c280f8c368 100644 (file)
@@ -786,7 +786,7 @@ static void iscsit_handle_time2retain_timeout(unsigned long data)
        }
 
        spin_unlock_bh(&se_tpg->session_lock);
-       target_put_session(sess->se_sess);
+       iscsit_close_session(sess);
 }
 
 void iscsit_start_time2retain_handler(struct iscsi_session *sess)
index a09498f16690c88581a00b154e5136b9002fae61..b5212f0f9571b5ce85c5c2413baac8f7d900b58a 100644 (file)
@@ -228,7 +228,7 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)
        if (sess->session_state == TARG_SESS_STATE_FAILED) {
                spin_unlock_bh(&sess->conn_lock);
                iscsit_dec_session_usage_count(sess);
-               target_put_session(sess->se_sess);
+               iscsit_close_session(sess);
                return 0;
        }
        spin_unlock_bh(&sess->conn_lock);
@@ -236,7 +236,7 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)
        iscsit_stop_session(sess, 1, 1);
        iscsit_dec_session_usage_count(sess);
 
-       target_put_session(sess->se_sess);
+       iscsit_close_session(sess);
        return 0;
 }