linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* remove leftovers of the old ->media_changed method
@ 2020-07-08 12:25 Christoph Hellwig
  2020-07-08 12:25 ` [PATCH 1/6] md: switch to ->check_events for media change notifications Christoph Hellwig
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Christoph Hellwig @ 2020-07-08 12:25 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Song Liu, Ulf Hansson, linux-kernel, linux-xtensa, linux-block,
	linux-raid, linux-mmc, linux-fsdevel

Hi Jens,

this series converts md as the last user of the ->media_changed method
over to the modern replacement, and then cleans up a few lose ends in
the area.

Diffstat:
 Documentation/cdrom/cdrom-standard.rst |   18 +-----------------
 Documentation/filesystems/locking.rst  |    4 +---
 arch/xtensa/platforms/iss/simdisk.c    |    2 --
 block/genhd.c                          |    7 +------
 drivers/cdrom/cdrom.c                  |   28 +++++-----------------------
 drivers/md/md.c                        |   19 ++++++++-----------
 drivers/mmc/core/block.c               |    3 ---
 fs/block_dev.c                         |   30 +++++++-----------------------
 fs/isofs/inode.c                       |    3 ---
 include/linux/blkdev.h                 |    2 --
 include/linux/cdrom.h                  |    2 --
 11 files changed, 23 insertions(+), 95 deletions(-)

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

* [PATCH 1/6] md: switch to ->check_events for media change notifications
  2020-07-08 12:25 remove leftovers of the old ->media_changed method Christoph Hellwig
@ 2020-07-08 12:25 ` Christoph Hellwig
  2020-07-08 13:17   ` Guoqing Jiang
  2020-07-08 12:25 ` [PATCH 2/6] cdrom: remove the unused cdrom_media_changed function Christoph Hellwig
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2020-07-08 12:25 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Song Liu, Ulf Hansson, linux-kernel, linux-xtensa, linux-block,
	linux-raid, linux-mmc, linux-fsdevel

md is the last driver using the legacy media_changed method.  Switch
it over to (not so) new ->clear_events approach, which also removes the
need for the ->revalidate_disk method.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 Documentation/filesystems/locking.rst |  4 +---
 block/genhd.c                         |  7 +------
 drivers/md/md.c                       | 19 ++++++++-----------
 include/linux/blkdev.h                |  2 --
 4 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index 318605de83f33c..17bea12538c32d 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -467,7 +467,6 @@ prototypes::
 	int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
 	int (*direct_access) (struct block_device *, sector_t, void **,
 				unsigned long *);
-	int (*media_changed) (struct gendisk *);
 	void (*unlock_native_capacity) (struct gendisk *);
 	int (*revalidate_disk) (struct gendisk *);
 	int (*getgeo)(struct block_device *, struct hd_geometry *);
@@ -483,14 +482,13 @@ release:		yes
 ioctl:			no
 compat_ioctl:		no
 direct_access:		no
-media_changed:		no
 unlock_native_capacity:	no
 revalidate_disk:	no
 getgeo:			no
 swap_slot_free_notify:	no	(see below)
 ======================= ===================
 
-media_changed, unlock_native_capacity and revalidate_disk are called only from
+unlock_native_capacity and revalidate_disk are called only from
 check_disk_change().
 
 swap_slot_free_notify is called with swap_lock and sometimes the page lock
diff --git a/block/genhd.c b/block/genhd.c
index 60ae4e1b4d3877..1070da9d4d9a77 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -2061,13 +2061,8 @@ unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask)
 	unsigned int pending;
 	unsigned int clearing = mask;
 
-	if (!ev) {
-		/* for drivers still using the old ->media_changed method */
-		if ((mask & DISK_EVENT_MEDIA_CHANGE) &&
-		    bdops->media_changed && bdops->media_changed(disk))
-			return DISK_EVENT_MEDIA_CHANGE;
+	if (!ev)
 		return 0;
-	}
 
 	disk_block_events(disk);
 
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 8bb69c61afe086..77dfe4765c3111 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5670,6 +5670,7 @@ static int md_alloc(dev_t dev, char *name)
 	 * remove it now.
 	 */
 	disk->flags |= GENHD_FL_EXT_DEVT;
