mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-16 05:26:07 +00:00
scsi: core: Delete unnecessary buffer allocation for every loop iteration
No need to allocate buffer every loop iteration. Allocate buffer once and reuse it. Link: https://lore.kernel.org/r/20200717090921.29243-2-yebin10@huawei.com Signed-off-by: Ye Bin <yebin10@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
f30785db75
commit
811f39479c
@ -205,13 +205,9 @@ void scsi_print_command(struct scsi_cmnd *cmd)
|
|||||||
/* Print opcode in one line and use separate lines for CDB */
|
/* Print opcode in one line and use separate lines for CDB */
|
||||||
off += scnprintf(logbuf + off, logbuf_len - off, "\n");
|
off += scnprintf(logbuf + off, logbuf_len - off, "\n");
|
||||||
dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s", logbuf);
|
dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s", logbuf);
|
||||||
scsi_log_release_buffer(logbuf);
|
|
||||||
for (k = 0; k < cmd->cmd_len; k += 16) {
|
for (k = 0; k < cmd->cmd_len; k += 16) {
|
||||||
size_t linelen = min(cmd->cmd_len - k, 16);
|
size_t linelen = min(cmd->cmd_len - k, 16);
|
||||||
|
|
||||||
logbuf = scsi_log_reserve_buffer(&logbuf_len);
|
|
||||||
if (!logbuf)
|
|
||||||
break;
|
|
||||||
off = sdev_format_header(logbuf, logbuf_len,
|
off = sdev_format_header(logbuf, logbuf_len,
|
||||||
scmd_name(cmd),
|
scmd_name(cmd),
|
||||||
cmd->request->tag);
|
cmd->request->tag);
|
||||||
@ -224,9 +220,8 @@ void scsi_print_command(struct scsi_cmnd *cmd)
|
|||||||
}
|
}
|
||||||
dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s",
|
dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s",
|
||||||
logbuf);
|
logbuf);
|
||||||
scsi_log_release_buffer(logbuf);
|
|
||||||
}
|
}
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!WARN_ON(off > logbuf_len - 49)) {
|
if (!WARN_ON(off > logbuf_len - 49)) {
|
||||||
off += scnprintf(logbuf + off, logbuf_len - off, " ");
|
off += scnprintf(logbuf + off, logbuf_len - off, " ");
|
||||||
@ -236,6 +231,7 @@ void scsi_print_command(struct scsi_cmnd *cmd)
|
|||||||
}
|
}
|
||||||
out_printk:
|
out_printk:
|
||||||
dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s", logbuf);
|
dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s", logbuf);
|
||||||
|
out:
|
||||||
scsi_log_release_buffer(logbuf);
|
scsi_log_release_buffer(logbuf);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(scsi_print_command);
|
EXPORT_SYMBOL(scsi_print_command);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user