Skip to content

Commit

Permalink
block: always allocate genhd->ev if check_events is implemented
Browse files Browse the repository at this point in the history
commit 75e3f3e upstream.

9fd097b (block: unexport DISK_EVENT_MEDIA_CHANGE for legacy/fringe
drivers) removed DISK_EVENT_MEDIA_CHANGE from legacy/fringe block
drivers which have inadequate ->check_events().  Combined with earlier
change 7c88a16 (block: don't propagate unlisted DISK_EVENTs to
userland), this enables using ->check_events() for internal processing
while avoiding enabling in-kernel block event polling which can lead
to infinite event loop.

Unfortunately, this made many drivers including floppy without any bit
set in disk->events and ->async_events in which case disk_add_events()
simply skipped allocation of disk->ev, which disables whole event
handling.  As ->check_events() is still used during open processing
for revalidation, this can lead to open failure.

This patch always allocates disk->ev if ->check_events is implemented.
In the long term, it would make sense to simply include the event
structure inline into genhd as it's now used by virtually all block
devices.

Signed-off-by: Tejun Heo <[email protected]>
Reported-by: Ondrej Zary <[email protected]>
Reported-by: Alex Villacis Lasso <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
htejun authored and gregkh committed Jun 3, 2011
1 parent f47c98a commit 0c3edf8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ static void disk_add_events(struct gendisk *disk)
{
struct disk_events *ev;

if (!disk->fops->check_events || !(disk->events | disk->async_events))
if (!disk->fops->check_events)
return;

ev = kzalloc(sizeof(*ev), GFP_KERNEL);
Expand Down

0 comments on commit 0c3edf8

Please sign in to comment.