+	disk->events |= DISK_EVENT_MEDIA_CHANGE;
 	mddev->gendisk = disk;
 	/* As soon as we call add_disk(), another thread could get
 	 * through to md_open, so make sure it doesn't get too far
@@ -7806,20 +7807,17 @@ static void md_release(struct gendisk *disk, fmode_t mode)
 	mddev_put(mddev);
 }
 
-static int md_media_changed(struct gendisk *disk)
-{
-	struct mddev *mddev = disk->private_data;
-
-	return mddev->changed;
-}
-
-static int md_revalidate(struct gendisk *disk)
+static unsigned int md_check_events(struct gendisk *disk, unsigned int clearing)
 {
 	struct mddev *mddev = disk->private_data;
+	unsigned int ret = 0;
 
+	if (mddev->changed)
+		ret = DISK_EVENT_MEDIA_CHANGE;
 	mddev->changed = 0;
-	return 0;
+	return ret;
 }
+
 static const struct block_device_operations md_fops =
 {
 	.owner		= THIS_MODULE,
@@ -7831,8 +7829,7 @@ static const struct block_device_operations md_fops =
 	.compat_ioctl	= md_compat_ioctl,
 #endif
 	.getgeo		= md_getgeo,
-	.media_changed  = md_media_changed,
-	.revalidate_disk= md_revalidate,
+	.check_events	= md_check_events,
 };
 
 static int md_thread(void *arg)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 408eb66a82fdc7..71173a1ffa8b87 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1781,8 +1781,6 @@ struct block_device_operations {
 	int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
 	unsigned int (*check_events) (struct gendisk *disk,
 				      unsigned int clearing);
-	/* ->media_changed() is DEPRECATED, use ->check_events() instead */
-	int (*media_changed) (struct gendisk *);
 	void (*unlock_native_capacity) (struct gendisk *);
 	int (*revalidate_disk) (struct gendisk *);
 	int (*getgeo)(struct block_device *, struct hd_geometry *);
-- 
2.26.2


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

