linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* rework check_disk_change() v2
@ 2020-09-08 14:53 Christoph Hellwig
  2020-09-08 14:53 ` [PATCH 01/19] block: add a bdev_check_media_change helper Christoph Hellwig
                   ` (19 more replies)
  0 siblings, 20 replies; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel

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(-)

^ permalink raw reply	[flat|nested] 46+ messages in thread

* [PATCH 01/19] block: add a bdev_check_media_change helper
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  6:59   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 02/19] amiflop: use bdev_check_media_change Christoph Hellwig
                   ` (18 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

Like check_disk_changed, except that it does not call ->revalidate_disk
but leaves that to the caller.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 block/genhd.c         | 29 ++++++++++++++++++++++++++++-
 fs/block_dev.c        | 17 +++--------------
 include/linux/genhd.h |  2 +-
 3 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 081f1039d9367f..9d060e79eb31d8 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -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.
diff --git a/fs/block_dev.c b/fs/block_dev.c
index c70c41ecba4872..c6ac0bd22eca70 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -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;
 }
 
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index c618b27292fcc8..322d48a207728a 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -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);
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 02/19] amiflop: use bdev_check_media_change
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
  2020-09-08 14:53 ` [PATCH 01/19] block: add a bdev_check_media_change helper Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  6:59   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 03/19] ataflop: " Christoph Hellwig
                   ` (17 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

The Amiga floppy driver does not have a ->revalidate_disk method, so it
can just use bdev_check_media_change without any additional changes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/block/amiflop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 226219da3da6a7..71c2b156455860 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -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;
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 03/19] ataflop: use bdev_check_media_change
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
  2020-09-08 14:53 ` [PATCH 01/19] block: add a bdev_check_media_change helper Christoph Hellwig
  2020-09-08 14:53 ` [PATCH 02/19] amiflop: use bdev_check_media_change Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:00   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 04/19] floppy: " Christoph Hellwig
                   ` (16 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

Switch 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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/block/ataflop.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index a50e13af030526..3e881fdb06e0ad 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -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 = {
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 04/19] floppy: use bdev_check_media_change
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (2 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 03/19] ataflop: " Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  6:52   ` Johannes Thumshirn
  2020-09-09  7:00   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 05/19] swim: " Christoph Hellwig
                   ` (15 subsequent siblings)
  19 siblings, 2 replies; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel

Switch 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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/floppy.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index a563b023458a8b..7df79ae6b0a1e1 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -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
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 05/19] swim: use bdev_check_media_change
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (3 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 04/19] floppy: " Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:01   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 06/19] swim: simplify media change handling Christoph Hellwig
                   ` (14 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

Switch 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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/block/swim.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index dd34504382e533..d4565c555b289f 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -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)
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 06/19] swim: simplify media change handling
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (4 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 05/19] swim: " Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:09   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 07/19] swim3: use bdev_check_media_changed Christoph Hellwig
                   ` (13 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

floppy_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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/block/swim.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index d4565c555b289f..52dd1efa00f9c5 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -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,
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 07/19] swim3: use bdev_check_media_changed
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (5 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 06/19] swim: simplify media change handling Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:10   ` Hannes Reinecke
  2020-09-09  7:50   ` Sergei Shtylyov
  2020-09-08 14:53 ` [PATCH 08/19] xsysace: use bdev_check_media_change Christoph Hellwig
                   ` (12 subsequent siblings)
  19 siblings, 2 replies; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

Switch 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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/block/swim3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index aa77eb5fb7de88..c2d922d125e281 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -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 = {
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 08/19] xsysace: use bdev_check_media_change
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (6 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 07/19] swim3: use bdev_check_media_changed Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:10   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 09/19] xsysace: simplify media change handling Christoph Hellwig
                   ` (11 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

Switch 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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/block/xsysace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 5d8e0ab3f054f5..eefe542f2d9fff 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -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,
 };
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 09/19] xsysace: simplify media change handling
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (7 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 08/19] xsysace: use bdev_check_media_change Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:10   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 10/19] paride/pcd: use bdev_check_media_change Christoph Hellwig
                   ` (10 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel

Pass 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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/xsysace.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index eefe542f2d9fff..8d581c7536fb51 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -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);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 10/19] paride/pcd: use bdev_check_media_change
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (8 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 09/19] xsysace: simplify media change handling Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:26   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 11/19] gdrom: " Christoph Hellwig
                   ` (9 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

The pcd driver does not have a ->revalidate_disk method, so it can just
use bdev_check_media_change without any additional changes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/block/paride/pcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index 5124eca90e8337..70da8b86ce587d 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -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);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 11/19] gdrom: use bdev_check_media_change
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (9 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 10/19] paride/pcd: use bdev_check_media_change Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:27   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 12/19] ide-cd: use bdev_check_media_changed Christoph Hellwig
                   ` (8 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

The Sega GD-ROM driver does not have a ->revalidate_disk method, so it
can just use bdev_check_media_change without any additional changes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/cdrom/gdrom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index 09b0cd292720fa..9874fc1c815b53 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -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);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 12/19] ide-cd: use bdev_check_media_changed
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (10 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 11/19] gdrom: " Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:27   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 13/19] ide-cd: remove idecd_revalidate_disk Christoph Hellwig
                   ` (7 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

Switch 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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/ide/ide-cd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 212bb2d8bf346a..6a38cbc80aea0d 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -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 */
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 13/19] ide-cd: remove idecd_revalidate_disk
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (11 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 12/19] ide-cd: use bdev_check_media_changed Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:28   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 14/19] ide-gd: stop using the disk events mechanism Christoph Hellwig
                   ` (6 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

Just merge the trivial function into its only caller.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/ide/ide-cd.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 6a38cbc80aea0d..25d2d88e82ada0 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -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,
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 14/19] ide-gd: stop using the disk events mechanism
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (12 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 13/19] ide-cd: remove idecd_revalidate_disk Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:32   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 15/19] md: use bdev_check_media_change Christoph Hellwig
                   ` (5 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel

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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 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(-)

diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 1d3407d7e095fa..34b9441084f84f 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -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)
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index af7503b47dbe32..f5a2870aaf54bb 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -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)
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 05c26986637ba3..661e2aa9c96784 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -225,8 +225,12 @@ static int ide_gd_open(struct block_device *bdev, fmode_t mode)
 		 * and the door_lock is irrelevant at this point.
 		 */
 		drive->disk_ops->set_doorlock(drive, disk, 1);
