aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-07-08 04:18:46 -0400
committerJens Axboe <jaxboe@fusionio.com>2010-08-07 12:25:00 -0400
commit8a6cfeb6deca3a8fefd639d898b0d163c0b5d368 (patch)
tree9a633ad48c3b1ada0519ee7bade0602f940037f6 /drivers/scsi
parent34484062445fe905bf02c72f87ddda21881acda3 (diff)
block: push down BKL into .locked_ioctl
As a preparation for the removal of the big kernel lock in the block layer, this removes the BKL from the common ioctl handling code, moving it into every single driver still using it. 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/scsi')
-rw-r--r--drivers/scsi/sd.c17
-rw-r--r--drivers/scsi/sr.c18
2 files changed, 25 insertions, 10 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 1d0c4b7c3b69..633ac32b25c1 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -46,6 +46,7 @@
46#include <linux/blkdev.h> 46#include <linux/blkdev.h>
47#include <linux/blkpg.h> 47#include <linux/blkpg.h>
48#include <linux/delay.h> 48#include <linux/delay.h>
49#include <linux/smp_lock.h>
49#include <linux/mutex.h> 50#include <linux/mutex.h>
50#include <linux/string_helpers.h> 51#include <linux/string_helpers.h>
51#include <linux/async.h> 52#include <linux/async.h>
@@ -924,6 +925,7 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,
924 SCSI_LOG_IOCTL(1, printk("sd_ioctl: disk=%s, cmd=0x%x\n", 925 SCSI_LOG_IOCTL(1, printk("sd_ioctl: disk=%s, cmd=0x%x\n",
925 disk->disk_name, cmd)); 926 disk->disk_name, cmd));
926 927
928 lock_kernel();
927 /* 929 /*
928 * If we are in the middle of error recovery, don't let anyone 930 * If we are in the middle of error recovery, don't let anyone
929 * else try and use this device. Also, if error recovery fails, it 931 * else try and use this device. Also, if error recovery fails, it
@@ -933,7 +935,7 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,
933 error = scsi_nonblockable_ioctl(sdp, cmd, p, 935 error = scsi_nonblockable_ioctl(sdp, cmd, p,
934 (mode & FMODE_NDELAY) != 0); 936 (mode & FMODE_NDELAY) != 0);
935 if (!scsi_block_when_processing_errors(sdp) || !error) 937 if (!scsi_block_when_processing_errors(sdp) || !error)
936 return error; 938 goto out;
937 939
938 /* 940 /*
939 * Send SCSI addressing ioctls directly to mid level, send other 941 * Send SCSI addressing ioctls directly to mid level, send other
@@ -943,13 +945,18 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,
943 switch (cmd) { 945 switch (cmd) {
944 case SCSI_IOCTL_GET_IDLUN: 946 case SCSI_IOCTL_GET_IDLUN:
945 case SCSI_IOCTL_GET_BUS_NUMBER: 947 case SCSI_IOCTL_GET_BUS_NUMBER:
946 return scsi_ioctl(sdp, cmd, p); 948 error = scsi_ioctl(sdp, cmd, p);
949 break;
947 default: 950 default:
948 error = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, p); 951 error = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, p);
949 if (error != -ENOTTY) 952 if (error != -ENOTTY)
950 return error; 953 break;
954 error = scsi_ioctl(sdp, cmd, p);
955 break;
951 } 956 }
952 return scsi_ioctl(sdp, cmd, p); 957out:
958 unlock_kernel();
959 return error;
953} 960}
954 961
955static void set_media_not_present(struct scsi_disk *sdkp) 962static void set_media_not_present(struct scsi_disk *sdkp)
@@ -1123,7 +1130,7 @@ static const struct block_device_operations sd_fops = {
1123 .owner = THIS_MODULE, 1130 .owner = THIS_MODULE,
1124 .open = sd_open, 1131 .open = sd_open,
1125 .release = sd_release, 1132 .release = sd_release,
1126 .locked_ioctl = sd_ioctl, 1133 .ioctl = sd_ioctl,
1127 .getgeo = sd_getgeo, 1134 .getgeo = sd_getgeo,
1128#ifdef CONFIG_COMPAT 1135#ifdef CONFIG_COMPAT
1129 .compat_ioctl = sd_compat_ioctl, 1136 .compat_ioctl = sd_compat_ioctl,
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 0a90abc7f140..d42fa6468f41 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -44,6 +44,7 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/blkdev.h> 45#include <linux/blkdev.h>
46#include <linux/mutex.h> 46#include <linux/mutex.h>
47#include <linux/smp_lock.h>
47#include <linux/slab.h> 48#include <linux/slab.h>
48#include <asm/uaccess.h> 49#include <asm/uaccess.h>
49 50
@@ -493,6 +494,8 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
493 void __user *argp = (void __user *)arg; 494 void __user *argp = (void __user *)arg;
494 int ret; 495 int ret;
495 496
497 lock_kernel();
498
496 /* 499 /*
497 * Send SCSI addressing ioctls directly to mid level, send other 500 * Send SCSI addressing ioctls directly to mid level, send other
498 * ioctls to cdrom/block level. 501 * ioctls to cdrom/block level.
@@ -500,12 +503,13 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
500 switch (cmd) { 503 switch (cmd) {
501 case SCSI_IOCTL_GET_IDLUN: 504 case SCSI_IOCTL_GET_IDLUN:
502 case SCSI_IOCTL_GET_BUS_NUMBER: 505 case SCSI_IOCTL_GET_BUS_NUMBER:
503 return scsi_ioctl(sdev, cmd, argp); 506 ret = scsi_ioctl(sdev, cmd, argp);
507 goto out;
504 } 508 }
505 509
506 ret = cdrom_ioctl(&cd->cdi, bdev, mode, cmd, arg); 510 ret = cdrom_ioctl(&cd->cdi, bdev, mode, cmd, arg);
507 if (ret != -ENOSYS) 511 if (ret != -ENOSYS)
508 return ret; 512 goto out;
509 513
510 /* 514 /*
511 * ENODEV means that we didn't recognise the ioctl, or that we 515 * ENODEV means that we didn't recognise the ioctl, or that we
@@ -516,8 +520,12 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
516 ret = scsi_nonblockable_ioctl(sdev, cmd, argp, 520 ret = scsi_nonblockable_ioctl(sdev, cmd, argp,
517 (mode & FMODE_NDELAY) != 0); 521 (mode & FMODE_NDELAY) != 0);
518 if (ret != -ENODEV) 522 if (ret != -ENODEV)
519 return ret; 523 goto out;
520 return scsi_ioctl(sdev, cmd, argp); 524 ret = scsi_ioctl(sdev, cmd, argp);
525
526out:
527 unlock_kernel();
528 return ret;
521} 529}
522 530
523static int sr_block_media_changed(struct gendisk *disk) 531static int sr_block_media_changed(struct gendisk *disk)
@@ -531,7 +539,7 @@ static const struct block_device_operations sr_bdops =
531 .owner = THIS_MODULE, 539 .owner = THIS_MODULE,
532 .open = sr_block_open, 540 .open = sr_block_open,
533 .release = sr_block_release, 541 .release = sr_block_release,
534 .locked_ioctl = sr_block_ioctl, 542 .ioctl = sr_block_ioctl,
535 .media_changed = sr_block_media_changed, 543 .media_changed = sr_block_media_changed,
536 /* 544 /*
537 * No compat_ioctl for now because sr_block_ioctl never 545 * No compat_ioctl for now because sr_block_ioctl never