Skip to content

Commit 771f712

Browse files
doug-gilbertmartinkpetersen
authored andcommitted
scsi: scsi_debug: Fix cmd duration calculation
In some cases, sdebug_defer::cmpl_ts (completion timestamp) wasn't being properly set when REQ_HIPRI was given. Fix that and improve code to only call ktime_get_boottime_ns() for commands with REQ_HIPRI set as cmpl_ts is only used in that case. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Douglas Gilbert <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 4309ea7 commit 771f712

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/scsi/scsi_debug.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5367,6 +5367,7 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
53675367
{
53685368
bool new_sd_dp;
53695369
bool inject = false;
5370+
bool hipri = (cmnd->request->cmd_flags & REQ_HIPRI);
53705371
int k, num_in_q, qdepth;
53715372
unsigned long iflags;
53725373
u64 ns_from_boot = 0;
@@ -5453,7 +5454,7 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
54535454
if (sdebug_host_max_queue)
54545455
sd_dp->hc_idx = get_tag(cmnd);
54555456

5456-
if (ndelay > 0 && ndelay < INCLUSIVE_TIMING_MAX_NS)
5457+
if (hipri)
54575458
ns_from_boot = ktime_get_boottime_ns();
54585459

54595460
/* one of the resp_*() response functions is called here */
@@ -5513,8 +5514,8 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
55135514
kt -= d;
55145515
}
55155516
}
5516-
sd_dp->cmpl_ts = ktime_add(ns_to_ktime(ns_from_boot), kt);
5517-
if (cmnd->request->cmd_flags & REQ_HIPRI) {
5517+
if (hipri) {
5518+
sd_dp->cmpl_ts = ktime_add(ns_to_ktime(ns_from_boot), kt);
55185519
spin_lock_irqsave(&sqp->qc_lock, iflags);
55195520
if (!sd_dp->init_poll) {
55205521
sd_dp->init_poll = true;
@@ -5544,8 +5545,8 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
55445545
if (unlikely((sdebug_opts & SDEBUG_OPT_CMD_ABORT) &&
55455546
atomic_read(&sdeb_inject_pending)))
55465547
sd_dp->aborted = true;
5547-
sd_dp->cmpl_ts = ns_to_ktime(ns_from_boot);
5548-
if (cmnd->request->cmd_flags & REQ_HIPRI) {
5548+
if (hipri) {
5549+
sd_dp->cmpl_ts = ns_to_ktime(ns_from_boot);
55495550
spin_lock_irqsave(&sqp->qc_lock, iflags);
55505551
if (!sd_dp->init_poll) {
55515552
sd_dp->init_poll = true;

0 commit comments

Comments
 (0)