-		drive->dev_flags |= IDE_DFLAG_MEDIA_CHANGED;
-		check_disk_change(bdev);
+		if (__invalidate_device(bdev, true))
+			pr_warn("VFS: busy inodes on changed media %s\n",
+				bdev->bd_disk->disk_name);
+		drive->disk_ops->get_capacity(drive);
+		set_capacity(disk, ide_gd_capacity(drive));
+		set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
 	} else if (drive->dev_flags & IDE_DFLAG_FORMAT_IN_PROGRESS) {
 		ret = -EBUSY;
 		goto out_put_idkp;
@@ -284,32 +288,6 @@ static int ide_gd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
 	return 0;
 }
 
-static unsigned int ide_gd_check_events(struct gendisk *disk,
-					unsigned int clearing)
-{
-	struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
-	ide_drive_t *drive = idkp->drive;
-	bool ret;
-
-	/* do not scan partitions twice if this is a removable device */
-	if (drive->dev_flags & IDE_DFLAG_ATTACH) {
-		drive->dev_flags &= ~IDE_DFLAG_ATTACH;
-		return 0;
-	}
-
-	/*
-	 * The following is used to force revalidation on the first open on
-	 * removeable devices, and never gets reported to userland as
-	 * DISK_EVENT_FLAG_UEVENT isn't set in genhd->event_flags.
-	 * This is intended as removable ide disk can't really detect
-	 * MEDIA_CHANGE events.
-	 */
-	ret = drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED;
-	drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
-
-	return ret ? DISK_EVENT_MEDIA_CHANGE : 0;
-}
-
 static void ide_gd_unlock_native_capacity(struct gendisk *disk)
 {
 	struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
@@ -320,18 +298,6 @@ static void ide_gd_unlock_native_capacity(struct gendisk *disk)
 		disk_ops->unlock_native_capacity(drive);
 }
 
