scsi: sr: Return appropriate error code when disk is ejected
authorManYi Li <limanyi@uniontech.com>
Fri, 11 Jun 2021 09:44:02 +0000 (17:44 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sat, 19 Jun 2021 02:15:47 +0000 (22:15 -0400)
Handle a reported media event code of 3. This indicates that the media has
been removed from the drive and user intervention is required to proceed.
Return DISK_EVENT_EJECT_REQUEST in that case.

Link: https://lore.kernel.org/r/20210611094402.23884-1-limanyi@uniontech.com
Signed-off-by: ManYi Li <limanyi@uniontech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/sr.c

index e4633b84c556a9a431d8a3183ea515a66314e460..7815ed642d434ccbcd6e886628fb448d6ab9014f 100644 (file)
@@ -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;
 }