On Fri, 2018-03-09 at 13:59 +0100, Maurizio Lombardi wrote:
> diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
> index 7b8c636..a026211 100644
> --- a/drivers/block/paride/pcd.c
> +++ b/drivers/block/paride/pcd.c
> @@ -230,6 +230,8 @@ static int pcd_block_open(struct block_device *bdev, 
> fmode_t mode)
>       struct pcd_unit *cd = bdev->bd_disk->private_data;
>       int ret;
>  
> +     check_disk_change(bdev);
> +
>       mutex_lock(&pcd_mutex);
>       ret = cdrom_open(&cd->info, bdev, mode);
>       mutex_unlock(&pcd_mutex);
> diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
> index e36d160..8327478 100644
> --- a/drivers/cdrom/cdrom.c
> +++ b/drivers/cdrom/cdrom.c
> @@ -1152,9 +1152,6 @@ int cdrom_open(struct cdrom_device_info *cdi, struct 
> block_device *bdev,
>  
>       cd_dbg(CD_OPEN, "entering cdrom_open\n");
>  
> -     /* open is event synchronization point, check events first */
> -     check_disk_change(bdev);
> -
>       /* if this was a O_NONBLOCK open and we should honor the flags,
>        * do a quick open without drive/disc integrity checks. */
>       cdi->use_count++;
> diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
> index 6495b03f..ae3a753 100644
> --- a/drivers/cdrom/gdrom.c
> +++ b/drivers/cdrom/gdrom.c
> @@ -497,6 +497,9 @@ static int gdrom_audio_ioctl(struct cdrom_device_info 
> *cdi, unsigned int cmd,
>  static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
>  {
>       int ret;
> +
> +     check_disk_change(bdev);
> +
>       mutex_lock(&gdrom_mutex);
>       ret = cdrom_open(gd.cd_info, bdev, mode);
>       mutex_unlock(&gdrom_mutex);

I think there is a much more elegant solution, namely splitting cdrom_mutex
into two synchronization objects - one that protects 'cdrom_list' changes
and another one that protects cdrom_sysctl_settings.info changes. Had you
considered that alternative?

Thanks,

Bart.


Reply via email to