-static int ide_gd_revalidate_disk(struct gendisk *disk)
-{
-	struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
-	ide_drive_t *drive = idkp->drive;
-
-	if (ide_gd_check_events(disk, 0))
-		drive->disk_ops->get_capacity(drive);
-
-	set_capacity(disk, ide_gd_capacity(drive));
-	return 0;
-}
-
 static int ide_gd_ioctl(struct block_device *bdev, fmode_t mode,
 			     unsigned int cmd, unsigned long arg)
 {
@@ -364,9 +330,7 @@ static const struct block_device_operations ide_gd_ops = {
 	.compat_ioctl		= ide_gd_compat_ioctl,
 #endif
 	.getgeo			= ide_gd_getgeo,
-	.check_events		= ide_gd_check_events,
 	.unlock_native_capacity	= ide_gd_unlock_native_capacity,
-	.revalidate_disk	= ide_gd_revalidate_disk
 };
 
 static int ide_gd_probe(ide_drive_t *drive)
diff --git a/include/linux/ide.h b/include/linux/ide.h
index a254841bd3156d..62653769509f89 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -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),
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 15/19] md: use bdev_check_media_change
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (13 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 14/19] ide-gd: stop using the disk events mechanism Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  0:49   ` Song Liu
  2020-09-09  7:34   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 16/19] sd: " Christoph Hellwig
                   ` (4 subsequent siblings)
  19 siblings, 2 replies; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

The md driver does not have a ->revalidate_disk method, so it can just
use bdev_check_media_change without any additional changes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/md/md.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 9562ef598ae1f4..27ed61197014ef 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -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


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 16/19] sd: use bdev_check_media_change
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (14 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 15/19] md: use bdev_check_media_change Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:36   ` Hannes Reinecke
  2020-09-09  7:52   ` Sergei Shtylyov
  2020-09-08 14:53 ` [PATCH 17/19] sr: " Christoph Hellwig
                   ` (3 subsequent siblings)
  19 siblings, 2 replies; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

Switch 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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/scsi/sd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 2bec8cd526164d..d020639c28c6ca 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -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,
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 17/19] sr: use bdev_check_media_change
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (15 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 16/19] sd: " Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:37   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 18/19] sr: simplify sr_block_revalidate_disk Christoph Hellwig
                   ` (2 subsequent siblings)
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

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 <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 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(&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,
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 18/19] sr: simplify sr_block_revalidate_disk
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (16 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 17/19] sr: " Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:38   ` Hannes Reinecke
  2020-09-08 14:53 ` [PATCH 19/19] block: remove check_disk_change Christoph Hellwig
  2020-09-10 15:54 ` rework check_disk_change() v2 Jens Axboe
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

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 <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/scsi/sr.c | 36 +++++++++++++-----------------------
 1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 34be94b62523fa..2b43c0f97442d4 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -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,
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 19/19] block: remove check_disk_change
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (17 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 18/19] sr: simplify sr_block_revalidate_disk Christoph Hellwig
@ 2020-09-08 14:53 ` Christoph Hellwig
  2020-09-09  7:39   ` Hannes Reinecke
  2020-09-10 15:54 ` rework check_disk_change() v2 Jens Axboe
  19 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

Remove the now unused check_disk_change helper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/block_dev.c        | 20 --------------------
 include/linux/genhd.h |  1 -
 2 files changed, 21 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index c6ac0bd22eca70..0b34955b9e360f 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -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);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 322d48a207728a..1c97cf84f011a7 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -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);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* Re: [PATCH 15/19] md: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 15/19] md: use bdev_check_media_change Christoph Hellwig
@ 2020-09-09  0:49   ` Song Liu
  2020-09-09  7:34   ` Hannes Reinecke
  1 sibling, 0 replies; 46+ messages in thread
From: Song Liu @ 2020-09-09  0:49 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Denis Efremov, Tim Waugh, Michal Simek,
	Borislav Petkov, David S. Miller, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, open list, linux-ide,
	linux-raid, linux-scsi, Linux-Fsdevel, Johannes Thumshirn

On Tue, Sep 8, 2020 at 7:55 AM Christoph Hellwig <hch@lst.de> wrote:
>
> The md driver does not have a ->revalidate_disk method, so it can just
> use bdev_check_media_change without any additional changes.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Acked-by: Song Liu <song@kernel.org>

> ---
>  drivers/md/md.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 9562ef598ae1f4..27ed61197014ef 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 04/19] floppy: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 04/19] floppy: " Christoph Hellwig
@ 2020-09-09  6:52   ` Johannes Thumshirn
  2020-09-09  7:00   ` Hannes Reinecke
  1 sibling, 0 replies; 46+ messages in thread
From: Johannes Thumshirn @ 2020-09-09  6:52 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 01/19] block: add a bdev_check_media_change helper
  2020-09-08 14:53 ` [PATCH 01/19] block: add a bdev_check_media_change helper Christoph Hellwig
