aboutsummaryrefslogtreecommitdiffstats
path: root/fs/block_dev.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-03-09 13:54:27 -0500
committerTejun Heo <tj@kernel.org>2011-03-09 13:54:27 -0500
commit6936217cc7e58573026bdba25b1bfb778e8f2267 (patch)
tree7ddfbc4912d9a29a9719c13b8d1b58a3b3291762 /fs/block_dev.c
parentfacc31ddc3570a3a0d8951c94f16b898e01b464d (diff)
block: Don't check events on close unless it was blocked
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>
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index fffdf86c1757..7dd2c658d429 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1448,13 +1448,11 @@ int blkdev_put(struct block_device *bdev, fmode_t mode)
1448 disk_unblock_events(bdev->bd_disk); 1448 disk_unblock_events(bdev->bd_disk);
1449 disk_check_events(bdev->bd_disk); 1449 disk_check_events(bdev->bd_disk);
1450 bdev->bd_write_holder = false; 1450 bdev->bd_write_holder = false;
1451 } else 1451 }
1452 disk_check_events(bdev->bd_disk);
1453 } 1452 }
1454 1453
1455 mutex_unlock(&bdev->bd_mutex); 1454 mutex_unlock(&bdev->bd_mutex);
1456 } else 1455 }
1457 disk_check_events(bdev->bd_disk);
1458 1456
1459 return __blkdev_put(bdev, mode, 0); 1457 return __blkdev_put(bdev, mode, 0);
1460} 1458}