Skip to content

Commit

Permalink
block: Don't check events on close unless it was blocked
Browse files Browse the repository at this point in the history
The block event mechanism currently always checks events when the
device is being closed regardless of the open mode.  The intention was
to allow detection of EJECT_REQUEST when a device is closed whether
disk event polling is enabled or not.

This is unnecessary as, for devices of interest, events are checked
from either userland or kernel and in the former case ->check_events()
is performed on open of each poll attempt anyway.  Furthermore, this
unconditional event check on close makes the code susceptible to event
loop if the block driver doesn't clear reported events correctly - an
event triggers userland to open and close the device which in turn
causes another event, rinse and repeat.

Check events on close only if it was blocked by excl write open.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Kay Sievers <kay.sievers@vrfy.org>
  • Loading branch information
Tejun Heo committed Mar 9, 2011
1 parent facc31d commit 6936217
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1448,13 +1448,11 @@ int blkdev_put(struct block_device *bdev, fmode_t mode)
disk_unblock_events(bdev->bd_disk);
disk_check_events(bdev->bd_disk);
bdev->bd_write_holder = false;
} else
disk_check_events(bdev->bd_disk);
}
}

mutex_unlock(&bdev->bd_mutex);
} else
disk_check_events(bdev->bd_disk);
}

return __blkdev_put(bdev, mode, 0);
}
Expand Down

0 comments on commit 6936217

Please sign in to comment.