Re: [PATCH 17/19] sr: use bdev_check_media_change

2020-09-09 Thread Hannes Reinecke
On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> Switch to use bdev_check_media_change instead of check_disk_change and
> call sr_block_revalidate_disk manually.  Also add an explicit call to
> sr_block_revalidate_disk just before disk_add() to ensure we always
> read check for a ready unit and read the TOC and then stop wiring up
> ->revalidate_disk.
> 
> Signed-off-by: Christoph Hellwig 
> Reviewed-by: Johannes Thumshirn 
> ---
>  drivers/scsi/sr.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

[PATCH 17/19] sr: use bdev_check_media_change

2020-09-08 Thread Christoph Hellwig
Switch to use bdev_check_media_change instead of check_disk_change and
call sr_block_revalidate_disk manually.  Also add an explicit call to
sr_block_revalidate_disk just before disk_add() to ensure we always
read check for a ready unit and read the TOC and then stop wiring up
->revalidate_disk.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/sr.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 3b3a53c6a0de53..34be94b62523fa 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -86,6 +86,7 @@ static int sr_remove(struct device *);
 static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt);
 static int sr_done(struct scsi_cmnd *);
 static int sr_runtime_suspend(struct device *dev);
+static int sr_block_revalidate_disk(struct gendisk *disk);
 
 static const struct dev_pm_ops sr_pm_ops = {
.runtime_suspend= sr_runtime_suspend,
@@ -529,7 +530,8 @@ static int sr_block_open(struct block_device *bdev, fmode_t 
mode)
 
sdev = cd->device;
scsi_autopm_get_device(sdev);
-   check_disk_change(bdev);
+   if (bdev_check_media_change(bdev))
+   sr_block_revalidate_disk(bdev->bd_disk);
 
mutex_lock(>lock);
ret = cdrom_open(>cdi, bdev, mode);
@@ -688,7 +690,6 @@ static const struct block_device_operations sr_bdops =
.compat_ioctl   = sr_block_compat_ioctl,
 #endif
.check_events   = sr_block_check_events,
-   .revalidate_disk = sr_block_revalidate_disk,
 };
 
 static int sr_open(struct cdrom_device_info *cdi, int purpose)
@@ -802,6 +803,7 @@ static int sr_probe(struct device *dev)
 
dev_set_drvdata(dev, cd);
disk->flags |= GENHD_FL_REMOVABLE;
+   sr_block_revalidate_disk(disk);
device_add_disk(>sdev_gendev, disk, NULL);
 
sdev_printk(KERN_DEBUG, sdev,
-- 
2.28.0



Re: [PATCH 17/19] sr: use bdev_check_media_change

2020-09-02 Thread Johannes Thumshirn
Looks good,
Reviewed-by: Johannes Thumshirn 


[PATCH 17/19] sr: use bdev_check_media_change

2020-09-02 Thread Christoph Hellwig
Switch to use bdev_check_media_change instead of check_disk_change and
call sr_block_revalidate_disk manually.  Also add an explicit call to
sr_block_revalidate_disk just before disk_add() to ensure we always
read check for a ready unit and read the TOC and then stop wiring up
->revalidate_disk.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/sr.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 3b3a53c6a0de53..34be94b62523fa 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -86,6 +86,7 @@ static int sr_remove(struct device *);
 static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt);
 static int sr_done(struct scsi_cmnd *);
 static int sr_runtime_suspend(struct device *dev);
+static int sr_block_revalidate_disk(struct gendisk *disk);
 
 static const struct dev_pm_ops sr_pm_ops = {
.runtime_suspend= sr_runtime_suspend,
@@ -529,7 +530,8 @@ static int sr_block_open(struct block_device *bdev, fmode_t 
mode)
 
sdev = cd->device;
scsi_autopm_get_device(sdev);
-   check_disk_change(bdev);
+   if (bdev_check_media_change(bdev))
+   sr_block_revalidate_disk(bdev->bd_disk);
 
mutex_lock(>lock);
ret = cdrom_open(>cdi, bdev, mode);
@@ -688,7 +690,6 @@ static const struct block_device_operations sr_bdops =
.compat_ioctl   = sr_block_compat_ioctl,
 #endif
.check_events   = sr_block_check_events,
-   .revalidate_disk = sr_block_revalidate_disk,
 };
 
 static int sr_open(struct cdrom_device_info *cdi, int purpose)
@@ -802,6 +803,7 @@ static int sr_probe(struct device *dev)
 
dev_set_drvdata(dev, cd);
disk->flags |= GENHD_FL_REMOVABLE;
+   sr_block_revalidate_disk(disk);
device_add_disk(>sdev_gendev, disk, NULL);
 
sdev_printk(KERN_DEBUG, sdev,
-- 
2.28.0