@ 2020-09-09  6:59   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  6:59 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> Like check_disk_changed, except that it does not call ->revalidate_disk
> but leaves that to the caller.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  block/genhd.c         | 29 ++++++++++++++++++++++++++++-
>  fs/block_dev.c        | 17 +++--------------
>  include/linux/genhd.h |  2 +-
>  3 files changed, 32 insertions(+), 16 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 02/19] amiflop: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 02/19] amiflop: use bdev_check_media_change Christoph Hellwig
@ 2020-09-09  6:59   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  6:59 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> The Amiga floppy driver does not have a ->revalidate_disk method, so it
> can just use bdev_check_media_change without any additional changes.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/block/amiflop.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
> index 226219da3da6a7..71c2b156455860 100644
> --- a/drivers/block/amiflop.c
> +++ b/drivers/block/amiflop.c
> @@ -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;
>  
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 03/19] ataflop: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 03/19] ataflop: " Christoph Hellwig
@ 2020-09-09  7:00   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:00 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> Switch 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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/block/ataflop.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 04/19] floppy: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 04/19] floppy: " Christoph Hellwig
  2020-09-09  6:52   ` Johannes Thumshirn
@ 2020-09-09  7:00   ` Hannes Reinecke
  1 sibling, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:00 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> Switch 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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/block/floppy.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 05/19] swim: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 05/19] swim: " Christoph Hellwig
@ 2020-09-09  7:01   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:01 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> Switch 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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/block/swim.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 06/19] swim: simplify media change handling
  2020-09-08 14:53 ` [PATCH 06/19] swim: simplify media change handling Christoph Hellwig
@ 2020-09-09  7:09   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:09 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> floppy_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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/block/swim.c | 24 ++----------------------
>  1 file changed, 2 insertions(+), 22 deletions(-)
> 
What a convoluted driver.

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 07/19] swim3: use bdev_check_media_changed
  2020-09-08 14:53 ` [PATCH 07/19] swim3: use bdev_check_media_changed Christoph Hellwig
@ 2020-09-09  7:10   ` Hannes Reinecke
  2020-09-09  7:50   ` Sergei Shtylyov
  1 sibling, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:10 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> Switch 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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/block/swim3.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 08/19] xsysace: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 08/19] xsysace: use bdev_check_media_change Christoph Hellwig
@ 2020-09-09  7:10   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:10 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> Switch 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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/block/xsysace.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 09/19] xsysace: simplify media change handling
  2020-09-08 14:53 ` [PATCH 09/19] xsysace: simplify media change handling Christoph Hellwig
@ 2020-09-09  7:10   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:10 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> Pass 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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/block/xsysace.c | 26 ++++++++++----------------
>  1 file changed, 10 insertions(+), 16 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 10/19] paride/pcd: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 10/19] paride/pcd: use bdev_check_media_change Christoph Hellwig
@ 2020-09-09  7:26   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:26 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> The pcd driver does not have a ->revalidate_disk method, so it can just
> use bdev_check_media_change without any additional changes.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/block/paride/pcd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
> index 5124eca90e8337..70da8b86ce587d 100644
> --- a/drivers/block/paride/pcd.c
> +++ b/drivers/block/paride/pcd.c
> @@ -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);
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 11/19] gdrom: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 11/19] gdrom: " Christoph Hellwig
@ 2020-09-09  7:27   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:27 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> The Sega GD-ROM driver does not have a ->revalidate_disk method, so it
> can just use bdev_check_media_change without any additional changes.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/cdrom/gdrom.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
> index 09b0cd292720fa..9874fc1c815b53 100644
> --- a/drivers/cdrom/gdrom.c
> +++ b/drivers/cdrom/gdrom.c
> @@ -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);
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 12/19] ide-cd: use bdev_check_media_changed
  2020-09-08 14:53 ` [PATCH 12/19] ide-cd: use bdev_check_media_changed Christoph Hellwig
