]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 11 Jul 2021 10:45:27 +0000 (12:45 +0200)
[ Upstream commit 7dd753ca59d6c8cc09aa1ed24f7657524803c7f3 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/sr.c

index 7dd4d9ded249103f08c01f7b15078d5deae96e6d..6e31cedf0b6c7c12bddd7ad5b437437a24c23df7 100644 (file)
@@ -216,6 +216,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;
 }