aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/swim3.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/swim3.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/swim3.c')
-rw-r--r--drivers/block/swim3.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index f3657b2a5386..cc6a3864822c 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -949,15 +949,28 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
949 return 0; 949 return 0;
950} 950}
951 951
952static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode)
953{
954 int ret;
955
956 lock_kernel();
957 ret = floppy_open(bdev, mode);
958 unlock_kernel();
959
960 return ret;
961}
962
952static int floppy_release(struct gendisk *disk, fmode_t mode) 963static int floppy_release(struct gendisk *disk, fmode_t mode)
953{ 964{
954 struct floppy_state *fs = disk->private_data; 965 struct floppy_state *fs = disk->private_data;
955 struct swim3 __iomem *sw = fs->swim3; 966 struct swim3 __iomem *sw = fs->swim3;
967 lock_kernel();
956 if (fs->ref_count > 0 && --fs->ref_count == 0) { 968 if (fs->ref_count > 0 && --fs->ref_count == 0) {
957 swim3_action(fs, MOTOR_OFF); 969 swim3_action(fs, MOTOR_OFF);
958 out_8(&sw->control_bic, 0xff); 970 out_8(&sw->control_bic, 0xff);
959 swim3_select(fs, RELAX); 971 swim3_select(fs, RELAX);
960 } 972 }
973 unlock_kernel();
961 return 0; 974 return 0;
962} 975}
963 976
@@ -1008,7 +1021,7 @@ static int floppy_revalidate(struct gendisk *disk)
1008} 1021}
1009 1022
1010static const struct block_device_operations floppy_fops = { 1023static const struct block_device_operations floppy_fops = {
1011 .open = floppy_open, 1024 .open = floppy_unlocked_open,
1012 .release = floppy_release, 1025 .release = floppy_release,
1013 .ioctl = floppy_ioctl, 1026 .ioctl = floppy_ioctl,
1014 .media_changed = floppy_check_change, 1027 .media_changed = floppy_check_change,