@ 2020-09-09  7:27   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:27 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> Switch 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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/ide/ide-cd.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 13/19] ide-cd: remove idecd_revalidate_disk
  2020-09-08 14:53 ` [PATCH 13/19] ide-cd: remove idecd_revalidate_disk Christoph Hellwig
@ 2020-09-09  7:28   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:28 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> Just merge the trivial function into its only caller.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/ide/ide-cd.c | 17 +++++------------
>  1 file changed, 5 insertions(+), 12 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 14/19] ide-gd: stop using the disk events mechanism
  2020-09-08 14:53 ` [PATCH 14/19] ide-gd: stop using the disk events mechanism Christoph Hellwig
@ 2020-09-09  7:32   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:32 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> 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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  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(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 15/19] md: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 15/19] md: use bdev_check_media_change Christoph Hellwig
  2020-09-09  0:49   ` Song Liu
@ 2020-09-09  7:34   ` Hannes Reinecke
  1 sibling, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:34 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> The md driver does not have a ->revalidate_disk method, so it can just
> use bdev_check_media_change without any additional changes.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/md/md.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 9562ef598ae1f4..27ed61197014ef 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -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);
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 16/19] sd: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 16/19] sd: " Christoph Hellwig
@ 2020-09-09  7:36   ` Hannes Reinecke
  2020-09-09  7:52   ` Sergei Shtylyov
  1 sibling, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:36 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> Switch 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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/scsi/sd.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 17/19] sr: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 17/19] sr: " Christoph Hellwig
@ 2020-09-09  7:37   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:37 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

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 <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/scsi/sr.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 18/19] sr: simplify sr_block_revalidate_disk
  2020-09-08 14:53 ` [PATCH 18/19] sr: simplify sr_block_revalidate_disk Christoph Hellwig
@ 2020-09-09  7:38   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:38 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> 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 <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/scsi/sr.c | 36 +++++++++++++-----------------------
>  1 file changed, 13 insertions(+), 23 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 19/19] block: remove check_disk_change
  2020-09-08 14:53 ` [PATCH 19/19] block: remove check_disk_change Christoph Hellwig
@ 2020-09-09  7:39   ` Hannes Reinecke
  0 siblings, 0 replies; 46+ messages in thread
From: Hannes Reinecke @ 2020-09-09  7:39 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 9/8/20 4:53 PM, Christoph Hellwig wrote:
> Remove the now unused check_disk_change helper.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  fs/block_dev.c        | 20 --------------------
>  include/linux/genhd.h |  1 -
>  2 files changed, 21 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 07/19] swim3: use bdev_check_media_changed
  2020-09-08 14:53 ` [PATCH 07/19] swim3: use bdev_check_media_changed Christoph Hellwig
  2020-09-09  7:10   ` Hannes Reinecke
@ 2020-09-09  7:50   ` Sergei Shtylyov
  1 sibling, 0 replies; 46+ messages in thread
From: Sergei Shtylyov @ 2020-09-09  7:50 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

Hello!

On 08.09.2020 17:53, Christoph Hellwig wrote:

> Switch to use bdev_check_media_changed instead of check_disk_change and
             ^^^
    Using?

> 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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 16/19] sd: use bdev_check_media_change
  2020-09-08 14:53 ` [PATCH 16/19] sd: " Christoph Hellwig
  2020-09-09  7:36   ` Hannes Reinecke
@ 2020-09-09  7:52   ` Sergei Shtylyov
  1 sibling, 0 replies; 46+ messages in thread
From: Sergei Shtylyov @ 2020-09-09  7:52 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel,
	Johannes Thumshirn

On 08.09.2020 17:53, Christoph Hellwig wrote:

> Switch 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

    Too many commas. :-)

> from bdev_disk_changed is not required either, so stop wiring up the
> method.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: rework check_disk_change() v2
  2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
                   ` (18 preceding siblings ...)
  2020-09-08 14:53 ` [PATCH 19/19] block: remove check_disk_change Christoph Hellwig
@ 2020-09-10 15:54 ` Jens Axboe
  19 siblings, 0 replies; 46+ messages in thread
