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/ide | |
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/ide')
-rw-r--r-- | drivers/ide/ide-cd.c | 14 | ||||
-rw-r--r-- | drivers/ide/ide-gd.c | 17 | ||||
-rw-r--r-- | drivers/ide/ide-tape.c | 9 |
3 files changed, 33 insertions, 7 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index bf9f61a5c2f8..5108e9739c96 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -1591,17 +1591,19 @@ static struct ide_driver ide_cdrom_driver = { | |||
1591 | 1591 | ||
1592 | static int idecd_open(struct block_device *bdev, fmode_t mode) | 1592 | static int idecd_open(struct block_device *bdev, fmode_t mode) |
1593 | { | 1593 | { |
1594 | struct cdrom_info *info = ide_cd_get(bdev->bd_disk); | 1594 | struct cdrom_info *info; |
1595 | int rc = -ENOMEM; | 1595 | int rc = -ENXIO; |
1596 | 1596 | ||
1597 | lock_kernel(); | ||
1598 | info = ide_cd_get(bdev->bd_disk); | ||
1597 | if (!info) | 1599 | if (!info) |
1598 | return -ENXIO; | 1600 | goto out; |
1599 | 1601 | ||
1600 | rc = cdrom_open(&info->devinfo, bdev, mode); | 1602 | rc = cdrom_open(&info->devinfo, bdev, mode); |
1601 | |||
1602 | if (rc < 0) | 1603 | if (rc < 0) |
1603 | ide_cd_put(info); | 1604 | ide_cd_put(info); |
1604 | 1605 | out: | |
1606 | unlock_kernel(); | ||
1605 | return rc; | 1607 | return rc; |
1606 | } | 1608 | } |
1607 | 1609 | ||
@@ -1609,9 +1611,11 @@ static int idecd_release(struct gendisk *disk, fmode_t mode) | |||
1609 | { | 1611 | { |
1610 | struct cdrom_info *info = ide_drv_g(disk, cdrom_info); | 1612 | struct cdrom_info *info = ide_drv_g(disk, cdrom_info); |
1611 | 1613 | ||
1614 | lock_kernel(); | ||
1612 | cdrom_release(&info->devinfo, mode); | 1615 | cdrom_release(&info->devinfo, mode); |
1613 | 1616 | ||
1614 | ide_cd_put(info); | 1617 | ide_cd_put(info); |
1618 | unlock_kernel(); | ||
1615 | 1619 | ||
1616 | return 0; | 1620 | return 0; |
1617 | } | 1621 | } |
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c index 883f0c979c9f..137337a795a9 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 | ||
241 | static 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 | |||
240 | static int ide_gd_release(struct gendisk *disk, fmode_t mode) | 253 | static 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 | ||
322 | static const struct block_device_operations ide_gd_ops = { | 337 | static 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, |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 39b0a5c45f07..6d622cb5ac81 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -1907,7 +1907,11 @@ static const struct file_operations idetape_fops = { | |||
1907 | 1907 | ||
1908 | static int idetape_open(struct block_device *bdev, fmode_t mode) | 1908 | static int idetape_open(struct block_device *bdev, fmode_t mode) |
1909 | { | 1909 | { |
1910 | struct ide_tape_obj *tape = ide_tape_get(bdev->bd_disk, false, 0); | 1910 | struct ide_tape_obj *tape; |
1911 | |||
1912 | lock_kernel(); | ||
1913 | tape = ide_tape_get(bdev->bd_disk, false, 0); | ||
1914 | unlock_kernel(); | ||
1911 | 1915 | ||
1912 | if (!tape) | 1916 | if (!tape) |
1913 | return -ENXIO; | 1917 | return -ENXIO; |
@@ -1919,7 +1923,10 @@ static int idetape_release(struct gendisk *disk, fmode_t mode) | |||
1919 | { | 1923 | { |
1920 | struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); | 1924 | struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); |
1921 | 1925 | ||
1926 | lock_kernel(); | ||
1922 | ide_tape_put(tape); | 1927 | ide_tape_put(tape); |
1928 | unlock_kernel(); | ||
1929 | |||
1923 | return 0; | 1930 | return 0; |
1924 | } | 1931 | } |
1925 | 1932 | ||