aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-gd.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/ide/ide-gd.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/ide/ide-gd.c')
-rw-r--r--drivers/ide/ide-gd.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 883f0c979c9..137337a795a 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -1,3 +1,4 @@
1#include <linux/smp_lock.h>
1#include <linux/module.h> 2#include <linux/module.h>
2#include <linux/types.h> 3#include <linux/types.h>
3#include <linux/string.h> 4#include <linux/string.h>
@@ -237,6 +238,18 @@ out_put_idkp:
237 return ret; 238 return ret;
238} 239}
239 240
241static int ide_gd_unlocked_open(struct block_device *bdev, fmode_t mode)
242{
243 int ret;
244
245 lock_kernel();
246 ret = ide_gd_open(bdev, mode);
247 unlock_kernel();
248
249 return ret;
250}
251
252
240static int ide_gd_release(struct gendisk *disk, fmode_t mode) 253static int ide_gd_release(struct gendisk *disk, fmode_t mode)
241{ 254{
242 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); 255 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
@@ -244,6 +257,7 @@ static int ide_gd_release(struct gendisk *disk, fmode_t mode)
244 257
245 ide_debug_log(IDE_DBG_FUNC, "enter"); 258 ide_debug_log(IDE_DBG_FUNC, "enter");
246 259
260 lock_kernel();
247 if (idkp->openers == 1) 261 if (idkp->openers == 1)
248 drive->disk_ops->flush(drive); 262 drive->disk_ops->flush(drive);
249 263
@@ -255,6 +269,7 @@ static int ide_gd_release(struct gendisk *disk, fmode_t mode)
255 idkp->openers--; 269 idkp->openers--;
256 270
257 ide_disk_put(idkp); 271 ide_disk_put(idkp);
272 unlock_kernel();
258 273
259 return 0; 274 return 0;
260} 275}
@@ -321,7 +336,7 @@ static int ide_gd_ioctl(struct block_device *bdev, fmode_t mode,
321 336
322static const struct block_device_operations ide_gd_ops = { 337static const struct block_device_operations ide_gd_ops = {
323 .owner = THIS_MODULE, 338 .owner = THIS_MODULE,
324 .open = ide_gd_open, 339 .open = ide_gd_unlocked_open,
325 .release = ide_gd_release, 340 .release = ide_gd_release,
326 .ioctl = ide_gd_ioctl, 341 .ioctl = ide_gd_ioctl,
327 .getgeo = ide_gd_getgeo, 342 .getgeo = ide_gd_getgeo,