From: Jens Axboe @ 2020-09-10 15:54 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel

On 9/8/20 8:53 AM, Christoph Hellwig wrote:
> 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.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 17/19] sr: use bdev_check_media_change
  2020-09-02 14:12 ` [PATCH 17/19] sr: use bdev_check_media_change Christoph Hellwig
@ 2020-09-02 15:52   ` Johannes Thumshirn
  0 siblings, 0 replies; 46+ messages in thread
From: Johannes Thumshirn @ 2020-09-02 15:52 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 46+ messages in thread

* [PATCH 17/19] sr: use bdev_check_media_change
  2020-09-02 14:11 rework check_disk_change() Christoph Hellwig
@ 2020-09-02 14:12 ` Christoph Hellwig
  2020-09-02 15:52   ` Johannes Thumshirn
  0 siblings, 1 reply; 46+ messages in thread
From: Christoph Hellwig @ 2020-09-02 14:12 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Denis Efremov, Tim Waugh, Michal Simek, Borislav Petkov,
	David S. Miller, Song Liu, Martin K. Petersen, Finn Thain,
	Michael Schmitz, linux-m68k, linux-block, linux-kernel,
	linux-ide, linux-raid, linux-scsi, linux-fsdevel

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 <hch@lst.de>
---
 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(&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,
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2020-09-10 19:18 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
2020-09-08 14:53 ` [PATCH 01/19] block: add a bdev_check_media_change helper Christoph Hellwig
2020-09-09  6:59   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 02/19] amiflop: use bdev_check_media_change Christoph Hellwig
2020-09-09  6:59   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 03/19] ataflop: " Christoph Hellwig
2020-09-09  7:00   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 04/19] floppy: " Christoph Hellwig
2020-09-09  6:52   ` Johannes Thumshirn
2020-09-09  7:00   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 05/19] swim: " Christoph Hellwig
2020-09-09  7:01   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 06/19] swim: simplify media change handling Christoph Hellwig
2020-09-09  7:09   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 07/19] swim3: use bdev_check_media_changed Christoph Hellwig
2020-09-09  7:10   ` Hannes Reinecke
2020-09-09  7:50   ` Sergei Shtylyov
2020-09-08 14:53 ` [PATCH 08/19] xsysace: use bdev_check_media_change Christoph Hellwig
2020-09-09  7:10   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 09/19] xsysace: simplify media change handling Christoph Hellwig
2020-09-09  7:10   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 10/19] paride/pcd: use bdev_check_media_change Christoph Hellwig
2020-09-09  7:26   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 11/19] gdrom: " Christoph Hellwig
2020-09-09  7:27   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 12/19] ide-cd: use bdev_check_media_changed Christoph Hellwig
2020-09-09  7:27   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 13/19] ide-cd: remove idecd_revalidate_disk Christoph Hellwig
2020-09-09  7:28   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 14/19] ide-gd: stop using the disk events mechanism Christoph Hellwig
2020-09-09  7:32   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 15/19] md: use bdev_check_media_change Christoph Hellwig
2020-09-09  0:49   ` Song Liu
2020-09-09  7:34   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 16/19] sd: " Christoph Hellwig
2020-09-09  7:36   ` Hannes Reinecke
2020-09-09  7:52   ` Sergei Shtylyov
2020-09-08 14:53 ` [PATCH 17/19] sr: " Christoph Hellwig
2020-09-09  7:37   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 18/19] sr: simplify sr_block_revalidate_disk Christoph Hellwig
2020-09-09  7:38   ` Hannes Reinecke
2020-09-08 14:53 ` [PATCH 19/19] block: remove check_disk_change Christoph Hellwig
2020-09-09  7:39   ` Hannes Reinecke
2020-09-10 15:54 ` rework check_disk_change() v2 Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2020-09-02 14:11 rework check_disk_change() Christoph Hellwig
2020-09-02 14:12 ` [PATCH 17/19] sr: use bdev_check_media_change Christoph Hellwig
2020-09-02 15:52   ` Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).