Skip to content

Commit

Permalink
scsi: target: remove boilerplate code
Browse files Browse the repository at this point in the history
[ Upstream commit e49a7d9 ]

iscsit_free_session() is equivalent to iscsit_stop_session() followed by a
call to iscsit_close_session().

Link: https://lore.kernel.org/r/[email protected]
Tested-by: Rahul Kundu <[email protected]>
Signed-off-by: Maurizio Lombardi <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
maurizio-lombardi authored and gregkh committed Jun 17, 2020
1 parent afeaa5f commit 1609ab7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 45 deletions.
46 changes: 2 additions & 44 deletions drivers/target/iscsi/iscsi_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -4566,49 +4566,6 @@ void iscsit_fail_session(struct iscsi_session *sess)
sess->session_state = TARG_SESS_STATE_FAILED;
}

int iscsit_free_session(struct iscsi_session *sess)
{
u16 conn_count = atomic_read(&sess->nconn);
struct iscsi_conn *conn, *conn_tmp = NULL;
int is_last;

spin_lock_bh(&sess->conn_lock);
atomic_set(&sess->sleep_on_sess_wait_comp, 1);

list_for_each_entry_safe(conn, conn_tmp, &sess->sess_conn_list,
conn_list) {
if (conn_count == 0)
break;

if (list_is_last(&conn->conn_list, &sess->sess_conn_list)) {
is_last = 1;
} else {
iscsit_inc_conn_usage_count(conn_tmp);
is_last = 0;
}
iscsit_inc_conn_usage_count(conn);

spin_unlock_bh(&sess->conn_lock);
iscsit_cause_connection_reinstatement(conn, 1);
spin_lock_bh(&sess->conn_lock);

iscsit_dec_conn_usage_count(conn);
if (is_last == 0)
iscsit_dec_conn_usage_count(conn_tmp);

conn_count--;
}

if (atomic_read(&sess->nconn)) {
spin_unlock_bh(&sess->conn_lock);
wait_for_completion(&sess->session_wait_comp);
} else
spin_unlock_bh(&sess->conn_lock);

iscsit_close_session(sess);
return 0;
}

void iscsit_stop_session(
struct iscsi_session *sess,
int session_sleep,
Expand Down Expand Up @@ -4693,7 +4650,8 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force)
list_for_each_entry_safe(se_sess, se_sess_tmp, &free_list, sess_list) {
sess = (struct iscsi_session *)se_sess->fabric_sess_ptr;

iscsit_free_session(sess);
iscsit_stop_session(sess, 1, 1);
iscsit_close_session(sess);
session_count++;
}

Expand Down
1 change: 0 additions & 1 deletion drivers/target/iscsi/iscsi_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ extern int iscsi_target_rx_thread(void *);
extern int iscsit_close_connection(struct iscsi_conn *);
extern int iscsit_close_session(struct iscsi_session *);
extern void iscsit_fail_session(struct iscsi_session *);
extern int iscsit_free_session(struct iscsi_session *);
extern void iscsit_stop_session(struct iscsi_session *, int, int);
extern int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *, int);

Expand Down

0 comments on commit 1609ab7

Please sign in to comment.