diff options
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r-- | fs/block_dev.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 889287019599..7d02afb2b7f4 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -1087,6 +1087,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1087 | if (!disk) | 1087 | if (!disk) |
1088 | goto out; | 1088 | goto out; |
1089 | 1089 | ||
1090 | disk_block_events(disk); | ||
1090 | mutex_lock_nested(&bdev->bd_mutex, for_part); | 1091 | mutex_lock_nested(&bdev->bd_mutex, for_part); |
1091 | if (!bdev->bd_openers) { | 1092 | if (!bdev->bd_openers) { |
1092 | bdev->bd_disk = disk; | 1093 | bdev->bd_disk = disk; |
@@ -1108,10 +1109,11 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1108 | */ | 1109 | */ |
1109 | disk_put_part(bdev->bd_part); | 1110 | disk_put_part(bdev->bd_part); |
1110 | bdev->bd_part = NULL; | 1111 | bdev->bd_part = NULL; |
1111 | module_put(disk->fops->owner); | ||
1112 | put_disk(disk); | ||
1113 | bdev->bd_disk = NULL; | 1112 | bdev->bd_disk = NULL; |
1114 | mutex_unlock(&bdev->bd_mutex); | 1113 | mutex_unlock(&bdev->bd_mutex); |
1114 | disk_unblock_events(disk); | ||
1115 | module_put(disk->fops->owner); | ||
1116 | put_disk(disk); | ||
1115 | goto restart; | 1117 | goto restart; |
1116 | } | 1118 | } |
1117 | if (ret) | 1119 | if (ret) |
@@ -1148,9 +1150,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1148 | bd_set_size(bdev, (loff_t)bdev->bd_part->nr_sects << 9); | 1150 | bd_set_size(bdev, (loff_t)bdev->bd_part->nr_sects << 9); |
1149 | } | 1151 | } |
1150 | } else { | 1152 | } else { |
1151 | module_put(disk->fops->owner); | ||
1152 | put_disk(disk); | ||
1153 | disk = NULL; | ||
1154 | if (bdev->bd_contains == bdev) { | 1153 | if (bdev->bd_contains == bdev) { |
1155 | if (bdev->bd_disk->fops->open) { | 1154 | if (bdev->bd_disk->fops->open) { |
1156 | ret = bdev->bd_disk->fops->open(bdev, mode); | 1155 | ret = bdev->bd_disk->fops->open(bdev, mode); |
@@ -1160,11 +1159,15 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1160 | if (bdev->bd_invalidated) | 1159 | if (bdev->bd_invalidated) |
1161 | rescan_partitions(bdev->bd_disk, bdev); | 1160 | rescan_partitions(bdev->bd_disk, bdev); |
1162 | } | 1161 | } |
1162 | /* only one opener holds refs to the module and disk */ | ||
1163 | module_put(disk->fops->owner); | ||
1164 | put_disk(disk); | ||
1163 | } | 1165 | } |
1164 | bdev->bd_openers++; | 1166 | bdev->bd_openers++; |
1165 | if (for_part) | 1167 | if (for_part) |
1166 | bdev->bd_part_count++; | 1168 | bdev->bd_part_count++; |
1167 | mutex_unlock(&bdev->bd_mutex); | 1169 | mutex_unlock(&bdev->bd_mutex); |
1170 | disk_unblock_events(disk); | ||
1168 | return 0; | 1171 | return 0; |
1169 | 1172 | ||
1170 | out_clear: | 1173 | out_clear: |
@@ -1177,10 +1180,10 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1177 | bdev->bd_contains = NULL; | 1180 | bdev->bd_contains = NULL; |
1178 | out_unlock_bdev: | 1181 | out_unlock_bdev: |
1179 | mutex_unlock(&bdev->bd_mutex); | 1182 | mutex_unlock(&bdev->bd_mutex); |
1180 | out: | 1183 | disk_unblock_events(disk); |
1181 | if (disk) | 1184 | module_put(disk->fops->owner); |
1182 | module_put(disk->fops->owner); | ||
1183 | put_disk(disk); | 1185 | put_disk(disk); |
1186 | out: | ||
1184 | bdput(bdev); | 1187 | bdput(bdev); |
1185 | 1188 | ||
1186 | return ret; | 1189 | return ret; |
@@ -1446,14 +1449,13 @@ int blkdev_put(struct block_device *bdev, fmode_t mode) | |||
1446 | if (bdev_free) { | 1449 | if (bdev_free) { |
1447 | if (bdev->bd_write_holder) { | 1450 | if (bdev->bd_write_holder) { |
1448 | disk_unblock_events(bdev->bd_disk); | 1451 | disk_unblock_events(bdev->bd_disk); |
1449 | bdev->bd_write_holder = false; | ||
1450 | } else | ||
1451 | disk_check_events(bdev->bd_disk); | 1452 | disk_check_events(bdev->bd_disk); |
1453 | bdev->bd_write_holder = false; | ||
1454 | } | ||
1452 | } | 1455 | } |
1453 | 1456 | ||
1454 | mutex_unlock(&bdev->bd_mutex); | 1457 | mutex_unlock(&bdev->bd_mutex); |
1455 | } else | 1458 | } |
1456 | disk_check_events(bdev->bd_disk); | ||
1457 | 1459 | ||
1458 | return __blkdev_put(bdev, mode, 0); | 1460 | return __blkdev_put(bdev, mode, 0); |
1459 | } | 1461 | } |
@@ -1527,7 +1529,6 @@ static int blkdev_releasepage(struct page *page, gfp_t wait) | |||
1527 | static const struct address_space_operations def_blk_aops = { | 1529 | static const struct address_space_operations def_blk_aops = { |
1528 | .readpage = blkdev_readpage, | 1530 | .readpage = blkdev_readpage, |
1529 | .writepage = blkdev_writepage, | 1531 | .writepage = blkdev_writepage, |
1530 | .sync_page = block_sync_page, | ||
1531 | .write_begin = blkdev_write_begin, | 1532 | .write_begin = blkdev_write_begin, |
1532 | .write_end = blkdev_write_end, | 1533 | .write_end = blkdev_write_end, |
1533 | .writepages = generic_writepages, | 1534 | .writepages = generic_writepages, |