* [PATCH 2/6] cdrom: remove the unused cdrom_media_changed function
  2020-07-08 12:25 remove leftovers of the old ->media_changed method Christoph Hellwig
  2020-07-08 12:25 ` [PATCH 1/6] md: switch to ->check_events for media change notifications Christoph Hellwig
@ 2020-07-08 12:25 ` Christoph Hellwig
  2020-07-08 12:25 ` [PATCH 3/6] block: remove flush_disk Christoph Hellwig
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2020-07-08 12:25 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Song Liu, Ulf Hansson, linux-kernel, linux-xtensa, linux-block,
	linux-raid, linux-mmc, linux-fsdevel

As well as the ->media_changed method.  All these are left over from
before the drivers were switched over to the check_events scheme.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 Documentation/cdrom/cdrom-standard.rst | 18 +----------------
 drivers/cdrom/cdrom.c                  | 28 +++++---------------------
 include/linux/cdrom.h                  |  2 --
 3 files changed, 6 insertions(+), 42 deletions(-)

diff --git a/Documentation/cdrom/cdrom-standard.rst b/Documentation/cdrom/cdrom-standard.rst
index dde4f7f7fdbf1c..2de90581059033 100644
--- a/Documentation/cdrom/cdrom-standard.rst
+++ b/Documentation/cdrom/cdrom-standard.rst
@@ -157,7 +157,6 @@ with the kernel as a block device by registering the following general
 		cdrom_release,		/∗ release ∗/
 		NULL,			/∗ fsync ∗/
 		NULL,			/∗ fasync ∗/
-		cdrom_media_changed,	/∗ media change ∗/
 		NULL			/∗ revalidate ∗/
 	};
 
@@ -366,19 +365,6 @@ which may or may not be in the drive). If the drive is not a changer,
 	CDS_DRIVE_NOT_READY	/* something is wrong, tray is moving? */
 	CDS_DISC_OK		/* a disc is loaded and everything is fine */
 
-::
-
-	int media_changed(struct cdrom_device_info *cdi, int disc_nr)
-
-This function is very similar to the original function in $struct
-file_operations*. It returns 1 if the medium of the device *cdi->dev*
-has changed since the last call, and 0 otherwise. The parameter
-*disc_nr* identifies a specific slot in a juke-box, it should be
-ignored for single-disc drives. Note that by `re-routing` this
-function through *cdrom_media_changed()*, we can implement separate
-queues for the VFS and a new *ioctl()* function that can report device
-changes to software (e. g., an auto-mounting daemon).
-
 ::
 
 	int tray_move(struct cdrom_device_info *cdi, int position)
@@ -917,9 +903,7 @@ commands can be identified by the underscores in their names.
 	maximum number of discs in the juke-box found in the *cdrom_dops*.
 `CDROM_MEDIA_CHANGED`
 	Returns 1 if a disc has been changed since the last call.
-	Note that calls to *cdrom_media_changed* by the VFS are treated
-	by an independent queue, so both mechanisms will detect a
-	media change once. For juke-boxes, an extra argument *arg*
+	For juke-boxes, an extra argument *arg*
 	specifies the slot for which the information is given. The special
 	value *CDSL_CURRENT* requests that information about the currently
 	selected slot be returned.
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index d82b3b7658bddc..0c271b9e3c5b79 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -605,7 +605,7 @@ int register_cdrom(struct gendisk *disk, struct cdrom_device_info *cdi)
 	disk->cdi = cdi;
 
 	ENSURE(cdo, drive_status, CDC_DRIVE_STATUS);
-	if (cdo->check_events == NULL && cdo->media_changed == NULL)
+	if (cdo->check_events == NULL)
 		WARN_ON_ONCE(cdo->capability & (CDC_MEDIA_CHANGED | CDC_SELECT_DISC));
 	ENSURE(cdo, tray_move, CDC_CLOSE_TRAY | CDC_OPEN_TRAY);
 	ENSURE(cdo, lock_door, CDC_LOCK);
@@ -1419,8 +1419,6 @@ static int cdrom_select_disc(struct cdrom_device_info *cdi, int slot)
 
 	if (cdi->ops->check_events)
 		cdi->ops->check_events(cdi, 0, slot);
-	else
-		cdi->ops->media_changed(cdi, slot);
 
 	if (slot == CDSL_NONE) {
 		/* set media changed bits, on both queues */
@@ -1517,13 +1515,10 @@ int media_changed(struct cdrom_device_info *cdi, int queue)
 		return ret;
 
 	/* changed since last call? */
-	if (cdi->ops->check_events) {
-		BUG_ON(!queue);	/* shouldn't be called from VFS path */
-		cdrom_update_events(cdi, DISK_EVENT_MEDIA_CHANGE);
-		changed = cdi->ioctl_events & DISK_EVENT_MEDIA_CHANGE;
-		cdi->ioctl_events = 0;
-	} else
-		changed = cdi->ops->media_changed(cdi, CDSL_CURRENT);
+	BUG_ON(!queue);	/* shouldn't be called from VFS path */
+	cdrom_update_events(cdi, DISK_EVENT_MEDIA_CHANGE);
+	changed = cdi->ioctl_events & DISK_EVENT_MEDIA_CHANGE;
+	cdi->ioctl_events = 0;
 
 	if (changed) {
 		cdi->mc_flags = 0x3;    /* set bit on both queues */
@@ -1535,18 +1530,6 @@ int media_changed(struct cdrom_device_info *cdi, int queue)
 	return ret;
 }
 
-int cdrom_media_changed(struct cdrom_device_info *cdi)
-{
-	/* This talks to the VFS, which doesn't like errors - just 1 or 0.  
-	 * Returning "0" is always safe (media hasn't been changed). Do that 
-	 * if the low-level cdrom driver dosn't support media changed. */ 
-	if (cdi == NULL || cdi->ops->media_changed == NULL)
-		return 0;
-	if (!CDROM_CAN(CDC_MEDIA_CHANGED))
-		return 0;
-	return media_changed(cdi, 0);
-}
-
 /* Requests to the low-level drivers will /always/ be done in the
    following format convention:
 
@@ -3464,7 +3447,6 @@ EXPORT_SYMBOL(unregister_cdrom);
 EXPORT_SYMBOL(cdrom_open);
 EXPORT_SYMBOL(cdrom_release);
 EXPORT_SYMBOL(cdrom_ioctl);
-EXPORT_SYMBOL(cdrom_media_changed);
 EXPORT_SYMBOL(cdrom_number_of_slots);
 EXPORT_SYMBOL(cdrom_mode_select);
 EXPORT_SYMBOL(cdrom_mode_sense);
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index 8543fa59da7207..f48d0a31deaece 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -73,7 +73,6 @@ struct cdrom_device_ops {
 	int (*drive_status) (struct cdrom_device_info *, int);
 	unsigned int (*check_events) (struct cdrom_device_info *cdi,
 				      unsigned int clearing, int slot);
-	int (*media_changed) (struct cdrom_device_info *, int);
 	int (*tray_move) (struct cdrom_device_info *, int);
 	int (*lock_door) (struct cdrom_device_info *, int);
 	int (*select_speed) (struct cdrom_device_info *, int);
@@ -107,7 +106,6 @@ extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,
 		       fmode_t mode, unsigned int cmd, unsigned long arg);
 extern unsigned int cdrom_check_events(struct cdrom_device_info *cdi,
 				       unsigned int clearing);
-extern int cdrom_media_changed(struct cdrom_device_info *);
 
 extern int register_cdrom(struct gendisk *disk, struct cdrom_device_info *cdi);
 extern void unregister_cdrom(struct cdrom_device_info *cdi);
-- 
2.26.2


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

* [PATCH 3/6] block: remove flush_disk
  2020-07-08 12:25 remove leftovers of the old ->media_changed method Christoph Hellwig
  2020-07-08 12:25 ` [PATCH 1/6] md: switch to ->check_events for media change notifications Christoph Hellwig
  2020-07-08 12:25 ` [PATCH 2/6] cdrom: remove the unused cdrom_media_changed function Christoph Hellwig
@ 2020-07-08 12:25 ` Christoph Hellwig
  2020-07-08 12:25 ` [PATCH 4/6] isofs: remove a stale comment Christoph Hellwig
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2020-07-08 12:25 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Song Liu, Ulf Hansson, linux-kernel, linux-xtensa, linux-block,
	linux-raid, linux-mmc, linux-fsdevel

flush_disk has only two callers, so open code it there.  That also helps
clarifying the error message for the particular case, and allows to remove
setting bd_invalidated in check_disk_size_change, which will be cleared
again instantly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/block_dev.c | 30 +++++++-----------------------
 1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 2d2fcb50e78eac..a36d5b6907ea4e 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1347,26 +1347,6 @@ void bd_unlink_disk_holder(struct block_device *bdev, struct gendisk *disk)
 EXPORT_SYMBOL_GPL(bd_unlink_disk_holder);
 #endif
 
-/**
- * flush_disk - invalidates all buffer-cache entries on a disk
- *
- * @bdev:      struct block device to be flushed
- * @kill_dirty: flag to guide handling of dirty inodes
- *
- * Invalidates all buffer-cache entries on a disk. It should be called
- * when a disk has been changed -- either by a media change or online
- * resize.
- */
-static void flush_disk(struct block_device *bdev, bool kill_dirty)
-{
-	if (__invalidate_device(bdev, kill_dirty)) {
-		printk(KERN_WARNING "VFS: busy inodes on changed media or "
-		       "resized disk %s\n",
-		       bdev->bd_disk ? bdev->bd_disk->disk_name : "");
-	}
-	bdev->bd_invalidated = 1;
-}
-
 /**
  * check_disk_size_change - checks for disk size change and adjusts bdev size.
  * @disk: struct gendisk to check
@@ -1391,8 +1371,9 @@ static void check_disk_size_change(struct gendisk *disk,
 			       disk->disk_name, bdev_size, disk_size);
 		}
 		i_size_write(bdev->bd_inode, disk_size);
-		if (bdev_size > disk_size)
-			flush_disk(bdev, false);
+		if (bdev_size > disk_size && __invalidate_device(bdev, false))
+			pr_warn("VFS: busy inodes on resized disk %s\n",
+				disk->disk_name);
 	}
 	bdev->bd_invalidated = 0;
 }
@@ -1451,7 +1432,10 @@ int check_disk_change(struct block_device *bdev)
 	if (!(events & DISK_EVENT_MEDIA_CHANGE))
 		return 0;
 
-	flush_disk(bdev, true);
+	if (__invalidate_device(bdev, true))
+		pr_warn("VFS: busy inodes on changed media %s\n",
+			disk->disk_name);
+	bdev->bd_invalidated = 1;
 	if (bdops->revalidate_disk)
 		bdops->revalidate_disk(bdev->bd_disk);
 	return 1;
-- 
2.26.2


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

* [PATCH 4/6] isofs: remove a stale comment
  2020-07-08 12:25 remove leftovers of the old ->media_changed method Christoph Hellwig
                   ` (2 preceding siblings ...)
  2020-07-08 12:25 ` [PATCH 3/6] block: remove flush_disk Christoph Hellwig
@ 2020-07-08 12:25 ` Christoph Hellwig
  2020-07-08 12:25 ` [PATCH 5/6] xtensa/simdisk: remove the call to check_disk_change Christoph Hellwig
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2020-07-08 12:25 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Song Liu, Ulf Hansson, linux-kernel, linux-xtensa, linux-block,
	linux-raid, linux-mmc, linux-fsdevel

check_disk_change isn't for consumers of the block layer, so remove
the comment mentioning it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/isofs/inode.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index d634561f871a56..78f5c96c76f31e 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -612,9 +612,6 @@ static bool rootdir_empty(struct super_block *sb, unsigned long block)
 
 /*
  * Initialize the superblock and read the root inode.
- *
- * Note: a check_disk_change() has been done immediately prior
- * to this call, so we don't need to check again.
  */
 static int isofs_fill_super(struct super_block *s, void *data, int silent)
 {
-- 
2.26.2


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

* [PATCH 5/6] xtensa/simdisk: remove the call to check_disk_change
  2020-07-08 12:25 remove leftovers of the old ->media_changed method Christoph Hellwig
                   ` (3 preceding siblings ...)
  2020-07-08 12:25 ` [PATCH 4/6] isofs: remove a stale comment Christoph Hellwig
@ 2020-07-08 12:25 ` Christoph Hellwig
  2020-07-08 12:25 ` [PATCH 6/6] mmc: " Christoph Hellwig
  2020-07-08 22:16 ` remove leftovers of the old ->media_changed method Jens Axboe
  6 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2020-07-08 12:25 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Song Liu, Ulf Hansson, linux-kernel, linux-xtensa, linux-block,
	linux-raid, linux-mmc, linux-fsdevel

