Michael S. Tsirkin
2019-Dec-11 23:05 UTC
[PATCH 15/24] compat_ioctl: scsi: move ioctl handling into drivers
On Wed, Dec 11, 2019 at 09:42:49PM +0100, Arnd Bergmann wrote:> Each driver calling scsi_ioctl() gets an equivalent compat_ioctl() > handler that implements the same commands by calling scsi_compat_ioctl(). > > The scsi_cmd_ioctl() and scsi_cmd_blk_ioctl() functions are compatible > at this point, so any driver that calls those can do so for both native > and compat mode, with the argument passed through compat_ptr(). > > With this, we can remove the entries from fs/compat_ioctl.c. The new > code is larger, but should be easier to maintain and keep updated with > newly added commands. > > Signed-off-by: Arnd Bergmann <arnd at arndb.de> > --- > drivers/block/virtio_blk.c | 3 + > drivers/scsi/ch.c | 9 ++- > drivers/scsi/sd.c | 50 ++++++-------- > drivers/scsi/sg.c | 44 ++++++++----- > drivers/scsi/sr.c | 57 ++++++++++++++-- > drivers/scsi/st.c | 51 ++++++++------ > fs/compat_ioctl.c | 132 +------------------------------------ > 7 files changed, 142 insertions(+), 204 deletions(-) > > diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c > index 7ffd719d89de..fbbf18ac1d5d 100644 > --- a/drivers/block/virtio_blk.c > +++ b/drivers/block/virtio_blk.c > @@ -405,6 +405,9 @@ static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo) > > static const struct block_device_operations virtblk_fops = { > .ioctl = virtblk_ioctl, > +#ifdef CONFIG_COMPAT > + .compat_ioctl = blkdev_compat_ptr_ioctl, > +#endif > .owner = THIS_MODULE, > .getgeo = virtblk_getgeo, > };Hmm - is virtio blk lumped in with scsi things intentionally? -- MST
Paolo Bonzini
2019-Dec-12 00:28 UTC
[PATCH 15/24] compat_ioctl: scsi: move ioctl handling into drivers
On 12/12/19 00:05, Michael S. Tsirkin wrote:>> @@ -405,6 +405,9 @@ static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo) >> >> static const struct block_device_operations virtblk_fops = { >> .ioctl = virtblk_ioctl, >> +#ifdef CONFIG_COMPAT >> + .compat_ioctl = blkdev_compat_ptr_ioctl, >> +#endif >> .owner = THIS_MODULE, >> .getgeo = virtblk_getgeo, >> }; > Hmm - is virtio blk lumped in with scsi things intentionally?I think it's because the only ioctl for virtio-blk is SG_IO. It makes sense to lump it in with scsi, but I wouldn't mind getting rid of CONFIG_VIRTIO_BLK_SCSI altogether. Paolo
Arnd Bergmann
2019-Dec-12 09:17 UTC
[PATCH 15/24] compat_ioctl: scsi: move ioctl handling into drivers
On Thu, Dec 12, 2019 at 1:28 AM Paolo Bonzini <pbonzini at redhat.com> wrote:> On 12/12/19 00:05, Michael S. Tsirkin wrote: > >> @@ -405,6 +405,9 @@ static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo) > >> > >> static const struct block_device_operations virtblk_fops = { > >> .ioctl = virtblk_ioctl, > >> +#ifdef CONFIG_COMPAT > >> + .compat_ioctl = blkdev_compat_ptr_ioctl, > >> +#endif > >> .owner = THIS_MODULE, > >> .getgeo = virtblk_getgeo, > >> }; > > Hmm - is virtio blk lumped in with scsi things intentionally? > > I think it's because the only ioctl for virtio-blk is SG_IO. It makes > sense to lump it in with scsi, but I wouldn't mind getting rid of > CONFIG_VIRTIO_BLK_SCSI altogether.It currently calls scsi_cmd_blk_ioctl(), which implements a bunch of ioctl commands, including some that are unrelated to SG_IO: case SG_GET_VERSION_NUM: case SCSI_IOCTL_GET_IDLUN: case SCSI_IOCTL_GET_BUS_NUMBER: case SG_SET_TIMEOUT: case SG_GET_TIMEOUT: case SG_GET_RESERVED_SIZE: case SG_SET_RESERVED_SIZE: case SG_EMULATED_HOST: case SG_IO: { case CDROM_SEND_PACKET: case SCSI_IOCTL_SEND_COMMAND: case CDROMCLOSETRAY: case CDROMEJECT: My patch changes all callers of this function, and the idea is to preserve the existing behavior through my series, so I think it makes sense to keep my patch as is. I would assume that calling scsi_cmd_blk_ioctl() is harmless here, but if you want to remove it or limit the set of supported commands, that should be independent of my change. Arnd
Michael S. Tsirkin
2019-Dec-12 10:27 UTC
[PATCH 15/24] compat_ioctl: scsi: move ioctl handling into drivers
On Thu, Dec 12, 2019 at 01:28:08AM +0100, Paolo Bonzini wrote:> On 12/12/19 00:05, Michael S. Tsirkin wrote: > >> @@ -405,6 +405,9 @@ static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo) > >> > >> static const struct block_device_operations virtblk_fops = { > >> .ioctl = virtblk_ioctl, > >> +#ifdef CONFIG_COMPAT > >> + .compat_ioctl = blkdev_compat_ptr_ioctl, > >> +#endif > >> .owner = THIS_MODULE, > >> .getgeo = virtblk_getgeo, > >> }; > > Hmm - is virtio blk lumped in with scsi things intentionally? > > I think it's because the only ioctl for virtio-blk is SG_IO.Oh right, I forgot about that one ...> It makes > sense to lump it in with scsi, but I wouldn't mind getting rid of > CONFIG_VIRTIO_BLK_SCSI altogether. > > Paolo
Christoph Hellwig
2019-Dec-12 16:27 UTC
[PATCH 15/24] compat_ioctl: scsi: move ioctl handling into drivers
On Thu, Dec 12, 2019 at 01:28:08AM +0100, Paolo Bonzini wrote:> I think it's because the only ioctl for virtio-blk is SG_IO. It makes > sense to lump it in with scsi, but I wouldn't mind getting rid of > CONFIG_VIRTIO_BLK_SCSI altogether.CONFIG_VIRTIO_BLK_SCSI has been broken for about two years, as it never set the QUEUE_FLAG_SCSI_PASSTHROUGH flag after that was introduced. I actually have a patch that I plan to send to remove this support as it was a really idea to start with (speaking as the person who had that idea back in the day).
Reasonably Related Threads
- [PATCH 15/24] compat_ioctl: scsi: move ioctl handling into drivers
- [PATCH 15/24] compat_ioctl: scsi: move ioctl handling into drivers
- [PATCH 15/24] compat_ioctl: scsi: move ioctl handling into drivers
- [PATCH v3 13/22] compat_ioctl: scsi: move ioctl handling into drivers
- [PATCH] virtio-blk: remove VIRTIO_BLK_F_SCSI support