mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
scsi: target: iscsit: isert: Alloc per conn cmd counter
This has iscsit allocate a per conn cmd counter and converts iscsit/isert to use it instead of the per session one. Signed-off-by: Mike Christie <michael.christie@oracle.com> Link: https://lore.kernel.org/r/20230319015620.96006-5-michael.christie@oracle.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
8e288be860
commit
6d256bee60
@ -2506,8 +2506,8 @@ isert_wait4cmds(struct iscsit_conn *conn)
|
||||
isert_info("iscsit_conn %p\n", conn);
|
||||
|
||||
if (conn->sess) {
|
||||
target_stop_session(conn->sess->se_sess);
|
||||
target_wait_for_sess_cmds(conn->sess->se_sess);
|
||||
target_stop_cmd_counter(conn->cmd_cnt);
|
||||
target_wait_for_cmds(conn->cmd_cnt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1193,7 +1193,7 @@ int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
|
||||
conn->sess->se_sess, be32_to_cpu(hdr->data_length),
|
||||
cmd->data_direction, sam_task_attr,
|
||||
cmd->sense_buffer + 2, scsilun_to_int(&hdr->lun),
|
||||
conn->sess->se_sess->cmd_cnt);
|
||||
conn->cmd_cnt);
|
||||
|
||||
pr_debug("Got SCSI Command, ITT: 0x%08x, CmdSN: 0x%08x,"
|
||||
" ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt,
|
||||
@ -2057,7 +2057,7 @@ iscsit_handle_task_mgt_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
|
||||
conn->sess->se_sess, 0, DMA_NONE,
|
||||
TCM_SIMPLE_TAG, cmd->sense_buffer + 2,
|
||||
scsilun_to_int(&hdr->lun),
|
||||
conn->sess->se_sess->cmd_cnt);
|
||||
conn->cmd_cnt);
|
||||
|
||||
target_get_sess_cmd(&cmd->se_cmd, true);
|
||||
|
||||
|
@ -324,18 +324,8 @@ static int iscsi_login_zero_tsih_s1(
|
||||
goto free_ops;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is temp for iser. It will be moved to per conn in later
|
||||
* patches for iscsi.
|
||||
*/
|
||||
sess->se_sess->cmd_cnt = target_alloc_cmd_counter();
|
||||
if (!sess->se_sess->cmd_cnt)
|
||||
goto free_se_sess;
|
||||
|
||||
return 0;
|
||||
|
||||
free_se_sess:
|
||||
transport_free_session(sess->se_sess);
|
||||
free_ops:
|
||||
kfree(sess->sess_ops);
|
||||
free_id:
|
||||
@ -1157,8 +1147,14 @@ static struct iscsit_conn *iscsit_alloc_conn(struct iscsi_np *np)
|
||||
goto free_conn_cpumask;
|
||||
}
|
||||
|
||||
conn->cmd_cnt = target_alloc_cmd_counter();
|
||||
if (!conn->cmd_cnt)
|
||||
goto free_conn_allowed_cpumask;
|
||||
|
||||
return conn;
|
||||
|
||||
free_conn_allowed_cpumask:
|
||||
free_cpumask_var(conn->allowed_cpumask);
|
||||
free_conn_cpumask:
|
||||
free_cpumask_var(conn->conn_cpumask);
|
||||
free_conn_ops:
|
||||
@ -1172,6 +1168,7 @@ free_conn:
|
||||
|
||||
void iscsit_free_conn(struct iscsit_conn *conn)
|
||||
{
|
||||
target_free_cmd_counter(conn->cmd_cnt);
|
||||
free_cpumask_var(conn->allowed_cpumask);
|
||||
free_cpumask_var(conn->conn_cpumask);
|
||||
kfree(conn->conn_ops);
|
||||
|
@ -254,7 +254,7 @@ free_cmd_cnt:
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(target_alloc_cmd_counter);
|
||||
|
||||
static void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt)
|
||||
void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt)
|
||||
{
|
||||
/*
|
||||
* Drivers like loop do not call target_stop_session during session
|
||||
@ -265,6 +265,7 @@ static void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt)
|
||||
|
||||
percpu_ref_exit(&cmd_cnt->refcnt);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(target_free_cmd_counter);
|
||||
|
||||
/**
|
||||
* transport_init_session - initialize a session object
|
||||
@ -3170,13 +3171,14 @@ static void target_stop_cmd_counter_confirm(struct percpu_ref *ref)
|
||||
* target_stop_cmd_counter - Stop new IO from being added to the counter.
|
||||
* @cmd_cnt: counter to stop
|
||||
*/
|
||||
static void target_stop_cmd_counter(struct target_cmd_counter *cmd_cnt)
|
||||
void target_stop_cmd_counter(struct target_cmd_counter *cmd_cnt)
|
||||
{
|
||||
pr_debug("Stopping command counter.\n");
|
||||
if (!atomic_cmpxchg(&cmd_cnt->stopped, 0, 1))
|
||||
percpu_ref_kill_and_confirm(&cmd_cnt->refcnt,
|
||||
target_stop_cmd_counter_confirm);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(target_stop_cmd_counter);
|
||||
|
||||
/**
|
||||
* target_stop_session - Stop new IO from being queued on the session.
|
||||
@ -3192,7 +3194,7 @@ EXPORT_SYMBOL(target_stop_session);
|
||||
* target_wait_for_cmds - Wait for outstanding cmds.
|
||||
* @cmd_cnt: counter to wait for active I/O for.
|
||||
*/
|
||||
static void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt)
|
||||
void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -3208,6 +3210,7 @@ static void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt)
|
||||
wait_for_completion(&cmd_cnt->stop_done);
|
||||
pr_debug("Waiting for cmds done.\n");
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(target_wait_for_cmds);
|
||||
|
||||
/**
|
||||
* target_wait_for_sess_cmds - Wait for outstanding commands
|
||||
|
@ -133,7 +133,10 @@ struct se_session *target_setup_session(struct se_portal_group *,
|
||||
struct se_session *, void *));
|
||||
void target_remove_session(struct se_session *);
|
||||
|
||||
void target_stop_cmd_counter(struct target_cmd_counter *cmd_cnt);
|
||||
void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt);
|
||||
struct target_cmd_counter *target_alloc_cmd_counter(void);
|
||||
void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt);
|
||||
|
||||
void transport_init_session(struct se_session *se_sess);
|
||||
struct se_session *transport_alloc_session(enum target_prot_op);
|
||||
|
Loading…
Reference in New Issue
Block a user