Skip to contentSkip to conversation

scsi: avoid repetitive logging of device offline messages

PATCH Applied Ewan D. Milne 3 participants 3 messages Mar 11, 2020 – Mar 12, 2020 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scsi: avoid repetitive logging of device offline messages

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.

v2:
Changed flag type from bitfield to bool by request

---
 drivers/scsi/scsi_lib.c    | 8 ++++++--
 include/scsi/scsi_device.h | 3 +++
 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/scsi/scsi_lib.c +6 -2
index 610ee41..a45e728 100644
@@ -1240,8 +1240,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:
 		/*
@@ -2340,6 +2343,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;
 
include/scsi/scsi_device.h +3 -0
index f8312a3..cd9656f 100644
@@ -204,6 +204,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 */
Signature · 1 line
2.1.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Ewan D. Milne

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.

Quoted 6 lines

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.

v2:
Changed flag type from bitfield to bool by request

Thanks!

#2 lore raw
In reply to Ewan D. Milne

Ewan,

Quoted 10 lines

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.

Applied to 5.7/scsi-queue, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering