scsi: core: avoid repetitive logging of device offline messages
authorEwan D. Milne <emilne@redhat.com>
Wed, 11 Mar 2020 14:39:30 +0000 (10:39 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 12 Mar 2020 03:09:27 +0000 (23:09 -0400)
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>
drivers/scsi/scsi_lib.c
include/scsi/scsi_device.h

index 9f20119..47835c4 100644 (file)
@@ -1215,8 +1215,11 @@ scsi_prep_state_check(struct scsi_device *sdev, struct request *req)
                 * commands.  The device must be brought online
                 * before trying any recovery commands.
                 */
-               sdev_printk(KERN_ERR, sdev,
-                           "rejecting I/O to offline device\n");
+               if (!sdev->offline_already) {
+                       sdev->offline_already = true;
+                       sdev_printk(KERN_ERR, sdev,
+                                   "rejecting I/O to offline device\n");
+               }
                return BLK_STS_IOERR;
        case SDEV_DEL:
                /*
@@ -2326,6 +2329,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
                break;
 
        }
+       sdev->offline_already = false;
        sdev->sdev_state = state;
        return 0;
 
index 579e24c..c3cba2a 100644 (file)
@@ -203,6 +203,9 @@ struct scsi_device {
        unsigned unmap_limit_for_ws:1;  /* Use the UNMAP limit for WRITE SAME */
        unsigned rpm_autosuspend:1;     /* Enable runtime autosuspend at device
                                         * creation time */
+
+       bool offline_already;           /* Device offline message logged */
+
        atomic_t disk_events_disable_depth; /* disable depth for disk events */
 
        DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */