Re: [PATCH v2 8/8] scsi: sr: wait for the medium to become ready

From: Christoph Hellwig
Date: Wed Oct 23 2019 - 22:24:08 EST


On Wed, Oct 23, 2019 at 02:52:47PM +0200, Michal Suchanek wrote:
> +static int sr_block_open_finish(struct block_device *bdev, fmode_t mode,
> + int ret)
> +{
> + struct scsi_cd *cd = scsi_cd(bdev->bd_disk);
> +
> + /* wait for drive to get ready */
> + if ((ret == -ENOMEDIUM) && !(mode & FMODE_NDELAY)) {
> + struct scsi_device *sdev = cd->device;
> + /*
> + * Cannot use sr_block_ioctl because it locks sr_mutex blocking
> + * out any processes trying to access the drive
> + */
> + scsi_autopm_get_device(sdev);
> + cdrom_ioctl(&cd->cdi, bdev, mode, CDROM_AUTOCLOSE, 0);
> + ret = __sr_block_open(bdev, mode);
> + scsi_autopm_put_device(sdev);

Ioctls should never be used from kernel space. We have a few leftovers,
but we need to get rid of that and not add more.