mirror of https://gitee.com/openkylin/linux.git
scsi: target: iscsi: Redo iscsit_check_session_usage_count() return code
The return value of iscsit_check_session_usage_count() is only checked if it was not allowed to sleep. If it returns `2' then a timer is prepared. If it returns something else or if it was allowed to sleep then it is ignored. Let iscsit_check_session_usage_count() return true if it needs to arm the timer - otherwise false. This simplifies the code flow of the only caller. Link: https://lore.kernel.org/r/20201220203638.43615-4-bigeasy@linutronix.de Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
efc9d73063
commit
f88a10f80d
|
@ -4399,14 +4399,10 @@ int iscsit_close_session(struct iscsi_session *sess, bool can_sleep)
|
|||
* time2retain handler) and contain and active session usage count we
|
||||
* restart the timer and exit.
|
||||
*/
|
||||
if (can_sleep) {
|
||||
iscsit_check_session_usage_count(sess, can_sleep);
|
||||
} else {
|
||||
if (iscsit_check_session_usage_count(sess, can_sleep) == 2) {
|
||||
atomic_set(&sess->session_logout, 0);
|
||||
iscsit_start_time2retain_handler(sess);
|
||||
return 0;
|
||||
}
|
||||
if (iscsit_check_session_usage_count(sess, can_sleep)) {
|
||||
atomic_set(&sess->session_logout, 0);
|
||||
iscsit_start_time2retain_handler(sess);
|
||||
return 0;
|
||||
}
|
||||
|
||||
transport_deregister_session(sess->se_sess);
|
||||
|
|
|
@ -779,21 +779,22 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown)
|
|||
}
|
||||
EXPORT_SYMBOL(iscsit_free_cmd);
|
||||
|
||||
int iscsit_check_session_usage_count(struct iscsi_session *sess, bool can_sleep)
|
||||
bool iscsit_check_session_usage_count(struct iscsi_session *sess,
|
||||
bool can_sleep)
|
||||
{
|
||||
spin_lock_bh(&sess->session_usage_lock);
|
||||
if (sess->session_usage_count != 0) {
|
||||
sess->session_waiting_on_uc = 1;
|
||||
spin_unlock_bh(&sess->session_usage_lock);
|
||||
if (!can_sleep)
|
||||
return 2;
|
||||
return true;
|
||||
|
||||
wait_for_completion(&sess->session_waiting_on_uc_comp);
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
spin_unlock_bh(&sess->session_usage_lock);
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void iscsit_dec_session_usage_count(struct iscsi_session *sess)
|
||||
|
|
|
@ -40,7 +40,7 @@ extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *);
|
|||
extern void iscsit_release_cmd(struct iscsi_cmd *);
|
||||
extern void __iscsit_free_cmd(struct iscsi_cmd *, bool);
|
||||
extern void iscsit_free_cmd(struct iscsi_cmd *, bool);
|
||||
extern int iscsit_check_session_usage_count(struct iscsi_session *sess, bool can_sleep);
|
||||
extern bool iscsit_check_session_usage_count(struct iscsi_session *sess, bool can_sleep);
|
||||
extern void iscsit_dec_session_usage_count(struct iscsi_session *);
|
||||
extern void iscsit_inc_session_usage_count(struct iscsi_session *);
|
||||
extern struct iscsi_conn *iscsit_get_conn_from_cid(struct iscsi_session *, u16);
|
||||
|
|
Loading…
Reference in New Issue