Skip to content

Commit

Permalink
scsi: sr: Return appropriate error code when disk is ejected
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ManYi Li authored and Martin K. Petersen committed Jun 19, 2021
1 parent 1e0d4e6 commit 7dd753c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/scsi/sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 7dd753c

Please sign in to comment.