rework check_disk_change() v2
Subsystems (6)
Hi Jens,
this series replaced the not very nice check_disk_change() function with a new bdev_media_changed that avoids having the ->revalidate_disk call at its end. As a result ->revalidate_disk can be removed from a lot of drivers.
Changes since v1:
- minor changelog spelling fixes
Diffstat:
block/genhd.c | 29 ++++++++++++++++++++++++++- drivers/block/amiflop.c | 2 - drivers/block/ataflop.c | 7 +++--- drivers/block/floppy.c | 8 ++++--- drivers/block/paride/pcd.c | 2 - drivers/block/swim.c | 22 +------------------- drivers/block/swim3.c | 4 +-- drivers/block/xsysace.c | 26 +++++++++--------------- drivers/cdrom/gdrom.c | 2 - drivers/ide/ide-cd.c | 16 ++++----------- drivers/ide/ide-disk.c | 5 ---- drivers/ide/ide-floppy.c | 2 - drivers/ide/ide-gd.c | 48 +++++---------------------------------------- drivers/md/md.c | 2 - drivers/scsi/sd.c | 7 +++--- drivers/scsi/sr.c | 36 +++++++++++++-------------------- fs/block_dev.c | 31 ----------------------------- include/linux/genhd.h | 3 -- include/linux/ide.h | 2 - 19 files changed, 86 insertions(+), 168 deletions(-)
PATCH 1/19 block: add a bdev_check_media_change helper
Like check_disk_changed, except that it does not call ->revalidate_disk but leaves that to the caller.
--- block/genhd.c | 29 ++++++++++++++++++++++++++++- fs/block_dev.c | 17 +++-------------- include/linux/genhd.h | 2 +- 3 files changed, 32 insertions(+), 16 deletions(-)
block/genhd.c +28 -1
@@ -2052,7 +2052,7 @@ void disk_flush_events(struct gendisk *disk, unsigned int mask)* CONTEXT: * Might sleep. */ -unsigned int disk_clear_events (struct gendisk *disk,unsigned int mask) +static unsigned int disk_clear_events (struct gendisk *disk,unsigned int mask) {struct disk_events *ev = disk->ev;unsigned int pending;
@@ -2090,6 +2090,33 @@ unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask)return pending; } +/** +* bdev_check_media_change - check if a removable media has been changed +* @bdev: block device to check +* +* Check whether a removable media has been changed, and attempt to free all +* dentries and inodes and invalidates all block device page cache entries in +* that case. +* +* Returns %true if the block device changed, or %false if not. +*/ +bool bdev_check_media_change (struct block_device *bdev) +{ +unsigned int events; + + events =disk_clear_events (bdev->bd_disk,DISK_EVENT_MEDIA_CHANGE | +DISK_EVENT_EJECT_REQUEST ); +if (!(events &DISK_EVENT_MEDIA_CHANGE )) +return false; + +if (__invalidate_device (bdev, true)) +pr_warn ("VFS: busy inodes on changed media %s\n" , + bdev->bd_disk->disk_name); +set_bit (BDEV_NEED_PART_SCAN , &bdev->bd_flags); +return true; +} +EXPORT_SYMBOL (bdev_check_media_change); +/* * Separate this part out so that a different pointer for clearing_ptr can be * passed in for disk_clear_events.
fs/block_dev.c +3 -14
@@ -1379,21 +1379,10 @@ EXPORT_SYMBOL(revalidate_disk_size);*/ int check_disk_change (struct block_device *bdev) { -struct gendisk *disk = bdev->bd_disk; -const struct block_device_operations *bdops = disk->fops; -unsigned int events; - - events =disk_clear_events (disk,DISK_EVENT_MEDIA_CHANGE | -DISK_EVENT_EJECT_REQUEST ); -if (!(events &DISK_EVENT_MEDIA_CHANGE )) +if (!bdev_check_media_change (bdev))return 0 ; - -if (__invalidate_device (bdev, true)) -pr_warn ("VFS: busy inodes on changed media %s\n" , - disk->disk_name); -set_bit (BDEV_NEED_PART_SCAN , &bdev->bd_flags); -if (bdops->revalidate_disk) - bdops->revalidate_disk (bdev->bd_disk); +if (bdev->bd_disk->fops->revalidate_disk) + bdev->bd_disk->fops->revalidate_disk (bdev->bd_disk);return 1 ; }
include/linux/genhd.h +1 -1
@@ -315,7 +315,6 @@ extern void disk_unblock_events(struct gendisk *disk);extern void disk_flush_events (struct gendisk *disk,unsigned int mask);void set_capacity_revalidate_and_notify (struct gendisk *disk,sector_t size,bool update_bdev); -extern unsigned int disk_clear_events (struct gendisk *disk,unsigned int mask);/* drivers/char/random.c */ extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
@@ -372,6 +371,7 @@ void unregister_blkdev(unsigned int major, const char *name);void revalidate_disk_size (struct gendisk *disk,bool verbose);int check_disk_change (struct block_device *bdev); +bool bdev_check_media_change (struct block_device *bdev);int __invalidate_device (struct block_device *bdev,bool kill_dirty);void bd_set_nr_sectors (struct block_device *bdev,sector_t sectors);
Signature · 1 line
2.28.0
Re: [PATCH 01/19] block: add a bdev_check_media_change helper
Quoted 11 lines · Christoph Hellwig
Like
check_disk_changed, except that it does not call ->revalidate_disk but leaves that to the caller.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- block/genhd.c | 29 ++++++++++++++++++++++++++++- fs/block_dev.c | 17 +++-------------- include/linux/genhd.h | 2 +- 3 files changed, 32 insertions(+), 16 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 2/19 amiflop: use bdev_check_media_change
In reply to Christoph HellwigThe Amiga floppy driver does not have a ->revalidate_disk method, so it can just use bdev_check_media_change without any additional changes.
--- drivers/block/amiflop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/amiflop.c +1 -1
@@ -1670,7 +1670,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) }if (mode & (FMODE_READ |FMODE_WRITE )) { -check_disk_change (bdev); +bdev_check_media_change (bdev);if (mode &FMODE_WRITE ) {int wrprot;
Signature · 1 line
2.28.0
Re: [PATCH 02/19] amiflop: use bdev_check_media_change
Quoted 15 lines · Christoph Hellwig
The Amiga floppy driver does not have a ->revalidate_disk method, so it can just use
bdev_check_media_changewithout any additional changes.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/block/amiflop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/block/amiflop.c +0
-0
drivers/block/amiflop.c static int floppy_open(struct block_device *bdev, fmode_t mode) · line 1676
Quoted 8 lines
drivers/block/amiflop.c +1
-1@@ -1670,7 +1670,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) }if (mode & (FMODE_READ |FMODE_WRITE )) { -check_disk_change (bdev); +bdev_check_media_change (bdev);if (mode &FMODE_WRITE ) {int wrprot;
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 3/19 ataflop: use bdev_check_media_change
In reply to Christoph HellwigSwitch to use bdev_check_media_change instead of check_disk_change and call floppy_revalidate manually. Given that floppy_revalidate only deals with media change events, the extra call into ->revalidate_disk from bdev_disk_changed is not required either, so stop wiring up the method.
--- drivers/block/ataflop.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/block/ataflop.c +4 -3
@@ -1732,7 +1732,8 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,/* invalidate the buffer track to force a reread */ BufferDrive =-1 ;set_bit (drive, &fake_change); -check_disk_change (bdev); +if (bdev_check_media_change (bdev)) +floppy_revalidate (bdev->bd_disk);return 0 ;default :return -EINVAL ;
@@ -1909,7 +1910,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)return 0 ;if (mode & (FMODE_READ |FMODE_WRITE )) { -check_disk_change (bdev); +if (bdev_check_media_change (bdev)) +floppy_revalidate (bdev->bd_disk);if (mode &FMODE_WRITE ) {if (p->wpstat) {if (p->ref <0 )
@@ -1953,7 +1955,6 @@ static const struct block_device_operations floppy_fops = { .release = floppy_release, .ioctl = fd_ioctl, .check_events = floppy_check_events, - .revalidate_disk= floppy_revalidate, };static const struct blk_mq_ops ataflop_mq_ops = {
Signature · 1 line
2.28.0
Re: [PATCH 03/19] ataflop: use bdev_check_media_change
Quoted 6 lines · Christoph Hellwig
Switch to use
bdev_check_media_changeinstead ofcheck_disk_changeand callfloppy_revalidatemanually. Given thatfloppy_revalidateonly deals with media change events, the extra call into ->revalidate_disk frombdev_disk_changedis not required either, so stop wiring up the method.
Quoted 6 lines
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/block/ataflop.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 4/19 floppy: use bdev_check_media_change
In reply to Christoph HellwigSwitch to use bdev_check_media_change instead of check_disk_change and call floppy_revalidate manually. Given that floppy_revalidate only deals with media change events, the extra call into ->revalidate_disk from bdev_disk_changed is not required either, so stop wiring up the method.
--- drivers/block/floppy.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/block/floppy.c +5 -3
@@ -561,6 +561,7 @@ static void floppy_release_irq_and_dma(void);* output_byte is automatically disabled when reset is set. */ static void reset_fdc (void ); +static int floppy_revalidate (struct gendisk *disk);/* * These are global variables, as that's the easiest way to give
@@ -3275,7 +3276,8 @@ static int invalidate_drive(struct block_device *bdev)/* invalidate the buffer track to force a reread */ set_bit ((long )bdev->bd_disk->private_data, &fake_change);process_fd_request (); -check_disk_change (bdev); +if (bdev_check_media_change (bdev)) +floppy_revalidate (bdev->bd_disk);return 0 ; }
@@ -4123,7 +4125,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) drive_state[drive].last_checked =0 ;clear_bit (FD_OPEN_SHOULD_FAIL_BIT , &drive_state[drive].flags); -check_disk_change (bdev); +if (bdev_check_media_change (bdev)) +floppy_revalidate (bdev->bd_disk);if (test_bit (FD_DISK_CHANGED_BIT , &drive_state[drive].flags)) goto out;if (test_bit (FD_OPEN_SHOULD_FAIL_BIT , &drive_state[drive].flags))
@@ -4291,7 +4294,6 @@ static const struct block_device_operations floppy_fops = { .ioctl = fd_ioctl, .getgeo = fd_getgeo, .check_events = floppy_check_events, - .revalidate_disk = floppy_revalidate,#ifdef CONFIG_COMPAT .compat_ioctl = fd_compat_ioctl,#endif
Signature · 1 line
2.28.0
Re: [PATCH 04/19] floppy: use bdev_check_media_change
Looks good,
Re: [PATCH 04/19] floppy: use bdev_check_media_change
In reply to Christoph HellwigQuoted 11 lines · Christoph Hellwig
Switch to use
bdev_check_media_changeinstead ofcheck_disk_changeand callfloppy_revalidatemanually. Given thatfloppy_revalidateonly deals with media change events, the extra call into ->revalidate_disk frombdev_disk_changedis not required either, so stop wiring up the method.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/block/floppy.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 5/19 swim: use bdev_check_media_change
In reply to Christoph HellwigSwitch to use bdev_check_media_change instead of check_disk_change and call floppy_revalidate manually. Given that floppy_revalidate only deals with media change events, the extra call into ->revalidate_disk from bdev_disk_changed is not required either, so stop wiring up the method.
--- drivers/block/swim.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/block/swim.c +4 -2
@@ -217,6 +217,8 @@ extern int swim_read_sector_header(struct swim __iomem *base,extern int swim_read_sector_data (struct swim __iomem *base,unsigned char *data); +static int floppy_revalidate (struct gendisk *disk); +static DEFINE_MUTEX (swim_mutex);static inline void set_swim_mode (struct swim __iomem *base,int enable) {
@@ -638,7 +640,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)return 0 ;if (mode & (FMODE_READ |FMODE_WRITE )) { -check_disk_change (bdev); +if (bdev_check_media_change (bdev)) +floppy_revalidate (bdev->bd_disk);if ((mode &FMODE_WRITE ) && fs->write_protected) { err = -EROFS ; goto out;
@@ -760,7 +763,6 @@ static const struct block_device_operations floppy_fops = { .ioctl = floppy_ioctl, .getgeo = floppy_getgeo, .check_events = floppy_check_events, - .revalidate_disk = floppy_revalidate, };static struct kobject *floppy_find (dev_t dev,int *part,void *data)
Signature · 1 line
2.28.0
Re: [PATCH 05/19] swim: use bdev_check_media_change
Quoted 6 lines · Christoph Hellwig
Switch to use
bdev_check_media_changeinstead ofcheck_disk_changeand callfloppy_revalidatemanually. Given thatfloppy_revalidateonly deals with media change events, the extra call into ->revalidate_disk frombdev_disk_changedis not required either, so stop wiring up the method.
Quoted 6 lines
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/block/swim.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 6/19 swim: simplify media change handling
In reply to Christoph Hellwigfloppy_revalidate mostly duplicates work already done in floppy_open despite only beeing called from floppy_open. Remove the function and just clear the ->ejected flag directly under the right condition.
--- drivers/block/swim.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
drivers/block/swim.c +2 -22
@@ -217,8 +217,6 @@ extern int swim_read_sector_header(struct swim __iomem *base,extern int swim_read_sector_data (struct swim __iomem *base,unsigned char *data); -static int floppy_revalidate (struct gendisk *disk); -static DEFINE_MUTEX (swim_mutex);static inline void set_swim_mode (struct swim __iomem *base,int enable) {
@@ -640,8 +638,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)return 0 ;if (mode & (FMODE_READ |FMODE_WRITE )) { -if (bdev_check_media_change (bdev)) -floppy_revalidate (bdev->bd_disk); +if (bdev_check_media_change (bdev) && fs->disk_in) + fs->ejected =0 ;if ((mode &FMODE_WRITE ) && fs->write_protected) { err = -EROFS ; goto out;
@@ -738,24 +736,6 @@ static unsigned int floppy_check_events(struct gendisk *disk,return fs->ejected ?DISK_EVENT_MEDIA_CHANGE :0 ; } -static int floppy_revalidate (struct gendisk *disk) -{ -struct floppy_state *fs = disk->private_data; -struct swim __iomem *base = fs->swd->base; - -swim_drive (base, fs->location); - -if (fs->ejected) -setup_medium (fs); - -if (!fs->disk_in) -swim_motor (base,OFF ); -else - fs->ejected =0 ; - -return !fs->disk_in; -} -static const struct block_device_operations floppy_fops = { .owner =THIS_MODULE , .open = floppy_unlocked_open,
Signature · 1 line
2.28.0
Re: [PATCH 06/19] swim: simplify media change handling
Quoted 10 lines · Christoph Hellwig
floppy_revalidatemostly duplicates work already done infloppy_opendespite only beeing called fromfloppy_open. Remove the function and just clear the ->ejected flag directly under the right condition.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/block/swim.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
What a convoluted driver.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 7/19 swim3: use bdev_check_media_changed
In reply to Christoph HellwigSwitch to use bdev_check_media_changed instead of check_disk_change and call floppy_revalidate manually. Given that floppy_revalidate only deals with media change events, the extra call into ->revalidate_disk from bdev_disk_changed is not required either, so stop wiring up the method.
--- drivers/block/swim3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/swim3.c +2 -2
@@ -945,7 +945,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)if (err ==0 && (mode &FMODE_NDELAY ) ==0 && (mode & (FMODE_READ |FMODE_WRITE ))) { -check_disk_change (bdev); +if (bdev_check_media_change (bdev)) +floppy_revalidate (bdev->bd_disk);if (fs->ejected) err = -ENXIO ; }
@@ -1055,7 +1056,6 @@ static const struct block_device_operations floppy_fops = { .release = floppy_release, .ioctl = floppy_ioctl, .check_events = floppy_check_events, - .revalidate_disk= floppy_revalidate, };static const struct blk_mq_ops swim3_mq_ops = {
Signature · 1 line
2.28.0
Re: [PATCH 07/19] swim3: use bdev_check_media_changed
Quoted 6 lines · Christoph Hellwig
Switch to use
bdev_check_media_changedinstead ofcheck_disk_changeand callfloppy_revalidatemanually. Given thatfloppy_revalidateonly deals with media change events, the extra call into ->revalidate_disk frombdev_disk_changedis not required either, so stop wiring up the method.
Quoted 6 lines
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/block/swim3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
Re: [PATCH 07/19] swim3: use bdev_check_media_changed
In reply to Christoph HellwigHello!
Quoted 1 line · Christoph Hellwig
Switch to use
bdev_check_media_changedinstead ofcheck_disk_changeand
^^^
Using?
Quoted 7 lines
call
floppy_revalidatemanually. Given thatfloppy_revalidateonly deals with media change events, the extra call into ->revalidate_disk frombdev_disk_changedis not required either, so stop wiring up the method.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>
[...]
MBR, Sergei
PATCH 8/19 xsysace: use bdev_check_media_change
In reply to Christoph HellwigSwitch to use bdev_check_media_change instead of check_disk_change and call ace_revalidate_disk manually. Given that ace_revalidate_disk only deals with media change events, the extra call into ->revalidate_disk from bdev_disk_changed is not required either, so stop wiring up the method.
--- drivers/block/xsysace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/xsysace.c +2 -2
@@ -922,7 +922,8 @@ static int ace_open(struct block_device *bdev, fmode_t mode) ace->users++;spin_unlock_irqrestore (&ace->lock, flags); -check_disk_change (bdev); +if (bdev_check_media_change (bdev)) +ace_revalidate_disk (bdev->bd_disk);mutex_unlock (&xsysace_mutex);return 0 ;
@@ -966,7 +967,6 @@ static const struct block_device_operations ace_fops = { .open = ace_open, .release = ace_release, .check_events = ace_check_events, - .revalidate_disk = ace_revalidate_disk, .getgeo = ace_getgeo, };
Signature · 1 line
2.28.0
Re: [PATCH 08/19] xsysace: use bdev_check_media_change
Quoted 6 lines · Christoph Hellwig
Switch to use
bdev_check_media_changeinstead ofcheck_disk_changeand callace_revalidate_diskmanually. Given thatace_revalidate_diskonly deals with media change events, the extra call into ->revalidate_disk frombdev_disk_changedis not required either, so stop wiring up the method.
Quoted 6 lines
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/block/xsysace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 9/19 xsysace: simplify media change handling
In reply to Christoph HellwigPass a struct ace_device to ace_revalidate_disk, move the media changed check into the one caller that needs it, and give the routine a better name.
--- drivers/block/xsysace.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
drivers/block/xsysace.c +10 -16
@@ -888,26 +888,20 @@ static unsigned int ace_check_events(struct gendisk *gd, unsigned int clearing)return ace->media_change ?DISK_EVENT_MEDIA_CHANGE :0 ; } -static int ace_revalidate_disk (struct gendisk *gd) +static void ace_media_changed (struct ace_device *ace) { -struct ace_device *ace = gd->private_data;unsigned long flags; -dev_dbg (ace->dev,"ace_revalidate_disk()\n" ); - -if (ace->media_change) { -dev_dbg (ace->dev,"requesting cf id and scheduling tasklet\n" ); +dev_dbg (ace->dev,"requesting cf id and scheduling tasklet\n" ); -spin_lock_irqsave (&ace->lock, flags); - ace->id_req_count++; -spin_unlock_irqrestore (&ace->lock, flags); +spin_lock_irqsave (&ace->lock, flags); + ace->id_req_count++; +spin_unlock_irqrestore (&ace->lock, flags); -tasklet_schedule (&ace->fsm_tasklet); -wait_for_completion (&ace->id_completion); - } +tasklet_schedule (&ace->fsm_tasklet); +wait_for_completion (&ace->id_completion);dev_dbg (ace->dev,"revalidate complete\n" ); -return ace->id_result; }static int ace_open (struct block_device *bdev,fmode_t mode)
@@ -922,8 +916,8 @@ static int ace_open(struct block_device *bdev, fmode_t mode) ace->users++;spin_unlock_irqrestore (&ace->lock, flags); -if (bdev_check_media_change (bdev)) -ace_revalidate_disk (bdev->bd_disk); +if (bdev_check_media_change (bdev) && ace->media_change) +ace_media_changed (ace);mutex_unlock (&xsysace_mutex);return 0 ;
@@ -1080,7 +1074,7 @@ static int ace_setup(struct ace_device *ace) (unsigned long long) ace->physaddr, ace->baseaddr, ace->irq); ace->media_change =1 ; -ace_revalidate_disk (ace->gd); +ace_media_changed (ace);/* Make the sysace device 'live' */ add_disk (ace->gd);
Signature · 1 line
2.28.0
Re: [PATCH 09/19] xsysace: simplify media change handling
Quoted 9 lines · Christoph Hellwig
Pass a struct
ace_devicetoace_revalidate_disk, move the media changed check into the one caller that needs it, and give the routine a better name.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/block/xsysace.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 10/19 paride/pcd: use bdev_check_media_change
In reply to Christoph HellwigThe pcd driver does not have a ->revalidate_disk method, so it can just use bdev_check_media_change without any additional changes.
--- drivers/block/paride/pcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/paride/pcd.c +1 -1
@@ -233,7 +233,7 @@ 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); +bdev_check_media_change (bdev);mutex_lock (&pcd_mutex); ret =cdrom_open (&cd->info, bdev, mode);
Signature · 1 line
2.28.0
Re: [PATCH 10/19] paride/pcd: use bdev_check_media_change
Quoted 15 lines · Christoph Hellwig
The pcd driver does not have a ->revalidate_disk method, so it can just use
bdev_check_media_changewithout any additional changes.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/block/paride/pcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/block/paride/pcd.c +0
-0
drivers/block/paride/pcd.c static int pcd_block_open(struct block_device *bdev, fmode_t mode) · line 239
Quoted 8 lines
drivers/block/paride/pcd.c +1
-1@@ -233,7 +233,7 @@ 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); +bdev_check_media_change (bdev);mutex_lock (&pcd_mutex); ret =cdrom_open (&cd->info, bdev, mode);
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 11/19 gdrom: use bdev_check_media_change
In reply to Christoph HellwigThe Sega GD-ROM driver does not have a ->revalidate_disk method, so it can just use bdev_check_media_change without any additional changes.
--- drivers/cdrom/gdrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cdrom/gdrom.c +1 -1
@@ -479,7 +479,7 @@ static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode) {int ret; -check_disk_change (bdev); +bdev_check_media_change (bdev);mutex_lock (&gdrom_mutex); ret =cdrom_open (gd.cd_info, bdev, mode);
Signature · 1 line
2.28.0
Re: [PATCH 11/19] gdrom: use bdev_check_media_change
Quoted 15 lines · Christoph Hellwig
The Sega GD-ROM driver does not have a ->revalidate_disk method, so it can just use
bdev_check_media_changewithout any additional changes.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/cdrom/gdrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cdrom/gdrom.c +0
-0
drivers/cdrom/gdrom.c static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode) · line 485
Quoted 8 lines
drivers/cdrom/gdrom.c +1
-1@@ -479,7 +479,7 @@ static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode) {int ret; -check_disk_change (bdev); +bdev_check_media_change (bdev);mutex_lock (&gdrom_mutex); ret =cdrom_open (gd.cd_info, bdev, mode);
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 12/19 ide-cd: use bdev_check_media_changed
In reply to Christoph HellwigSwitch to use bdev_check_media_changed instead of check_disk_change and call idecd_revalidate_disk manually. Given that idecd_revalidate_disk only re-reads the TOC, and we already do the same at probe time, the extra call into ->revalidate_disk from bdev_disk_changed is not required either, so stop wiring up the method.
--- drivers/ide/ide-cd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/ide/ide-cd.c +3 -2
@@ -56,6 +56,7 @@ static DEFINE_MUTEX(ide_cd_mutex);static DEFINE_MUTEX (idecd_ref_mutex);static void ide_cd_release (struct device *); +static int idecd_revalidate_disk (struct gendisk *disk);static struct cdrom_info *ide_cd_get (struct gendisk *disk) {
@@ -1611,7 +1612,8 @@ static int idecd_open(struct block_device *bdev, fmode_t mode)struct cdrom_info *info;int rc = -ENXIO ; -check_disk_change (bdev); +if (bdev_check_media_change (bdev)) +idecd_revalidate_disk (bdev->bd_disk);mutex_lock (&ide_cd_mutex); info =ide_cd_get (bdev->bd_disk);
@@ -1770,7 +1772,6 @@ static const struct block_device_operations idecd_ops = { .compat_ioctl = IS_ENABLED(CONFIG_COMPAT) ? idecd_compat_ioctl : NULL, .check_events = idecd_check_events, - .revalidate_disk = idecd_revalidate_disk };/* module options */
Signature · 1 line
2.28.0
Re: [PATCH 12/19] ide-cd: use bdev_check_media_changed
Quoted 6 lines · Christoph Hellwig
Switch to use
bdev_check_media_changedinstead ofcheck_disk_changeand callidecd_revalidate_diskmanually. Given thatidecd_revalidate_diskonly re-reads the TOC, and we already do the same at probe time, the extra call into ->revalidate_disk frombdev_disk_changedis not required either, so stop wiring up the method.
Quoted 6 lines
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/ide/ide-cd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 13/19 ide-cd: remove idecd_revalidate_disk
In reply to Christoph HellwigJust merge the trivial function into its only caller.
--- drivers/ide/ide-cd.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/ide/ide-cd.c +5 -12
@@ -56,7 +56,6 @@ static DEFINE_MUTEX(ide_cd_mutex);static DEFINE_MUTEX (idecd_ref_mutex);static void ide_cd_release (struct device *); -static int idecd_revalidate_disk (struct gendisk *disk);static struct cdrom_info *ide_cd_get (struct gendisk *disk) {
@@ -1612,8 +1611,11 @@ static int idecd_open(struct block_device *bdev, fmode_t mode)struct cdrom_info *info;int rc = -ENXIO ; -if (bdev_check_media_change (bdev)) -idecd_revalidate_disk (bdev->bd_disk); +if (bdev_check_media_change (bdev)) { + info =ide_drv_g (bdev->bd_disk, cdrom_info); + +ide_cd_read_toc (info->drive); + }mutex_lock (&ide_cd_mutex); info =ide_cd_get (bdev->bd_disk);
@@ -1755,15 +1757,6 @@ static unsigned int idecd_check_events(struct gendisk *disk,return cdrom_check_events (&info->devinfo, clearing); } -static int idecd_revalidate_disk (struct gendisk *disk) -{ -struct cdrom_info *info =ide_drv_g (disk, cdrom_info); - -ide_cd_read_toc (info->drive); - -return 0 ; -} -static const struct block_device_operations idecd_ops = { .owner =THIS_MODULE , .open = idecd_open,
Signature · 1 line
2.28.0
Re: [PATCH 13/19] ide-cd: remove idecd_revalidate_disk
Quoted 8 lines · Christoph Hellwig
Just merge the trivial function into its only caller.
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/ide/ide-cd.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 14/19 ide-gd: stop using the disk events mechanism
In reply to Christoph Hellwigide-gd is only using the disk events mechanism to be able to force an invalidation and partition scan on opening removable media. Just open code the logic without invoving the block layer.
--- drivers/ide/ide-disk.c | 5 +---- drivers/ide/ide-floppy.c | 2 -- drivers/ide/ide-gd.c | 48 +++++----------------------------------- include/linux/ide.h | 2 -- 4 files changed, 7 insertions(+), 50 deletions(-)
drivers/ide/ide-disk.c +1 -4
@@ -739,12 +739,9 @@ static void ide_disk_setup(ide_drive_t *drive)set_wcache (drive,1 );if ((drive->dev_flags &IDE_DFLAG_LBA ) ==0 && - (drive->head ==0 || drive->head >16 )) { + (drive->head ==0 || drive->head >16 ))printk (KERN_ERR "%s: invalid geometry: %d physical heads?\n" , drive->name, drive->head); - drive->dev_flags &= ~IDE_DFLAG_ATTACH ; - }else - drive->dev_flags |=IDE_DFLAG_ATTACH ; }static void ide_disk_flush (ide_drive_t *drive)
drivers/ide/ide-floppy.c +0 -2
@@ -516,8 +516,6 @@ static void ide_floppy_setup(ide_drive_t *drive) (void )ide_floppy_get_capacity (drive);ide_proc_register_driver (drive, floppy->driver); - - drive->dev_flags |=IDE_DFLAG_ATTACH ; }static void ide_floppy_flush (ide_drive_t *drive)
drivers/ide/ide-gd.c +6 -42
73 lines not on this page · raw message
include/linux/ide.h +0 -2
@@ -490,8 +490,6 @@ enum {IDE_DFLAG_NOPROBE =BIT (9 ),/* need to do check_media_change() */ IDE_DFLAG_REMOVABLE =BIT (10 ), -/* needed for removable devices */ -IDE_DFLAG_ATTACH =BIT (11 ),IDE_DFLAG_FORCED_GEOM =BIT (12 ),/* disallow setting unmask bit */ IDE_DFLAG_NO_UNMASK = BIT(13),
Signature · 1 line
2.28.0
Re: [PATCH 14/19] ide-gd: stop using the disk events mechanism
Quoted 4 lines · Christoph Hellwig
ide-gd is only using the disk events mechanism to be able to force an invalidation and partition scan on opening removable media. Just open code the logic without invoving the block layer.
Quoted 8 lines
Signed-off-by Christoph Hellwig <[email protected]>--- drivers/ide/ide-disk.c | 5 +---- drivers/ide/ide-floppy.c | 2 -- drivers/ide/ide-gd.c | 48 +++++----------------------------------- include/linux/ide.h | 2 -- 4 files changed, 7 insertions(+), 50 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 15/19 md: use bdev_check_media_change
In reply to Christoph HellwigThe md driver does not have a ->revalidate_disk method, so it can just use bdev_check_media_change without any additional changes.
--- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.c +1 -1
@@ -7848,7 +7848,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)atomic_inc (&mddev->openers);mutex_unlock (&mddev->open_mutex); -check_disk_change (bdev); +bdev_check_media_change (bdev); out:if (err)mddev_put (mddev);
Signature · 1 line
2.28.0
Re: [PATCH 15/19] md: use bdev_check_media_change
Quoted 6 lines · Christoph Hellwig
The md driver does not have a ->revalidate_disk method, so it can just use
bdev_check_media_changewithout any additional changes.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>
Quoted 20 lines
--- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/md.c +1
-2@@ -7848,7 +7848,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)atomic_inc (&mddev->openers);mutex_unlock (&mddev->open_mutex); -check_disk_change (bdev); +bdev_check_media_change (bdev); out:if (err)mddev_put (mddev); --2.28.0
Re: [PATCH 15/19] md: use bdev_check_media_change
In reply to Christoph HellwigQuoted 15 lines · Christoph Hellwig
The md driver does not have a ->revalidate_disk method, so it can just use
bdev_check_media_changewithout any additional changes.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/md.c +0
-0
drivers/md/md.c static int md_open(struct block_device *bdev, fmode_t mode) · line 7854
Quoted 8 lines
drivers/md/md.c +1
-1@@ -7848,7 +7848,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)atomic_inc (&mddev->openers);mutex_unlock (&mddev->open_mutex); -check_disk_change (bdev); +bdev_check_media_change (bdev); out:if (err)mddev_put (mddev);
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 16/19 sd: use bdev_check_media_change
In reply to Christoph HellwigSwitch to use bdev_check_media_change instead of check_disk_change and call sd_revalidate_disk manually. As sd also calls sd_revalidate_disk manually during probe and open, , the extra call into ->revalidate_disk from bdev_disk_changed is not required either, so stop wiring up the method.
--- drivers/scsi/sd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/sd.c +4 -3
@@ -1381,8 +1381,10 @@ 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) -check_disk_change (bdev); +if (sdev->removable || sdkp->write_prot) { +if (bdev_check_media_change (bdev)) +sd_revalidate_disk (bdev->bd_disk); + }/* * If the drive is empty, just let the open fail.
@@ -1843,7 +1845,6 @@ static const struct block_device_operations sd_fops = { .compat_ioctl = sd_compat_ioctl, #endif .check_events = sd_check_events, - .revalidate_disk = sd_revalidate_disk, .unlock_native_capacity = sd_unlock_native_capacity, .report_zones = sd_zbc_report_zones, .pr_ops = &sd_pr_ops,
Signature · 1 line
2.28.0
Re: [PATCH 16/19] sd: use bdev_check_media_change
Quoted 6 lines · Christoph Hellwig
Switch to use
bdev_check_media_changeinstead ofcheck_disk_changeand callsd_revalidate_diskmanually. As sd also callssd_revalidate_diskmanually during probe and open, , the extra call into ->revalidate_disk frombdev_disk_changedis not required either, so stop wiring up the method.
Quoted 6 lines
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/scsi/sd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
Re: [PATCH 16/19] sd: use bdev_check_media_change
In reply to Christoph HellwigQuoted 3 lines · Christoph Hellwig
Switch to use
bdev_check_media_changeinstead ofcheck_disk_changeand callsd_revalidate_diskmanually. As sd also callssd_revalidate_diskmanually during probe and open, , the extra call into ->revalidate_disk
Too many commas. :-)
Quoted 5 lines
from
bdev_disk_changedis not required either, so stop wiring up the method.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>
[...]
MBR, Sergei
PATCH 17/19 sr: use bdev_check_media_change
In reply to Christoph HellwigSwitch 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.
--- drivers/scsi/sr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/sr.c +4 -2
@@ -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 (&cd->lock); ret =cdrom_open (&cd->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->sdev_gendev, disk,NULL ); sdev_printk(KERN_DEBUG, sdev,
Signature · 1 line
2.28.0
Re: [PATCH 17/19] sr: use bdev_check_media_change
Quoted 6 lines · Christoph Hellwig
Switch to use
bdev_check_media_changeinstead ofcheck_disk_changeand callsr_block_revalidate_diskmanually. Also add an explicit call tosr_block_revalidate_diskjust beforedisk_add()to ensure we always read check for a ready unit and read the TOC and then stop wiring up ->revalidate_disk.
Quoted 6 lines
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/scsi/sr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 18/19 sr: simplify sr_block_revalidate_disk
In reply to Christoph HellwigBoth callers have a valid CD struture available, so rely on that instead of getting another reference. Also move the function to avoid a forward declaration.
--- drivers/scsi/sr.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-)
drivers/scsi/sr.c +13 -23
@@ -86,7 +86,6 @@ 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,
@@ -518,6 +517,17 @@ static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt)return ret; } +static void sr_revalidate_disk (struct scsi_cd *cd) +{ +struct scsi_sense_hdr sshdr; + +/* if the unit is not ready, nothing more to do */ +if (scsi_test_unit_ready (cd->device,SR_TIMEOUT ,MAX_RETRIES , &sshdr)) +return ; +sr_cd_check (&cd->cdi); +get_sectorsize (cd); +} +static int sr_block_open (struct block_device *bdev,fmode_t mode) {struct scsi_cd *cd;
@@ -531,7 +541,7 @@ static int sr_block_open(struct block_device *bdev, fmode_t mode) sdev = cd->device;scsi_autopm_get_device (sdev);if (bdev_check_media_change (bdev)) -sr_block_revalidate_disk (bdev->bd_disk); +sr_revalidate_disk (cd);mutex_lock (&cd->lock); ret =cdrom_open (&cd->cdi, bdev, mode);
@@ -660,26 +670,6 @@ static unsigned int sr_block_check_events(struct gendisk *disk,return ret; } -static int sr_block_revalidate_disk (struct gendisk *disk) -{ -struct scsi_sense_hdr sshdr; -struct scsi_cd *cd; - - cd =scsi_cd_get (disk); -if (!cd) -return -ENXIO ; - -/* if the unit is not ready, nothing more to do */ -if (scsi_test_unit_ready (cd->device,SR_TIMEOUT ,MAX_RETRIES , &sshdr)) - goto out; - -sr_cd_check (&cd->cdi); -get_sectorsize (cd); -out: -scsi_cd_put (cd); -return 0 ; -} -static const struct block_device_operations sr_bdops = { .owner =THIS_MODULE ,
@@ -803,7 +793,7 @@ static int sr_probe(struct device *dev)dev_set_drvdata (dev, cd); disk->flags |=GENHD_FL_REMOVABLE ; -sr_block_revalidate_disk (disk); +sr_revalidate_disk (cd);device_add_disk (&sdev->sdev_gendev, disk,NULL ); sdev_printk(KERN_DEBUG, sdev,
Signature · 1 line
2.28.0
Re: [PATCH 18/19] sr: simplify sr_block_revalidate_disk
Quoted 10 lines · Christoph Hellwig
Both callers have a valid CD struture available, so rely on that instead of getting another reference. Also move the function to avoid a forward declaration.
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/scsi/sr.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 19/19 block: remove check_disk_change
In reply to Christoph HellwigRemove the now unused check_disk_change helper.
--- fs/block_dev.c | 20 -------------------- include/linux/genhd.h | 1 - 2 files changed, 21 deletions(-)
fs/block_dev.c +0 -20
@@ -1368,26 +1368,6 @@ void revalidate_disk_size(struct gendisk *disk, bool verbose) }EXPORT_SYMBOL (revalidate_disk_size); -/* -* This routine checks whether a removable media has been changed, -* and invalidates all buffer-cache-entries in that case. This -* is a relatively slow routine, so we have to try to minimize using -* it. Thus it is called only upon a 'mount' or 'open'. This -* is the best way of combining speed and utility, I think. -* People changing diskettes in the middle of an operation deserve -* to lose :-) -*/ -int check_disk_change (struct block_device *bdev) -{ -if (!bdev_check_media_change (bdev)) -return 0 ; -if (bdev->bd_disk->fops->revalidate_disk) - bdev->bd_disk->fops->revalidate_disk (bdev->bd_disk); -return 1 ; -} - -EXPORT_SYMBOL (check_disk_change); -void bd_set_nr_sectors (struct block_device *bdev,sector_t sectors) {spin_lock (&bdev->bd_size_lock);
include/linux/genhd.h +0 -1
@@ -370,7 +370,6 @@ int register_blkdev(unsigned int major, const char *name);void unregister_blkdev (unsigned int major,const char *name);void revalidate_disk_size (struct gendisk *disk,bool verbose); -int check_disk_change (struct block_device *bdev);bool bdev_check_media_change (struct block_device *bdev);int __invalidate_device (struct block_device *bdev,bool kill_dirty);void bd_set_nr_sectors (struct block_device *bdev,sector_t sectors);
Signature · 1 line
2.28.0
Re: [PATCH 19/19] block: remove check_disk_change
Quoted 9 lines · Christoph Hellwig
Remove the now unused
check_disk_changehelper.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- fs/block_dev.c | 20 -------------------- include/linux/genhd.h | 1 - 2 files changed, 21 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
Quoted 6 lines · Christoph Hellwig
Hi Jens,
this series replaced the not very nice
check_disk_change()function with a newbdev_media_changedthat avoids having the ->revalidate_disk call at its end. As a result ->revalidate_disk can be removed from a lot of drivers.
Applied, thanks.
Signature · 1 line
Jens Axboe