mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-23 05:31:28 +00:00
Logging improvements
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6216 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -721,13 +721,14 @@ static const char *const scst_cmd_state_name[] = {
|
||||
[SCST_CMD_STATE_XMIT_WAIT] = "XMIT_WAIT",
|
||||
};
|
||||
|
||||
static void scst_get_cmd_state_name(char *name, int len, unsigned state)
|
||||
char *scst_get_cmd_state_name(char *name, int len, unsigned state)
|
||||
{
|
||||
if (state < ARRAY_SIZE(scst_cmd_state_name) &&
|
||||
scst_cmd_state_name[state])
|
||||
strlcpy(name, scst_cmd_state_name[state], len);
|
||||
else
|
||||
snprintf(name, len, "%d", state);
|
||||
return name;
|
||||
}
|
||||
|
||||
static char *scst_dump_cdb(char *buf, int buf_len, struct scst_cmd *cmd)
|
||||
@@ -796,13 +797,13 @@ static const char *const scst_tm_fn_name[] = {
|
||||
[SCST_PR_ABORT_ALL] = "PR_ABORT_ALL",
|
||||
};
|
||||
|
||||
static void scst_get_tm_fn_name(char *name, int len, unsigned fn)
|
||||
char *scst_get_tm_fn_name(char *name, int len, unsigned fn)
|
||||
{
|
||||
if (fn < ARRAY_SIZE(scst_tm_fn_name) && scst_tm_fn_name[fn])
|
||||
strlcpy(name, scst_tm_fn_name[fn], len);
|
||||
else
|
||||
snprintf(name, len, "%d", fn);
|
||||
return;
|
||||
return name;
|
||||
}
|
||||
|
||||
static const char *const scst_mcmd_state_name[] = {
|
||||
@@ -815,14 +816,14 @@ static const char *const scst_mcmd_state_name[] = {
|
||||
[SCST_MCMD_STATE_FINISHED] = "FINISHED",
|
||||
};
|
||||
|
||||
static void scst_get_mcmd_state_name(char *name, int len, unsigned state)
|
||||
char *scst_get_mcmd_state_name(char *name, int len, unsigned state)
|
||||
{
|
||||
if (state < ARRAY_SIZE(scst_mcmd_state_name) &&
|
||||
scst_mcmd_state_name[state])
|
||||
strlcpy(name, scst_mcmd_state_name[state], len);
|
||||
else
|
||||
snprintf(name, len, "%d", state);
|
||||
return;
|
||||
return name;
|
||||
}
|
||||
|
||||
void scst_trace_mcmds(scst_show_fn show, void *arg)
|
||||
|
||||
@@ -274,6 +274,10 @@ extern void scst_tgt_dev_stop_threads(struct scst_tgt_dev *tgt_dev);
|
||||
|
||||
extern struct scst_dev_type scst_null_devtype;
|
||||
|
||||
char *scst_get_cmd_state_name(char *name, int len, unsigned state);
|
||||
char *scst_get_mcmd_state_name(char *name, int len, unsigned state);
|
||||
char *scst_get_tm_fn_name(char *name, int len, unsigned fn);
|
||||
|
||||
extern struct scst_cmd *__scst_check_deferred_commands_locked(
|
||||
struct scst_order_data *order_data, bool return_first);
|
||||
extern struct scst_cmd *__scst_check_deferred_commands(
|
||||
|
||||
@@ -5482,18 +5482,21 @@ void scst_abort_cmd(struct scst_cmd *cmd, struct scst_mgmt_cmd *mcmd,
|
||||
|
||||
if (mstb->done_counted || mstb->finish_counted) {
|
||||
unsigned long t;
|
||||
char state_name[32];
|
||||
if (mcmd->fn != SCST_PR_ABORT_ALL)
|
||||
t = TRACE_MGMT;
|
||||
else
|
||||
t = TRACE_MGMT_DEBUG;
|
||||
TRACE(t, "cmd %p (tag %llu, "
|
||||
"sn %u) being executed/xmitted (state %d, "
|
||||
"sn %u) being executed/xmitted (state %s, "
|
||||
"op %s, proc time %ld sec., timeout %d sec.), "
|
||||
"deferring ABORT (cmd_done_wait_count %d, "
|
||||
"cmd_finish_wait_count %d, internal %d, mcmd "
|
||||
"fn %d (mcmd %p), initiator %s, target %s)",
|
||||
cmd, (unsigned long long int)cmd->tag,
|
||||
cmd->sn, cmd->state, scst_get_opcode_name(cmd),
|
||||
cmd->sn, scst_get_cmd_state_name(state_name,
|
||||
sizeof(state_name), cmd->state),
|
||||
scst_get_opcode_name(cmd),
|
||||
(long)(jiffies - cmd->start_time) / HZ,
|
||||
cmd->timeout / HZ, mcmd->cmd_done_wait_count,
|
||||
mcmd->cmd_finish_wait_count, cmd->internal,
|
||||
@@ -5565,9 +5568,13 @@ static int scst_set_mcmd_next_state(struct scst_mgmt_cmd *mcmd)
|
||||
break;
|
||||
|
||||
default:
|
||||
PRINT_CRIT_ERROR("Wrong mcmd %p state %d (fn %d, "
|
||||
{
|
||||
char fn_name[16], state_name[32];
|
||||
PRINT_CRIT_ERROR("Wrong mcmd %p state %s (fn %s, "
|
||||
"cmd_finish_wait_count %d, cmd_done_wait_count %d)",
|
||||
mcmd, mcmd->state, mcmd->fn,
|
||||
mcmd, scst_get_mcmd_state_name(state_name,
|
||||
sizeof(state_name), mcmd->state),
|
||||
scst_get_tm_fn_name(fn_name, sizeof(fn_name), mcmd->fn),
|
||||
mcmd->cmd_finish_wait_count, mcmd->cmd_done_wait_count);
|
||||
#if !defined(__CHECKER__)
|
||||
spin_unlock_irq(&scst_mcmd_lock);
|
||||
@@ -5575,6 +5582,7 @@ static int scst_set_mcmd_next_state(struct scst_mgmt_cmd *mcmd)
|
||||
res = -1;
|
||||
sBUG();
|
||||
}
|
||||
}
|
||||
|
||||
spin_unlock_irq(&scst_mcmd_lock);
|
||||
|
||||
@@ -6604,13 +6612,18 @@ static int scst_process_mgmt_cmd(struct scst_mgmt_cmd *mcmd)
|
||||
goto out;
|
||||
|
||||
default:
|
||||
PRINT_CRIT_ERROR("Wrong mcmd %p state %d (fn %d, "
|
||||
{
|
||||
char fn_name[16], state_name[32];
|
||||
PRINT_CRIT_ERROR("Wrong mcmd %p state %s (fn %s, "
|
||||
"cmd_finish_wait_count %d, cmd_done_wait_count "
|
||||
"%d)", mcmd, mcmd->state, mcmd->fn,
|
||||
"%d)", mcmd, scst_get_mcmd_state_name(state_name,
|
||||
sizeof(state_name), mcmd->state),
|
||||
scst_get_tm_fn_name(fn_name, sizeof(fn_name), mcmd->fn),
|
||||
mcmd->cmd_finish_wait_count,
|
||||
mcmd->cmd_done_wait_count);
|
||||
sBUG();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
@@ -6797,6 +6810,7 @@ int scst_rx_mgmt_fn(struct scst_session *sess,
|
||||
{
|
||||
int res = -EFAULT;
|
||||
struct scst_mgmt_cmd *mcmd = NULL;
|
||||
char state_name[32];
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
@@ -6832,11 +6846,13 @@ int scst_rx_mgmt_fn(struct scst_session *sess,
|
||||
mcmd->cmd_sn = params->cmd_sn;
|
||||
|
||||
if (params->fn < SCST_UNREG_SESS_TM)
|
||||
TRACE(TRACE_MGMT, "TM fn %d (mcmd %p, initiator %s, target %s)",
|
||||
params->fn, mcmd, sess->initiator_name,
|
||||
sess->tgt->tgt_name);
|
||||
TRACE(TRACE_MGMT, "TM fn %s/%d (mcmd %p, initiator %s, target %s)",
|
||||
scst_get_tm_fn_name(state_name, sizeof(state_name), params->fn),
|
||||
params->fn, mcmd, sess->initiator_name, sess->tgt->tgt_name);
|
||||
else
|
||||
TRACE_MGMT_DBG("TM fn %d (mcmd %p)", params->fn, mcmd);
|
||||
TRACE_MGMT_DBG("TM fn %s/%d (mcmd %p)",
|
||||
scst_get_tm_fn_name(state_name, sizeof(state_name), params->fn),
|
||||
params->fn, mcmd);
|
||||
|
||||
TRACE_MGMT_DBG("sess=%p, tag_set %d, tag %lld, lun_set %d, "
|
||||
"lun=%lld, cmd_sn_set %d, cmd_sn %d, priv %p", sess,
|
||||
|
||||
Reference in New Issue
Block a user