SCSI fixes on 20210625
Two small fixes, both in upper layer drivers (scsi disk and cdrom). The sd one is fixing a commit changing revalidation that came from the block tree a while ago (5.10) and the sr one adds handling of a condition we didn't previously handle for manually removed media. Signed-off-by: James E.J. Bottomley <jejb@linux.ibm.com> -----BEGIN PGP SIGNATURE----- iJwEABMIAEQWIQTnYEDbdso9F2cI+arnQslM7pishQUCYNZTQSYcamFtZXMuYm90 dG9tbGV5QGhhbnNlbnBhcnRuZXJzaGlwLmNvbQAKCRDnQslM7pishSp6AP9Q8jdJ 29ditYcnr23nsLgtzK0koo7ip3TM6WjEf3SSIAEA45wPiEdC8G35wfQFzefy3UfO LGbq6eNGwPDakldysAs= =NKGv -----END PGP SIGNATURE----- Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi Pull SCSI fixes from James Bottomley: "Two small fixes, both in upper layer drivers (scsi disk and cdrom). The sd one is fixing a commit changing revalidation that came from the block tree a while ago (5.10) and the sr one adds handling of a condition we didn't previously handle for manually removed media" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: sd: Call sd_revalidate_disk() for ioctl(BLKRRPART) scsi: sr: Return appropriate error code when disk is ejected
This commit is contained in:
commit
e2f527b58e
|
@ -1387,6 +1387,22 @@ static void sd_uninit_command(struct scsi_cmnd *SCpnt)
|
|||
}
|
||||
}
|
||||
|
||||
static bool sd_need_revalidate(struct block_device *bdev,
|
||||
struct scsi_disk *sdkp)
|
||||
{
|
||||
if (sdkp->device->removable || sdkp->write_prot) {
|
||||
if (bdev_check_media_change(bdev))
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Force a full rescan after ioctl(BLKRRPART). While the disk state has
|
||||
* nothing to do with partitions, BLKRRPART is used to force a full
|
||||
* revalidate after things like a format for historical reasons.
|
||||
*/
|
||||
return test_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
|
||||
}
|
||||
|
||||
/**
|
||||
* sd_open - open a scsi disk device
|
||||
* @bdev: Block device of the scsi disk to open
|
||||
|
@ -1423,10 +1439,8 @@ static int sd_open(struct block_device *bdev, fmode_t mode)
|
|||
if (!scsi_block_when_processing_errors(sdev))
|
||||
goto error_out;
|
||||
|
||||
if (sdev->removable || sdkp->write_prot) {
|
||||
if (bdev_check_media_change(bdev))
|
||||
sd_revalidate_disk(bdev->bd_disk);
|
||||
}
|
||||
if (sd_need_revalidate(bdev, sdkp))
|
||||
sd_revalidate_disk(bdev->bd_disk);
|
||||
|
||||
/*
|
||||
* If the drive is empty, just let the open fail.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue