linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Denis Efremov <efremov@linux.com>, Tim Waugh <tim@cyberelk.net>,
	Michal Simek <michal.simek@xilinx.com>,
	Borislav Petkov <bp@alien8.de>,
	"David S. Miller" <davem@davemloft.net>,
	Song Liu <song@kernel.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Finn Thain <fthain@telegraphics.com.au>,
	Michael Schmitz <schmitzmic@gmail.com>,
	linux-m68k@lists.linux-m68k.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org,
	linux-raid@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: [PATCH 14/19] ide-gd: stop using the disk events mechanism
Date: Wed,  2 Sep 2020 16:12:13 +0200	[thread overview]
Message-ID: <20200902141218.212614-15-hch@lst.de> (raw)
In-Reply-To: <20200902141218.212614-1-hch@lst.de>

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


  parent reply	other threads:[~2020-09-02 14:43 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-02 14:11 rework check_disk_change() Christoph Hellwig
2020-09-02 14:12 ` [PATCH 01/19] block: add a bdev_check_media_change helper Christoph Hellwig
2020-09-02 15:17   ` Johannes Thumshirn
2020-09-02 14:12 ` [PATCH 02/19] amiflop: use bdev_check_media_change Christoph Hellwig
2020-09-02 15:19   ` Johannes Thumshirn
2020-09-02 14:12 ` [PATCH 03/19] ataflop: " Christoph Hellwig
2020-09-02 15:22   ` Johannes Thumshirn
2020-09-02 14:12 ` [PATCH 04/19] floppy: " Christoph Hellwig
2020-09-02 15:24   ` Johannes Thumshirn
2020-09-02 14:12 ` [PATCH 05/19] swim: " Christoph Hellwig
2020-09-02 15:30   ` Johannes Thumshirn
2020-09-02 15:31     ` Christoph Hellwig
2020-09-02 14:12 ` [PATCH 06/19] swim: simplify media change handling Christoph Hellwig
2020-09-02 15:33   ` Johannes Thumshirn
2020-09-02 14:12 ` [PATCH 07/19] swim3: use bdev_check_media_changed Christoph Hellwig
2020-09-02 15:41   ` Johannes Thumshirn
2020-09-02 14:12 ` [PATCH 08/19] xsysace: use bdev_check_media_change Christoph Hellwig
2020-09-02 15:41   ` Johannes Thumshirn
2020-09-02 14:12 ` [PATCH 09/19] xsysace: simplify media change handling Christoph Hellwig
2020-09-02 14:12 ` [PATCH 10/19] paride/pcd: use bdev_check_media_change Christoph Hellwig
2020-09-02 15:44   ` Johannes Thumshirn
2020-09-02 14:12 ` [PATCH 11/19] gdrom: " Christoph Hellwig
2020-09-02 15:44   ` Johannes Thumshirn
2020-09-02 22:00   ` antlists
2020-09-08 14:23     ` Christoph Hellwig
2020-09-02 14:12 ` [PATCH 12/19] ide-cd: use bdev_check_media_changed Christoph Hellwig
2020-09-02 15:47   ` Johannes Thumshirn
2020-09-02 14:12 ` [PATCH 13/19] ide-cd: remove idecd_revalidate_disk Christoph Hellwig
2020-09-02 15:48   ` Johannes Thumshirn
2020-09-02 14:12 ` Christoph Hellwig [this message]
2020-09-02 14:12 ` [PATCH 15/19] md: use bdev_check_media_change Christoph Hellwig
2020-09-02 15:50   ` Johannes Thumshirn
2020-09-02 16:15   ` Sergei Shtylyov
2020-09-02 14:12 ` [PATCH 16/19] sd: " Christoph Hellwig
2020-09-02 15:51   ` Johannes Thumshirn
2020-09-02 16:19   ` Sergei Shtylyov
2020-09-02 14:12 ` [PATCH 17/19] sr: " Christoph Hellwig
2020-09-02 15:52   ` Johannes Thumshirn
2020-09-02 14:12 ` [PATCH 18/19] sr: simplify sr_block_revalidate_disk Christoph Hellwig
2020-09-02 15:53   ` Johannes Thumshirn
2020-09-02 14:12 ` [PATCH 19/19] block: remove check_disk_change Christoph Hellwig
2020-09-02 15:54   ` Johannes Thumshirn
2020-09-02 15:38 ` rework check_disk_change() Douglas Gilbert
2020-09-04  9:23   ` Hannes Reinecke
2020-09-08 14:53 rework check_disk_change() v2 Christoph Hellwig
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200902141218.212614-15-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=bp@alien8.de \
    --cc=davem@davemloft.net \
    --cc=efremov@linux.com \
    --cc=fthain@telegraphics.com.au \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=michal.simek@xilinx.com \
    --cc=schmitzmic@gmail.com \
    --cc=song@kernel.org \
    --cc=tim@cyberelk.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).