cleanup SCSI ioctl support
Subsystems (8)
Hi all,
this series cleans up the scsi ioctl handler and merges the "block layer" SCSI ioctl code that is only used by the SCSI layer and its drivers now into the main SCSI ioctl handler.
Diffstat:
b/block/Kconfig | 26 - b/block/Makefile | 3 b/block/bsg.c | 123 +---- b/drivers/block/Kconfig | 3 b/drivers/block/paride/Kconfig | 1 b/drivers/cdrom/cdrom.c | 7 b/drivers/scsi/Kconfig | 18 b/drivers/scsi/Makefile | 3 b/drivers/scsi/ch.c | 73 --- b/drivers/scsi/scsi_bsg.c | 95 ++++ b/drivers/scsi/scsi_common.c | 6 b/drivers/scsi/scsi_ioctl.c | 848 ++++++++++++++++++++++++++++++++++----- b/drivers/scsi/scsi_lib.c | 7 b/drivers/scsi/scsi_priv.h | 10 b/drivers/scsi/sd.c | 66 --- b/drivers/scsi/sg.c | 33 - b/drivers/scsi/sr.c | 74 --- b/drivers/scsi/st.c | 72 +-- b/drivers/target/Kconfig | 2 b/fs/nfsd/Kconfig | 2 b/include/linux/blkdev.h | 21 b/include/linux/bsg.h | 11 b/include/scsi/scsi_ioctl.h | 9 b/include/scsi/scsi_request.h | 2 block/scsi_ioctl.c | 890 ----------------------------------------- 25 files changed, 1011 insertions(+), 1394 deletions(-)
PATCH 1/24 bsg: remove support for SCSI_IOCTL_SEND_COMMAND
SCSI_IOCTL_SEND_COMMAND has been deprecated longer than bsg exists and has been warning for just as long. More importantly it harcodes SCSI CDBs and thus will do the wrong thing on non-scsi bsg nodes.
--- block/bsg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
block/bsg.c +4 -1
@@ -373,10 +373,13 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case SG_GET_RESERVED_SIZE :case SG_SET_RESERVED_SIZE :case SG_EMULATED_HOST : -case SCSI_IOCTL_SEND_COMMAND :return scsi_cmd_ioctl (bd->queue,NULL , file->f_mode, cmd, uarg);case SG_IO :return bsg_sg_io (bd->queue, file->f_mode, uarg); +case SCSI_IOCTL_SEND_COMMAND : +pr_warn_ratelimited ("%s: calling unsupported SCSI_IOCTL_SEND_COMMAND\n" , + current->comm); +return -EINVAL ;default :return -ENOTTY ; }
Signature · 1 line
2.30.2
Re: [PATCH 01/24] bsg: remove support for SCSI_IOCTL_SEND_COMMAND
Quoted 19 lines · Christoph Hellwig
SCSI_IOCTL_SEND_COMMANDhas been deprecated longer than bsg exists and has been warning for just as long. More importantly it harcodes SCSI CDBs and thus will do the wrong thing on non-scsi bsg nodes.Fixes aa387cc89567 ("block: add bsg helper library")Signed-off-by Christoph Hellwig <[email protected]>--- block/bsg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)block/bsg.c +0
-1@@ -373,10 +373,13 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case SG_GET_RESERVED_SIZE :case SG_SET_RESERVED_SIZE :case SG_EMULATED_HOST : -case SCSI_IOCTL_SEND_COMMAND :
block/bsg.c static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 385
Quoted 10 lines
block/bsg.c +4
-0return scsi_cmd_ioctl (bd->queue,NULL , file->f_mode, cmd, uarg);case SG_IO :return bsg_sg_io (bd->queue, file->f_mode, uarg); +case SCSI_IOCTL_SEND_COMMAND : +pr_warn_ratelimited ("%s: calling unsupported SCSI_IOCTL_SEND_COMMAND\n" , + current->comm); +return -EINVAL ;default :return -ENOTTY ; }
The Fixes: tag will cause this patch to be backported to stable trees. Is that intentional?
Anyway:
Re: [PATCH 01/24] bsg: remove support for SCSI_IOCTL_SEND_COMMAND
Quoted 8 lines · Bart Van Assche
block/bsg.c static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 385
Quoted 5 lines
block/bsg.c +2
-0+ current->comm); +return -EINVAL ;default :return -ENOTTY ; }The Fixes: tag will cause this patch to be backported to stable trees. Is that intentional?
Yes, as this ioctl actively does the wrong thing for non-scsi queues.
PATCH 2/24 sr: consolidate compat ioctl handling
In reply to Christoph HellwigMerge the native and compat ioctl handlers into a single one using in_compat_syscall().
--- drivers/scsi/sr.c | 64 +++++++---------------------------------------- 1 file changed, 9 insertions(+), 55 deletions(-)
drivers/scsi/sr.c +9 -55
@@ -577,68 +577,24 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,switch (cmd) {case SCSI_IOCTL_GET_IDLUN :case SCSI_IOCTL_GET_BUS_NUMBER : - ret =scsi_ioctl (sdev, cmd, argp); - goto put; +break ; +default : + ret =cdrom_ioctl (&cd->cdi, bdev, mode, cmd, arg); +if (ret != -ENOSYS ) + goto put; } - ret =cdrom_ioctl (&cd->cdi, bdev, mode, cmd, arg); -if (ret != -ENOSYS ) - goto put; - - ret =scsi_ioctl (sdev, cmd, argp); - -put: -scsi_autopm_put_device (sdev); - -out: -mutex_unlock (&cd->lock); -return ret; -} - -#ifdef CONFIG_COMPAT -static int sr_block_compat_ioctl (struct block_device *bdev,fmode_t mode,unsigned cmd, -unsigned long arg) -{ -struct scsi_cd *cd =scsi_cd (bdev->bd_disk); -struct scsi_device *sdev = cd->device; -void __user *argp =compat_ptr (arg); -int ret; - -mutex_lock (&cd->lock); - - ret =scsi_ioctl_block_when_processing_errors (sdev, cmd, - (mode &FMODE_NDELAY ) !=0 ); -if (ret) - goto out; - -scsi_autopm_get_device (sdev); - -/* -* Send SCSI addressing ioctls directly to mid level, send other -* ioctls to cdrom/block level. -*/ -switch (cmd) { -case SCSI_IOCTL_GET_IDLUN : -case SCSI_IOCTL_GET_BUS_NUMBER : +if (in_compat_syscall ()) ret =scsi_compat_ioctl (sdev, cmd, argp); - goto put; - } - - ret =cdrom_ioctl (&cd->cdi, bdev, mode, cmd, (unsigned long )argp); -if (ret != -ENOSYS ) - goto put; - - ret =scsi_compat_ioctl (sdev, cmd, argp); +else + ret =scsi_ioctl (sdev, cmd, argp); put:scsi_autopm_put_device (sdev); - out:mutex_unlock (&cd->lock);return ret; - } -#endif static unsigned int sr_block_check_events (struct gendisk *disk,unsigned int clearing)
@@ -663,9 +619,7 @@ static const struct block_device_operations sr_bdops = .open = sr_block_open, .release = sr_block_release, .ioctl = sr_block_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = sr_block_compat_ioctl, -#endif + .compat_ioctl = blkdev_compat_ptr_ioctl, .check_events = sr_block_check_events, };
Signature · 1 line
2.30.2
PATCH 3/24 sd: consolidate compat ioctl handling
In reply to Christoph HellwigMerge the native and compat ioctl handlers into a single one using in_compat_syscall(), and also simplify the calling conventions by mergin sd_ioctl_common into sd_ioctl.
--- drivers/scsi/sd.c | 63 ++++++++++++++--------------------------------- 1 file changed, 18 insertions(+), 45 deletions(-)
drivers/scsi/sd.c +18 -45
@@ -1533,11 +1533,11 @@ static int sd_getgeo(struct block_device *bdev, struct hd_geometry *geo) }/** -* sd_ioctl_common - process an ioctl +* sd_ioctl - process an ioctl * @bdev: target block device * @mode: FMODE_* mask * @cmd: ioctl command number -* @p: this is third argument given to ioctl(2) system call. +* @arg: this is third argument given to ioctl(2) system call. * Often contains a pointer. * * Returns 0 if successful (some ioctls return positive numbers on
@@ -1546,12 +1546,13 @@ static int sd_getgeo(struct block_device *bdev, struct hd_geometry *geo)* Note: most ioctls are forward onto the block subsystem or further * down in the scsi subsystem. **/ -static int sd_ioctl_common (struct block_device *bdev,fmode_t mode, -unsigned int cmd,void __user *p) +static int sd_ioctl (struct block_device *bdev,fmode_t mode, +unsigned int cmd,unsigned long arg) {struct gendisk *disk = bdev->bd_disk;struct scsi_disk *sdkp =scsi_disk (disk);struct scsi_device *sdp = sdkp->device; +void __user *p = (void __user *)arg;int error; SCSI_LOG_IOCTL(1, sd_printk(KERN_INFO, sdkp, "sd_ioctl: disk=%s, "
@@ -1570,7 +1571,7 @@ static int sd_ioctl_common(struct block_device *bdev, fmode_t mode, error =scsi_ioctl_block_when_processing_errors (sdp, cmd, (mode &FMODE_NDELAY ) !=0 );if (error) - goto out; +return error;if (is_sed_ioctl (cmd))return sed_ioctl (sdkp->opal_dev, cmd, p);
@@ -1581,16 +1582,18 @@ static int sd_ioctl_common(struct block_device *bdev, fmode_t mode,* resolved. */ switch (cmd) { -case SCSI_IOCTL_GET_IDLUN : -case SCSI_IOCTL_GET_BUS_NUMBER : - error =scsi_ioctl (sdp, cmd, p); -break ; -default : - error =scsi_cmd_blk_ioctl (bdev, mode, cmd, p); -break ; +case SCSI_IOCTL_GET_IDLUN : +case SCSI_IOCTL_GET_BUS_NUMBER : +break ; +default : + error =scsi_cmd_blk_ioctl (bdev, mode, cmd, p); +if (error != -ENOTTY ) +return error; } -out: -return error; + +if (in_compat_syscall ()) +return scsi_compat_ioctl (sdp, cmd, p); +return scsi_ioctl (sdp, cmd, p); }static void set_media_not_present (struct scsi_disk *sdkp)
@@ -1773,34 +1776,6 @@ static void sd_rescan(struct device *dev)sd_revalidate_disk (sdkp->disk); } -static int sd_ioctl (struct block_device *bdev,fmode_t mode, -unsigned int cmd,unsigned long arg) -{ -void __user *p = (void __user *)arg; -int ret; - - ret =sd_ioctl_common (bdev, mode, cmd, p); -if (ret != -ENOTTY ) -return ret; - -return scsi_ioctl (scsi_disk (bdev->bd_disk)->device, cmd, p); -} - -#ifdef CONFIG_COMPAT -static int sd_compat_ioctl (struct block_device *bdev,fmode_t mode, -unsigned int cmd,unsigned long arg) -{ -void __user *p =compat_ptr (arg); -int ret; - - ret =sd_ioctl_common (bdev, mode, cmd, p); -if (ret != -ENOTTY ) -return ret; - -return scsi_compat_ioctl (scsi_disk (bdev->bd_disk)->device, cmd, p); -} -#endif -static char sd_pr_type (enum pr_type type) {switch (type) {
@@ -1901,9 +1876,7 @@ static const struct block_device_operations sd_fops = { .release = sd_release, .ioctl = sd_ioctl, .getgeo = sd_getgeo, -#ifdef CONFIG_COMPAT - .compat_ioctl = sd_compat_ioctl, -#endif + .compat_ioctl = blkdev_compat_ptr_ioctl, .check_events = sd_check_events, .unlock_native_capacity = sd_unlock_native_capacity, .report_zones = sd_zbc_report_zones,
Signature · 1 line
2.30.2
PATCH 4/24 ch: consolidate compat ioctl handling
In reply to Christoph HellwigMerge the native and compat ioctl handlers into a single one using in_compat_syscall().
--- drivers/scsi/ch.c | 73 ++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 51 deletions(-)
drivers/scsi/ch.c +22 -51
@@ -618,6 +618,12 @@ ch_checkrange(scsi_changer *ch, unsigned int type, unsigned int unit)return 0 ; } +struct changer_element_status32 { +int ces_type; +compat_uptr_t ces_data; +}; +#define CHIOGSTATUS32 _IOW('c', 8,struct changer_element_status32) +static long ch_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {
@@ -748,7 +754,20 @@ static long ch_ioctl(struct file *file,return ch_gstatus (ch, ces.ces_type, ces.ces_data); } +#ifdef CONFIG_COMPAT +case CHIOGSTATUS32 : + { +struct changer_element_status32 ces32; + +if (copy_from_user (&ces32, argp,sizeof (ces32))) +return -EFAULT ; +if (ces32.ces_type <0 || ces32.ces_type >=CH_TYPES ) +return -EINVAL ; +return ch_gstatus (ch, ces32.ces_type, +compat_ptr (ces32.ces_data)); + } +#endif case CHIOGELEM : {struct changer_get_element cge;
@@ -858,59 +877,13 @@ static long ch_ioctl(struct file *file, }default : +if (in_compat_syscall ()) +return scsi_compat_ioctl (ch->device, cmd, argp);return scsi_ioctl (ch->device, cmd, argp); } } -#ifdef CONFIG_COMPAT - -struct changer_element_status32 { -int ces_type; -compat_uptr_t ces_data; -}; -#define CHIOGSTATUS32 _IOW('c', 8,struct changer_element_status32) - -static long ch_ioctl_compat (struct file * file, -unsigned int cmd,unsigned long arg) -{ -scsi_changer *ch = file->private_data; -int retval =scsi_ioctl_block_when_processing_errors (ch->device, cmd, - file->f_flags &O_NDELAY ); -if (retval) -return retval; - -switch (cmd) { -case CHIOGPARAMS : -case CHIOGVPARAMS : -case CHIOPOSITION : -case CHIOMOVE : -case CHIOEXCHANGE : -case CHIOGELEM : -case CHIOINITELEM : -case CHIOSVOLTAG : -/* compatible */ -return ch_ioctl (file, cmd, (unsigned long )compat_ptr (arg)); -case CHIOGSTATUS32 : - { -struct changer_element_status32 ces32; -unsigned char __user *data; - -if (copy_from_user (&ces32, (void __user *)arg,sizeof (ces32))) -return -EFAULT ; -if (ces32.ces_type <0 || ces32.ces_type >=CH_TYPES ) -return -EINVAL ; - - data =compat_ptr (ces32.ces_data); -return ch_gstatus (ch, ces32.ces_type, data); - } -default : -return scsi_compat_ioctl (ch->device, cmd,compat_ptr (arg)); - - } -} -#endif -/* ------------------------------------------------------------------------ */ static int ch_probe (struct device *dev)
@@ -1015,9 +988,7 @@ static const struct file_operations changer_fops = { .open = ch_open, .release = ch_release, .unlocked_ioctl = ch_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = ch_ioctl_compat, -#endif + .compat_ioctl = compat_ptr_ioctl, .llseek = noop_llseek, };
Signature · 1 line
2.30.2
PATCH 5/24 cg: consolidate compat ioctl handling
In reply to Christoph HellwigMerge the native and compat ioctl handlers into a single one using in_compat_syscall().
--- drivers/scsi/sg.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-)
drivers/scsi/sg.c +3 -22
@@ -1166,28 +1166,11 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)if (ret != -ENOIOCTLCMD )return ret; +if (in_compat_syscall ()) +return scsi_compat_ioctl (sdp->device, cmd_in, p);return scsi_ioctl (sdp->device, cmd_in, p); } -#ifdef CONFIG_COMPAT -static long sg_compat_ioctl (struct file *filp,unsigned int cmd_in,unsigned long arg) -{ -void __user *p =compat_ptr (arg); -Sg_device *sdp; -Sg_fd *sfp; -int ret; - -if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) -return -ENXIO ; - - ret =sg_ioctl_common (filp, sdp, sfp, cmd_in, p); -if (ret != -ENOIOCTLCMD ) -return ret; - -return scsi_compat_ioctl (sdp->device, cmd_in, p); -} -#endif -static __poll_t sg_poll (struct file *filp,poll_table * wait) {
@@ -1441,9 +1424,7 @@ static const struct file_operations sg_fops = { .write = sg_write, .poll = sg_poll, .unlocked_ioctl = sg_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = sg_compat_ioctl, -#endif + .compat_ioctl = compat_ptr_ioctl, .open = sg_open, .mmap = sg_mmap, .release = sg_release,
Signature · 1 line
2.30.2
PATCH 6/24 scsi: remove scsi_compat_ioctl
In reply to Christoph HellwigJust handle the compat case in scsi_ioctl using in_compat_syscall().
--- drivers/scsi/ch.c | 2 -- drivers/scsi/scsi_ioctl.c | 60 +++++++++++++-------------------------- drivers/scsi/sd.c | 2 -- drivers/scsi/sg.c | 3 -- drivers/scsi/sr.c | 5 +--- drivers/scsi/st.c | 2 +- include/scsi/scsi_ioctl.h | 1 - 7 files changed, 22 insertions(+), 53 deletions(-)
drivers/scsi/ch.c +0 -2
@@ -877,8 +877,6 @@ static long ch_ioctl(struct file *file, }default : -if (in_compat_syscall ()) -return scsi_compat_ioctl (ch->device, cmd, argp);return scsi_ioctl (ch->device, cmd, argp); }
drivers/scsi/scsi_ioctl.c +20 -40
76 lines not on this page · raw message
drivers/scsi/sd.c +0 -2
@@ -1591,8 +1591,6 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,return error; } -if (in_compat_syscall ()) -return scsi_compat_ioctl (sdp, cmd, p);return scsi_ioctl (sdp, cmd, p); }
drivers/scsi/sg.c +0 -3
@@ -1165,9 +1165,6 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) ret =sg_ioctl_common (filp, sdp, sfp, cmd_in, p);if (ret != -ENOIOCTLCMD )return ret; - -if (in_compat_syscall ()) -return scsi_compat_ioctl (sdp->device, cmd_in, p);return scsi_ioctl (sdp->device, cmd_in, p); }
drivers/scsi/sr.c +1 -4
@@ -584,10 +584,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, goto put; } -if (in_compat_syscall ()) - ret =scsi_compat_ioctl (sdev, cmd, argp); -else - ret =scsi_ioctl (sdev, cmd, argp); + ret =scsi_ioctl (sdev, cmd, argp); put:scsi_autopm_put_device (sdev);
drivers/scsi/st.c +1 -1
@@ -3886,7 +3886,7 @@ static long st_compat_ioctl(struct file *file, unsigned int cmd_in, unsigned lonif (ret != -ENOTTY )return ret; - return scsi_compat_ioctl(STp->device, cmd_in, p); + return scsi_ioctl(STp->device, cmd_in, p); }#endif
include/scsi/scsi_ioctl.h +0 -1
@@ -44,7 +44,6 @@ typedef struct scsi_fctargaddress {int scsi_ioctl_block_when_processing_errors (struct scsi_device *sdev,int cmd,bool ndelay);extern int scsi_ioctl (struct scsi_device *,int ,void __user *); -extern int scsi_compat_ioctl (struct scsi_device *sdev,int cmd,void __user *arg);#endif /* __KERNEL__ */ #endif /* _SCSI_IOCTL_H */
Signature · 1 line
2.30.2
PATCH 7/24 st: simplify ioctl handling
In reply to Christoph HellwigMerge st_ioctl_common into st_ioctl and streamline the invocation of the common ioctl helpers.
--- drivers/scsi/st.c | 78 ++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 49 deletions(-)
drivers/scsi/st.c +29 -49
@@ -3499,8 +3499,9 @@ static int partition_tape(struct scsi_tape *STp, int size)/* The ioctl command */ -static long st_ioctl_common (struct file *file,unsigned int cmd_in,void __user *p) +static long st_ioctl (struct file *file,unsigned int cmd_in,unsigned long arg) { +void __user *p = (void __user *)arg;int i, cmd_nr, cmd_type, bt;int retval =0 ;unsigned int blk;
@@ -3820,73 +3821,52 @@ static long st_ioctl_common(struct file *file, unsigned int cmd_in, void __user goto out; }mutex_unlock (&STp->lock); +switch (cmd_in) { -case SCSI_IOCTL_STOP_UNIT : -/* unload */ - retval =scsi_ioctl (STp->device, cmd_in, p); -if (!retval) { - STp->rew_at_close =0 ; - STp->ready =ST_NO_TAPE ; - } +case SCSI_IOCTL_GET_IDLUN : +case SCSI_IOCTL_GET_BUS_NUMBER : +break ; +case SG_IO : +case SCSI_IOCTL_SEND_COMMAND : +case CDROM_SEND_PACKET : +if (!capable (CAP_SYS_RAWIO )) +return -EPERM ; + fallthrough; +default : + retval =scsi_cmd_ioctl (STp->disk->queue, STp->disk, + file->f_mode, cmd_in, p); +if (retval != -ENOTTY )return retval; +break ; + } -case SCSI_IOCTL_GET_IDLUN : -case SCSI_IOCTL_GET_BUS_NUMBER : -break ; - -default : -if ((cmd_in ==SG_IO || - cmd_in ==SCSI_IOCTL_SEND_COMMAND || - cmd_in ==CDROM_SEND_PACKET ) && - !capable (CAP_SYS_RAWIO )) - i = -EPERM ; -else - i =scsi_cmd_ioctl (STp->disk->queue, STp->disk, - file->f_mode, cmd_in, p); -if (i != -ENOTTY ) -return i; -break ; + retval =scsi_ioctl (STp->device, cmd_in, p); +if (!retval && cmd_in ==SCSI_IOCTL_STOP_UNIT ) { +/* unload */ + STp->rew_at_close =0 ; + STp->ready =ST_NO_TAPE ; } -return -ENOTTY ; +return retval; out:mutex_unlock (&STp->lock);return retval; } -static long st_ioctl (struct file *file,unsigned int cmd_in,unsigned long arg) -{ -void __user *p = (void __user *)arg; -struct scsi_tape *STp = file->private_data; -int ret; - - ret =st_ioctl_common (file, cmd_in, p); -if (ret != -ENOTTY ) -return ret; - -return scsi_ioctl (STp->device, cmd_in, p); -} -#ifdef CONFIG_COMPAT static long st_compat_ioctl (struct file *file,unsigned int cmd_in,unsigned long arg) { -void __user *p =compat_ptr (arg); -struct scsi_tape *STp = file->private_data; -int ret; -/* argument conversion is handled using put_user_mtpos/put_user_mtget */ switch (cmd_in) {case MTIOCPOS32 : -return st_ioctl_common (file,MTIOCPOS , p); + cmd_in =MTIOCPOS ; +break ;case MTIOCGET32 : -return st_ioctl_common (file,MTIOCGET , p); + cmd_in =MTIOCGET ; +break ; } - ret =st_ioctl_common (file, cmd_in, p); -if (ret != -ENOTTY ) -return ret; - -return scsi_ioctl (STp->device, cmd_in, p); +return st_ioctl (file, cmd_in, arg); }#endif
Signature · 1 line
2.30.2
PATCH 8/24 cdrom: remove the call to scsi_cmd_blk_ioctl from cdrom_ioctl
In reply to Christoph HellwigOnly the sr driver can handle SCSI passthrough requests, so move the call to scsi_cmd_blk_ioctl there.
--- drivers/block/Kconfig | 1 - drivers/block/paride/Kconfig | 1 - drivers/cdrom/cdrom.c | 7 ------- drivers/scsi/sr.c | 3 +++ 4 files changed, 3 insertions(+), 9 deletions(-)
drivers/block/Kconfig +0 -1
@@ -74,7 +74,6 @@ config N64CART config CDROM tristate - select BLK_SCSI_REQUEST config GDROM tristate "SEGA Dreamcast GD-ROM drive"
drivers/block/paride/Kconfig +0 -1
@@ -27,7 +27,6 @@ config PARIDE_PCD tristate "Parallel port ATAPI CD-ROMs" depends on PARIDE select CDROM - select BLK_SCSI_REQUEST # only for the generic cdrom code help This option enables the high-level driver for ATAPI CD-ROM devices connected through a parallel port. If you chose to build PARIDE
drivers/cdrom/cdrom.c +0 -7
@@ -3357,13 +3357,6 @@ int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,void __user *argp = (void __user *)arg;int ret; -/* -* Try the generic SCSI command ioctl's first. -*/ - ret =scsi_cmd_blk_ioctl (bdev, mode, cmd, argp); -if (ret != -ENOTTY ) -return ret; -switch (cmd) {case CDROMMULTISESSION :return cdrom_ioctl_multisession (cdi, argp);
drivers/scsi/sr.c +3 -0
@@ -579,6 +579,9 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,case SCSI_IOCTL_GET_BUS_NUMBER :break ;default : + ret =scsi_cmd_blk_ioctl (bdev, mode, cmd, argp); +if (ret != -ENOTTY ) + goto put; ret =cdrom_ioctl (&cd->cdi, bdev, mode, cmd, arg);if (ret != -ENOSYS ) goto put;
Signature · 1 line
2.30.2
PATCH 9/24 scsi_ioctl: remove scsi_cmd_blk_ioctl
In reply to Christoph HellwigOpen code scsi_cmd_blk_ioctl in its two callers.
--- block/scsi_ioctl.c | 13 ------------- drivers/scsi/sd.c | 5 ++++- drivers/scsi/sr.c | 8 ++++++-- include/linux/blkdev.h | 2 -- 4 files changed, 10 insertions(+), 18 deletions(-)
block/scsi_ioctl.c +0 -13
@@ -854,19 +854,6 @@ int scsi_verify_blk_ioctl(struct block_device *bd, unsigned int cmd) }EXPORT_SYMBOL (scsi_verify_blk_ioctl); -int scsi_cmd_blk_ioctl (struct block_device *bd,fmode_t mode, -unsigned int cmd,void __user *arg) -{ -int ret; - - ret =scsi_verify_blk_ioctl (bd, cmd); -if (ret <0 ) -return ret; - -return scsi_cmd_ioctl (bd->bd_disk->queue, bd->bd_disk, mode, cmd, arg); -} -EXPORT_SYMBOL (scsi_cmd_blk_ioctl); -/** * scsi_req_init - initialize certain fields of a scsi_request structure * @req: Pointer to a scsi_request structure.
drivers/scsi/sd.c +4 -1
@@ -1586,7 +1586,10 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,case SCSI_IOCTL_GET_BUS_NUMBER :break ;default : - error =scsi_cmd_blk_ioctl (bdev, mode, cmd, p); + error =scsi_verify_blk_ioctl (bdev, cmd); +if (error <0 ) +return error; + error =scsi_cmd_ioctl (disk->queue, disk, mode, cmd, p);if (error != -ENOTTY )return error; }
drivers/scsi/sr.c +6 -2
@@ -556,7 +556,8 @@ static void sr_block_release(struct gendisk *disk, fmode_t mode)static int sr_block_ioctl (struct block_device *bdev,fmode_t mode,unsigned cmd,unsigned long arg) { -struct scsi_cd *cd =scsi_cd (bdev->bd_disk); +struct gendisk *disk = bdev->bd_disk; +struct scsi_cd *cd =scsi_cd (disk);struct scsi_device *sdev = cd->device;void __user *argp = (void __user *)arg;int ret;
@@ -579,7 +580,10 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,case SCSI_IOCTL_GET_BUS_NUMBER :break ;default : - ret =scsi_cmd_blk_ioctl (bdev, mode, cmd, argp); + ret =scsi_verify_blk_ioctl (bdev, cmd); +if (ret <0 ) + goto put; + ret =scsi_cmd_ioctl (disk->queue, disk, mode, cmd, argp);if (ret != -ENOTTY ) goto put; ret =cdrom_ioctl (&cd->cdi, bdev, mode, cmd, arg);
include/linux/blkdev.h +0 -2
@@ -889,8 +889,6 @@ extern blk_status_t blk_insert_cloned_request(struct request_queue *q,int blk_rq_append_bio (struct request *rq,struct bio *bio);extern void blk_queue_split (struct bio **);extern int scsi_verify_blk_ioctl (struct block_device *,unsigned int ); -extern int scsi_cmd_blk_ioctl (struct block_device *,fmode_t , -unsigned int ,void __user *);extern int scsi_cmd_ioctl (struct request_queue *,struct gendisk *,fmode_t ,unsigned int ,void __user *); extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t,
Signature · 1 line
2.30.2
PATCH 10/24 scsi_ioctl: remove scsi_verify_blk_ioctl
In reply to Christoph HellwigJust verify that the device is no a partition or the caller has admin privіleges at the beginning of the sr ioctl method manually and open code the trivial check for sd as well.
--- block/scsi_ioctl.c | 12 ------------ drivers/scsi/sd.c | 8 ++------ drivers/scsi/sr.c | 6 +++--- include/linux/blkdev.h | 1 - 4 files changed, 5 insertions(+), 22 deletions(-)
block/scsi_ioctl.c +0 -12
@@ -842,18 +842,6 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mod }EXPORT_SYMBOL (scsi_cmd_ioctl); -int scsi_verify_blk_ioctl (struct block_device *bd,unsigned int cmd) -{ -if (bd && !bdev_is_partition (bd)) -return 0 ; - -if (capable (CAP_SYS_RAWIO )) -return 0 ; - -return -ENOIOCTLCMD ; -} -EXPORT_SYMBOL (scsi_verify_blk_ioctl); -/** * scsi_req_init - initialize certain fields of a scsi_request structure * @req: Pointer to a scsi_request structure.
drivers/scsi/sd.c +2 -6
@@ -1558,9 +1558,8 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,SCSI_LOG_IOCTL (1 ,sd_printk (KERN_INFO , sdkp,"sd_ioctl: disk=%s, " "cmd=0x%x\n" , disk->disk_name, cmd)); - error =scsi_verify_blk_ioctl (bdev, cmd); -if (error <0 ) -return error; +if (bdev_is_partition (bdev) && !capable (CAP_SYS_RAWIO )) +return -ENOIOCTLCMD ;/* * If we are in the middle of error recovery, don't let anyone
@@ -1586,9 +1585,6 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,case SCSI_IOCTL_GET_BUS_NUMBER :break ;default : - error =scsi_verify_blk_ioctl (bdev, cmd); -if (error <0 ) -return error; error =scsi_cmd_ioctl (disk->queue, disk, mode, cmd, p);if (error != -ENOTTY )return error;
drivers/scsi/sr.c +3 -3
@@ -562,6 +562,9 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,void __user *argp = (void __user *)arg;int ret; +if (bdev_is_partition (bdev) && !capable (CAP_SYS_RAWIO )) +return -ENOIOCTLCMD ; +mutex_lock (&cd->lock); ret = scsi_ioctl_block_when_processing_errors(sdev, cmd,
@@ -580,9 +583,6 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,case SCSI_IOCTL_GET_BUS_NUMBER :break ;default : - ret =scsi_verify_blk_ioctl (bdev, cmd); -if (ret <0 ) - goto put; ret =scsi_cmd_ioctl (disk->queue, disk, mode, cmd, argp);if (ret != -ENOTTY ) goto put;
include/linux/blkdev.h +0 -1
@@ -888,7 +888,6 @@ extern blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request *rq);int blk_rq_append_bio (struct request *rq,struct bio *bio);extern void blk_queue_split (struct bio **); -extern int scsi_verify_blk_ioctl (struct block_device *,unsigned int );extern int scsi_cmd_ioctl (struct request_queue *,struct gendisk *,fmode_t ,unsigned int ,void __user *); extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t,
Signature · 1 line
2.30.2
PATCH 11/24 scsi: call scsi_cmd_ioctl from scsi_ioctl
In reply to Christoph HellwigEnsure SCSI ULD only have to call a single ioctl helper. This also adds a bunch of missing ioctls to the ch driver, and removes the need for a duplicate implementation of SCSI_IOCTL_SEND_COMMAND command.
--- drivers/scsi/ch.c | 2 +- drivers/scsi/scsi_ioctl.c | 17 ++++++++++++----- drivers/scsi/sd.c | 18 +----------------- drivers/scsi/sg.c | 2 +- drivers/scsi/sr.c | 16 ++-------------- drivers/scsi/st.c | 10 +--------- include/scsi/scsi_ioctl.h | 4 +++- 7 files changed, 21 insertions(+), 48 deletions(-)
drivers/scsi/ch.c +1 -1
@@ -877,7 +877,7 @@ static long ch_ioctl(struct file *file, }default : -return scsi_ioctl (ch->device, cmd, argp); +return scsi_ioctl (ch->device,NULL , file->f_mode, cmd, argp); } }
drivers/scsi/scsi_ioctl.c +12 -5
@@ -192,6 +192,8 @@ static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg)/** * scsi_ioctl - Dispatch ioctl to scsi device * @sdev: scsi device receiving ioctl +* @disk: disk receiving the ioctl +* @mode: mode the block/char device is opened with * @cmd: which ioctl is it * @arg: data associated with ioctl *
@@ -199,10 +201,13 @@ static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg)* does not take a major/minor number as the dev field. Rather, it takes * a pointer to a &struct scsi_device. */ -int scsi_ioctl (struct scsi_device *sdev,int cmd,void __user *arg) +int scsi_ioctl (struct scsi_device *sdev,struct gendisk *disk,fmode_t mode, +int cmd,void __user *arg) { +struct request_queue *q = sdev->request_queue;char scsi_cmd[MAX_COMMAND_SIZE ];struct scsi_sense_hdr sense_hdr; +int error;/* Check for deprecated ioctls ... all the ioctls which don't * follow the new unique numbering scheme are deprecated */
@@ -220,6 +225,12 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)break ; } +if (cmd !=SCSI_IOCTL_GET_IDLUN && cmd !=SCSI_IOCTL_GET_BUS_NUMBER ) { + error =scsi_cmd_ioctl (q, disk, mode, cmd, arg); +if (error != -ENOTTY ) +return error; + } +switch (cmd) {case SCSI_IOCTL_GET_IDLUN : { struct scsi_idlun v = {
@@ -237,10 +248,6 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)return put_user (sdev->host->host_no, (int __user *)arg);case SCSI_IOCTL_PROBE_HOST :return ioctl_probe (sdev->host, arg); -case SCSI_IOCTL_SEND_COMMAND : -if (!capable (CAP_SYS_ADMIN ) || !capable (CAP_SYS_RAWIO )) -return -EACCES ; -return sg_scsi_ioctl (sdev->request_queue,NULL ,0 , arg);case SCSI_IOCTL_DOORLOCK :return scsi_set_medium_removal (sdev,SCSI_REMOVAL_PREVENT );case SCSI_IOCTL_DOORUNLOCK :
drivers/scsi/sd.c +1 -17
@@ -1574,23 +1574,7 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,if (is_sed_ioctl (cmd))return sed_ioctl (sdkp->opal_dev, cmd, p); - -/* -* Send SCSI addressing ioctls directly to mid level, send other -* ioctls to block level and then onto mid level if they can't be -* resolved. -*/ -switch (cmd) { -case SCSI_IOCTL_GET_IDLUN : -case SCSI_IOCTL_GET_BUS_NUMBER : -break ; -default : - error =scsi_cmd_ioctl (disk->queue, disk, mode, cmd, p); -if (error != -ENOTTY ) -return error; - } - -return scsi_ioctl (sdp, cmd, p); +return scsi_ioctl (sdp, disk, mode, cmd, p); }static void set_media_not_present (struct scsi_disk *sdkp)
drivers/scsi/sg.c +1 -1
@@ -1165,7 +1165,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) ret =sg_ioctl_common (filp, sdp, sfp, cmd_in, p);if (ret != -ENOIOCTLCMD )return ret; -return scsi_ioctl (sdp->device, cmd_in, p); +return scsi_ioctl (sdp->device,NULL , filp->f_mode, cmd_in, p); } static __poll_t
drivers/scsi/sr.c +2 -14
@@ -574,24 +574,12 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,scsi_autopm_get_device (sdev); -/* -* Send SCSI addressing ioctls directly to mid level, send other -* ioctls to cdrom/block level. -*/ -switch (cmd) { -case SCSI_IOCTL_GET_IDLUN : -case SCSI_IOCTL_GET_BUS_NUMBER : -break ; -default : - ret =scsi_cmd_ioctl (disk->queue, disk, mode, cmd, argp); -if (ret != -ENOTTY ) - goto put; +if (ret !=CDROMCLOSETRAY && ret !=CDROMEJECT ) { ret =cdrom_ioctl (&cd->cdi, bdev, mode, cmd, arg);if (ret != -ENOSYS ) goto put; } - - ret =scsi_ioctl (sdev, cmd, argp); + ret =scsi_ioctl (sdev, disk, mode, cmd, argp); put:scsi_autopm_put_device (sdev);
drivers/scsi/st.c +1 -9
@@ -3823,24 +3823,16 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)mutex_unlock (&STp->lock);switch (cmd_in) { -case SCSI_IOCTL_GET_IDLUN : -case SCSI_IOCTL_GET_BUS_NUMBER : -break ;case SG_IO :case SCSI_IOCTL_SEND_COMMAND :case CDROM_SEND_PACKET :if (!capable (CAP_SYS_RAWIO ))return -EPERM ; - fallthrough;default : - retval =scsi_cmd_ioctl (STp->disk->queue, STp->disk, - file->f_mode, cmd_in, p); -if (retval != -ENOTTY ) -return retval;break ; } - retval =scsi_ioctl (STp->device, cmd_in, p); + retval =scsi_ioctl (STp->device, STp->disk, file->f_mode, cmd_in, p);if (!retval && cmd_in ==SCSI_IOCTL_STOP_UNIT ) {/* unload */ STp->rew_at_close =0 ;
include/scsi/scsi_ioctl.h +3 -1
@@ -18,6 +18,7 @@#ifdef __KERNEL__ +struct gendisk ;struct scsi_device ;/*
@@ -43,7 +44,8 @@ typedef struct scsi_fctargaddress {int scsi_ioctl_block_when_processing_errors (struct scsi_device *sdev,int cmd,bool ndelay); -extern int scsi_ioctl (struct scsi_device *,int ,void __user *); +int scsi_ioctl (struct scsi_device *sdev,struct gendisk *disk,fmode_t mode, +int cmd,void __user *arg);#endif /* __KERNEL__ */ #endif /* _SCSI_IOCTL_H */
Signature · 1 line
2.30.2
PATCH 12/24 block: add a queue_max_sectors_bytes helper
In reply to Christoph HellwigReturn the max_sectors value in bytes. Lifted from scsi_ioctl.c.
--- block/scsi_ioctl.c | 13 ++----------- include/linux/blkdev.h | 5 +++++ 2 files changed, 7 insertions(+), 11 deletions(-)
block/scsi_ioctl.c +2 -11
@@ -68,18 +68,9 @@ static int sg_set_timeout(struct request_queue *q, int __user *p)return err; } -static int max_sectors_bytes (struct request_queue *q) -{ -unsigned int max_sectors =queue_max_sectors (q); - - max_sectors = min_t(unsigned int, max_sectors, INT_MAX >> 9); - -return max_sectors <<9 ; -} -static int sg_get_reserved_size (struct request_queue *q,int __user *p) { -int val =min_t (int, q->sg_reserved_size,max_sectors_bytes (q)); +int val =min_t (int, q->sg_reserved_size,queue_max_sectors_bytes (q));return put_user (val, p); }
@@ -94,7 +85,7 @@ static int sg_set_reserved_size(struct request_queue *q, int __user *p)if (size <0 )return -EINVAL ; - q->sg_reserved_size =min (size,max_sectors_bytes (q)); + q->sg_reserved_size =min (size,queue_max_sectors_bytes (q));return 0 ; }
include/linux/blkdev.h +5 -0
@@ -1373,6 +1373,11 @@ static inline unsigned int queue_max_sectors(const struct request_queue *q)return q->limits.max_sectors; } +static inline int queue_max_sectors_bytes (struct request_queue *q) +{ + return min_t(unsigned int, queue_max_sectors(q), INT_MAX >> 9) << 9; +} +static inline unsigned int queue_max_hw_sectors (const struct request_queue *q) {return q->limits.max_hw_sectors;
Signature · 1 line
2.30.2
Re: [PATCH 12/24] block: add a queue_max_sectors_bytes helper
include/linux/blkdev.h static inline unsigned int queue_max_sectors(const struct request_queue *q) · line 1379
Quoted 4 lines · Christoph Hellwig
include/linux/blkdev.h +4
-0+static inline int queue_max_sectors_bytes (struct request_queue *q) +{ + return min_t(unsigned int, queue_max_sectors(q), INT_MAX >> 9) << 9; +}
Should this function return a signed or an unsigned integer? I'm asking because I see 'unsigned int' as the first argument for min_t().
Thanks,
Bart.
Re: [PATCH 12/24] block: add a queue_max_sectors_bytes helper
Quoted 8 lines · Bart Van Assche
include/linux/blkdev.h static inline unsigned int queue_max_sectors(const struct request_queue *q) · line 1379
Quoted 4 lines · Christoph Hellwig
include/linux/blkdev.h +4
-0+static inline int queue_max_sectors_bytes (struct request_queue *q) +{ + return min_t(unsigned int, queue_max_sectors(q), INT_MAX >> 9) << 9; +}Should this function return a signed or an unsigned integer? I'm asking because I see 'unsigned int' as the first argument for
min_t().
Yes, it really should be unsigned.
Re: [PATCH 12/24] block: add a queue_max_sectors_bytes helper
In reply to Christoph HellwigChristoph,
include/linux/blkdev.h static inline unsigned int queue_max_sectors(const struct request_queue *q) · line 1380
Quoted 5 lines
include/linux/blkdev.h +5
-0+static inline int queue_max_sectors_bytes (struct request_queue *q) +{ + return min_t(unsigned int, queue_max_sectors(q), INT_MAX >> 9) << 9; +} +
Maybe simply queue_max_bytes()?
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 12/24] block: add a queue_max_sectors_bytes helper
Quoted 1 line · Martin K. Petersen
Maybe simply
queue_max_bytes()?
Fine with me.
PATCH 13/24 bsg: decouple from scsi_cmd_ioctl
In reply to Christoph HellwigDecouple bsg from scsi_cmd_ioctl. This requires a small amount of code duplication, but will allow moving ll SCSI ioctl handling into SCSI midlayer.
--- block/bsg.c | 23 +++++++++++++++++++++-- block/scsi_ioctl.c | 16 ---------------- 2 files changed, 21 insertions(+), 18 deletions(-)
block/bsg.c +21 -2
@@ -351,7 +351,10 @@ static int bsg_set_command_q(struct bsg_device *bd, int __user *uarg)static long bsg_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {struct bsg_device *bd = file->private_data; +struct request_queue *q = bd->queue;void __user *uarg = (void __user *) arg; +int __user *intp = uarg; +int val;switch (cmd) {/*
@@ -366,16 +369,32 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg)* SCSI/sg ioctls */ case SG_GET_VERSION_NUM : +return put_user (30527 , intp);case SCSI_IOCTL_GET_IDLUN : +return put_user (0 , intp);case SCSI_IOCTL_GET_BUS_NUMBER : +return put_user (0 , intp);case SG_SET_TIMEOUT : +if (get_user (val, intp)) +return -EFAULT ; + q->sg_timeout =clock_t_to_jiffies (val); +return 0 ;case SG_GET_TIMEOUT : +return jiffies_to_clock_t (q->sg_timeout);case SG_GET_RESERVED_SIZE : +return put_user (min_t (int, q->sg_reserved_size, +queue_max_sectors_bytes (q)), intp);case SG_SET_RESERVED_SIZE : +if (get_user (val, intp)) +return -EFAULT ; +if (val <0 ) +return -EINVAL ; + q->sg_reserved_size =min (val,queue_max_sectors_bytes (q)); +return 0 ;case SG_EMULATED_HOST : -return scsi_cmd_ioctl (bd->queue,NULL , file->f_mode, cmd, uarg); +return put_user (1 , intp);case SG_IO : -return bsg_sg_io (bd->queue, file->f_mode, uarg); +return bsg_sg_io (q, file->f_mode, uarg);case SCSI_IOCTL_SEND_COMMAND :pr_warn_ratelimited ("%s: calling unsupported SCSI_IOCTL_SEND_COMMAND\n" , current->comm);
block/scsi_ioctl.c +0 -16
@@ -43,16 +43,6 @@ static int sg_get_version(int __user *p)return put_user (sg_version_num, p); } -static int scsi_get_idlun (struct request_queue *q,int __user *p) -{ -return put_user (0 , p); -} - -static int scsi_get_bus (struct request_queue *q,int __user *p) -{ -return put_user (0 , p); -} -static int sg_get_timeout (struct request_queue *q) {return jiffies_to_clock_t (q->sg_timeout);
@@ -769,12 +759,6 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t modcase SG_GET_VERSION_NUM : err =sg_get_version (arg);break ; -case SCSI_IOCTL_GET_IDLUN : - err =scsi_get_idlun (q, arg); -break ; -case SCSI_IOCTL_GET_BUS_NUMBER : - err =scsi_get_bus (q, arg); -break ;case SG_SET_TIMEOUT : err =sg_set_timeout (q, arg);break ;
Signature · 1 line
2.30.2
PATCH 14/24 bsg: move bsg_scsi_ops to drivers/scsi/
In reply to Christoph HellwigMove the SCSI-specific bsg code in the SCSI midlayer instead of in the common bsg code. This just keeps the common bsg code block/ and also allows building it as a module.
--- block/Kconfig | 23 ++-------- block/Makefile | 2 +- block/bsg.c | 95 +--------------------------------------- drivers/scsi/Kconfig | 13 ++++++ drivers/scsi/Makefile | 1 + drivers/scsi/scsi_bsg.c | 95 ++++++++++++++++++++++++++++++++++++++++ drivers/scsi/scsi_priv.h | 10 +++++ include/linux/blkdev.h | 2 +- include/linux/bsg.h | 11 ++--- 9 files changed, 128 insertions(+), 124 deletions(-) create mode 100644 drivers/scsi/scsi_bsg.c
block/Kconfig +3 -20
@@ -35,29 +35,12 @@ config BLK_SCSI_REQUEST config BLK_CGROUP_RWSTAT bool -config BLK_DEV_BSG - bool "Block layer SG support v4" - default y - select BLK_SCSI_REQUEST - help - Saying Y here will enable generic SG (SCSI generic) v4 support - for any block device. - - Unlike SG v3 (aka block/scsi_ioctl.c drivers/scsi/sg.c), SG v4 - can handle complicated SCSI commands: tagged variable length cdbs - with bidirectional data transfers and generic request/response - protocols (e.g. Task Management Functions and SMP in Serial - Attached SCSI). - - This option is required by recent UDEV versions to properly - access device serial numbers, etc. - - If unsure, say Y. +config BLK_DEV_BSG_COMMON + tristate config BLK_DEV_BSGLIB bool "Block layer SG support v4 helper lib" - select BLK_DEV_BSG - select BLK_SCSI_REQUEST + select BLK_DEV_BSG_COMMON help Subsystems will normally enable this if needed. Users will not normally need to manually enable this.
block/Makefile +1 -1
@@ -13,7 +13,7 @@ obj-$(CONFIG_BLOCK) := bio.o elevator.o blk-core.o blk-sysfs.o \ obj-$(CONFIG_BOUNCE) += bounce.o obj-$(CONFIG_BLK_SCSI_REQUEST) += scsi_ioctl.o -obj-$(CONFIG_BLK_DEV_BSG) += bsg.o +obj-$(CONFIG_BLK_DEV_BSG_COMMON) += bsg.o obj-$(CONFIG_BLK_DEV_BSGLIB) += bsg-lib.o obj-$(CONFIG_BLK_CGROUP) += blk-cgroup.o obj-$(CONFIG_BLK_CGROUP_RWSTAT) += blk-cgroup-rwstat.o
block/bsg.c +1 -94
113 lines not on this page · raw message
drivers/scsi/Kconfig +13 -0
@@ -20,6 +20,7 @@ config SCSI select SCSI_DMA if HAS_DMA select SG_POOL select BLK_SCSI_REQUEST + select BLK_DEV_BSG_COMMON if BLK_DEV_BSG help If you want to use a SCSI hard disk, SCSI tape drive, SCSI CD-ROM or any other SCSI device under Linux, say Y and make sure that you know
@@ -140,6 +141,18 @@ config CHR_DEV_SG If unsure, say N. +config BLK_DEV_BSG + bool "/dev/bsg support (SG v4)" + depends on SCSI + default y + help + Saying Y here will enable generic SG (SCSI generic) v4 support + for any SCSI device. + + This option is required by UDEV to access device serial numbers, etc. + + If unsure, say Y. + config CHR_DEV_SCH tristate "SCSI media changer support" depends on SCSI
drivers/scsi/Makefile +1 -0
@@ -168,6 +168,7 @@ scsi_mod-$(CONFIG_BLK_DEBUG_FS) += scsi_debugfs.o scsi_mod-y += scsi_trace.o scsi_logging.o scsi_mod-$(CONFIG_PM) += scsi_pm.o scsi_mod-$(CONFIG_SCSI_DH) += scsi_dh.o +scsi_mod-$(CONFIG_BLK_DEV_BSG) += scsi_bsg.o hv_storvsc-y := storvsc_drv.o
drivers/scsi/scsi_bsg.c new file +95 -0
95 lines not on this page · raw message
drivers/scsi/scsi_priv.h +10 -0
@@ -181,6 +181,16 @@ static inline void scsi_dh_add_device(struct scsi_device *sdev) { }static inline void scsi_dh_release_device (struct scsi_device *sdev) { }#endif +#ifdef CONFIG_BLK_DEV_BSG +int bsg_scsi_register_queue (struct request_queue *q,struct device *parent); +#else +static inline int bsg_scsi_register_queue (struct request_queue *q, +struct device *parent) +{ +return 0 ; +} +#endif +extern int scsi_device_max_queue_depth (struct scsi_device *sdev);/*
include/linux/blkdev.h +1 -1
@@ -537,7 +537,7 @@ struct request_queue {int mq_freeze_depth; -#if defined(CONFIG_BLK_DEV_BSG ) +#if defined(CONFIG_BLK_DEV_BSG_COMMON )struct bsg_class_device bsg_dev;#endif
include/linux/bsg.h +3 -8
@@ -5,8 +5,9 @@#include <uapi/linux/bsg.h> struct request ; +struct request_queue ; -#ifdef CONFIG_BLK_DEV_BSG +#ifdef CONFIG_BLK_DEV_BSG_COMMON struct bsg_ops { int (*check_proto)(struct sg_io_v4 *hdr); int (*fill_hdr)(struct request *rq, struct sg_io_v4 *hdr,
@@ -24,16 +25,10 @@ struct bsg_class_device {int bsg_register_queue (struct request_queue *q,struct device *parent,const char *name,const struct bsg_ops *ops); -int bsg_scsi_register_queue (struct request_queue *q,struct device *parent);void bsg_unregister_queue (struct request_queue *q);#else -static inline int bsg_scsi_register_queue (struct request_queue *q, -struct device *parent) -{ -return 0 ; -}static inline void bsg_unregister_queue (struct request_queue *q) { } -#endif /* CONFIG_BLK_DEV_BSG */ +#endif /* CONFIG_BLK_DEV_BSG_COMMON */ #endif /* _LINUX_BSG_H */
Signature · 1 line
2.30.2
kernel test robot
build botRe: [PATCH 14/24] bsg: move bsg_scsi_ops to drivers/scsi/
I love your patch! Yet something to improve:
Hi Christoph,
I love your patch! Yet something to improve:
[auto build test ERROR on block/for-next]
[also build test ERROR on v5.14-rc1 next-20210712]
[cannot apply to mkp-scsi/for-next scsi/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Christoph-Hellwig/bsg-remove-support-for-SCSI_IOCTL_SEND_COMMAND/20210712-144839 base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next config: powerpc64-randconfig-r005-20210712 (attached as .config) compiler: powerpc64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/7cec3a06b11a61835f2fad5d32a67536aea04a7b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christoph-Hellwig/bsg-remove-support-for-SCSI_IOCTL_SEND_COMMAND/20210712-144839 git checkout 7cec3a06b11a61835f2fad5d32a67536aea04a7b
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross O=build_dir ARCH=powerpc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All error/warnings (new ones prefixed by >>):
block/bsg.c: In function 'bsg_sg_io':
>> block/bsg.c:64:8: error: 'struct request_queue' has no member named 'bsg_dev'
64 | if (!q->bsg_dev.class_dev)
| ^~
block/bsg.c:69:9: error: 'struct request_queue' has no member named 'bsg_dev'
69 | ret = q->bsg_dev.ops->check_proto(&hdr);
| ^~
block/bsg.c:78:9: error: 'struct request_queue' has no member named 'bsg_dev'
78 | ret = q->bsg_dev.ops->fill_hdr(rq, &hdr, mode);
| ^~
block/bsg.c:106:13: error: 'struct request_queue' has no member named 'bsg_dev'
106 | ret = rq->q->bsg_dev.ops->complete_rq(rq, &hdr);
| ^~
block/bsg.c:110:7: error: 'struct request_queue' has no member named 'bsg_dev'
110 | rq->q->bsg_dev.ops->free_rq(rq);
| ^~
block/bsg.c: In function 'bsg_add_device':
block/bsg.c:178:31: error: 'struct request_queue' has no member named 'bsg_dev'
178 | strncpy(bd->name, dev_name(rq->bsg_dev.class_dev), sizeof(bd->name) - 1);
| ^~
block/bsg.c: In function 'bsg_get_device':
>> block/bsg.c:218:42: error: dereferencing pointer to incomplete type 'struct bsg_class_device'
218 | bd = __bsg_get_device(iminor(inode), bcd->queue);
| ^~
block/bsg.c: At top level:
>> block/bsg.c:333:6: error: redefinition of 'bsg_unregister_queue'
333 | void bsg_unregister_queue(struct request_queue *q)
| ^~~~~~~~~~~~~~~~~~~~
In file included from include/linux/blkdev.h:21,
from block/bsg.c:8:
include/linux/bsg.h:30:20: note: previous definition of 'bsg_unregister_queue' was here
30 | static inline void bsg_unregister_queue(struct request_queue *q)
| ^~~~~~~~~~~~~~~~~~~~
block/bsg.c: In function 'bsg_unregister_queue':
block/bsg.c:335:35: error: 'struct request_queue' has no member named 'bsg_dev'
335 | struct bsg_class_device *bcd = &q->bsg_dev;
| ^~
block/bsg.c:337:10: error: dereferencing pointer to incomplete type 'struct bsg_class_device'
337 | if (!bcd->class_dev)
| ^~
block/bsg.c: At top level:
>> block/bsg.c:351:34: warning: 'struct bsg_ops' declared inside parameter list will not be visible outside of this definition or declaration
351 | const char *name, const struct bsg_ops *ops)
| ^~~~~~~
>> block/bsg.c:350:5: warning: no previous prototype for 'bsg_register_queue' [-Wmissing-prototypes]
350 | int bsg_register_queue(struct request_queue *q, struct device *parent,
| ^~~~~~~~~~~~~~~~~~
block/bsg.c: In function 'bsg_register_queue':
block/bsg.c:364:10: error: 'struct request_queue' has no member named 'bsg_dev'
364 | bcd = &q->bsg_dev;
| ^~
block/bsg.c:365:24: error: dereferencing pointer to incomplete type 'struct bsg_class_device'
365 | memset(bcd, 0, sizeof(*bcd));
| ^~~~vim +64 block/bsg.c
17cb960f29c29e Christoph Hellwig 2018-03-13 53
ccf3209f0044e4 Christoph Hellwig 2018-11-09 54 static int bsg_sg_io(struct request_queue *q, fmode_t mode, void __user *uarg)
3d6392cfbd7dc1 Jens Axboe 2007-07-09 55 {
972248e9111ee6 Christoph Hellwig 2019-01-29 56 struct request *rq;
972248e9111ee6 Christoph Hellwig 2019-01-29 57 struct bio *bio;
ccf3209f0044e4 Christoph Hellwig 2018-11-09 58 struct sg_io_v4 hdr;
aebf526b53aea1 Christoph Hellwig 2017-01-31 59 int ret;
c7a841f3aca469 James Smart 2010-11-14 60
ccf3209f0044e4 Christoph Hellwig 2018-11-09 61 if (copy_from_user(&hdr, uarg, sizeof(hdr)))
ccf3209f0044e4 Christoph Hellwig 2018-11-09 62 return -EFAULT;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 63
ccf3209f0044e4 Christoph Hellwig 2018-11-09 @64 if (!q->bsg_dev.class_dev)
ccf3209f0044e4 Christoph Hellwig 2018-11-09 65 return -ENXIO;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 66
ccf3209f0044e4 Christoph Hellwig 2018-11-09 67 if (hdr.guard != 'Q')
ccf3209f0044e4 Christoph Hellwig 2018-11-09 68 return -EINVAL;
ccf3209f0044e4 Christoph Hellwig 2018-11-09 69 ret = q->bsg_dev.ops->check_proto(&hdr);
3d6392cfbd7dc1 Jens Axboe 2007-07-09 70 if (ret)
ccf3209f0044e4 Christoph Hellwig 2018-11-09 71 return ret;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 72
ccf3209f0044e4 Christoph Hellwig 2018-11-09 73 rq = blk_get_request(q, hdr.dout_xfer_len ?
da6269da4cfe29 Christoph Hellwig 2021-06-24 74 REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0);
a492f075450f3b Joe Lawrence 2014-08-28 75 if (IS_ERR(rq))
ccf3209f0044e4 Christoph Hellwig 2018-11-09 76 return PTR_ERR(rq);
f27b087b81b705 Jens Axboe 2014-06-06 77
ccf3209f0044e4 Christoph Hellwig 2018-11-09 78 ret = q->bsg_dev.ops->fill_hdr(rq, &hdr, mode);
0f7b4bc6bb1e57 Pan Bian 2021-01-19 79 if (ret) {
0f7b4bc6bb1e57 Pan Bian 2021-01-19 80 blk_put_request(rq);
972248e9111ee6 Christoph Hellwig 2019-01-29 81 return ret;
0f7b4bc6bb1e57 Pan Bian 2021-01-19 82 }
2c9ecdf40af055 FUJITA Tomonori 2007-07-16 83
ccf3209f0044e4 Christoph Hellwig 2018-11-09 84 rq->timeout = msecs_to_jiffies(hdr.timeout);
17cb960f29c29e Christoph Hellwig 2018-03-13 85 if (!rq->timeout)
17cb960f29c29e Christoph Hellwig 2018-03-13 86 rq->timeout = q->sg_timeout;
17cb960f29c29e Christoph Hellwig 2018-03-13 87 if (!rq->timeout)
17cb960f29c29e Christoph Hellwig 2018-03-13 88 rq->timeout = BLK_DEFAULT_SG_TIMEOUT;
17cb960f29c29e Christoph Hellwig 2018-03-13 89 if (rq->timeout < BLK_MIN_SG_TIMEOUT)
17cb960f29c29e Christoph Hellwig 2018-03-13 90 rq->timeout = BLK_MIN_SG_TIMEOUT;
17cb960f29c29e Christoph Hellwig 2018-03-13 91
ccf3209f0044e4 Christoph Hellwig 2018-11-09 92 if (hdr.dout_xfer_len) {
ccf3209f0044e4 Christoph Hellwig 2018-11-09 93 ret = blk_rq_map_user(q, rq, NULL, uptr64(hdr.dout_xferp),
ccf3209f0044e4 Christoph Hellwig 2018-11-09 94 hdr.dout_xfer_len, GFP_KERNEL);
ccf3209f0044e4 Christoph Hellwig 2018-11-09 95 } else if (hdr.din_xfer_len) {
ccf3209f0044e4 Christoph Hellwig 2018-11-09 96 ret = blk_rq_map_user(q, rq, NULL, uptr64(hdr.din_xferp),
ccf3209f0044e4 Christoph Hellwig 2018-11-09 97 hdr.din_xfer_len, GFP_KERNEL);
70e36eceaf897d FUJITA Tomonori 2006-12-20 98 }
c1c201200a359c Boaz Harrosh 2009-02-03 99
17cb960f29c29e Christoph Hellwig 2018-03-13 100 if (ret)
972248e9111ee6 Christoph Hellwig 2019-01-29 101 goto out_free_rq;
17cb960f29c29e Christoph Hellwig 2018-03-13 102
ccf3209f0044e4 Christoph Hellwig 2018-11-09 103 bio = rq->bio;
70e36eceaf897d FUJITA Tomonori 2006-12-20 104
684da7628d93bb Guoqing Jiang 2021-01-25 105 blk_execute_rq(NULL, rq, !(hdr.flags & BSG_FLAG_Q_AT_TAIL));
ccf3209f0044e4 Christoph Hellwig 2018-11-09 106 ret = rq->q->bsg_dev.ops->complete_rq(rq, &hdr);
70e36eceaf897d FUJITA Tomonori 2006-12-20 107 blk_rq_unmap_user(bio);
972248e9111ee6 Christoph Hellwig 2019-01-29 108
972248e9111ee6 Christoph Hellwig 2019-01-29 109 out_free_rq:
17cb960f29c29e Christoph Hellwig 2018-03-13 @110 rq->q->bsg_dev.ops->free_rq(rq);
70e36eceaf897d FUJITA Tomonori 2006-12-20 111 blk_put_request(rq);
972248e9111ee6 Christoph Hellwig 2019-01-29 112 if (!ret && copy_to_user(uarg, &hdr, sizeof(hdr)))
ccf3209f0044e4 Christoph Hellwig 2018-11-09 113 return -EFAULT;
ccf3209f0044e4 Christoph Hellwig 2018-11-09 114 return ret;
70e36eceaf897d FUJITA Tomonori 2006-12-20 115 }
70e36eceaf897d FUJITA Tomonori 2006-12-20 116
3d6392cfbd7dc1 Jens Axboe 2007-07-09 117 static struct bsg_device *bsg_alloc_device(void)
3d6392cfbd7dc1 Jens Axboe 2007-07-09 118 {
3d6392cfbd7dc1 Jens Axboe 2007-07-09 119 struct bsg_device *bd;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 120
3d6392cfbd7dc1 Jens Axboe 2007-07-09 121 bd = kzalloc(sizeof(struct bsg_device), GFP_KERNEL);
3d6392cfbd7dc1 Jens Axboe 2007-07-09 122 if (unlikely(!bd))
3d6392cfbd7dc1 Jens Axboe 2007-07-09 123 return NULL;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 124
3d6392cfbd7dc1 Jens Axboe 2007-07-09 125 spin_lock_init(&bd->lock);
5309cb38de65ed Jens Axboe 2007-01-23 126 bd->max_queue = BSG_DEFAULT_CMDS;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 127 INIT_HLIST_NODE(&bd->dev_list);
3d6392cfbd7dc1 Jens Axboe 2007-07-09 128 return bd;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 129 }
3d6392cfbd7dc1 Jens Axboe 2007-07-09 130
3d6392cfbd7dc1 Jens Axboe 2007-07-09 131 static int bsg_put_device(struct bsg_device *bd)
3d6392cfbd7dc1 Jens Axboe 2007-07-09 132 {
97f46ae45c7085 FUJITA Tomonori 2008-04-19 133 struct request_queue *q = bd->queue;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 134
3d6392cfbd7dc1 Jens Axboe 2007-07-09 135 mutex_lock(&bsg_mutex);
3d6392cfbd7dc1 Jens Axboe 2007-07-09 136
db193954ed9e35 John Pittman 2018-08-27 137 if (!refcount_dec_and_test(&bd->ref_count)) {
3f27e3ed11e67c FUJITA Tomonori 2008-05-29 138 mutex_unlock(&bsg_mutex);
28519c891c5ad5 Christoph Hellwig 2018-07-12 139 return 0;
3f27e3ed11e67c FUJITA Tomonori 2008-05-29 140 }
3f27e3ed11e67c FUJITA Tomonori 2008-05-29 141
3f27e3ed11e67c FUJITA Tomonori 2008-05-29 142 hlist_del(&bd->dev_list);
3f27e3ed11e67c FUJITA Tomonori 2008-05-29 143 mutex_unlock(&bsg_mutex);
3d6392cfbd7dc1 Jens Axboe 2007-07-09 144
3124b65dad946c Johannes Thumshirn 2018-01-24 145 bsg_dbg(bd, "tearing down\n");
3d6392cfbd7dc1 Jens Axboe 2007-07-09 146
3d6392cfbd7dc1 Jens Axboe 2007-07-09 147 /*
3d6392cfbd7dc1 Jens Axboe 2007-07-09 148 * close can always block
3d6392cfbd7dc1 Jens Axboe 2007-07-09 149 */
5309cb38de65ed Jens Axboe 2007-01-23 150 kfree(bd);
97f46ae45c7085 FUJITA Tomonori 2008-04-19 151 blk_put_queue(q);
28519c891c5ad5 Christoph Hellwig 2018-07-12 152 return 0;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 153 }
3d6392cfbd7dc1 Jens Axboe 2007-07-09 154
3d6392cfbd7dc1 Jens Axboe 2007-07-09 155 static struct bsg_device *bsg_add_device(struct inode *inode,
d351af01b93075 FUJITA Tomonori 2007-07-09 156 struct request_queue *rq,
3d6392cfbd7dc1 Jens Axboe 2007-07-09 157 struct file *file)
3d6392cfbd7dc1 Jens Axboe 2007-07-09 158 {
25fd164303cd69 Jens Axboe 2007-07-17 159 struct bsg_device *bd;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 160 unsigned char buf[32];
d9f972644606ec Bart Van Assche 2017-05-31 161
d6c73964f1e2a0 Anatoliy Glagolev 2018-06-13 162 lockdep_assert_held(&bsg_mutex);
d6c73964f1e2a0 Anatoliy Glagolev 2018-06-13 163
09ac46c429464c Tejun Heo 2011-12-14 164 if (!blk_get_queue(rq))
c3ff1b90d8924d FUJITA Tomonori 2008-03-31 165 return ERR_PTR(-ENXIO);
3d6392cfbd7dc1 Jens Axboe 2007-07-09 166
3d6392cfbd7dc1 Jens Axboe 2007-07-09 167 bd = bsg_alloc_device();
c3ff1b90d8924d FUJITA Tomonori 2008-03-31 168 if (!bd) {
c3ff1b90d8924d FUJITA Tomonori 2008-03-31 169 blk_put_queue(rq);
3d6392cfbd7dc1 Jens Axboe 2007-07-09 170 return ERR_PTR(-ENOMEM);
c3ff1b90d8924d FUJITA Tomonori 2008-03-31 171 }
3d6392cfbd7dc1 Jens Axboe 2007-07-09 172
d351af01b93075 FUJITA Tomonori 2007-07-09 173 bd->queue = rq;
0b07de85a76e13 Adel Gadllah 2008-06-26 174
db193954ed9e35 John Pittman 2018-08-27 175 refcount_set(&bd->ref_count, 1);
842ea771c38a3f FUJITA Tomonori 2008-03-31 176 hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(iminor(inode)));
3d6392cfbd7dc1 Jens Axboe 2007-07-09 177
3ada8b7e980dac Kay Sievers 2009-01-06 @178 strncpy(bd->name, dev_name(rq->bsg_dev.class_dev), sizeof(bd->name) - 1);
3124b65dad946c Johannes Thumshirn 2018-01-24 179 bsg_dbg(bd, "bound to <%s>, max queue %d\n",
9e69fbb5373f7c FUJITA Tomonori 2006-12-20 180 format_dev_t(buf, inode->i_rdev), bd->max_queue);
3d6392cfbd7dc1 Jens Axboe 2007-07-09 181
3d6392cfbd7dc1 Jens Axboe 2007-07-09 182 return bd;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 183 }
3d6392cfbd7dc1 Jens Axboe 2007-07-09 184
842ea771c38a3f FUJITA Tomonori 2008-03-31 185 static struct bsg_device *__bsg_get_device(int minor, struct request_queue *q)
3d6392cfbd7dc1 Jens Axboe 2007-07-09 186 {
43ac9e62c4a0a4 FUJITA Tomonori 2008-03-31 187 struct bsg_device *bd;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 188
d6c73964f1e2a0 Anatoliy Glagolev 2018-06-13 189 lockdep_assert_held(&bsg_mutex);
3d6392cfbd7dc1 Jens Axboe 2007-07-09 190
b67bfe0d42cac5 Sasha Levin 2013-02-27 191 hlist_for_each_entry(bd, bsg_dev_idx_hash(minor), dev_list) {
842ea771c38a3f FUJITA Tomonori 2008-03-31 192 if (bd->queue == q) {
db193954ed9e35 John Pittman 2018-08-27 193 refcount_inc(&bd->ref_count);
43ac9e62c4a0a4 FUJITA Tomonori 2008-03-31 194 goto found;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 195 }
3d6392cfbd7dc1 Jens Axboe 2007-07-09 196 }
43ac9e62c4a0a4 FUJITA Tomonori 2008-03-31 197 bd = NULL;
43ac9e62c4a0a4 FUJITA Tomonori 2008-03-31 198 found:
3d6392cfbd7dc1 Jens Axboe 2007-07-09 199 return bd;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 200 }
3d6392cfbd7dc1 Jens Axboe 2007-07-09 201
3d6392cfbd7dc1 Jens Axboe 2007-07-09 202 static struct bsg_device *bsg_get_device(struct inode *inode, struct file *file)
3d6392cfbd7dc1 Jens Axboe 2007-07-09 203 {
598443a2124618 FUJITA Tomonori 2007-07-23 204 struct bsg_device *bd;
598443a2124618 FUJITA Tomonori 2007-07-23 205 struct bsg_class_device *bcd;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 206
3d6392cfbd7dc1 Jens Axboe 2007-07-09 207 /*
3d6392cfbd7dc1 Jens Axboe 2007-07-09 208 * find the class device
3d6392cfbd7dc1 Jens Axboe 2007-07-09 209 */
3d6392cfbd7dc1 Jens Axboe 2007-07-09 210 mutex_lock(&bsg_mutex);
598443a2124618 FUJITA Tomonori 2007-07-23 211 bcd = idr_find(&bsg_minor_idr, iminor(inode));
3d6392cfbd7dc1 Jens Axboe 2007-07-09 212
d6c73964f1e2a0 Anatoliy Glagolev 2018-06-13 213 if (!bcd) {
d6c73964f1e2a0 Anatoliy Glagolev 2018-06-13 214 bd = ERR_PTR(-ENODEV);
d6c73964f1e2a0 Anatoliy Glagolev 2018-06-13 215 goto out_unlock;
d6c73964f1e2a0 Anatoliy Glagolev 2018-06-13 216 }
3d6392cfbd7dc1 Jens Axboe 2007-07-09 217
842ea771c38a3f FUJITA Tomonori 2008-03-31 @218 bd = __bsg_get_device(iminor(inode), bcd->queue);
d6c73964f1e2a0 Anatoliy Glagolev 2018-06-13 219 if (!bd)
d45ac4fa8f277e FUJITA Tomonori 2008-03-31 220 bd = bsg_add_device(inode, bcd->queue, file);
d45ac4fa8f277e FUJITA Tomonori 2008-03-31 221
d6c73964f1e2a0 Anatoliy Glagolev 2018-06-13 222 out_unlock:
d6c73964f1e2a0 Anatoliy Glagolev 2018-06-13 223 mutex_unlock(&bsg_mutex);
d45ac4fa8f277e FUJITA Tomonori 2008-03-31 224 return bd;
3d6392cfbd7dc1 Jens Axboe 2007-07-09 225 }
3d6392cfbd7dc1 Jens Axboe 2007-07-09 226 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH 14/24] bsg: move bsg_scsi_ops to drivers/scsi/
In reply to Christoph HellwigChristoph,
drivers/scsi/scsi_bsg.c line 90
Quoted 10 lines
Move the SCSI-specific bsg code in the SCSI midlayer instead of in the common bsg code. This just keeps the common bsg code
block/and also allows building it as a module.drivers/scsi/scsi_bsg.c new file +6
-0+static const struct bsg_ops bsg_scsi_ops = { + .check_proto = bsg_scsi_check_proto, + .fill_hdr = bsg_scsi_fill_hdr, + .complete_rq = bsg_scsi_complete_rq, + .free_rq = bsg_scsi_free_rq, +};
Maybe just cosmetic, but now that this code lives in scsi_bsg.c (which I do like), I think these functions should be named scsi_bsg_check_proto(), etc.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 14/24] bsg: move bsg_scsi_ops to drivers/scsi/
Quoted 3 lines · Martin K. Petersen
Maybe just cosmetic, but now that this code lives in
scsi_bsg.c(which I do like), I think these functions should be namedscsi_bsg_check_proto(), etc.
Done.
PATCH 15/24 scsi_ioctl: remove scsi_req_init
In reply to Christoph HellwigMerge scsi_req_init into its only caller.
--- block/scsi_ioctl.c | 15 --------------- drivers/scsi/scsi_lib.c | 7 ++++++- include/scsi/scsi_request.h | 2 -- 3 files changed, 6 insertions(+), 18 deletions(-)
block/scsi_ioctl.c +0 -15
@@ -817,21 +817,6 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mod }EXPORT_SYMBOL (scsi_cmd_ioctl); -/** -* scsi_req_init - initialize certain fields of a scsi_request structure -* @req: Pointer to a scsi_request structure. -* Initializes .__cmd[], .cmd, .cmd_len and .sense_len but no other members -* of struct scsi_request. -*/ -void scsi_req_init (struct scsi_request *req) -{ -memset (req->__cmd,0 ,sizeof (req->__cmd)); - req->cmd = req->__cmd; - req->cmd_len =BLK_MAX_CDB ; - req->sense_len =0 ; -} -EXPORT_SYMBOL (scsi_req_init); -static int __init blk_scsi_ioctl_init (void ) {blk_set_cmd_filter_defaults (&blk_default_cmd_filter);
drivers/scsi/scsi_lib.c +6 -1
@@ -1082,8 +1082,13 @@ EXPORT_SYMBOL(scsi_alloc_sgtables);static void scsi_initialize_rq (struct request *rq) {struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (rq); +struct scsi_request *req = &cmd->req; + +memset (req->__cmd,0 ,sizeof (req->__cmd)); + req->cmd = req->__cmd; + req->cmd_len =BLK_MAX_CDB ; + req->sense_len =0 ; -scsi_req_init (&cmd->req);init_rcu_head (&cmd->rcu); cmd->jiffies_at_alloc = jiffies; cmd->retries =0 ;
include/scsi/scsi_request.h +0 -2
@@ -28,6 +28,4 @@ static inline void scsi_req_free_cmd(struct scsi_request *req) kfree(req->cmd); } -void scsi_req_init (struct scsi_request *req); -#endif /* _SCSI_SCSI_REQUEST_H */
Signature · 1 line
2.30.2
PATCH 16/24 scsi_ioctl: move scsi_command_size_tbl to scsi_common.c
In reply to Christoph HellwigMove the SCSI command size table towards the rest of the common SCSI code.
--- block/scsi_ioctl.c | 8 -------- drivers/scsi/scsi_common.c | 6 ++++++ 2 files changed, 6 insertions(+), 8 deletions(-)
block/scsi_ioctl.c +0 -8
@@ -29,14 +29,6 @@ struct blk_cmd_filter {static struct blk_cmd_filter blk_default_cmd_filter; -/* Command group 3 is reserved and should never be used. */ -const unsigned char scsi_command_size_tbl[8 ] = -{ -6 ,10 ,10 ,12 , -16 ,12 ,10 ,10 -}; -EXPORT_SYMBOL (scsi_command_size_tbl); -static int sg_get_version (int __user *p) {static const int sg_version_num =30527 ;
drivers/scsi/scsi_common.c +6 -0
@@ -10,6 +10,12 @@#include <asm/unaligned.h> #include <scsi/scsi_common.h> +/* Command group 3 is reserved and should never be used. */ +const unsigned char scsi_command_size_tbl[8 ] = { +6 ,10 ,10 ,12 ,16 ,12 ,10 ,10 +}; +EXPORT_SYMBOL (scsi_command_size_tbl); +/* NB: These are exposed through /proc/scsi/scsi and form part of the ABI. * You may not alter any existing entry (although adding new ones is * encouraged once assigned by ANSI/INCITS T10).
Signature · 1 line
2.30.2
PATCH 17/24 scsi_ioctl: simplify SCSI passthrough permission checking
In reply to Christoph HellwigRemove the separate command filter structure and just use a switch statement (which also cought two duplicate commands), return a bool and give the function a sensible name.
--- block/scsi_ioctl.c | 213 ++++++++++++++++++---------------------- drivers/scsi/scsi_bsg.c | 2 +- drivers/scsi/sg.c | 5 +- include/linux/blkdev.h | 2 +- 4 files changed, 98 insertions(+), 124 deletions(-)
block/scsi_ioctl.c +93 -120
@@ -22,13 +22,6 @@#include <scsi/scsi_cmnd.h> #include <scsi/sg.h> -struct blk_cmd_filter { -unsigned long read_ok[BLK_SCSI_CMD_PER_LONG ]; -unsigned long write_ok[BLK_SCSI_CMD_PER_LONG ]; -}; - -static struct blk_cmd_filter blk_default_cmd_filter; -static int sg_get_version (int __user *p) {static const int sg_version_num =30527 ;
@@ -80,115 +73,102 @@ static int sg_emulated_host(struct request_queue *q, int __user *p)return put_user (1 , p); } -static void blk_set_cmd_filter_defaults (struct blk_cmd_filter *filter) -{ -/* Basic read-only commands */ -__set_bit (TEST_UNIT_READY , filter->read_ok); -__set_bit (REQUEST_SENSE , filter->read_ok); -__set_bit (READ_6 , filter->read_ok); -__set_bit (READ_10 , filter->read_ok); -__set_bit (READ_12 , filter->read_ok); -__set_bit (READ_16 , filter->read_ok); -__set_bit (READ_BUFFER , filter->read_ok); -__set_bit (READ_DEFECT_DATA , filter->read_ok); -__set_bit (READ_CAPACITY , filter->read_ok); -__set_bit (READ_LONG , filter->read_ok); -__set_bit (INQUIRY , filter->read_ok); -__set_bit (MODE_SENSE , filter->read_ok); -__set_bit (MODE_SENSE_10 , filter->read_ok); -__set_bit (LOG_SENSE , filter->read_ok); -__set_bit (START_STOP , filter->read_ok); -__set_bit (GPCMD_VERIFY_10 , filter->read_ok); -__set_bit (VERIFY_16 , filter->read_ok); -__set_bit (REPORT_LUNS , filter->read_ok); -__set_bit (SERVICE_ACTION_IN_16 , filter->read_ok); -__set_bit (RECEIVE_DIAGNOSTIC , filter->read_ok); -__set_bit (MAINTENANCE_IN , filter->read_ok); -__set_bit (GPCMD_READ_BUFFER_CAPACITY , filter->read_ok); - -/* Audio CD commands */ -__set_bit (GPCMD_PLAY_CD , filter->read_ok); -__set_bit (GPCMD_PLAY_AUDIO_10 , filter->read_ok); -__set_bit (GPCMD_PLAY_AUDIO_MSF , filter->read_ok); -__set_bit (GPCMD_PLAY_AUDIO_TI , filter->read_ok); -__set_bit (GPCMD_PAUSE_RESUME , filter->read_ok); - -/* CD/DVD data reading */ -__set_bit (GPCMD_READ_CD , filter->read_ok); -__set_bit (GPCMD_READ_CD_MSF , filter->read_ok); -__set_bit (GPCMD_READ_DISC_INFO , filter->read_ok); -__set_bit (GPCMD_READ_CDVD_CAPACITY , filter->read_ok); -__set_bit (GPCMD_READ_DVD_STRUCTURE , filter->read_ok); -__set_bit (GPCMD_READ_HEADER , filter->read_ok); -__set_bit (GPCMD_READ_TRACK_RZONE_INFO , filter->read_ok); -__set_bit (GPCMD_READ_SUBCHANNEL , filter->read_ok); -__set_bit (GPCMD_READ_TOC_PMA_ATIP , filter->read_ok); -__set_bit (GPCMD_REPORT_KEY , filter->read_ok); -__set_bit (GPCMD_SCAN , filter->read_ok); -__set_bit (GPCMD_GET_CONFIGURATION , filter->read_ok); -__set_bit (GPCMD_READ_FORMAT_CAPACITIES , filter->read_ok); -__set_bit (GPCMD_GET_EVENT_STATUS_NOTIFICATION , filter->read_ok); -__set_bit (GPCMD_GET_PERFORMANCE , filter->read_ok); -__set_bit (GPCMD_SEEK , filter->read_ok); -__set_bit (GPCMD_STOP_PLAY_SCAN , filter->read_ok); - -/* Basic writing commands */ -__set_bit (WRITE_6 , filter->write_ok); -__set_bit (WRITE_10 , filter->write_ok); -__set_bit (WRITE_VERIFY , filter->write_ok); -__set_bit (WRITE_12 , filter->write_ok); -__set_bit (WRITE_VERIFY_12 , filter->write_ok); -__set_bit (WRITE_16 , filter->write_ok); -__set_bit (WRITE_LONG , filter->write_ok); -__set_bit (WRITE_LONG_2 , filter->write_ok); -__set_bit (WRITE_SAME , filter->write_ok); -__set_bit (WRITE_SAME_16 , filter->write_ok); -__set_bit (WRITE_SAME_32 , filter->write_ok); -__set_bit (ERASE , filter->write_ok); -__set_bit (GPCMD_MODE_SELECT_10 , filter->write_ok); -__set_bit (MODE_SELECT , filter->write_ok); -__set_bit (LOG_SELECT , filter->write_ok); -__set_bit (GPCMD_BLANK , filter->write_ok); -__set_bit (GPCMD_CLOSE_TRACK , filter->write_ok); -__set_bit (GPCMD_FLUSH_CACHE , filter->write_ok); -__set_bit (GPCMD_FORMAT_UNIT , filter->write_ok); -__set_bit (GPCMD_REPAIR_RZONE_TRACK , filter->write_ok); -__set_bit (GPCMD_RESERVE_RZONE_TRACK , filter->write_ok); -__set_bit (GPCMD_SEND_DVD_STRUCTURE , filter->write_ok); -__set_bit (GPCMD_SEND_EVENT , filter->write_ok); -__set_bit (GPCMD_SEND_KEY , filter->write_ok); -__set_bit (GPCMD_SEND_OPC , filter->write_ok); -__set_bit (GPCMD_SEND_CUE_SHEET , filter->write_ok); -__set_bit (GPCMD_SET_SPEED , filter->write_ok); -__set_bit (GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL , filter->write_ok); -__set_bit (GPCMD_LOAD_UNLOAD , filter->write_ok); -__set_bit (GPCMD_SET_STREAMING , filter->write_ok); -__set_bit (GPCMD_SET_READ_AHEAD , filter->write_ok); - -/* ZBC Commands */ -__set_bit (ZBC_OUT , filter->write_ok); -__set_bit (ZBC_IN , filter->read_ok); -} - -int blk_verify_command (unsigned char *cmd,fmode_t mode) +bool scsi_cmd_allowed (unsigned char *cmd,fmode_t mode) { -struct blk_cmd_filter *filter = &blk_default_cmd_filter; -/* root can do any command. */ if (capable (CAP_SYS_RAWIO )) -return 0 ; +return true;/* Anybody who can open the device can do a read-safe command */ -if (test_bit (cmd[0 ], filter->read_ok)) -return 0 ; - -/* Write-safe commands require a writable open */ -if (test_bit (cmd[0 ], filter->write_ok) && (mode &FMODE_WRITE )) -return 0 ; - -return -EPERM ; +switch (cmd[0 ]) { +/* Basic read-only commands */ +case TEST_UNIT_READY : +case REQUEST_SENSE : +case READ_6 : +case READ_10 : +case READ_12 : +case READ_16 : +case READ_BUFFER : +case READ_DEFECT_DATA : +case READ_CAPACITY :/* also GPCMD_READ_CDVD_CAPACITY */ +case READ_LONG : +case INQUIRY : +case MODE_SENSE : +case MODE_SENSE_10 : +case LOG_SENSE : +case START_STOP : +case GPCMD_VERIFY_10 : +case VERIFY_16 : +case REPORT_LUNS : +case SERVICE_ACTION_IN_16 : +case RECEIVE_DIAGNOSTIC : +case MAINTENANCE_IN :/* also GPCMD_SEND_KEY, which is a write command */ +case GPCMD_READ_BUFFER_CAPACITY : +/* Audio CD commands */ +case GPCMD_PLAY_CD : +case GPCMD_PLAY_AUDIO_10 : +case GPCMD_PLAY_AUDIO_MSF : +case GPCMD_PLAY_AUDIO_TI : +case GPCMD_PAUSE_RESUME : +/* CD/DVD data reading */ +case GPCMD_READ_CD : +case GPCMD_READ_CD_MSF : +case GPCMD_READ_DISC_INFO : +case GPCMD_READ_DVD_STRUCTURE : +case GPCMD_READ_HEADER : +case GPCMD_READ_TRACK_RZONE_INFO : +case GPCMD_READ_SUBCHANNEL : +case GPCMD_READ_TOC_PMA_ATIP : +case GPCMD_REPORT_KEY : +case GPCMD_SCAN : +case GPCMD_GET_CONFIGURATION : +case GPCMD_READ_FORMAT_CAPACITIES : +case GPCMD_GET_EVENT_STATUS_NOTIFICATION : +case GPCMD_GET_PERFORMANCE : +case GPCMD_SEEK : +case GPCMD_STOP_PLAY_SCAN : +/* ZBC */ +case ZBC_IN : +return true; +/* Basic writing commands */ +case WRITE_6 : +case WRITE_10 : +case WRITE_VERIFY : +case WRITE_12 : +case WRITE_VERIFY_12 : +case WRITE_16 : +case WRITE_LONG : +case WRITE_LONG_2 : +case WRITE_SAME : +case WRITE_SAME_16 : +case WRITE_SAME_32 : +case ERASE : +case GPCMD_MODE_SELECT_10 : +case MODE_SELECT : +case LOG_SELECT : +case GPCMD_BLANK : +case GPCMD_CLOSE_TRACK : +case GPCMD_FLUSH_CACHE : +case GPCMD_FORMAT_UNIT : +case GPCMD_REPAIR_RZONE_TRACK : +case GPCMD_RESERVE_RZONE_TRACK : +case GPCMD_SEND_DVD_STRUCTURE : +case GPCMD_SEND_EVENT : +case GPCMD_SEND_OPC : +case GPCMD_SEND_CUE_SHEET : +case GPCMD_SET_SPEED : +case GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL : +case GPCMD_LOAD_UNLOAD : +case GPCMD_SET_STREAMING : +case GPCMD_SET_READ_AHEAD : +/* ZBC */ +case ZBC_OUT : +return (mode &FMODE_WRITE ); +default : +return false; + } } -EXPORT_SYMBOL (blk_verify_command); +EXPORT_SYMBOL (scsi_cmd_allowed);static int blk_fill_sghdr_rq (struct request_queue *q,struct request *rq,struct sg_io_hdr *hdr,fmode_t mode)
@@ -197,7 +177,7 @@ static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,if (copy_from_user (req->cmd, hdr->cmdp, hdr->cmd_len))return -EFAULT ; -if (blk_verify_command (req->cmd, mode)) +if (!scsi_cmd_allowed (req->cmd, mode))return -EPERM ;/*
@@ -428,8 +408,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,if (in_len &©_from_user (buffer, sic->data + cmdlen, in_len)) goto error; - err =blk_verify_command (req->cmd, mode); -if (err) + err = -EPERM ; +if (!scsi_cmd_allowed (req->cmd, mode)) goto error;/* default. possible overriden later */
@@ -808,10 +788,3 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t modreturn err; }EXPORT_SYMBOL (scsi_cmd_ioctl); - -static int __init blk_scsi_ioctl_init (void ) -{ -blk_set_cmd_filter_defaults (&blk_default_cmd_filter); -return 0 ; -} -fs_initcall (blk_scsi_ioctl_init);
drivers/scsi/scsi_bsg.c +1 -1
@@ -36,7 +36,7 @@ static int bsg_scsi_fill_hdr(struct request *rq, struct sg_io_v4 *hdr,if (copy_from_user (sreq->cmd,uptr64 (hdr->request), sreq->cmd_len))return -EFAULT ; -if (blk_verify_command (sreq->cmd, mode)) +if (!scsi_cmd_allowed (sreq->cmd, mode))return -EPERM ;return 0 ; }
drivers/scsi/sg.c +3 -2
@@ -238,8 +238,9 @@ static int sg_allow_access(struct file *filp, unsigned char *cmd)if (sfp->parentdp->device->type ==TYPE_SCANNER )return 0 ; - -return blk_verify_command (cmd, filp->f_mode); +if (!scsi_cmd_allowed (cmd, filp->f_mode)) +return -EPERM ; +return 0 ; } static int
include/linux/blkdev.h +1 -1
@@ -1343,7 +1343,7 @@ static inline int sb_issue_zeroout(struct super_block *sb, sector_t block, gfp_mask, 0); } -extern int blk_verify_command (unsigned char *cmd,fmode_t mode); +bool scsi_cmd_allowed (unsigned char *cmd,fmode_t mode);static inline bool bdev_is_partition (struct block_device *bdev) {
Signature · 1 line
2.30.2
Re: [PATCH 17/24] scsi_ioctl: simplify SCSI passthrough permission checking
Quoted 2 lines · Christoph Hellwig
+bool
scsi_cmd_allowed(unsigned char *cmd, fmode_t mode)
{
The first time I encountered this function it was not clear to me what the purpose of this function is. I think this is a good time to add a comment above this function that explains its purpose, namely to prevent that unprivileged SG I/O users can modify storage device firmware.
Thanks,
Bart.
Re: [PATCH 17/24] scsi_ioctl: simplify SCSI passthrough permission checking
Quoted 4 lines · Bart Van Assche
The first time I encountered this function it was not clear to me what the purpose of this function is. I think this is a good time to add a comment above this function that explains its purpose, namely to prevent that unprivileged SG I/O users can modify storage device firmware.
Or generally do unexpected things, yes. I'll add a patch at the end of the series to avoid the pain of adding a comment first and then moving the whole code around.
PATCH 18/24 scsi_ioctl: move all "block layer" SCSI ioctl handling to drivers/scsi
In reply to Christoph HellwigMerge the ioctl handling in block/scsi_ioctl.c into its only caller in drivers/scsi/scsi_ioctl.c.
--- block/Makefile | 1 - block/scsi_ioctl.c | 790 -------------------------------------- drivers/scsi/scsi_ioctl.c | 734 ++++++++++++++++++++++++++++++++++- include/linux/blkdev.h | 11 - include/scsi/scsi_ioctl.h | 6 + 5 files changed, 735 insertions(+), 807 deletions(-) delete mode 100644 block/scsi_ioctl.c
block/Makefile +0 -1
@@ -12,7 +12,6 @@ obj-$(CONFIG_BLOCK) := bio.o elevator.o blk-core.o blk-sysfs.o \ disk-events.o obj-$(CONFIG_BOUNCE) += bounce.o -obj-$(CONFIG_BLK_SCSI_REQUEST) += scsi_ioctl.o obj-$(CONFIG_BLK_DEV_BSG_COMMON) += bsg.o obj-$(CONFIG_BLK_DEV_BSGLIB) += bsg-lib.o obj-$(CONFIG_BLK_CGROUP) += blk-cgroup.o
block/scsi_ioctl.c deleted +0 -790
790 lines not on this page · raw message
drivers/scsi/scsi_ioctl.c +729 -5
754 lines not on this page · raw message
include/linux/blkdev.h +0 -11
@@ -28,8 +28,6 @@#include <linux/sbitmap.h> struct module ; -struct scsi_ioctl_command ; -struct request_queue ;struct elevator_queue ;struct blk_trace ;
@@ -888,13 +886,6 @@ extern blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request *rq);int blk_rq_append_bio (struct request *rq,struct bio *bio);extern void blk_queue_split (struct bio **); -extern int scsi_cmd_ioctl (struct request_queue *,struct gendisk *,fmode_t , -unsigned int ,void __user *); -extern int sg_scsi_ioctl (struct request_queue *,struct gendisk *,fmode_t , -struct scsi_ioctl_command __user *); -extern int get_sg_io_hdr (struct sg_io_hdr *hdr,const void __user *argp); -extern int put_sg_io_hdr (const struct sg_io_hdr *hdr,void __user *argp); -extern int blk_queue_enter (struct request_queue *q,blk_mq_req_flags_t flags);extern void blk_queue_exit (struct request_queue *q);extern void blk_sync_queue (struct request_queue *q);
@@ -1343,8 +1334,6 @@ static inline int sb_issue_zeroout(struct super_block *sb, sector_t block, gfp_mask, 0); } -bool scsi_cmd_allowed (unsigned char *cmd,fmode_t mode); -static inline bool bdev_is_partition (struct block_device *bdev) {return bdev->bd_partno;
include/scsi/scsi_ioctl.h +6 -0
@@ -20,6 +20,7 @@struct gendisk ;struct scsi_device ; +struct sg_io_hdr ;/* * Structures used for scsi_ioctl et al.
@@ -46,6 +47,11 @@ int scsi_ioctl_block_when_processing_errors(struct scsi_device *sdev, int cmd, bool ndelay);int scsi_ioctl (struct scsi_device *sdev,struct gendisk *disk,fmode_t mode,int cmd,void __user *arg); +int sg_scsi_ioctl (struct request_queue *q,struct gendisk *disk,fmode_t mode, +struct scsi_ioctl_command __user *argp); +int get_sg_io_hdr (struct sg_io_hdr *hdr,const void __user *argp); +int put_sg_io_hdr (const struct sg_io_hdr *hdr,void __user *argp); +bool scsi_cmd_allowed (unsigned char *cmd,fmode_t mode);#endif /* __KERNEL__ */ #endif /* _SCSI_IOCTL_H */
Signature · 1 line
2.30.2
Re: [PATCH 18/24] scsi_ioctl: move all "block layer" SCSI ioctl handling to drivers/scsi
Christoph,
Quoted 5 lines
Merge the ioctl handling in
block/scsi_ioctl.cinto its only caller indrivers/scsi/scsi_ioctl.c.drivers/scsi/scsi_ioctl.c +2
-0+static int blk_fill_sghdr_rq (struct request_queue *q,struct request *rq, +struct sg_io_hdr *hdr,fmode_t mode)
[...]
drivers/scsi/scsi_ioctl.c static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg) · line 396
Quoted 3 lines
drivers/scsi/scsi_ioctl.c +3
-0+static int blk_complete_sghdr_rq (struct request *rq,struct sg_io_hdr *hdr, +struct bio *bio) +{
Another couple of peculiar naming vestiges. These probably shouldn't have a "blk_" prefix now that they are under SCSI. Since they are internal to scsi_ioctl.c I propose you either drop the prefix completely or make it "scsi_".
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 18/24] scsi_ioctl: move all "block layer" SCSI ioctl handling to drivers/scsi
Quoted 5 lines · Martin K. Petersen
Quoted 2 lines
drivers/scsi/scsi_ioctl.c +2
-0+static int blk_fill_sghdr_rq (struct request_queue *q,struct request *rq, +struct sg_io_hdr *hdr,fmode_t mode)[...]
Quoted 8 lines
drivers/scsi/scsi_ioctl.c static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg) · line 396
Quoted 3 lines
drivers/scsi/scsi_ioctl.c +3
-0+static int blk_complete_sghdr_rq (struct request *rq,struct sg_io_hdr *hdr, +struct bio *bio) +{Another couple of peculiar naming vestiges. These probably shouldn't have a "
blk_" prefix now that they are under SCSI. Since they are internal toscsi_ioctl.cI propose you either drop the prefix completely or make it "scsi_".
Ok. I'll keep __blk_send_generic and its callers for now as they'll get removed later in the series.
PATCH 19/24 scsi: rename CONFIG_BLK_SCSI_REQUEST to CONFIG_SCSI_COMMON
In reply to Christoph HellwigCONFIG_BLK_SCSI_REQUEST is rather misnamed now as it just enabled building a small amount of code shared by the scsi initiator, target and consumers of the scsi_request passthrough API. Rename it and also allow building it as a module.
--- block/Kconfig | 3 --- drivers/block/Kconfig | 2 +- drivers/scsi/Kconfig | 5 ++++- drivers/scsi/Makefile | 2 +- drivers/target/Kconfig | 2 +- fs/nfsd/Kconfig | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-)
block/Kconfig +0 -3
@@ -29,9 +29,6 @@ if BLOCK config BLK_RQ_ALLOC_TIME bool -config BLK_SCSI_REQUEST - bool - config BLK_CGROUP_RWSTAT bool
drivers/block/Kconfig +1 -1
@@ -305,7 +305,7 @@ config CDROM_PKTCDVD tristate "Packet writing on CD/DVD media (DEPRECATED)" depends on !UML select CDROM - select BLK_SCSI_REQUEST + select SCSI_COMMON help Note: This driver is deprecated and will be removed from the kernel in the near future!
drivers/scsi/Kconfig +4 -1
@@ -14,12 +14,15 @@ config RAID_ATTRS help Provides RAID +config SCSI_COMMON + tristate + config SCSI tristate "SCSI device support" depends on BLOCK select SCSI_DMA if HAS_DMA select SG_POOL - select BLK_SCSI_REQUEST + select SCSI_COMMON select BLK_DEV_BSG_COMMON if BLK_DEV_BSG help If you want to use a SCSI hard disk, SCSI tape drive, SCSI CD-ROM or
drivers/scsi/Makefile +1 -1
@@ -20,7 +20,7 @@ CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF obj-$(CONFIG_PCMCIA) += pcmcia/ obj-$(CONFIG_SCSI) += scsi_mod.o -obj-$(CONFIG_BLK_SCSI_REQUEST) += scsi_common.o +obj-$(CONFIG_SCSI_COMMON) += scsi_common.o obj-$(CONFIG_RAID_ATTRS) += raid_class.o
drivers/target/Kconfig +1 -1
@@ -5,7 +5,7 @@ menuconfig TARGET_CORE depends on BLOCK select CONFIGFS_FS select CRC_T10DIF - select BLK_SCSI_REQUEST + select SCSI_COMMON select SGL_ALLOC default n help
fs/nfsd/Kconfig +1 -1
@@ -109,7 +109,7 @@ config NFSD_SCSILAYOUT depends on NFSD_V4 && BLOCK select NFSD_PNFS select EXPORTFS_BLOCK_OPS - select BLK_SCSI_REQUEST + select SCSI_COMMON help This option enables support for the exporting pNFS SCSI layouts in the kernel's NFS server. The pNFS SCSI layout enables NFS
Signature · 1 line
2.30.2
Re: [PATCH 19/24] scsi: rename CONFIG_BLK_SCSI_REQUEST to CONFIG_SCSI_COMMON
Christoph,
Quoted 4 lines
CONFIG_BLK_SCSI_REQUESTis rather misnamed now as it just enabled building a small amount of code shared by the scsi initiator, target and consumers of thescsi_requestpassthrough API. Rename it and also allow building it as a module.
Build now fails. Needs:
drivers/scsi/scsi_common.c +3 -1
@@ -7,9 +7,12 @@#include <linux/kernel.h> #include <linux/string.h> #include <linux/errno.h> +#include <linux/module.h> #include <asm/unaligned.h> #include <scsi/scsi_common.h> +MODULE_LICENSE ("GPL v2" ); + --
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 19/24] scsi: rename CONFIG_BLK_SCSI_REQUEST to CONFIG_SCSI_COMMON
Quoted 9 lines · Martin K. Petersen
Christoph,
Quoted 4 lines
CONFIG_BLK_SCSI_REQUESTis rather misnamed now as it just enabled building a small amount of code shared by the scsi initiator, target and consumers of thescsi_requestpassthrough API. Rename it and also allow building it as a module.Build now fails. Needs:
Interesting - this did not show up in any of my builds and not in weeks of buildbot coverage. But I'll add the include just to be on the safe side.
PATCH 20/24 scsi: remove a very misleading comment
In reply to Christoph HellwigRemove the comment above ioctl_internal_command, which doesn't document this function at all.
--- drivers/scsi/scsi_ioctl.c | 23 ----------------------- 1 file changed, 23 deletions(-)
drivers/scsi/scsi_ioctl.c +0 -23
@@ -64,29 +64,6 @@ static int ioctl_probe(struct Scsi_Host *host, void __user *buffer)return 1 ; } -/* - -* The SCSI_IOCTL_SEND_COMMAND ioctl sends a command out to the SCSI host. -* The IOCTL_NORMAL_TIMEOUT and NORMAL_RETRIES variables are used. -* -* dev is the SCSI device struct ptr, *(int *) arg is the length of the -* input data, if any, not including the command string & counts, -* *((int *)arg + 1) is the output buffer size in bytes. -* -* *(char *) ((int *) arg)[2] the actual command byte. -* -* Note that if more than MAX_BUF bytes are requested to be transferred, -* the ioctl will fail with error EINVAL. -* -* This size *does not* include the initial lengths that were passed. -* -* The SCSI command is read from the memory location immediately after the -* length words, and the input data is right after the command. The SCSI -* routines know the command size based on the opcode decode. -* -* The output area is then filled in starting from the command byte. -*/ -static int ioctl_internal_command (struct scsi_device *sdev,char *cmd,int timeout,int retries) {
Signature · 1 line
2.30.2
Re: [PATCH 20/24] scsi: remove a very misleading comment
Quoted 32 lines · Christoph Hellwig
Remove the comment above
ioctl_internal_command, which doesn't document this function at all.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/scsi/scsi_ioctl.c | 23 ----------------------- 1 file changed, 23 deletions(-)drivers/scsi/scsi_ioctl.c +0
-16@@ -64,29 +64,6 @@ static int ioctl_probe(struct Scsi_Host *host, void __user *buffer)return 1 ; } -/* - -* The SCSI_IOCTL_SEND_COMMAND ioctl sends a command out to the SCSI host. -* The IOCTL_NORMAL_TIMEOUT and NORMAL_RETRIES variables are used. -* -* dev is the SCSI device struct ptr, *(int *) arg is the length of the -* input data, if any, not including the command string & counts, -* *((int *)arg + 1) is the output buffer size in bytes. -* -* *(char *) ((int *) arg)[2] the actual command byte. -* -* Note that if more than MAX_BUF bytes are requested to be transferred, -* the ioctl will fail with error EINVAL. -* -* This size *does not* include the initial lengths that were passed. -*
drivers/scsi/scsi_ioctl.c static int ioctl_probe(struct Scsi_Host *host, void __user *buffer) · line 69
Quoted 10 lines
drivers/scsi/scsi_ioctl.c +0
-7-* The SCSI command is read from the memory location immediately after the -* length words, and the input data is right after the command. The SCSI -* routines know the command size based on the opcode decode. -* -* The output area is then filled in starting from the command byte. -*/ -static int ioctl_internal_command (struct scsi_device *sdev,char *cmd,int timeout,int retries) {
How about adding a comment that explains what this function does? How about declaring 'cmd' const and adding a comment that it is a pointer to a SCSI CDB? How about documenting the unit of 'timeout'?
Thanks,
Bart.
Re: [PATCH 20/24] scsi: remove a very misleading comment
Quoted 9 lines · Bart Van Assche
Quoted 8 lines
- * routines know the command size based on the opcode decode.
- *
- * The output area is then filled in starting from the command byte.
- */
-
static int ioctl_internal_command(structscsi_device*sdev, char *cmd,
int timeout, int retries)
{
Quoted 3 lines
How about adding a comment that explains what this function does? How about declaring 'cmd' const and adding a comment that it is a pointer to a SCSI CDB? How about documenting the unit of 'timeout'?
Not sure there is much of a point for a static function in (pun intended) fairly static code.
PATCH 21/24 scsi: consolidate the START STOP UNIT handling
In reply to Christoph HellwigFactor out a helper for the various flavors of START STOP UNIT command ioctls.
--- drivers/scsi/scsi_ioctl.c | 48 ++++++++------------------------------- 1 file changed, 10 insertions(+), 38 deletions(-)
drivers/scsi/scsi_ioctl.c +10 -38
@@ -218,31 +218,14 @@ static int sg_emulated_host(struct request_queue *q, int __user *p)return put_user (1 , p); } -/* Send basic block requests */ -static int __blk_send_generic (struct request_queue *q,struct gendisk *bd_disk, -int cmd,int data) +static int scsi_send_start_stop (struct scsi_device *sdev,int data) { -struct request *rq; -int err; - - rq =blk_get_request (q,REQ_OP_DRV_OUT ,0 ); -if (IS_ERR (rq)) -return PTR_ERR (rq); - rq->timeout =BLK_DEFAULT_SG_TIMEOUT ; -scsi_req (rq)->cmd[0 ] = cmd; -scsi_req (rq)->cmd[4 ] = data; -scsi_req (rq)->cmd_len =6 ; -blk_execute_rq (bd_disk, rq,0 ); - err =scsi_req (rq)->result ? -EIO :0 ; -blk_put_request (rq); +char cdb[MAX_COMMAND_SIZE ] = { }; -return err; -} - -static inline int blk_send_start_stop (struct request_queue *q, -struct gendisk *bd_disk,int data) -{ -return __blk_send_generic (q, bd_disk,GPCMD_START_STOP_UNIT , data); + cdb[0 ] =START_STOP ; + cdb[4 ] = data; +return ioctl_internal_command (sdev, cdb,START_STOP_TIMEOUT , +NORMAL_RETRIES ); }bool scsi_cmd_allowed (unsigned char *cmd,fmode_t mode)
@@ -877,7 +860,6 @@ int scsi_ioctl(struct scsi_device *sdev, struct gendisk *disk, fmode_t mode, int cmd, void __user *arg) { struct request_queue *q = sdev->request_queue; -char scsi_cmd[MAX_COMMAND_SIZE ];struct scsi_sense_hdr sense_hdr;int error;
@@ -930,9 +912,9 @@ int scsi_ioctl(struct scsi_device *sdev, struct gendisk *disk, fmode_t mode,case CDROM_SEND_PACKET :return scsi_cdrom_send_packet (q, disk, mode, arg);case CDROMCLOSETRAY : -return blk_send_start_stop (q, disk,0x03 ); +return scsi_send_start_stop (sdev,3 );case CDROMEJECT : -return blk_send_start_stop (q, disk,0x02 ); +return scsi_send_start_stop (sdev,2 );case SCSI_IOCTL_GET_IDLUN : {struct scsi_idlun v = { .dev_id = (sdev->id &0xff )
@@ -957,19 +939,9 @@ int scsi_ioctl(struct scsi_device *sdev, struct gendisk *disk, fmode_t mode,return scsi_test_unit_ready (sdev,IOCTL_NORMAL_TIMEOUT ,NORMAL_RETRIES , &sense_hdr);case SCSI_IOCTL_START_UNIT : - scsi_cmd[0 ] =START_STOP ; - scsi_cmd[1 ] =0 ; - scsi_cmd[2 ] = scsi_cmd[3 ] = scsi_cmd[5 ] =0 ; - scsi_cmd[4 ] =1 ; -return ioctl_internal_command (sdev, scsi_cmd, -START_STOP_TIMEOUT ,NORMAL_RETRIES ); +return scsi_send_start_stop (sdev,1 );case SCSI_IOCTL_STOP_UNIT : - scsi_cmd[0 ] =START_STOP ; - scsi_cmd[1 ] =0 ; - scsi_cmd[2 ] = scsi_cmd[3 ] = scsi_cmd[5 ] =0 ; - scsi_cmd[4 ] =0 ; -return ioctl_internal_command (sdev, scsi_cmd, -START_STOP_TIMEOUT ,NORMAL_RETRIES ); +return scsi_send_start_stop (sdev,0 );case SCSI_IOCTL_GET_PCI :return scsi_ioctl_get_pci (sdev, arg);case SG_SCSI_RESET :
Signature · 1 line
2.30.2
Re: [PATCH 21/24] scsi: consolidate the START STOP UNIT handling
drivers/scsi/scsi_ioctl.c static int sg_emulated_host(struct request_queue *q, int __user *p) · line 223
Quoted 1 line · Christoph Hellwig
drivers/scsi/scsi_ioctl.c +1
-0+char cdb[MAX_COMMAND_SIZE ] = { };
How about using 'u8' instead of 'char'?
Additionally, MAX_COMMAND_SIZE equals 16. According to SBC-4 6 bytes is enough for the START STOP UNIT command.
drivers/scsi/scsi_ioctl.c static int sg_emulated_host(struct request_queue *q, int __user *p) · line 226
Quoted 2 lines
drivers/scsi/scsi_ioctl.c +2
-0+ cdb[0 ] =START_STOP ; + cdb[4 ] = data;
Please combine the above two statements with the cdb[] declaration into a single line.
Additionally, please split data into two arguments to make calls of this function easier to read. This is what I found in SBC-4:
* bit 1 of byte 4 has the name LOEJ (load eject).
* bit 0 of byte 4 has the name START (start unit).
Thanks,
Bart.
Re: [PATCH 21/24] scsi: consolidate the START STOP UNIT handling
Quoted 4 lines · Bart Van Assche
drivers/scsi/scsi_ioctl.c static int sg_emulated_host(struct request_queue *q, int __user *p) · line 223
Quoted 1 line · Christoph Hellwig
drivers/scsi/scsi_ioctl.c +1
-0+char cdb[MAX_COMMAND_SIZE ] = { };How about using 'u8' instead of 'char'?
Sure.
Quoted 3 lines
Additionally,
MAX_COMMAND_SIZEequals 16. According to SBC-4 6 bytes is enough for the START STOP UNIT command.
This just keeps the existing logic.
Quoted 6 lines
drivers/scsi/scsi_ioctl.c static int sg_emulated_host(struct request_queue *q, int __user *p) · line 226
Quoted 3 lines
drivers/scsi/scsi_ioctl.c +2
-0+ cdb[0 ] =START_STOP ; + cdb[4 ] = data;Please combine the above two statements with the cdb[] declaration into a single line.
Just keeping the style of the existing code, which seems fine. Even when initializing at declaration time this would have to be multiple lines to stay readable.
Quoted 4 lines
Additionally, please split data into two arguments to make calls of this function easier to read. This is what I found in SBC-4:
* bit 1 of byte 4 has the name LOEJ (load eject).
* bit 0 of byte 4 has the name START (start unit).
Not sure how that really helps anyone. And again I'm not trying to do a grand rewrite, just consoidating the existing code a bit.
PATCH 22/24 scsi: factor SCSI_IOCTL_GET_IDLUN handling into a helper
In reply to Christoph HellwigSplit the SCSI_IOCTL_GET_IDLUN handler from the main scsi_ioctl routine.
--- drivers/scsi/scsi_ioctl.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
drivers/scsi/scsi_ioctl.c +16 -12
@@ -218,6 +218,20 @@ static int sg_emulated_host(struct request_queue *q, int __user *p)return put_user (1 , p); } +static int scsi_get_idlun (struct scsi_device *sdev,void __user *argp) +{ +struct scsi_idlun v = { + .dev_id = (sdev->id &0xff ) + + ((sdev->lun &0xff ) <<8 ) + + ((sdev->channel &0xff ) <<16 ) + + ((sdev->host->host_no &0xff ) <<24 ), + .host_unique_id = sdev->host->unique_id + }; +if (copy_to_user (argp, &v,sizeof (struct scsi_idlun ))) +return -EFAULT ; +return 0 ; +} +static int scsi_send_start_stop (struct scsi_device *sdev,int data) {char cdb[MAX_COMMAND_SIZE ] = { };
@@ -915,18 +929,8 @@ int scsi_ioctl(struct scsi_device *sdev, struct gendisk *disk, fmode_t mode,return scsi_send_start_stop (sdev,3 );case CDROMEJECT :return scsi_send_start_stop (sdev,2 ); -case SCSI_IOCTL_GET_IDLUN : { -struct scsi_idlun v = { - .dev_id = (sdev->id &0xff ) - + ((sdev->lun &0xff ) <<8 ) - + ((sdev->channel &0xff ) <<16 ) - + ((sdev->host->host_no &0xff ) <<24 ), - .host_unique_id = sdev->host->unique_id - }; -if (copy_to_user (arg, &v,sizeof (struct scsi_idlun ))) -return -EFAULT ; -return 0 ; - } +case SCSI_IOCTL_GET_IDLUN : +return scsi_get_idlun (sdev, arg);case SCSI_IOCTL_GET_BUS_NUMBER :return put_user (sdev->host->host_no, (int __user *)arg);case SCSI_IOCTL_PROBE_HOST :
Signature · 1 line
2.30.2
PATCH 23/24 scsi: factor SG_IO handling into a helper
In reply to Christoph HellwigSplit the SG_IO handler from the main scsi_ioctl routine.
--- drivers/scsi/scsi_ioctl.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/scsi/scsi_ioctl.c +19 -16
@@ -858,6 +858,23 @@ static int scsi_cdrom_send_packet(struct request_queue *q,return err; } +static int scsi_ioctl_sg_io (struct request_queue *q,struct gendisk *disk, +fmode_t mode,void __user *argp) +{ +struct sg_io_hdr hdr; +int error; + + error =get_sg_io_hdr (&hdr, argp); +if (error) +return error; + error =sg_io (q, disk, &hdr, mode); +if (error == -EFAULT ) +return error; +if (put_sg_io_hdr (&hdr, argp)) +return -EFAULT ; +return 0 ; +} +/** * scsi_ioctl - Dispatch ioctl to scsi device * @sdev: scsi device receiving ioctl
@@ -875,7 +892,6 @@ int scsi_ioctl(struct scsi_device *sdev, struct gendisk *disk, fmode_t mode, {struct request_queue *q = sdev->request_queue;struct scsi_sense_hdr sense_hdr; -int error;/* Check for deprecated ioctls ... all the ioctls which don't * follow the new unique numbering scheme are deprecated */
@@ -906,21 +922,8 @@ int scsi_ioctl(struct scsi_device *sdev, struct gendisk *disk, fmode_t mode,return sg_set_reserved_size (q, arg);case SG_EMULATED_HOST :return sg_emulated_host (q, arg); -case SG_IO : { -struct sg_io_hdr hdr; - - error =get_sg_io_hdr (&hdr, arg); -if (error) -return error; - - error =sg_io (q, disk, &hdr, mode); -if (error == -EFAULT ) -return error; - -if (put_sg_io_hdr (&hdr, arg)) -return -EFAULT ; -return 0 ; - } +case SG_IO : +return scsi_ioctl_sg_io (q, disk, mode, arg);case SCSI_IOCTL_SEND_COMMAND :return sg_scsi_ioctl (q, disk, mode, arg);case CDROM_SEND_PACKET :
Signature · 1 line
2.30.2
PATCH 24/24 scsi: unexport sg_scsi_ioctl
In reply to Christoph HellwigJust call scsi_ioctl in sg as that has the same effect.
--- drivers/scsi/scsi_ioctl.c | 5 ++--- drivers/scsi/sg.c | 2 +- include/scsi/scsi_ioctl.h | 2 -- 3 files changed, 3 insertions(+), 6 deletions(-)
drivers/scsi/scsi_ioctl.c +2 -3
@@ -524,8 +524,8 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,* Positive numbers returned are the compacted SCSI error codes (4 * bytes in one int) where the lowest byte is the SCSI status. */ -int sg_scsi_ioctl (struct request_queue *q,struct gendisk *disk,fmode_t mode, -struct scsi_ioctl_command __user *sic) +static int sg_scsi_ioctl (struct request_queue *q,struct gendisk *disk, +fmode_t mode,struct scsi_ioctl_command __user *sic) {enum {OMAX_SB_LEN =16 };/* For backward compatibility */ struct request *rq;
@@ -637,7 +637,6 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,return err; } -EXPORT_SYMBOL_GPL (sg_scsi_ioctl);int put_sg_io_hdr (const struct sg_io_hdr *hdr,void __user *argp) {
drivers/scsi/sg.c +1 -1
@@ -1109,7 +1109,7 @@ sg_ioctl_common(struct file *filp, Sg_device *sdp, Sg_fd *sfp,case SCSI_IOCTL_SEND_COMMAND :if (atomic_read (&sdp->detaching))return -ENODEV ; -return sg_scsi_ioctl (sdp->device->request_queue,NULL , filp->f_mode, p); +return scsi_ioctl (sdp->device,NULL , filp->f_mode, cmd_in, p);case SG_SET_DEBUG : result =get_user (val, ip);if (result)
include/scsi/scsi_ioctl.h +0 -2
@@ -47,8 +47,6 @@ int scsi_ioctl_block_when_processing_errors(struct scsi_device *sdev, int cmd, bool ndelay);int scsi_ioctl (struct scsi_device *sdev,struct gendisk *disk,fmode_t mode,int cmd,void __user *arg); -int sg_scsi_ioctl (struct request_queue *q,struct gendisk *disk,fmode_t mode, -struct scsi_ioctl_command __user *argp);int get_sg_io_hdr (struct sg_io_hdr *hdr,const void __user *argp);int put_sg_io_hdr (const struct sg_io_hdr *hdr,void __user *argp);bool scsi_cmd_allowed (unsigned char *cmd,fmode_t mode);
Signature · 1 line
2.30.2
Any comments?