diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-08-07 12:25:34 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-08-07 12:25:34 -0400 |
commit | 6e9624b8caec290d28b4c6d9ec75749df6372b87 (patch) | |
tree | 47225b544e1da82742795553dc4e8aa70c17afdc /drivers/block/paride | |
parent | 8a6cfeb6deca3a8fefd639d898b0d163c0b5d368 (diff) |
block: push down BKL into .open and .release
The open and release block_device_operations are currently
called with the BKL held. In order to change that, we must
first make sure that all drivers that currently rely
on this have no regressions.
This blindly pushes the BKL into all .open and .release
operations for all block drivers to prepare for the
next step. The drivers can subsequently replace the BKL
with their own locks or remove it completely when it can
be shown that it is not needed.
The functions blkdev_get and blkdev_put are the only
remaining users of the big kernel lock in the block
layer, besides a few uses in the ioctl code, none
of which need to serialize with blkdev_{get,put}.
Most of these two functions is also under the protection
of bdev->bd_mutex, including the actual calls to
->open and ->release, and the common code does not
access any global data structures that need the BKL.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers/block/paride')
-rw-r--r-- | drivers/block/paride/pcd.c | 10 | ||||
-rw-r--r-- | drivers/block/paride/pd.c | 4 | ||||
-rw-r--r-- | drivers/block/paride/pf.c | 20 |
3 files changed, 28 insertions, 6 deletions
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index daba7a62a663..76f8565e1e8d 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c | |||
@@ -225,13 +225,21 @@ static char *pcd_buf; /* buffer for request in progress */ | |||
225 | static int pcd_block_open(struct block_device *bdev, fmode_t mode) | 225 | static int pcd_block_open(struct block_device *bdev, fmode_t mode) |
226 | { | 226 | { |
227 | struct pcd_unit *cd = bdev->bd_disk->private_data; | 227 | struct pcd_unit *cd = bdev->bd_disk->private_data; |
228 | return cdrom_open(&cd->info, bdev, mode); | 228 | int ret; |
229 | |||
230 | lock_kernel(); | ||
231 | ret = cdrom_open(&cd->info, bdev, mode); | ||
232 | unlock_kernel(); | ||
233 | |||
234 | return ret; | ||
229 | } | 235 | } |
230 | 236 | ||
231 | static int pcd_block_release(struct gendisk *disk, fmode_t mode) | 237 | static int pcd_block_release(struct gendisk *disk, fmode_t mode) |
232 | { | 238 | { |
233 | struct pcd_unit *cd = disk->private_data; | 239 | struct pcd_unit *cd = disk->private_data; |
240 | lock_kernel(); | ||
234 | cdrom_release(&cd->info, mode); | 241 | cdrom_release(&cd->info, mode); |
242 | unlock_kernel(); | ||
235 | return 0; | 243 | return 0; |
236 | } | 244 | } |
237 | 245 | ||
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index c4d6ed9846ca..985f0d4f1d1e 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c | |||
@@ -736,12 +736,14 @@ static int pd_open(struct block_device *bdev, fmode_t mode) | |||
736 | { | 736 | { |
737 | struct pd_unit *disk = bdev->bd_disk->private_data; | 737 | struct pd_unit *disk = bdev->bd_disk->private_data; |
738 | 738 | ||
739 | lock_kernel(); | ||
739 | disk->access++; | 740 | disk->access++; |
740 | 741 | ||
741 | if (disk->removable) { | 742 | if (disk->removable) { |
742 | pd_special_command(disk, pd_media_check); | 743 | pd_special_command(disk, pd_media_check); |
743 | pd_special_command(disk, pd_door_lock); | 744 | pd_special_command(disk, pd_door_lock); |
744 | } | 745 | } |
746 | unlock_kernel(); | ||
745 | return 0; | 747 | return 0; |
746 | } | 748 | } |
747 | 749 | ||
@@ -783,8 +785,10 @@ static int pd_release(struct gendisk *p, fmode_t mode) | |||
783 | { | 785 | { |
784 | struct pd_unit *disk = p->private_data; | 786 | struct pd_unit *disk = p->private_data; |
785 | 787 | ||
788 | lock_kernel(); | ||
786 | if (!--disk->access && disk->removable) | 789 | if (!--disk->access && disk->removable) |
787 | pd_special_command(disk, pd_door_unlock); | 790 | pd_special_command(disk, pd_door_unlock); |
791 | unlock_kernel(); | ||
788 | 792 | ||
789 | return 0; | 793 | return 0; |
790 | } | 794 | } |
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index 38b4d566b816..4457b494882a 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c | |||
@@ -300,20 +300,26 @@ static void __init pf_init_units(void) | |||
300 | static int pf_open(struct block_device *bdev, fmode_t mode) | 300 | static int pf_open(struct block_device *bdev, fmode_t mode) |
301 | { | 301 | { |
302 | struct pf_unit *pf = bdev->bd_disk->private_data; | 302 | struct pf_unit *pf = bdev->bd_disk->private_data; |
303 | int ret; | ||
303 | 304 | ||
305 | lock_kernel(); | ||
304 | pf_identify(pf); | 306 | pf_identify(pf); |
305 | 307 | ||
308 | ret = -ENODEV; | ||
306 | if (pf->media_status == PF_NM) | 309 | if (pf->media_status == PF_NM) |
307 | return -ENODEV; | 310 | goto out; |
308 | 311 | ||
312 | ret = -EROFS; | ||
309 | if ((pf->media_status == PF_RO) && (mode & FMODE_WRITE)) | 313 | if ((pf->media_status == PF_RO) && (mode & FMODE_WRITE)) |
310 | return -EROFS; | 314 | goto out; |
311 | 315 | ||
316 | ret = 0; | ||
312 | pf->access++; | 317 | pf->access++; |
313 | if (pf->removable) | 318 | if (pf->removable) |
314 | pf_lock(pf, 1); | 319 | pf_lock(pf, 1); |
315 | 320 | out: | |
316 | return 0; | 321 | unlock_kernel(); |
322 | return ret; | ||
317 | } | 323 | } |
318 | 324 | ||
319 | static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo) | 325 | static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo) |
@@ -354,14 +360,18 @@ static int pf_release(struct gendisk *disk, fmode_t mode) | |||
354 | { | 360 | { |
355 | struct pf_unit *pf = disk->private_data; | 361 | struct pf_unit *pf = disk->private_data; |
356 | 362 | ||
357 | if (pf->access <= 0) | 363 | lock_kernel(); |
364 | if (pf->access <= 0) { | ||
365 | unlock_kernel(); | ||
358 | return -EINVAL; | 366 | return -EINVAL; |
367 | } | ||
359 | 368 | ||
360 | pf->access--; | 369 | pf->access--; |
361 | 370 | ||
362 | if (!pf->access && pf->removable) | 371 | if (!pf->access && pf->removable) |
363 | pf_lock(pf, 0); | 372 | pf_lock(pf, 0); |
364 | 373 | ||
374 | unlock_kernel(); | ||
365 | return 0; | 375 | return 0; |
366 | 376 | ||
367 | } | 377 | } |