Commit e6755376 authored by Ewan D. Milne's avatar Ewan D. Milne Committed by Yang Yingliang
Browse files

scsi: core: avoid repetitive logging of device offline messages

mainline inclusion
from mainline-v5.7-rc1
commit b0962c53
category: bugfix
bugzilla: 34604
CVE: NA

-----------------------------------------------

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: default avatarBart van Assche <bvanassche@acm.org>
Signed-off-by: default avatarEwan D. Milne <emilne@redhat.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>

conflicts:
drivers/scsi/scsi_lib.c
include/scsi/scsi_device.h

Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
Reviewed-by: default avatarHou Tao <houtao1@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent cb392b12
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -1437,8 +1437,11 @@ scsi_prep_state_check(struct scsi_device *sdev, struct request *req)
			 * commands.  The device must be brought online
			 * before trying any recovery commands.
			 */
			if (!sdev->offline_already) {
				sdev->offline_already = true;
				sdev_printk(KERN_ERR, sdev,
					    "rejecting I/O to offline device\n");
			}
			ret = BLKPREP_KILL;
			break;
		case SDEV_DEL:
@@ -2856,6 +2859,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;

+2 −0
Original line number Diff line number Diff line
@@ -201,6 +201,8 @@ struct scsi_device {
	unsigned lun_in_cdb:1;		/* Store LUN bits in CDB[1] */
	unsigned unmap_limit_for_ws:1;	/* Use the UNMAP limit for WRITE SAME */

	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 */