From: "Ewan D. Milne" <emilne@redhat.com>
Date: Wed, 11 Mar 2020 10:39:30 -0400
Subject: scsi: core: avoid repetitive logging of device offline messages
Patch-mainline: v5.7-rc1
Git-commit: b0962c53bde9a485c8ebc401fa1dbe821a76bc3e
References: bsc#1145929
Large queues of I/O to offline devices that are eventually submitted when
devices are unblocked result in a many repeated "rejecting I/O to offline
device" messages. These messages can fill up the dmesg buffer in crash
dumps so no useful prior messages remain. In addition, if a serial console
is used, the flood of messages can cause a hard lockup in the console code.
Introduce a flag indicating the message has already been logged for the
device, and reset the flag when scsi_device_set_state() changes the device
state.
Link: https://lore.kernel.org/r/20200311143930.20674-1-emilne@redhat.com
Reviewed-by: Bart van Assche <bvanassche@acm.org>
Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Daniel Wagner <dwagner@suse.de>
---
drivers/scsi/scsi_lib.c | 9 ++++++---
include/scsi/scsi_device.h | 3 +++
2 files changed, 9 insertions(+), 3 deletions(-)
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1266,9 +1266,11 @@ scsi_prep_state_check(struct scsi_device
* commands. The device must be brought online
* before trying any recovery commands.
*/
- sdev_printk(KERN_ERR, sdev,
- "rejecting I/O to offline device\n");
- ret = BLKPREP_KILL;
+ if (!sdev->offline_already) {
+ sdev->offline_already = true;
+ sdev_printk(KERN_ERR, sdev,
+ "rejecting I/O to offline device\n");
+ }
break;
case SDEV_DEL:
/*
@@ -2680,6 +2682,7 @@ scsi_device_set_state(struct scsi_device
break;
}
+ sdev->offline_already = false;
sdev->sdev_state = state;
return 0;
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -203,6 +203,9 @@ struct scsi_device {
struct work_struct event_work;
unsigned int max_device_blocked; /* what device_blocked counts down from */
+
+ bool offline_already; /* Device offline message logged */
+
#define SCSI_DEFAULT_DEVICE_BLOCKED 3
atomic_t iorequest_cnt;