[PATCH 6/8] block: add example ioctl

Christoph Hellwig hch at lst.de
Thu Mar 18 05:45:06 GMT 2021


On Wed, Mar 17, 2021 at 04:10:25PM -0600, Jens Axboe wrote:
> +static int blkdev_uring_ioctl(struct block_device *bdev,
> +			      struct io_uring_cmd *cmd)
> +{
> +	struct block_uring_cmd *bcmd = (struct block_uring_cmd *) &cmd->pdu;
> +
> +	switch (bcmd->ioctl_cmd) {
> +	case BLKBSZGET:
> +		return block_size(bdev);
> +	default:
> +		return -ENOTTY;
> +	}
> +}
> +
>  static int blkdev_uring_cmd(struct io_uring_cmd *cmd,
>  			    enum io_uring_cmd_flags flags)
>  {
>  	struct block_device *bdev = I_BDEV(cmd->file->f_mapping->host);
>  
> +	switch (cmd->op) {
> +	case BLOCK_URING_OP_IOCTL:
> +		return blkdev_uring_ioctl(bdev, cmd);

I don't think the two level dispatch here makes any sense.  Then again
I don't think this code makes sense either except as an example..



More information about the Linux-nvme mailing list