Commit 45e79a3a authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by Jens Axboe

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: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 7e75d730
...@@ -900,7 +900,7 @@ bsg_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -900,7 +900,7 @@ bsg_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
case SG_EMULATED_HOST: case SG_EMULATED_HOST:
case SCSI_IOCTL_SEND_COMMAND: { case SCSI_IOCTL_SEND_COMMAND: {
void __user *uarg = (void __user *) arg; void __user *uarg = (void __user *) arg;
return scsi_cmd_ioctl(file, bd->disk, cmd, uarg); return scsi_cmd_ioctl(file, bd->queue, bd->disk, cmd, uarg);
} }
case SG_IO: { case SG_IO: {
struct request *rq; struct request *rq;
......
...@@ -548,16 +548,12 @@ static inline int blk_send_start_stop(request_queue_t *q, struct gendisk *bd_dis ...@@ -548,16 +548,12 @@ static inline int blk_send_start_stop(request_queue_t *q, struct gendisk *bd_dis
return __blk_send_generic(q, bd_disk, GPCMD_START_STOP_UNIT, data); return __blk_send_generic(q, bd_disk, GPCMD_START_STOP_UNIT, data);
} }
int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd, void __user *arg) int scsi_cmd_ioctl(struct file *file, struct request_queue *q,
struct gendisk *bd_disk, unsigned int cmd, void __user *arg)
{ {
request_queue_t *q;
int err; int err;
q = bd_disk->queue; if (!q || blk_get_queue(q))
if (!q)
return -ENXIO;
if (blk_get_queue(q))
return -ENXIO; return -ENXIO;
switch (cmd) { switch (cmd) {
......
...@@ -1709,7 +1709,7 @@ static int ub_bd_ioctl(struct inode *inode, struct file *filp, ...@@ -1709,7 +1709,7 @@ static int ub_bd_ioctl(struct inode *inode, struct file *filp,
struct gendisk *disk = inode->i_bdev->bd_disk; struct gendisk *disk = inode->i_bdev->bd_disk;
void __user *usermem = (void __user *) arg; void __user *usermem = (void __user *) arg;
return scsi_cmd_ioctl(filp, disk, cmd, usermem); return scsi_cmd_ioctl(filp, disk->queue, disk, cmd, usermem);
} }
/* /*
......
...@@ -2695,11 +2695,12 @@ int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi, ...@@ -2695,11 +2695,12 @@ int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi,
{ {
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
int ret; int ret;
struct gendisk *disk = ip->i_bdev->bd_disk;
/* /*
* Try the generic SCSI command ioctl's first. * Try the generic SCSI command ioctl's first.
*/ */
ret = scsi_cmd_ioctl(file, ip->i_bdev->bd_disk, cmd, argp); ret = scsi_cmd_ioctl(file, disk->queue, disk, cmd, argp);
if (ret != -ENOTTY) if (ret != -ENOTTY)
return ret; return ret;
......
...@@ -1052,7 +1052,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device ...@@ -1052,7 +1052,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
int err, (*setfunc)(ide_drive_t *, int); int err, (*setfunc)(ide_drive_t *, int);
u8 *val; u8 *val;
err = scsi_cmd_ioctl(file, bdev->bd_disk, cmd, p); err = scsi_cmd_ioctl(file, bdev->bd_disk->queue, bdev->bd_disk, cmd, p);
if (err != -ENOTTY) if (err != -ENOTTY)
return err; return err;
......
...@@ -684,7 +684,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp, ...@@ -684,7 +684,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
case SCSI_IOCTL_GET_BUS_NUMBER: case SCSI_IOCTL_GET_BUS_NUMBER:
return scsi_ioctl(sdp, cmd, p); return scsi_ioctl(sdp, cmd, p);
default: default:
error = scsi_cmd_ioctl(filp, disk, cmd, p); error = scsi_cmd_ioctl(filp, disk->queue, disk, cmd, p);
if (error != -ENOTTY) if (error != -ENOTTY)
return error; return error;
} }
......
...@@ -3549,7 +3549,8 @@ static int st_ioctl(struct inode *inode, struct file *file, ...@@ -3549,7 +3549,8 @@ static int st_ioctl(struct inode *inode, struct file *file,
!capable(CAP_SYS_RAWIO)) !capable(CAP_SYS_RAWIO))
i = -EPERM; i = -EPERM;
else else
i = scsi_cmd_ioctl(file, STp->disk, cmd_in, p); i = scsi_cmd_ioctl(file, STp->disk->queue,
STp->disk, cmd_in, p);
if (i != -ENOTTY) if (i != -ENOTTY)
return i; return i;
break; break;
......
...@@ -644,7 +644,8 @@ extern void blk_requeue_request(request_queue_t *, struct request *); ...@@ -644,7 +644,8 @@ extern void blk_requeue_request(request_queue_t *, struct request *);
extern void blk_plug_device(request_queue_t *); extern void blk_plug_device(request_queue_t *);
extern int blk_remove_plug(request_queue_t *); extern int blk_remove_plug(request_queue_t *);
extern void blk_recount_segments(request_queue_t *, struct bio *); extern void blk_recount_segments(request_queue_t *, struct bio *);
extern int scsi_cmd_ioctl(struct file *, struct gendisk *, unsigned int, void __user *); extern int scsi_cmd_ioctl(struct file *, struct request_queue *,
struct gendisk *, unsigned int, void __user *);
extern int sg_scsi_ioctl(struct file *, struct request_queue *, extern int sg_scsi_ioctl(struct file *, struct request_queue *,
struct gendisk *, struct scsi_ioctl_command __user *); struct gendisk *, struct scsi_ioctl_command __user *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment