diff options
author | Jens Axboe <jaxboe@fusionio.com> | 2011-01-13 08:47:54 -0500 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2011-01-13 08:47:54 -0500 |
commit | 81c5e2ae33c4b19e53966b427e33646bf6811830 (patch) | |
tree | a602a6dd100165c8948bfa713e6f0b422dcba5d8 /fs/block_dev.c | |
parent | 797a455d2c682476c3797dbfecf5bf84c1e3b9d3 (diff) | |
parent | fcc57045d53edc35bcce456e60ac4aa802712934 (diff) |
Merge branch 'for-2.6.38/event-handling' into for-2.6.38/core
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r-- | fs/block_dev.c | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index c1c1b8c3fb99..6017389711ee 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -948,10 +948,11 @@ int check_disk_change(struct block_device *bdev) | |||
948 | { | 948 | { |
949 | struct gendisk *disk = bdev->bd_disk; | 949 | struct gendisk *disk = bdev->bd_disk; |
950 | const struct block_device_operations *bdops = disk->fops; | 950 | const struct block_device_operations *bdops = disk->fops; |
951 | unsigned int events; | ||
951 | 952 | ||
952 | if (!bdops->media_changed) | 953 | events = disk_clear_events(disk, DISK_EVENT_MEDIA_CHANGE | |
953 | return 0; | 954 | DISK_EVENT_EJECT_REQUEST); |
954 | if (!bdops->media_changed(bdev->bd_disk)) | 955 | if (!(events & DISK_EVENT_MEDIA_CHANGE)) |
955 | return 0; | 956 | return 0; |
956 | 957 | ||
957 | flush_disk(bdev); | 958 | flush_disk(bdev); |
@@ -1158,9 +1159,10 @@ int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder) | |||
1158 | 1159 | ||
1159 | if (whole) { | 1160 | if (whole) { |
1160 | /* finish claiming */ | 1161 | /* finish claiming */ |
1162 | mutex_lock(&bdev->bd_mutex); | ||
1161 | spin_lock(&bdev_lock); | 1163 | spin_lock(&bdev_lock); |
1162 | 1164 | ||
1163 | if (res == 0) { | 1165 | if (!res) { |
1164 | BUG_ON(!bd_may_claim(bdev, whole, holder)); | 1166 | BUG_ON(!bd_may_claim(bdev, whole, holder)); |
1165 | /* | 1167 | /* |
1166 | * Note that for a whole device bd_holders | 1168 | * Note that for a whole device bd_holders |
@@ -1180,6 +1182,20 @@ int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder) | |||
1180 | wake_up_bit(&whole->bd_claiming, 0); | 1182 | wake_up_bit(&whole->bd_claiming, 0); |
1181 | 1183 | ||
1182 | spin_unlock(&bdev_lock); | 1184 | spin_unlock(&bdev_lock); |
1185 | |||
1186 | /* | ||
1187 | * Block event polling for write claims. Any write | ||
1188 | * holder makes the write_holder state stick until all | ||
1189 | * are released. This is good enough and tracking | ||
1190 | * individual writeable reference is too fragile given | ||
1191 | * the way @mode is used in blkdev_get/put(). | ||
1192 | */ | ||
1193 | if (!res && (mode & FMODE_WRITE) && !bdev->bd_write_holder) { | ||
1194 | bdev->bd_write_holder = true; | ||
1195 | disk_block_events(bdev->bd_disk); | ||
1196 | } | ||
1197 | |||
1198 | mutex_unlock(&bdev->bd_mutex); | ||
1183 | bdput(whole); | 1199 | bdput(whole); |
1184 | } | 1200 | } |
1185 | 1201 | ||
@@ -1353,12 +1369,23 @@ int blkdev_put(struct block_device *bdev, fmode_t mode) | |||
1353 | 1369 | ||
1354 | spin_unlock(&bdev_lock); | 1370 | spin_unlock(&bdev_lock); |
1355 | 1371 | ||
1356 | /* if this was the last claim, holder link should go too */ | 1372 | /* |
1357 | if (bdev_free) | 1373 | * If this was the last claim, remove holder link and |
1374 | * unblock evpoll if it was a write holder. | ||
1375 | */ | ||
1376 | if (bdev_free) { | ||
1358 | bd_unlink_disk_holder(bdev); | 1377 | bd_unlink_disk_holder(bdev); |
1378 | if (bdev->bd_write_holder) { | ||
1379 | disk_unblock_events(bdev->bd_disk); | ||
1380 | bdev->bd_write_holder = false; | ||
1381 | } else | ||
1382 | disk_check_events(bdev->bd_disk); | ||
1383 | } | ||
1359 | 1384 | ||
1360 | mutex_unlock(&bdev->bd_mutex); | 1385 | mutex_unlock(&bdev->bd_mutex); |
1361 | } | 1386 | } else |
1387 | disk_check_events(bdev->bd_disk); | ||
1388 | |||
1362 | return __blkdev_put(bdev, mode, 0); | 1389 | return __blkdev_put(bdev, mode, 0); |
1363 | } | 1390 | } |
1364 | EXPORT_SYMBOL(blkdev_put); | 1391 | EXPORT_SYMBOL(blkdev_put); |