aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/amiflop.c17
-rw-r--r--drivers/block/ataflop.c18
-rw-r--r--drivers/block/brd.c5
-rw-r--r--drivers/block/cciss.c8
-rw-r--r--drivers/block/cpqarray.c18
-rw-r--r--drivers/block/floppy.c17
-rw-r--r--drivers/block/nbd.c5
-rw-r--r--drivers/block/paride/pcd.c11
-rw-r--r--drivers/block/paride/pd.c5
-rw-r--r--drivers/block/paride/pf.c6
-rw-r--r--drivers/block/pktcdvd.c13
-rw-r--r--drivers/block/swim.c5
-rw-r--r--drivers/block/swim3.c17
-rw-r--r--drivers/block/ub.c10
-rw-r--r--drivers/block/virtio_blk.c17
-rw-r--r--drivers/block/xd.c17
-rw-r--r--drivers/block/xen-blkfront.c2
17 files changed, 159 insertions, 32 deletions
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 832798aa14f6..0fa26359304c 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -60,6 +60,7 @@
60#include <linux/hdreg.h> 60#include <linux/hdreg.h>
61#include <linux/delay.h> 61#include <linux/delay.h>
62#include <linux/init.h> 62#include <linux/init.h>
63#include <linux/smp_lock.h>
63#include <linux/amifdreg.h> 64#include <linux/amifdreg.h>
64#include <linux/amifd.h> 65#include <linux/amifd.h>
65#include <linux/buffer_head.h> 66#include <linux/buffer_head.h>
@@ -1423,7 +1424,7 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1423 return 0; 1424 return 0;
1424} 1425}
1425 1426
1426static int fd_ioctl(struct block_device *bdev, fmode_t mode, 1427static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,
1427 unsigned int cmd, unsigned long param) 1428 unsigned int cmd, unsigned long param)
1428{ 1429{
1429 struct amiga_floppy_struct *p = bdev->bd_disk->private_data; 1430 struct amiga_floppy_struct *p = bdev->bd_disk->private_data;
@@ -1500,6 +1501,18 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode,
1500 return 0; 1501 return 0;
1501} 1502}
1502 1503
1504static int fd_ioctl(struct block_device *bdev, fmode_t mode,
1505 unsigned int cmd, unsigned long param)
1506{
1507 int ret;
1508
1509 lock_kernel();
1510 ret = fd_locked_ioctl(bdev, mode, cmd, param);
1511 unlock_kernel();
1512
1513 return ret;
1514}
1515
1503static void fd_probe(int dev) 1516static void fd_probe(int dev)
1504{ 1517{
1505 unsigned long code; 1518 unsigned long code;
@@ -1638,7 +1651,7 @@ static const struct block_device_operations floppy_fops = {
1638 .owner = THIS_MODULE, 1651 .owner = THIS_MODULE,
1639 .open = floppy_open, 1652 .open = floppy_open,
1640 .release = floppy_release, 1653 .release = floppy_release,
1641 .locked_ioctl = fd_ioctl, 1654 .ioctl = fd_ioctl,
1642 .getgeo = fd_getgeo, 1655 .getgeo = fd_getgeo,
1643 .media_changed = amiga_floppy_change, 1656 .media_changed = amiga_floppy_change,
1644}; 1657};
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index e35cf59cbfde..1bb8bfcfdbd9 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -67,6 +67,7 @@
67#include <linux/delay.h> 67#include <linux/delay.h>
68#include <linux/init.h> 68#include <linux/init.h>
69#include <linux/blkdev.h> 69#include <linux/blkdev.h>
70#include <linux/smp_lock.h>
70 71
71#include <asm/atafd.h> 72#include <asm/atafd.h>
72#include <asm/atafdreg.h> 73#include <asm/atafdreg.h>
@@ -359,7 +360,7 @@ static void finish_fdc( void );
359static void finish_fdc_done( int dummy ); 360static void finish_fdc_done( int dummy );
360static void setup_req_params( int drive ); 361static void setup_req_params( int drive );
361static void redo_fd_request( void); 362static void redo_fd_request( void);
362static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int 363static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
363 cmd, unsigned long param); 364 cmd, unsigned long param);
364static void fd_probe( int drive ); 365static void fd_probe( int drive );
365static int fd_test_drive_present( int drive ); 366static int fd_test_drive_present( int drive );
@@ -1480,7 +1481,7 @@ void do_fd_request(struct request_queue * q)
1480 atari_enable_irq( IRQ_MFP_FDC ); 1481 atari_enable_irq( IRQ_MFP_FDC );
1481} 1482}
1482 1483
1483static int fd_ioctl(struct block_device *bdev, fmode_t mode, 1484static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,
1484 unsigned int cmd, unsigned long param) 1485 unsigned int cmd, unsigned long param)
1485{ 1486{
1486 struct gendisk *disk = bdev->bd_disk; 1487 struct gendisk *disk = bdev->bd_disk;
@@ -1665,6 +1666,17 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode,
1665 } 1666 }
1666} 1667}
1667 1668
1669static int fd_ioctl(struct block_device *bdev, fmode_t mode,
1670 unsigned int cmd, unsigned long arg)
1671{
1672 int ret;
1673
1674 lock_kernel();
1675 ret = fd_locked_ioctl(bdev, mode, cmd, arg);
1676 unlock_kernel();
1677
1678 return ret;
1679}
1668 1680
1669/* Initialize the 'unit' variable for drive 'drive' */ 1681/* Initialize the 'unit' variable for drive 'drive' */
1670 1682
@@ -1855,7 +1867,7 @@ static const struct block_device_operations floppy_fops = {
1855 .owner = THIS_MODULE, 1867 .owner = THIS_MODULE,
1856 .open = floppy_open, 1868 .open = floppy_open,
1857 .release = floppy_release, 1869 .release = floppy_release,
1858 .locked_ioctl = fd_ioctl, 1870 .ioctl = fd_ioctl,
1859 .media_changed = check_floppy_change, 1871 .media_changed = check_floppy_change,
1860 .revalidate_disk= floppy_revalidate, 1872 .revalidate_disk= floppy_revalidate,
1861}; 1873};
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 1d2c18620f9a..1c7f63792ff8 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -15,6 +15,7 @@
15#include <linux/blkdev.h> 15#include <linux/blkdev.h>
16#include <linux/bio.h> 16#include <linux/bio.h>
17#include <linux/highmem.h> 17#include <linux/highmem.h>
18#include <linux/smp_lock.h>
18#include <linux/radix-tree.h> 19#include <linux/radix-tree.h>
19#include <linux/buffer_head.h> /* invalidate_bh_lrus() */ 20#include <linux/buffer_head.h> /* invalidate_bh_lrus() */
20#include <linux/slab.h> 21#include <linux/slab.h>
@@ -401,6 +402,7 @@ static int brd_ioctl(struct block_device *bdev, fmode_t mode,
401 * ram device BLKFLSBUF has special semantics, we want to actually 402 * ram device BLKFLSBUF has special semantics, we want to actually
402 * release and destroy the ramdisk data. 403 * release and destroy the ramdisk data.
403 */ 404 */
405 lock_kernel();
404 mutex_lock(&bdev->bd_mutex); 406 mutex_lock(&bdev->bd_mutex);
405 error = -EBUSY; 407 error = -EBUSY;
406 if (bdev->bd_openers <= 1) { 408 if (bdev->bd_openers <= 1) {
@@ -417,13 +419,14 @@ static int brd_ioctl(struct block_device *bdev, fmode_t mode,
417 error = 0; 419 error = 0;
418 } 420 }
419 mutex_unlock(&bdev->bd_mutex); 421 mutex_unlock(&bdev->bd_mutex);
422 unlock_kernel();
420 423
421 return error; 424 return error;
422} 425}
423 426
424static const struct block_device_operations brd_fops = { 427static const struct block_device_operations brd_fops = {
425 .owner = THIS_MODULE, 428 .owner = THIS_MODULE,
426 .locked_ioctl = brd_ioctl, 429 .ioctl = brd_ioctl,
427#ifdef CONFIG_BLK_DEV_XIP 430#ifdef CONFIG_BLK_DEV_XIP
428 .direct_access = brd_direct_access, 431 .direct_access = brd_direct_access,
429#endif 432#endif
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 11b377762b8e..a6c0494dd054 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -179,6 +179,8 @@ static irqreturn_t do_cciss_intx(int irq, void *dev_id);
179static irqreturn_t do_cciss_msix_intr(int irq, void *dev_id); 179static irqreturn_t do_cciss_msix_intr(int irq, void *dev_id);
180static int cciss_open(struct block_device *bdev, fmode_t mode); 180static int cciss_open(struct block_device *bdev, fmode_t mode);
181static int cciss_release(struct gendisk *disk, fmode_t mode); 181static int cciss_release(struct gendisk *disk, fmode_t mode);
182static int do_ioctl(struct block_device *bdev, fmode_t mode,
183 unsigned int cmd, unsigned long arg);
182static int cciss_ioctl(struct block_device *bdev, fmode_t mode, 184static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
183 unsigned int cmd, unsigned long arg); 185 unsigned int cmd, unsigned long arg);
184static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); 186static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo);
@@ -237,7 +239,7 @@ static const struct block_device_operations cciss_fops = {
237 .owner = THIS_MODULE, 239 .owner = THIS_MODULE,
238 .open = cciss_open, 240 .open = cciss_open,
239 .release = cciss_release, 241 .release = cciss_release,
240 .locked_ioctl = cciss_ioctl, 242 .ioctl = do_ioctl,
241 .getgeo = cciss_getgeo, 243 .getgeo = cciss_getgeo,
242#ifdef CONFIG_COMPAT 244#ifdef CONFIG_COMPAT
243 .compat_ioctl = cciss_compat_ioctl, 245 .compat_ioctl = cciss_compat_ioctl,
@@ -1057,8 +1059,6 @@ static int cciss_release(struct gendisk *disk, fmode_t mode)
1057 return 0; 1059 return 0;
1058} 1060}
1059 1061
1060#ifdef CONFIG_COMPAT
1061
1062static int do_ioctl(struct block_device *bdev, fmode_t mode, 1062static int do_ioctl(struct block_device *bdev, fmode_t mode,
1063 unsigned cmd, unsigned long arg) 1063 unsigned cmd, unsigned long arg)
1064{ 1064{
@@ -1069,6 +1069,8 @@ static int do_ioctl(struct block_device *bdev, fmode_t mode,
1069 return ret; 1069 return ret;
1070} 1070}
1071 1071
1072#ifdef CONFIG_COMPAT
1073
1072static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode, 1074static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
1073 unsigned cmd, unsigned long arg); 1075 unsigned cmd, unsigned long arg);
1074static int cciss_ioctl32_big_passthru(struct block_device *bdev, fmode_t mode, 1076static int cciss_ioctl32_big_passthru(struct block_device *bdev, fmode_t mode,
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index abb4ec6690fc..c459aeea3c0c 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -35,6 +35,7 @@
35#include <linux/seq_file.h> 35#include <linux/seq_file.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/hdreg.h> 37#include <linux/hdreg.h>
38#include <linux/smp_lock.h>
38#include <linux/spinlock.h> 39#include <linux/spinlock.h>
39#include <linux/blkdev.h> 40#include <linux/blkdev.h>
40#include <linux/genhd.h> 41#include <linux/genhd.h>
@@ -197,7 +198,7 @@ static const struct block_device_operations ida_fops = {
197 .owner = THIS_MODULE, 198 .owner = THIS_MODULE,
198 .open = ida_open, 199 .open = ida_open,
199 .release = ida_release, 200 .release = ida_release,
200 .locked_ioctl = ida_ioctl, 201 .ioctl = ida_ioctl,
201 .getgeo = ida_getgeo, 202 .getgeo = ida_getgeo,
202 .revalidate_disk= ida_revalidate, 203 .revalidate_disk= ida_revalidate,
203}; 204};
@@ -1128,7 +1129,7 @@ static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1128 * ida_ioctl does some miscellaneous stuff like reporting drive geometry, 1129 * ida_ioctl does some miscellaneous stuff like reporting drive geometry,
1129 * setting readahead and submitting commands from userspace to the controller. 1130 * setting readahead and submitting commands from userspace to the controller.
1130 */ 1131 */
1131static int ida_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) 1132static int ida_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)
1132{ 1133{
1133 drv_info_t *drv = get_drv(bdev->bd_disk); 1134 drv_info_t *drv = get_drv(bdev->bd_disk);
1134 ctlr_info_t *host = get_host(bdev->bd_disk); 1135 ctlr_info_t *host = get_host(bdev->bd_disk);
@@ -1192,6 +1193,19 @@ out_passthru:
1192 } 1193 }
1193 1194
1194} 1195}
1196
1197static int ida_ioctl(struct block_device *bdev, fmode_t mode,
1198 unsigned int cmd, unsigned long param)
1199{
1200 int ret;
1201
1202 lock_kernel();
1203 ret = ida_locked_ioctl(bdev, mode, cmd, param);
1204 unlock_kernel();
1205
1206 return ret;
1207}
1208
1195/* 1209/*
1196 * ida_ctlr_ioctl is for passing commands to the controller from userspace. 1210 * ida_ctlr_ioctl is for passing commands to the controller from userspace.
1197 * The command block (io) has already been copied to kernel space for us, 1211 * The command block (io) has already been copied to kernel space for us,
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 82c30f9f81ca..40419b066aa9 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -178,6 +178,7 @@ static int print_unex = 1;
178#include <linux/slab.h> 178#include <linux/slab.h>
179#include <linux/mm.h> 179#include <linux/mm.h>
180#include <linux/bio.h> 180#include <linux/bio.h>
181#include <linux/smp_lock.h>
181#include <linux/string.h> 182#include <linux/string.h>
182#include <linux/jiffies.h> 183#include <linux/jiffies.h>
183#include <linux/fcntl.h> 184#include <linux/fcntl.h>
@@ -3371,7 +3372,7 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
3371 return 0; 3372 return 0;
3372} 3373}
3373 3374
3374static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, 3375static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
3375 unsigned long param) 3376 unsigned long param)
3376{ 3377{
3377 int drive = (long)bdev->bd_disk->private_data; 3378 int drive = (long)bdev->bd_disk->private_data;
@@ -3547,6 +3548,18 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
3547 return 0; 3548 return 0;
3548} 3549}
3549 3550
3551static int fd_ioctl(struct block_device *bdev, fmode_t mode,
3552 unsigned int cmd, unsigned long param)
3553{
3554 int ret;
3555
3556 lock_kernel();
3557 ret = fd_locked_ioctl(bdev, mode, cmd, param);
3558 unlock_kernel();
3559
3560 return ret;
3561}
3562
3550static void __init config_types(void) 3563static void __init config_types(void)
3551{ 3564{
3552 bool has_drive = false; 3565 bool has_drive = false;
@@ -3848,7 +3861,7 @@ static const struct block_device_operations floppy_fops = {
3848 .owner = THIS_MODULE, 3861 .owner = THIS_MODULE,
3849 .open = floppy_open, 3862 .open = floppy_open,
3850 .release = floppy_release, 3863 .release = floppy_release,
3851 .locked_ioctl = fd_ioctl, 3864 .ioctl = fd_ioctl,
3852 .getgeo = fd_getgeo, 3865 .getgeo = fd_getgeo,
3853 .media_changed = check_floppy_change, 3866 .media_changed = check_floppy_change,
3854 .revalidate_disk = floppy_revalidate, 3867 .revalidate_disk = floppy_revalidate,
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 2e74e7d475ca..6751789fb379 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -24,6 +24,7 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/file.h> 25#include <linux/file.h>
26#include <linux/ioctl.h> 26#include <linux/ioctl.h>
27#include <linux/smp_lock.h>
27#include <linux/compiler.h> 28#include <linux/compiler.h>
28#include <linux/err.h> 29#include <linux/err.h>
29#include <linux/kernel.h> 30#include <linux/kernel.h>
@@ -716,9 +717,11 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
716 dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n", 717 dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n",
717 lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg); 718 lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg);
718 719
720 lock_kernel();
719 mutex_lock(&lo->tx_lock); 721 mutex_lock(&lo->tx_lock);
720 error = __nbd_ioctl(bdev, lo, cmd, arg); 722 error = __nbd_ioctl(bdev, lo, cmd, arg);
721 mutex_unlock(&lo->tx_lock); 723 mutex_unlock(&lo->tx_lock);
724 unlock_kernel();
722 725
723 return error; 726 return error;
724} 727}
@@ -726,7 +729,7 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
726static const struct block_device_operations nbd_fops = 729static const struct block_device_operations nbd_fops =
727{ 730{
728 .owner = THIS_MODULE, 731 .owner = THIS_MODULE,
729 .locked_ioctl = nbd_ioctl, 732 .ioctl = nbd_ioctl,
730}; 733};
731 734
732/* 735/*
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index 71acf4e53356..daba7a62a663 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -138,6 +138,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY};
138#include <linux/cdrom.h> 138#include <linux/cdrom.h>
139#include <linux/spinlock.h> 139#include <linux/spinlock.h>
140#include <linux/blkdev.h> 140#include <linux/blkdev.h>
141#include <linux/smp_lock.h>
141#include <asm/uaccess.h> 142#include <asm/uaccess.h>
142 143
143static DEFINE_SPINLOCK(pcd_lock); 144static DEFINE_SPINLOCK(pcd_lock);
@@ -238,7 +239,13 @@ static int pcd_block_ioctl(struct block_device *bdev, fmode_t mode,
238 unsigned cmd, unsigned long arg) 239 unsigned cmd, unsigned long arg)
239{ 240{
240 struct pcd_unit *cd = bdev->bd_disk->private_data; 241 struct pcd_unit *cd = bdev->bd_disk->private_data;
241 return cdrom_ioctl(&cd->info, bdev, mode, cmd, arg); 242 int ret;
243
244 lock_kernel();
245 ret = cdrom_ioctl(&cd->info, bdev, mode, cmd, arg);
246 unlock_kernel();
247
248 return ret;
242} 249}
243 250
244static int pcd_block_media_changed(struct gendisk *disk) 251static int pcd_block_media_changed(struct gendisk *disk)
@@ -251,7 +258,7 @@ static const struct block_device_operations pcd_bdops = {
251 .owner = THIS_MODULE, 258 .owner = THIS_MODULE,
252 .open = pcd_block_open, 259 .open = pcd_block_open,
253 .release = pcd_block_release, 260 .release = pcd_block_release,
254 .locked_ioctl = pcd_block_ioctl, 261 .ioctl = pcd_block_ioctl,
255 .media_changed = pcd_block_media_changed, 262 .media_changed = pcd_block_media_changed,
256}; 263};
257 264
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 4e8b9bff3abe..c4d6ed9846ca 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -153,6 +153,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_GEO, D_SBY, D_DLY, D_SLV};
153#include <linux/blkdev.h> 153#include <linux/blkdev.h>
154#include <linux/blkpg.h> 154#include <linux/blkpg.h>
155#include <linux/kernel.h> 155#include <linux/kernel.h>
156#include <linux/smp_lock.h>
156#include <asm/uaccess.h> 157#include <asm/uaccess.h>
157#include <linux/workqueue.h> 158#include <linux/workqueue.h>
158 159
@@ -768,8 +769,10 @@ static int pd_ioctl(struct block_device *bdev, fmode_t mode,
768 769
769 switch (cmd) { 770 switch (cmd) {
770 case CDROMEJECT: 771 case CDROMEJECT:
772 lock_kernel();
771 if (disk->access == 1) 773 if (disk->access == 1)
772 pd_special_command(disk, pd_eject); 774 pd_special_command(disk, pd_eject);
775 unlock_kernel();
773 return 0; 776 return 0;
774 default: 777 default:
775 return -EINVAL; 778 return -EINVAL;
@@ -812,7 +815,7 @@ static const struct block_device_operations pd_fops = {
812 .owner = THIS_MODULE, 815 .owner = THIS_MODULE,
813 .open = pd_open, 816 .open = pd_open,
814 .release = pd_release, 817 .release = pd_release,
815 .locked_ioctl = pd_ioctl, 818 .ioctl = pd_ioctl,
816 .getgeo = pd_getgeo, 819 .getgeo = pd_getgeo,
817 .media_changed = pd_check_media, 820 .media_changed = pd_check_media,
818 .revalidate_disk= pd_revalidate 821 .revalidate_disk= pd_revalidate
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index c059aab3006b..38b4d566b816 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -152,6 +152,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_LUN, D_DLY};
152#include <linux/spinlock.h> 152#include <linux/spinlock.h>
153#include <linux/blkdev.h> 153#include <linux/blkdev.h>
154#include <linux/blkpg.h> 154#include <linux/blkpg.h>
155#include <linux/smp_lock.h>
155#include <asm/uaccess.h> 156#include <asm/uaccess.h>
156 157
157static DEFINE_SPINLOCK(pf_spin_lock); 158static DEFINE_SPINLOCK(pf_spin_lock);
@@ -266,7 +267,7 @@ static const struct block_device_operations pf_fops = {
266 .owner = THIS_MODULE, 267 .owner = THIS_MODULE,
267 .open = pf_open, 268 .open = pf_open,
268 .release = pf_release, 269 .release = pf_release,
269 .locked_ioctl = pf_ioctl, 270 .ioctl = pf_ioctl,
270 .getgeo = pf_getgeo, 271 .getgeo = pf_getgeo,
271 .media_changed = pf_check_media, 272 .media_changed = pf_check_media,
272}; 273};
@@ -342,7 +343,10 @@ static int pf_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, u
342 343
343 if (pf->access != 1) 344 if (pf->access != 1)
344 return -EBUSY; 345 return -EBUSY;
346 lock_kernel();
345 pf_eject(pf); 347 pf_eject(pf);
348 unlock_kernel();
349
346 return 0; 350 return 0;
347} 351}
348 352
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 9f3e4454274b..40f1e31f42c4 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -57,6 +57,7 @@
57#include <linux/seq_file.h> 57#include <linux/seq_file.h>
58#include <linux/miscdevice.h> 58#include <linux/miscdevice.h>
59#include <linux/freezer.h> 59#include <linux/freezer.h>
60#include <linux/smp_lock.h>
60#include <linux/mutex.h> 61#include <linux/mutex.h>
61#include <linux/slab.h> 62#include <linux/slab.h>
62#include <scsi/scsi_cmnd.h> 63#include <scsi/scsi_cmnd.h>
@@ -2762,10 +2763,12 @@ out_mem:
2762static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) 2763static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)
2763{ 2764{
2764 struct pktcdvd_device *pd = bdev->bd_disk->private_data; 2765 struct pktcdvd_device *pd = bdev->bd_disk->private_data;
2766 int ret;
2765 2767
2766 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, 2768 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd,
2767 MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev)); 2769 MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev));
2768 2770
2771 lock_kernel();
2769 switch (cmd) { 2772 switch (cmd) {
2770 case CDROMEJECT: 2773 case CDROMEJECT:
2771 /* 2774 /*
@@ -2783,14 +2786,16 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
2783 case CDROM_LAST_WRITTEN: 2786 case CDROM_LAST_WRITTEN:
2784 case CDROM_SEND_PACKET: 2787 case CDROM_SEND_PACKET:
2785 case SCSI_IOCTL_SEND_COMMAND: 2788 case SCSI_IOCTL_SEND_COMMAND:
2786 return __blkdev_driver_ioctl(pd->bdev, mode, cmd, arg); 2789 ret = __blkdev_driver_ioctl(pd->bdev, mode, cmd, arg);
2790 break;
2787 2791
2788 default: 2792 default:
2789 VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); 2793 VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd);
2790 return -ENOTTY; 2794 ret = -ENOTTY;
2791 } 2795 }
2796 unlock_kernel();
2792 2797
2793 return 0; 2798 return ret;
2794} 2799}
2795 2800
2796static int pkt_media_changed(struct gendisk *disk) 2801static int pkt_media_changed(struct gendisk *disk)
@@ -2812,7 +2817,7 @@ static const struct block_device_operations pktcdvd_ops = {
2812 .owner = THIS_MODULE, 2817 .owner = THIS_MODULE,
2813 .open = pkt_open, 2818 .open = pkt_open,
2814 .release = pkt_close, 2819 .release = pkt_close,
2815 .locked_ioctl = pkt_ioctl, 2820 .ioctl = pkt_ioctl,
2816 .media_changed = pkt_media_changed, 2821 .media_changed = pkt_media_changed,
2817}; 2822};
2818 2823
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index e463657569ff..f04f74e3758f 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -20,6 +20,7 @@
20#include <linux/fd.h> 20#include <linux/fd.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/blkdev.h> 22#include <linux/blkdev.h>
23#include <linux/smp_lock.h>
23#include <linux/hdreg.h> 24#include <linux/hdreg.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
@@ -690,7 +691,9 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode,
690 case FDEJECT: 691 case FDEJECT:
691 if (fs->ref_count != 1) 692 if (fs->ref_count != 1)
692 return -EBUSY; 693 return -EBUSY;
694 lock_kernel();
693 err = floppy_eject(fs); 695 err = floppy_eject(fs);
696 unlock_kernel();
694 return err; 697 return err;
695 698
696 case FDGETPRM: 699 case FDGETPRM:
@@ -753,7 +756,7 @@ static const struct block_device_operations floppy_fops = {
753 .owner = THIS_MODULE, 756 .owner = THIS_MODULE,
754 .open = floppy_open, 757 .open = floppy_open,
755 .release = floppy_release, 758 .release = floppy_release,
756 .locked_ioctl = floppy_ioctl, 759 .ioctl = floppy_ioctl,
757 .getgeo = floppy_getgeo, 760 .getgeo = floppy_getgeo,
758 .media_changed = floppy_check_change, 761 .media_changed = floppy_check_change,
759 .revalidate_disk = floppy_revalidate, 762 .revalidate_disk = floppy_revalidate,
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index ed6fb91123ab..f3657b2a5386 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -25,6 +25,7 @@
25#include <linux/ioctl.h> 25#include <linux/ioctl.h>
26#include <linux/blkdev.h> 26#include <linux/blkdev.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/smp_lock.h>
28#include <linux/module.h> 29#include <linux/module.h>
29#include <linux/spinlock.h> 30#include <linux/spinlock.h>
30#include <asm/io.h> 31#include <asm/io.h>
@@ -839,7 +840,7 @@ static int fd_eject(struct floppy_state *fs)
839static struct floppy_struct floppy_type = 840static struct floppy_struct floppy_type =
840 { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL }; /* 7 1.44MB 3.5" */ 841 { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL }; /* 7 1.44MB 3.5" */
841 842
842static int floppy_ioctl(struct block_device *bdev, fmode_t mode, 843static int floppy_locked_ioctl(struct block_device *bdev, fmode_t mode,
843 unsigned int cmd, unsigned long param) 844 unsigned int cmd, unsigned long param)
844{ 845{
845 struct floppy_state *fs = bdev->bd_disk->private_data; 846 struct floppy_state *fs = bdev->bd_disk->private_data;
@@ -867,6 +868,18 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode,
867 return -ENOTTY; 868 return -ENOTTY;
868} 869}
869 870
871static int floppy_ioctl(struct block_device *bdev, fmode_t mode,
872 unsigned int cmd, unsigned long param)
873{
874 int ret;
875
876 lock_kernel();
877 ret = floppy_locked_ioctl(bdev, mode, cmd, param);
878 unlock_kernel();
879
880 return ret;
881}
882
870static int floppy_open(struct block_device *bdev, fmode_t mode) 883static int floppy_open(struct block_device *bdev, fmode_t mode)
871{ 884{
872 struct floppy_state *fs = bdev->bd_disk->private_data; 885 struct floppy_state *fs = bdev->bd_disk->private_data;
@@ -997,7 +1010,7 @@ static int floppy_revalidate(struct gendisk *disk)
997static const struct block_device_operations floppy_fops = { 1010static const struct block_device_operations floppy_fops = {
998 .open = floppy_open, 1011 .open = floppy_open,
999 .release = floppy_release, 1012 .release = floppy_release,
1000 .locked_ioctl = floppy_ioctl, 1013 .ioctl = floppy_ioctl,
1001 .media_changed = floppy_check_change, 1014 .media_changed = floppy_check_change,
1002 .revalidate_disk= floppy_revalidate, 1015 .revalidate_disk= floppy_revalidate,
1003}; 1016};
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index aaf27fb4efd6..102ed52d0e0f 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -28,6 +28,7 @@
28#include <linux/timer.h> 28#include <linux/timer.h>
29#include <linux/scatterlist.h> 29#include <linux/scatterlist.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/smp_lock.h>
31#include <scsi/scsi.h> 32#include <scsi/scsi.h>
32 33
33#define DRV_NAME "ub" 34#define DRV_NAME "ub"
@@ -1729,8 +1730,13 @@ static int ub_bd_ioctl(struct block_device *bdev, fmode_t mode,
1729{ 1730{
1730 struct gendisk *disk = bdev->bd_disk; 1731 struct gendisk *disk = bdev->bd_disk;
1731 void __user *usermem = (void __user *) arg; 1732 void __user *usermem = (void __user *) arg;
1733 int ret;
1734
1735 lock_kernel();
1736 ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem);
1737 unlock_kernel();
1732 1738
1733 return scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); 1739 return ret;
1734} 1740}
1735 1741
1736/* 1742/*
@@ -1794,7 +1800,7 @@ static const struct block_device_operations ub_bd_fops = {
1794 .owner = THIS_MODULE, 1800 .owner = THIS_MODULE,
1795 .open = ub_bd_open, 1801 .open = ub_bd_open,
1796 .release = ub_bd_release, 1802 .release = ub_bd_release,
1797 .locked_ioctl = ub_bd_ioctl, 1803 .ioctl = ub_bd_ioctl,
1798 .media_changed = ub_bd_media_changed, 1804 .media_changed = ub_bd_media_changed,
1799 .revalidate_disk = ub_bd_revalidate, 1805 .revalidate_disk = ub_bd_revalidate,
1800}; 1806};
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 0a3222fd4442..7b0f7b624adf 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -2,6 +2,7 @@
2#include <linux/spinlock.h> 2#include <linux/spinlock.h>
3#include <linux/slab.h> 3#include <linux/slab.h>
4#include <linux/blkdev.h> 4#include <linux/blkdev.h>
5#include <linux/smp_lock.h>
5#include <linux/hdreg.h> 6#include <linux/hdreg.h>
6#include <linux/virtio.h> 7#include <linux/virtio.h>
7#include <linux/virtio_blk.h> 8#include <linux/virtio_blk.h>
@@ -217,7 +218,7 @@ static int virtblk_get_id(struct gendisk *disk, char *id_str)
217 return blk_execute_rq(vblk->disk->queue, vblk->disk, req, false); 218 return blk_execute_rq(vblk->disk->queue, vblk->disk, req, false);
218} 219}
219 220
220static int virtblk_ioctl(struct block_device *bdev, fmode_t mode, 221static int virtblk_locked_ioctl(struct block_device *bdev, fmode_t mode,
221 unsigned cmd, unsigned long data) 222 unsigned cmd, unsigned long data)
222{ 223{
223 struct gendisk *disk = bdev->bd_disk; 224 struct gendisk *disk = bdev->bd_disk;
@@ -243,6 +244,18 @@ static int virtblk_ioctl(struct block_device *bdev, fmode_t mode,
243 (void __user *)data); 244 (void __user *)data);
244} 245}
245 246
247static int virtblk_ioctl(struct block_device *bdev, fmode_t mode,
248 unsigned int cmd, unsigned long param)
249{
250 int ret;
251
252 lock_kernel();
253 ret = virtblk_locked_ioctl(bdev, mode, cmd, param);
254 unlock_kernel();
255
256 return ret;
257}
258
246/* We provide getgeo only to please some old bootloader/partitioning tools */ 259/* We provide getgeo only to please some old bootloader/partitioning tools */
247static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo) 260static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo)
248{ 261{
@@ -269,7 +282,7 @@ static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo)
269} 282}
270 283
271static const struct block_device_operations virtblk_fops = { 284static const struct block_device_operations virtblk_fops = {
272 .locked_ioctl = virtblk_ioctl, 285 .ioctl = virtblk_ioctl,
273 .owner = THIS_MODULE, 286 .owner = THIS_MODULE,
274 .getgeo = virtblk_getgeo, 287 .getgeo = virtblk_getgeo,
275}; 288};
diff --git a/drivers/block/xd.c b/drivers/block/xd.c
index b16a3a926cf2..d5a3cd750561 100644
--- a/drivers/block/xd.c
+++ b/drivers/block/xd.c
@@ -46,6 +46,7 @@
46#include <linux/init.h> 46#include <linux/init.h>
47#include <linux/wait.h> 47#include <linux/wait.h>
48#include <linux/blkdev.h> 48#include <linux/blkdev.h>
49#include <linux/smp_lock.h>
49#include <linux/blkpg.h> 50#include <linux/blkpg.h>
50#include <linux/delay.h> 51#include <linux/delay.h>
51#include <linux/io.h> 52#include <linux/io.h>
@@ -133,7 +134,7 @@ static int xd_getgeo(struct block_device *bdev, struct hd_geometry *geo);
133 134
134static const struct block_device_operations xd_fops = { 135static const struct block_device_operations xd_fops = {
135 .owner = THIS_MODULE, 136 .owner = THIS_MODULE,
136 .locked_ioctl = xd_ioctl, 137 .ioctl = xd_ioctl,
137 .getgeo = xd_getgeo, 138 .getgeo = xd_getgeo,
138}; 139};
139static DECLARE_WAIT_QUEUE_HEAD(xd_wait_int); 140static DECLARE_WAIT_QUEUE_HEAD(xd_wait_int);
@@ -347,7 +348,7 @@ static int xd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
347} 348}
348 349
349/* xd_ioctl: handle device ioctl's */ 350/* xd_ioctl: handle device ioctl's */
350static int xd_ioctl(struct block_device *bdev, fmode_t mode, u_int cmd, u_long arg) 351static int xd_locked_ioctl(struct block_device *bdev, fmode_t mode, u_int cmd, u_long arg)
351{ 352{
352 switch (cmd) { 353 switch (cmd) {
353 case HDIO_SET_DMA: 354 case HDIO_SET_DMA:
@@ -375,6 +376,18 @@ static int xd_ioctl(struct block_device *bdev, fmode_t mode, u_int cmd, u_long a
375 } 376 }
376} 377}
377 378
379static int xd_ioctl(struct block_device *bdev, fmode_t mode,
380 unsigned int cmd, unsigned long param)
381{
382 int ret;
383
384 lock_kernel();
385 ret = xd_locked_ioctl(bdev, mode, cmd, param);
386 unlock_kernel();
387
388 return ret;
389}
390
378/* xd_readwrite: handle a read/write request */ 391/* xd_readwrite: handle a read/write request */
379static int xd_readwrite (u_char operation,XD_INFO *p,char *buffer,u_int block,u_int count) 392static int xd_readwrite (u_char operation,XD_INFO *p,char *buffer,u_int block,u_int count)
380{ 393{
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 76af65b654e3..9119cd3d56a4 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -1045,7 +1045,7 @@ static const struct block_device_operations xlvbd_block_fops =
1045 .open = blkif_open, 1045 .open = blkif_open,
1046 .release = blkif_release, 1046 .release = blkif_release,
1047 .getgeo = blkif_getgeo, 1047 .getgeo = blkif_getgeo,
1048 .locked_ioctl = blkif_ioctl, 1048 .ioctl = blkif_ioctl,
1049}; 1049};
1050 1050
1051 1051