aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2007-07-09 06:39:20 -0400
committerJens Axboe <jens.axboe@oracle.com>2007-07-16 02:52:45 -0400
commit45e79a3acdcf54113b3d7b23e9e64e6541dbfeb5 (patch)
treeb8e7598b26ce446577e162189e635f6b87b10a5b
parent7e75d73080d822d2bbbd5b0f7f293719dd1f9109 (diff)
bsg: add a request_queue argument to scsi_cmd_ioctl()
bsg uses scsi_cmd_ioctl() for some SCSI/sg ioctl commands. scsi_cmd_ioctl() gets a request queue from a gendisk arguement. This prevents bsg being bound to SCSI devices that don't have a gendisk (like OSD). This adds a request_queue argument to scsi_cmd_ioctl(). The SCSI/sg ioctl commands doesn't use a gendisk so it's safe for any SCSI devices to use scsi_cmd_ioctl(). Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--block/bsg.c2
-rw-r--r--block/scsi_ioctl.c10
-rw-r--r--drivers/block/ub.c2
-rw-r--r--drivers/cdrom/cdrom.c3
-rw-r--r--drivers/ide/ide.c2
-rw-r--r--drivers/scsi/sd.c2
-rw-r--r--drivers/scsi/st.c3
-rw-r--r--include/linux/blkdev.h3
8 files changed, 13 insertions, 14 deletions
diff --git a/block/bsg.c b/block/bsg.c
index c85d961ee41e..0427ece9b6d8 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -900,7 +900,7 @@ bsg_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
900 case SG_EMULATED_HOST: 900 case SG_EMULATED_HOST:
901 case SCSI_IOCTL_SEND_COMMAND: { 901 case SCSI_IOCTL_SEND_COMMAND: {
902 void __user *uarg = (void __user *) arg; 902 void __user *uarg = (void __user *) arg;
903 return scsi_cmd_ioctl(file, bd->disk, cmd, uarg); 903 return scsi_cmd_ioctl(file, bd->queue, bd->disk, cmd, uarg);
904 } 904 }
905 case SG_IO: { 905 case SG_IO: {
906 struct request *rq; 906 struct request *rq;
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index db53b2c268d3..a26ba07955fe 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -548,16 +548,12 @@ static inline int blk_send_start_stop(request_queue_t *q, struct gendisk *bd_dis
548 return __blk_send_generic(q, bd_disk, GPCMD_START_STOP_UNIT, data); 548 return __blk_send_generic(q, bd_disk, GPCMD_START_STOP_UNIT, data);
549} 549}
550 550
551int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd, void __user *arg) 551int scsi_cmd_ioctl(struct file *file, struct request_queue *q,
552 struct gendisk *bd_disk, unsigned int cmd, void __user *arg)
552{ 553{
553 request_queue_t *q;
554 int err; 554 int err;
555 555
556 q = bd_disk->queue; 556 if (!q || blk_get_queue(q))
557 if (!q)
558 return -ENXIO;
559
560 if (blk_get_queue(q))
561 return -ENXIO; 557 return -ENXIO;
562 558
563 switch (cmd) { 559 switch (cmd) {
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 18c8b6c0db20..8b13d7d2cb63 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -1709,7 +1709,7 @@ static int ub_bd_ioctl(struct inode *inode, struct file *filp,
1709 struct gendisk *disk = inode->i_bdev->bd_disk; 1709 struct gendisk *disk = inode->i_bdev->bd_disk;
1710 void __user *usermem = (void __user *) arg; 1710 void __user *usermem = (void __user *) arg;
1711 1711
1712 return scsi_cmd_ioctl(filp, disk, cmd, usermem); 1712 return scsi_cmd_ioctl(filp, disk->queue, disk, cmd, usermem);
1713} 1713}
1714 1714
1715/* 1715/*
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index aa5468f487ba..499019bf8f40 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -2695,11 +2695,12 @@ int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi,
2695{ 2695{
2696 void __user *argp = (void __user *)arg; 2696 void __user *argp = (void __user *)arg;
2697 int ret; 2697 int ret;
2698 struct gendisk *disk = ip->i_bdev->bd_disk;
2698 2699
2699 /* 2700 /*
2700 * Try the generic SCSI command ioctl's first. 2701 * Try the generic SCSI command ioctl's first.
2701 */ 2702 */
2702 ret = scsi_cmd_ioctl(file, ip->i_bdev->bd_disk, cmd, argp); 2703 ret = scsi_cmd_ioctl(file, disk->queue, disk, cmd, argp);
2703 if (ret != -ENOTTY) 2704 if (ret != -ENOTTY)
2704 return ret; 2705 return ret;
2705 2706
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 9ae60a7400a2..8cd7694593c9 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1052,7 +1052,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
1052 int err, (*setfunc)(ide_drive_t *, int); 1052 int err, (*setfunc)(ide_drive_t *, int);
1053 u8 *val; 1053 u8 *val;
1054 1054
1055 err = scsi_cmd_ioctl(file, bdev->bd_disk, cmd, p); 1055 err = scsi_cmd_ioctl(file, bdev->bd_disk->queue, bdev->bd_disk, cmd, p);
1056 if (err != -ENOTTY) 1056 if (err != -ENOTTY)
1057 return err; 1057 return err;
1058 1058
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 448d316f12d7..424d557284a9 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -684,7 +684,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
684 case SCSI_IOCTL_GET_BUS_NUMBER: 684 case SCSI_IOCTL_GET_BUS_NUMBER:
685 return scsi_ioctl(sdp, cmd, p); 685 return scsi_ioctl(sdp, cmd, p);
686 default: 686 default:
687 error = scsi_cmd_ioctl(filp, disk, cmd, p); 687 error = scsi_cmd_ioctl(filp, disk->queue, disk, cmd, p);
688 if (error != -ENOTTY) 688 if (error != -ENOTTY)
689 return error; 689 return error;
690 } 690 }
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 55bfeccf68a2..a4f7b8465773 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -3549,7 +3549,8 @@ static int st_ioctl(struct inode *inode, struct file *file,
3549 !capable(CAP_SYS_RAWIO)) 3549 !capable(CAP_SYS_RAWIO))
3550 i = -EPERM; 3550 i = -EPERM;
3551 else 3551 else
3552 i = scsi_cmd_ioctl(file, STp->disk, cmd_in, p); 3552 i = scsi_cmd_ioctl(file, STp->disk->queue,
3553 STp->disk, cmd_in, p);
3553 if (i != -ENOTTY) 3554 if (i != -ENOTTY)
3554 return i; 3555 return i;
3555 break; 3556 break;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f6bc0d03ffad..2746632c2267 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -644,7 +644,8 @@ extern void blk_requeue_request(request_queue_t *, struct request *);
644extern void blk_plug_device(request_queue_t *); 644extern void blk_plug_device(request_queue_t *);
645extern int blk_remove_plug(request_queue_t *); 645extern int blk_remove_plug(request_queue_t *);
646extern void blk_recount_segments(request_queue_t *, struct bio *); 646extern void blk_recount_segments(request_queue_t *, struct bio *);
647extern int scsi_cmd_ioctl(struct file *, struct gendisk *, unsigned int, void __user *); 647extern int scsi_cmd_ioctl(struct file *, struct request_queue *,
648 struct gendisk *, unsigned int, void __user *);
648extern int sg_scsi_ioctl(struct file *, struct request_queue *, 649extern int sg_scsi_ioctl(struct file *, struct request_queue *,
649 struct gendisk *, struct scsi_ioctl_command __user *); 650 struct gendisk *, struct scsi_ioctl_command __user *);
650 651