Skip to contentSkip to conversation

sr: Fix get the error media event code

PATCH Applied ManYi Li 2 participants 2 messages Jun 11, 2021 – Jun 19, 2021 SCSI

lore
Share & tools
lore

ManYi Li

author
#0 lore raw

PATCH 1/1 sr: Fix get the error media event code

Eject the specified slot or media through a mechanical switch on the Drive, med->media_event_code is 3 not 1 in the sr_get_events().

If disk_flush_events() and sr_block_open() are called, clearing is 1 or 3 in the sr_check_events(),then it report DISK_EVENT_MEDIA_CHANGE not DISK_EVENT_EJECT_REQUEST.

If disk_flush_events() and sr_block_open() aren't called, clearing is 0 in the sr_check_events(),then it doesn't report any event.

---
 drivers/scsi/sr.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/sr.c +2 -0
index 482a07b662a9..94c254e9012e 100644
@@ -220,6 +220,8 @@ static unsigned int sr_get_events(struct scsi_device *sdev)
 		return DISK_EVENT_EJECT_REQUEST;
 	else if (med->media_event_code == 2)
 		return DISK_EVENT_MEDIA_CHANGE;
+	else if (med->media_event_code == 3)
+		return DISK_EVENT_EJECT_REQUEST;
 	return 0;
 }
 
Signature · 1 line
2.20.1
#1 lore raw
Quoted 8 lines · ManYi Li

Eject the specified slot or media through a mechanical switch on the Drive, med->media_event_code is 3 not 1 in the sr_get_events().

If disk_flush_events() and sr_block_open() are called, clearing is 1 or 3 in the sr_check_events(),then it report DISK_EVENT_MEDIA_CHANGE not DISK_EVENT_EJECT_REQUEST.

[...]

Applied to 5.13/scsi-fixes, thanks!

[1/1] sr: Fix get the error media event code

      https://git.kernel.org/mkp/scsi/c/7dd753ca59d6
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering