Re: [PATCH] nvme: add a compat_ioctl handler for NVME_IOCTL_SUBMIT_IO
From: Christoph Hellwig
Date: Wed Mar 04 2020 - 11:13:23 EST
> +static int nvme_compat_ioctl(struct block_device *bdev, fmode_t mode,
> + unsigned int cmd, unsigned long arg)
> +{
> + if (cmd == NVME_IOCTL_SUBMIT_IO32)
> + return nvme_ioctl(bdev, mode, NVME_IOCTL_SUBMIT_IO, arg);
I think this really need a comment explaining what is going on, including
why not translating anything works in this specific case.
> +
> + return nvme_ioctl(bdev, mode, cmd, arg);
> +}
This function should also be under CONFIG_COMPAT, with a
#define nvme_compat_ioctl NULL
in the #else branch.
> index d99b5a772698..52699a26b9b3 100644
> --- a/include/uapi/linux/nvme_ioctl.h
> +++ b/include/uapi/linux/nvme_ioctl.h
> @@ -24,6 +24,21 @@ struct nvme_user_io {
> __u16 appmask;
> };
>
> +struct nvme_user_io32 {
> + __u8 opcode;
> + __u8 flags;
> + __u16 control;
> + __u16 nblocks;
> + __u16 rsvd;
> + __u64 metadata;
> + __u64 addr;
> + __u64 slba;
> + __u32 dsmgmt;
> + __u32 reftag;
> + __u16 apptag;
> + __u16 appmask;
> +} __attribute__((packed));
This should not be exposed in the UAPI header. I think it should just
go into the #ifdef CONFIG_COMPAT block in core.c near the comment and
the compat_ioctl handler.