mirror of
https://github.com/torvalds/linux.git
synced 2026-04-27 11:02:31 -04:00
target/iscsi: Simplify timer manipulation code
Move timer initialization from before add_timer() to the context where the containing object is initialized. Use setup_timer() and mod_timer() instead of open coding these. Use 'jiffies' instead of get_jiffies_64() when calculating expiry times because expiry times have type unsigned long, just like 'jiffies'. Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Andy Grover <agrover@redhat.com> Cc: David Disseldorp <ddiss@suse.de> Signed-off-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
committed by
Kees Cook
parent
d744644ad7
commit
8a47aa9dc6
@@ -176,6 +176,8 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state)
|
||||
spin_lock_init(&cmd->istate_lock);
|
||||
spin_lock_init(&cmd->error_lock);
|
||||
spin_lock_init(&cmd->r2t_lock);
|
||||
setup_timer(&cmd->dataout_timer, iscsit_handle_dataout_timeout,
|
||||
(unsigned long)cmd);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
@@ -880,7 +882,7 @@ static int iscsit_add_nopin(struct iscsi_conn *conn, int want_response)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void iscsit_handle_nopin_response_timeout(unsigned long data)
|
||||
void iscsit_handle_nopin_response_timeout(unsigned long data)
|
||||
{
|
||||
struct iscsi_conn *conn = (struct iscsi_conn *) data;
|
||||
|
||||
@@ -949,14 +951,10 @@ void iscsit_start_nopin_response_timer(struct iscsi_conn *conn)
|
||||
return;
|
||||
}
|
||||
|
||||
init_timer(&conn->nopin_response_timer);
|
||||
conn->nopin_response_timer.expires =
|
||||
(get_jiffies_64() + na->nopin_response_timeout * HZ);
|
||||
conn->nopin_response_timer.data = (unsigned long)conn;
|
||||
conn->nopin_response_timer.function = iscsit_handle_nopin_response_timeout;
|
||||
conn->nopin_response_timer_flags &= ~ISCSI_TF_STOP;
|
||||
conn->nopin_response_timer_flags |= ISCSI_TF_RUNNING;
|
||||
add_timer(&conn->nopin_response_timer);
|
||||
mod_timer(&conn->nopin_response_timer,
|
||||
jiffies + na->nopin_response_timeout * HZ);
|
||||
|
||||
pr_debug("Started NOPIN Response Timer on CID: %d to %u"
|
||||
" seconds\n", conn->cid, na->nopin_response_timeout);
|
||||
@@ -980,7 +978,7 @@ void iscsit_stop_nopin_response_timer(struct iscsi_conn *conn)
|
||||
spin_unlock_bh(&conn->nopin_timer_lock);
|
||||
}
|
||||
|
||||
static void iscsit_handle_nopin_timeout(unsigned long data)
|
||||
void iscsit_handle_nopin_timeout(unsigned long data)
|
||||
{
|
||||
struct iscsi_conn *conn = (struct iscsi_conn *) data;
|
||||
|
||||
@@ -1015,13 +1013,9 @@ void __iscsit_start_nopin_timer(struct iscsi_conn *conn)
|
||||
if (conn->nopin_timer_flags & ISCSI_TF_RUNNING)
|
||||
return;
|
||||
|
||||
init_timer(&conn->nopin_timer);
|
||||
conn->nopin_timer.expires = (get_jiffies_64() + na->nopin_timeout * HZ);
|
||||
conn->nopin_timer.data = (unsigned long)conn;
|
||||
conn->nopin_timer.function = iscsit_handle_nopin_timeout;
|
||||
conn->nopin_timer_flags &= ~ISCSI_TF_STOP;
|
||||
conn->nopin_timer_flags |= ISCSI_TF_RUNNING;
|
||||
add_timer(&conn->nopin_timer);
|
||||
mod_timer(&conn->nopin_timer, jiffies + na->nopin_timeout * HZ);
|
||||
|
||||
pr_debug("Started NOPIN Timer on CID: %d at %u second"
|
||||
" interval\n", conn->cid, na->nopin_timeout);
|
||||
@@ -1043,13 +1037,9 @@ void iscsit_start_nopin_timer(struct iscsi_conn *conn)
|
||||
return;
|
||||
}
|
||||
|
||||
init_timer(&conn->nopin_timer);
|
||||
conn->nopin_timer.expires = (get_jiffies_64() + na->nopin_timeout * HZ);
|
||||
conn->nopin_timer.data = (unsigned long)conn;
|
||||
conn->nopin_timer.function = iscsit_handle_nopin_timeout;
|
||||
conn->nopin_timer_flags &= ~ISCSI_TF_STOP;
|
||||
conn->nopin_timer_flags |= ISCSI_TF_RUNNING;
|
||||
add_timer(&conn->nopin_timer);
|
||||
mod_timer(&conn->nopin_timer, jiffies + na->nopin_timeout * HZ);
|
||||
|
||||
pr_debug("Started NOPIN Timer on CID: %d at %u second"
|
||||
" interval\n", conn->cid, na->nopin_timeout);
|
||||
|
||||
Reference in New Issue
Block a user