Skip to content

Commit 7eec77a

Browse files
htejunJens Axboe
authored andcommitted
ide: unexport DISK_EVENT_MEDIA_CHANGE for ide-gd and ide-cd
check_events() implementations in both ide-gd and ide-cd are inadequate for in-kernel event polling. Both generate media change events continuously when certain conditions are met causing infinite event loop between the driver and userland event handler. As disk event now supports suppression of unlisted events, simply de-listing DISK_EVENT_MEDIA_CHANGE from disk->events resolves the problem. Internal handling around media revalidation will behave the same while userland will fall back to userland event polling after detecting the device doesn't support disk events. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Jens Axboe <jaxboe@fusionio.com> Acked-by: "David S. Miller" <davem@davemloft.net> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1 parent 7c88a16 commit 7eec77a

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

drivers/ide/ide-cd.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,6 @@ static int ide_cd_probe(ide_drive_t *drive)
17821782
ide_cd_read_toc(drive, &sense);
17831783
g->fops = &idecd_ops;
17841784
g->flags |= GENHD_FL_REMOVABLE;
1785-
g->events = DISK_EVENT_MEDIA_CHANGE;
17861785
add_disk(g);
17871786
return 0;
17881787

drivers/ide/ide-cd_ioctl.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ int ide_cdrom_drive_status(struct cdrom_device_info *cdi, int slot_nr)
7979
return CDS_DRIVE_NOT_READY;
8080
}
8181

82+
/*
83+
* ide-cd always generates media changed event if media is missing, which
84+
* makes it impossible to use for proper event reporting, so disk->events
85+
* is cleared to 0 and the following function is used only to trigger
86+
* revalidation and never propagated to userland.
87+
*/
8288
unsigned int ide_cdrom_check_events_real(struct cdrom_device_info *cdi,
8389
unsigned int clearing, int slot_nr)
8490
{

drivers/ide/ide-gd.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ static unsigned int ide_gd_check_events(struct gendisk *disk,
298298
return 0;
299299
}
300300

301+
/*
302+
* The following is used to force revalidation on the first open on
303+
* removeable devices, and never gets reported to userland as
304+
* genhd->events is 0. This is intended as removeable ide disk
305+
* can't really detect MEDIA_CHANGE events.
306+
*/
301307
ret = drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED;
302308
drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
303309

@@ -413,7 +419,6 @@ static int ide_gd_probe(ide_drive_t *drive)
413419
if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
414420
g->flags = GENHD_FL_REMOVABLE;
415421
g->fops = &ide_gd_ops;
416-
g->events = DISK_EVENT_MEDIA_CHANGE;
417422
add_disk(g);
418423
return 0;
419424

0 commit comments

Comments
 (0)