The simdisk driver doesn't support event notifications, which means
that check_disk_change is a no-op.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/xtensa/platforms/iss/simdisk.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/xtensa/platforms/iss/simdisk.c b/arch/xtensa/platforms/iss/simdisk.c
index 5107140dbb7edc..3447556d276d32 100644
--- a/arch/xtensa/platforms/iss/simdisk.c
+++ b/arch/xtensa/platforms/iss/simdisk.c
@@ -127,8 +127,6 @@ static int simdisk_open(struct block_device *bdev, fmode_t mode)
 	struct simdisk *dev = bdev->bd_disk->private_data;
 
 	spin_lock(&dev->lock);
-	if (!dev->users)
-		check_disk_change(bdev);
 	++dev->users;
 	spin_unlock(&dev->lock);
 	return 0;
-- 
2.26.2


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

* [PATCH 6/6] mmc: remove the call to check_disk_change
  2020-07-08 12:25 remove leftovers of the old ->media_changed method Christoph Hellwig
                   ` (4 preceding siblings ...)
  2020-07-08 12:25 ` [PATCH 5/6] xtensa/simdisk: remove the call to check_disk_change Christoph Hellwig
@ 2020-07-08 12:25 ` Christoph Hellwig
  2020-07-08 14:17   ` Ulf Hansson
  2020-07-10  7:28   ` Ulf Hansson
  2020-07-08 22:16 ` remove leftovers of the old ->media_changed method Jens Axboe
  6 siblings, 2 replies; 15+ messages in thread
