aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/floppy.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-08-07 12:25:34 -0400
committerJens Axboe <jaxboe@fusionio.com>2010-08-07 12:25:34 -0400
commit6e9624b8caec290d28b4c6d9ec75749df6372b87 (patch)
tree47225b544e1da82742795553dc4e8aa70c17afdc /drivers/block/floppy.c
parent8a6cfeb6deca3a8fefd639d898b0d163c0b5d368 (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/floppy.c')
-rw-r--r--drivers/block/floppy.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 40419b066aa9..3126d5122b2b 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3616,6 +3616,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
3616{ 3616{
3617 int drive = (long)disk->private_data; 3617 int drive = (long)disk->private_data;
3618 3618
3619 lock_kernel();
3619 mutex_lock(&open_lock); 3620 mutex_lock(&open_lock);
3620 if (UDRS->fd_ref < 0) 3621 if (UDRS->fd_ref < 0)
3621 UDRS->fd_ref = 0; 3622 UDRS->fd_ref = 0;
@@ -3626,6 +3627,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
3626 if (!UDRS->fd_ref) 3627 if (!UDRS->fd_ref)
3627 opened_bdev[drive] = NULL; 3628 opened_bdev[drive] = NULL;
3628 mutex_unlock(&open_lock); 3629 mutex_unlock(&open_lock);
3630 unlock_kernel();
3629 3631
3630 return 0; 3632 return 0;
3631} 3633}
@@ -3643,6 +3645,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
3643 int res = -EBUSY; 3645 int res = -EBUSY;
3644 char *tmp; 3646 char *tmp;
3645 3647
3648 lock_kernel();
3646 mutex_lock(&open_lock); 3649 mutex_lock(&open_lock);
3647 old_dev = UDRS->fd_device; 3650 old_dev = UDRS->fd_device;
3648 if (opened_bdev[drive] && opened_bdev[drive] != bdev) 3651 if (opened_bdev[drive] && opened_bdev[drive] != bdev)
@@ -3719,6 +3722,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
3719 goto out; 3722 goto out;
3720 } 3723 }
3721 mutex_unlock(&open_lock); 3724 mutex_unlock(&open_lock);
3725 unlock_kernel();
3722 return 0; 3726 return 0;
3723out: 3727out:
3724 if (UDRS->fd_ref < 0) 3728 if (UDRS->fd_ref < 0)
@@ -3729,6 +3733,7 @@ out:
3729 opened_bdev[drive] = NULL; 3733 opened_bdev[drive] = NULL;
3730out2: 3734out2:
3731 mutex_unlock(&open_lock); 3735 mutex_unlock(&open_lock);
3736 unlock_kernel();
3732 return res; 3737 return res;
3733} 3738}
3734 3739