aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/ataflop.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/ataflop.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/ataflop.c')
-rw-r--r--drivers/block/ataflop.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 1bb8bfcfdbd..aceb9647652 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -1850,22 +1850,34 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
1850 return 0; 1850 return 0;
1851} 1851}
1852 1852
1853static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode)
1854{
1855 int ret;
1856
1857 lock_kernel();
1858 ret = floppy_open(bdev, mode);
1859 unlock_kernel();
1860
1861 return ret;
1862}
1853 1863
1854static int floppy_release(struct gendisk *disk, fmode_t mode) 1864static int floppy_release(struct gendisk *disk, fmode_t mode)
1855{ 1865{
1856 struct atari_floppy_struct *p = disk->private_data; 1866 struct atari_floppy_struct *p = disk->private_data;
1867 lock_kernel();
1857 if (p->ref < 0) 1868 if (p->ref < 0)
1858 p->ref = 0; 1869 p->ref = 0;
1859 else if (!p->ref--) { 1870 else if (!p->ref--) {
1860 printk(KERN_ERR "floppy_release with fd_ref == 0"); 1871 printk(KERN_ERR "floppy_release with fd_ref == 0");
1861 p->ref = 0; 1872 p->ref = 0;
1862 } 1873 }
1874 unlock_kernel();
1863 return 0; 1875 return 0;
1864} 1876}
1865 1877
1866static const struct block_device_operations floppy_fops = { 1878static const struct block_device_operations floppy_fops = {
1867 .owner = THIS_MODULE, 1879 .owner = THIS_MODULE,
1868 .open = floppy_open, 1880 .open = floppy_unlocked_open,
1869 .release = floppy_release, 1881 .release = floppy_release,
1870 .ioctl = fd_ioctl, 1882 .ioctl = fd_ioctl,
1871 .media_changed = check_floppy_change, 1883 .media_changed = check_floppy_change,