From: Christoph Hellwig @ 2020-07-08 12:25 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Song Liu, Ulf Hansson, linux-kernel, linux-xtensa, linux-block,
	linux-raid, linux-mmc, linux-fsdevel

The mmc driver doesn't support event notifications, which means
that check_disk_change is a no-op.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/mmc/core/block.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 4791c82f8f7c78..fa313b63413547 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -312,10 +312,7 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
 
 	mutex_lock(&block_mutex);
 	if (md) {
-		if (md->usage == 2)
-			check_disk_change(bdev);
 		ret = 0;
-
 		if ((mode & FMODE_WRITE) && md->read_only) {
 			mmc_blk_put(md);
 			ret = -EROFS;
-- 
2.26.2


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

* Re: [PATCH 1/6] md: switch to ->check_events for media change notifications
  2020-07-08 12:25 ` [PATCH 1/6] md: switch to ->check_events for media change notifications Christoph Hellwig
@ 2020-07-08 13:17   ` Guoqing Jiang
  2020-07-08 13:23     ` Christoph Hellwig
  2020-07-08 13:23     ` Matthew Wilcox
  0 siblings, 2 replies; 15+ messages in thread
From: Guoqing Jiang @ 2020-07-08 13:17 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Song Liu, Ulf Hansson, linux-kernel, linux-xtensa, linux-block,
	linux-raid, linux-mmc, linux-fsdevel

On 7/8/20 2:25 PM, Christoph Hellwig wrote:
> -static int md_media_changed(struct gendisk *disk)
> -{
> -	struct mddev *mddev = disk->private_data;
> -
> -	return mddev->changed;
> -}

Maybe we can remove "changed" from struct mddev since no one reads it
after the change.

Thanks,
Guoqing

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

* Re: [PATCH 1/6] md: switch to ->check_events for media change notifications
  2020-07-08 13:17   ` Guoqing Jiang
@ 2020-07-08 13:23     ` Christoph Hellwig
  2020-07-08 13:23     ` Matthew Wilcox
  1 sibling, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2020-07-08 13:23 UTC (permalink / raw)
  To: Guoqing Jiang
  Cc: Christoph Hellwig, Jens Axboe, Song Liu, Ulf Hansson,
	linux-kernel, linux-xtensa, linux-block, linux-raid, linux-mmc,
	linux-fsdevel

On Wed, Jul 08, 2020 at 03:17:31PM +0200, Guoqing Jiang wrote:
> On 7/8/20 2:25 PM, Christoph Hellwig wrote:
>> -static int md_media_changed(struct gendisk *disk)
>> -{
>> -	struct mddev *mddev = disk->private_data;
>> -
>> -	return mddev->changed;
>> -}
>
> Maybe we can remove "changed" from struct mddev since no one reads it
> after the change.

The new md_check_events method reads it.

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

* Re: [PATCH 1/6] md: switch to ->check_events for media change notifications
  2020-07-08 13:17   ` Guoqing Jiang
  2020-07-08 13:23     ` Christoph Hellwig
@ 2020-07-08 13:23     ` Matthew Wilcox
  2020-07-08 13:36       ` Guoqing Jiang
  1 sibling, 1 reply; 15+ messages in thread
From: Matthew Wilcox @ 2020-07-08 13:23 UTC (permalink / raw)
  To: Guoqing Jiang
  Cc: Christoph Hellwig, Jens Axboe, Song Liu, Ulf Hansson,
	linux-kernel, linux-xtensa, linux-block, linux-raid, linux-mmc,
	linux-fsdevel

On Wed, Jul 08, 2020 at 03:17:31PM +0200, Guoqing Jiang wrote:
> On 7/8/20 2:25 PM, Christoph Hellwig wrote:
> > -static int md_media_changed(struct gendisk *disk)
> > -{
> > -	struct mddev *mddev = disk->private_data;
> > -
> > -	return mddev->changed;
> > -}
> 
> Maybe we can remove "changed" from struct mddev since no one reads it
> after the change.

You missed this hunk:

+static unsigned int md_check_events(struct gendisk *disk, unsigned int clearing)
 {
        struct mddev *mddev = disk->private_data;
+	unsigned int ret = 0;

+	if (mddev->changed)
+               ret = DISK_EVENT_MEDIA_CHANGE;
        mddev->changed = 0;
-	return 0;
+	return ret;
 }


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

* Re: [PATCH 1/6] md: switch to ->check_events for media change notifications
  2020-07-08 13:23     ` Matthew Wilcox
@ 2020-07-08 13:36       ` Guoqing Jiang
  0 siblings, 0 replies; 15+ messages in thread
From: Guoqing Jiang @ 2020-07-08 13:36 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Christoph Hellwig, Jens Axboe, Song Liu, Ulf Hansson,
	linux-kernel, linux-xtensa, linux-block, linux-raid, linux-mmc,
	linux-fsdevel

On 7/8/20 3:23 PM, Matthew Wilcox wrote:
> On Wed, Jul 08, 2020 at 03:17:31PM +0200, Guoqing Jiang wrote:
>> On 7/8/20 2:25 PM, Christoph Hellwig wrote:
>>> -static int md_media_changed(struct gendisk *disk)
>>> -{
>>> -	struct mddev *mddev = disk->private_data;
>>> -
>>> -	return mddev->changed;
>>> -}
>> Maybe we can remove "changed" from struct mddev since no one reads it
>> after the change.
> You missed this hunk:
>
> +static unsigned int md_check_events(struct gendisk *disk, unsigned int clearing)
>   {
>          struct mddev *mddev = disk->private_data;
> +	unsigned int ret = 0;
>
> +	if (mddev->changed)
> +               ret = DISK_EVENT_MEDIA_CHANGE;
>          mddev->changed = 0;
> -	return 0;
> +	return ret;
>   }
>

Yes, sorry for the noise.

Thanks,
Guoqing


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

* Re: [PATCH 6/6] mmc: remove the call to check_disk_change
  2020-07-08 12:25 ` [PATCH 6/6] mmc: " Christoph Hellwig
@ 2020-07-08 14:17   ` Ulf Hansson
  2020-07-08 14:22     ` Christoph Hellwig
  2020-07-10  7:28   ` Ulf Hansson
  1 sibling, 1 reply; 15+ messages in thread
From: Ulf Hansson @ 2020-07-08 14:17 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Song Liu, Linux Kernel Mailing List, linux-xtensa,
	linux-block, linux-raid, linux-mmc, linux-fsdevel

On Wed, 8 Jul 2020 at 14:41, Christoph Hellwig <hch@lst.de> wrote:
>
> The mmc driver doesn't support event notifications, which means
> that check_disk_change is a no-op.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

I can queue this via my mmc tree, but perhaps you have plans for some
additional cleanups on top? In such a case, it may be better that this
goes through Jens' tree?

Kind regards
Uffe

> ---
>  drivers/mmc/core/block.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 4791c82f8f7c78..fa313b63413547 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -312,10 +312,7 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
>
>         mutex_lock(&block_mutex);
>         if (md) {
> -               if (md->usage == 2)
> -                       check_disk_change(bdev);
>                 ret = 0;
> -
>                 if ((mode & FMODE_WRITE) && md->read_only) {
>                         mmc_blk_put(md);
>                         ret = -EROFS;
> --
> 2.26.2
>

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

* Re: [PATCH 6/6] mmc: remove the call to check_disk_change
  2020-07-08 14:17   ` Ulf Hansson
@ 2020-07-08 14:22     ` Christoph Hellwig
  0 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2020-07-08 14:22 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Christoph Hellwig, Jens Axboe, Song Liu,
	Linux Kernel Mailing List, linux-xtensa, linux-block, linux-raid,
	linux-mmc, linux-fsdevel

On Wed, Jul 08, 2020 at 04:17:26PM +0200, Ulf Hansson wrote:
> On Wed, 8 Jul 2020 at 14:41, Christoph Hellwig <hch@lst.de> wrote:
> >
> > The mmc driver doesn't support event notifications, which means
> > that check_disk_change is a no-op.
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> I can queue this via my mmc tree, but perhaps you have plans for some
> additional cleanups on top? In such a case, it may be better that this
> goes through Jens' tree?

I have some vague plans.  They might or might not hit this merge window,
so if you are fine with Jens picking up the whole thing that would
avoid any potential problems.

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

* Re: remove leftovers of the old ->media_changed method
  2020-07-08 12:25 remove leftovers of the old ->media_changed method Christoph Hellwig
                   ` (5 preceding siblings ...)
  2020-07-08 12:25 ` [PATCH 6/6] mmc: " Christoph Hellwig
@ 2020-07-08 22:16 ` Jens Axboe
  6 siblings, 0 replies; 15+ messages in thread
From: Jens Axboe @ 2020-07-08 22:16 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Song Liu, Ulf Hansson, linux-kernel, linux-xtensa, linux-block,
	linux-raid, linux-mmc, linux-fsdevel

On 7/8/20 6:25 AM, Christoph Hellwig wrote:
> Hi Jens,
> 
> this series converts md as the last user of the ->media_changed method
> over to the modern replacement, and then cleans up a few lose ends in
> the area.

Applied, thanks.

-- 
Jens Axboe


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

* Re: [PATCH 6/6] mmc: remove the call to check_disk_change
  2020-07-08 12:25 ` [PATCH 6/6] mmc: " Christoph Hellwig
  2020-07-08 14:17   ` Ulf Hansson
@ 2020-07-10  7:28   ` Ulf Hansson
  1 sibling, 0 replies; 15+ messages in thread
From: Ulf Hansson @ 2020-07-10  7:28 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Song Liu, Linux Kernel Mailing List, linux-xtensa,
	linux-block, linux-raid, linux-mmc, linux-fsdevel

On Wed, 8 Jul 2020 at 14:41, Christoph Hellwig <hch@lst.de> wrote:
>
> The mmc driver doesn't support event notifications, which means
> that check_disk_change is a no-op.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Feel free to add:

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  drivers/mmc/core/block.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 4791c82f8f7c78..fa313b63413547 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -312,10 +312,7 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
>
>         mutex_lock(&block_mutex);
>         if (md) {
> -               if (md->usage == 2)
> -                       check_disk_change(bdev);
>                 ret = 0;
> -
>                 if ((mode & FMODE_WRITE) && md->read_only) {
>                         mmc_blk_put(md);
>                         ret = -EROFS;
> --
> 2.26.2
>

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

end of thread, other threads:[~2020-07-10  7:29 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08 12:25 remove leftovers of the old ->media_changed method Christoph Hellwig
2020-07-08 12:25 ` [PATCH 1/6] md: switch to ->check_events for media change notifications Christoph Hellwig
2020-07-08 13:17   ` Guoqing Jiang
2020-07-08 13:23     ` Christoph Hellwig
2020-07-08 13:23     ` Matthew Wilcox
2020-07-08 13:36       ` Guoqing Jiang
2020-07-08 12:25 ` [PATCH 2/6] cdrom: remove the unused cdrom_media_changed function Christoph Hellwig
2020-07-08 12:25 ` [PATCH 3/6] block: remove flush_disk Christoph Hellwig
2020-07-08 12:25 ` [PATCH 4/6] isofs: remove a stale comment Christoph Hellwig
2020-07-08 12:25 ` [PATCH 5/6] xtensa/simdisk: remove the call to check_disk_change Christoph Hellwig
2020-07-08 12:25 ` [PATCH 6/6] mmc: " Christoph Hellwig
2020-07-08 14:17   ` Ulf Hansson
2020-07-08 14:22     ` Christoph Hellwig
2020-07-10  7:28   ` Ulf Hansson
2020-07-08 22:16 ` remove leftovers of the old ->media_changed method Jens Axboe

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