Commit f1569ff1 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Christoph Hellwig

scsi: ratelimit I/O error messages

There can be quite a lot of I/O error messages, even on smaller
machines. So we need to ratelimit them to not overwhelm logging.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Tested-by: default avatarRobert Elliott <elliott@hp.com>
Reviewed-by: default avatarRobert Elliott <elliott@hp.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent b6c92b7e
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/hardirq.h> #include <linux/hardirq.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/blk-mq.h> #include <linux/blk-mq.h>
#include <linux/ratelimit.h>
#include <scsi/scsi.h> #include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h> #include <scsi/scsi_cmnd.h>
...@@ -1038,19 +1039,26 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) ...@@ -1038,19 +1039,26 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
switch (action) { switch (action) {
case ACTION_FAIL: case ACTION_FAIL:
/* Give up and fail the remainder of the request */ /* Give up and fail the remainder of the request */
if (!(req->cmd_flags & REQ_QUIET)) {
static DEFINE_RATELIMIT_STATE(_rs,
DEFAULT_RATELIMIT_INTERVAL,
DEFAULT_RATELIMIT_BURST);
if (unlikely(scsi_logging_level)) if (unlikely(scsi_logging_level))
level = SCSI_LOG_LEVEL(SCSI_LOG_MLQUEUE_SHIFT, level = SCSI_LOG_LEVEL(SCSI_LOG_MLCOMPLETE_SHIFT,
SCSI_LOG_MLQUEUE_BITS); SCSI_LOG_MLCOMPLETE_BITS);
/* /*
* if logging is enabled the failure will be printed * if logging is enabled the failure will be printed
* in scsi_log_completion(), so avoid duplicate messages * in scsi_log_completion(), so avoid duplicate messages
*/ */
if (!level && !(req->cmd_flags & REQ_QUIET)) { if (!level && __ratelimit(&_rs)) {
scsi_print_result(cmd, NULL, FAILED); scsi_print_result(cmd, NULL, FAILED);
if (driver_byte(result) & DRIVER_SENSE) if (driver_byte(result) & DRIVER_SENSE)
scsi_print_sense(cmd); scsi_print_sense(cmd);
scsi_print_command(cmd); scsi_print_command(cmd);
} }
}
if (!scsi_end_request(req, error, blk_rq_err_bytes(req), 0)) if (!scsi_end_request(req, error, blk_rq_err_bytes(req), 0))
return; return;
/*FALLTHRU*/ /*FALLTHRU*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment