Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Minwoo Im <minwoo.im.dev@gmail.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
	Kanchan Joshi <joshiiitr@gmail.com>,
	Javier Gonz??lez <javier.gonz@samsung.com>,
	linux-nvme@lists.infradead.org
Subject: Re: [PATCH 13/13] nvme: introduce generic per-namespace chardev
Date: Fri, 9 Apr 2021 16:29:01 +0900	[thread overview]
Message-ID: <20210409072901.GA2085@localhost> (raw)
In-Reply-To: <20210408120842.1450092-14-hch@lst.de>

On 21-04-08 14:08:42, Christoph Hellwig wrote:
> diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
> index 001faf31fb944f..304dc66bcebf22 100644
> --- a/drivers/nvme/host/ioctl.c
> +++ b/drivers/nvme/host/ioctl.c
> @@ -357,6 +357,14 @@ int nvme_ioctl(struct block_device *bdev, fmode_t mode,
>  	return nvme_ns_ioctl(ns, cmd, argp);
>  }
>  
> +long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> +{
> +	struct nvme_ns *ns =
> +		container_of(file_inode(file)->i_cdev, struct nvme_ns, cdev);
> +
> +	return nvme_ns_ioctl(ns, cmd, (void __user *)arg);
> +}
> +
>  #ifdef CONFIG_NVME_MULTIPATH
>  static int nvme_ns_head_ctrl_ioctl(struct nvme_ns_head *head,
>  		unsigned int cmd, void __user *argp)
> @@ -393,6 +401,15 @@ int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode,
>  		return nvme_ns_head_ctrl_ioctl(head, cmd, (void __user *)arg);
>  	return nvme_ns_head_ns_ioctl(head, cmd, (void __user *)arg);
>  }
> +
> +long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd,
> +		unsigned long arg)
> +{
> +	struct cdev *cdev = file_inode(file)->i_cdev;
> +	struct nvme_ns_head *head = container_of(cdev, struct nvme_ns_head, cdev);
> +
> +	return nvme_ns_head_ns_ioctl(head, cmd, (void __user *)arg);
> +}
>  #endif /* CONFIG_NVME_MULTIPATH */

Tested with namespace-specific admin commmand (Identify Namespace).  And
it fails with invalid IOCTl because we don't have a route to the
controller IOCTL for the generic chrdev.

Maybe we can have the following patch with simplifying the little bit
duplicated codes and make blkdev and generic device consistent which
will make user-space application happy?

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 304dc66bcebf..cbce9e35a591 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -346,15 +346,19 @@ static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd,
 	}
 }
 
+static int __nvme_ioctl(struct nvme_ns *ns, unsigned int cmd, void __user *arg)
+{
+	if (is_ctrl_ioctl(cmd))
+		return nvme_ctrl_ioctl(ns->ctrl, cmd, arg);
+	return nvme_ns_ioctl(ns, cmd, arg);
+}
+
 int nvme_ioctl(struct block_device *bdev, fmode_t mode,
 		unsigned int cmd, unsigned long arg)
 {
 	struct nvme_ns *ns = bdev->bd_disk->private_data;
-	void __user *argp = (void __user *)arg;
 
-	if (is_ctrl_ioctl(cmd))
-		return nvme_ctrl_ioctl(ns->ctrl, cmd, argp);
-	return nvme_ns_ioctl(ns, cmd, argp);
+	return __nvme_ioctl(ns, cmd, (void __user *)arg);
 }
 
 long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
@@ -362,7 +366,7 @@ long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	struct nvme_ns *ns =
 		container_of(file_inode(file)->i_cdev, struct nvme_ns, cdev);
 
-	return nvme_ns_ioctl(ns, cmd, (void __user *)arg);
+	return __nvme_ioctl(ns, cmd, (void __user *)arg);
 }
 
 #ifdef CONFIG_NVME_MULTIPATH
@@ -392,14 +396,20 @@ static int nvme_ns_head_ns_ioctl(struct nvme_ns_head *head,
 	return ret;
 }
 
+static int __nvme_ns_head_ioctl(struct nvme_ns_head *head, unsigned int cmd,
+		void __user *arg)
+{
+	if (is_ctrl_ioctl(cmd))
+		return nvme_ns_head_ctrl_ioctl(head, cmd, arg);
+	return nvme_ns_head_ns_ioctl(head, cmd, arg);
+}
+
 int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode,
 		unsigned int cmd, unsigned long arg)
 {
 	struct nvme_ns_head *head = bdev->bd_disk->private_data;
 
-	if (is_ctrl_ioctl(cmd))
-		return nvme_ns_head_ctrl_ioctl(head, cmd, (void __user *)arg);
-	return nvme_ns_head_ns_ioctl(head, cmd, (void __user *)arg);
+	return __nvme_ns_head_ioctl(head, cmd, (void __user *)arg);
 }
 
 long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd,
@@ -408,7 +418,7 @@ long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd,
 	struct cdev *cdev = file_inode(file)->i_cdev;
 	struct nvme_ns_head *head = container_of(cdev, struct nvme_ns_head, cdev);
 
-	return nvme_ns_head_ns_ioctl(head, cmd, (void __user *)arg);
+	return __nvme_ns_head_ioctl(head, cmd, (void __user *)arg);
 }
 #endif /* CONFIG_NVME_MULTIPATH */
 

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2021-04-09  7:30 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210408121108eucas1p1fb60de8498a7461b453295497c206246@eucas1p1.samsung.com>
2021-04-08 12:08 ` nvme ioctl refactor and generic per-namespace char device Christoph Hellwig
2021-04-08 12:08   ` [PATCH 01/13] nvme: add a nvme_ns_head_multipath helper Christoph Hellwig
2021-04-09  2:33     ` Chaitanya Kulkarni
2021-04-08 12:08   ` [PATCH 02/13] nvme: cleanup setting the disk name Christoph Hellwig
2021-04-08 12:08   ` [PATCH 03/13] nvme: pass a user pointer to nvme_nvm_ioctl Christoph Hellwig
2021-04-08 12:08   ` [PATCH 04/13] nvme: factor out a nvme_ns_ioctl helper Christoph Hellwig
2021-04-09  2:40     ` Chaitanya Kulkarni
2021-04-08 12:08   ` [PATCH 05/13] nvme: simplify the compat ioctl handling Christoph Hellwig
2021-04-09  2:42     ` Chaitanya Kulkarni
2021-04-09  5:39       ` Christoph Hellwig
2021-04-08 12:08   ` [PATCH 06/13] nvme: simplify block device ioctl handling for the !multipath case Christoph Hellwig
2021-04-08 12:08   ` [PATCH 07/13] nvme: don't bother to look up a namespace for controller ioctls Christoph Hellwig
2021-04-08 12:08   ` [PATCH 08/13] nvme: move the ioctl code to a separate file Christoph Hellwig
2021-04-09  2:45     ` Chaitanya Kulkarni
2021-04-08 12:08   ` [PATCH 09/13] nvme: factor out a nvme_tryget_ns_head helper Christoph Hellwig
2021-04-09  2:46     ` Chaitanya Kulkarni
2021-04-09  5:39       ` Christoph Hellwig
2021-04-09  5:40         ` Chaitanya Kulkarni
2021-04-09  9:18     ` Kanchan Joshi
2021-04-09  9:49       ` Christoph Hellwig
2021-04-08 12:08   ` [PATCH 10/13] nvme: move nvme_ns_head_ops to multipath.c Christoph Hellwig
2021-04-09  2:47     ` Chaitanya Kulkarni
2021-04-08 12:08   ` [PATCH 11/13] nvme: factor out nvme_ns_open and nvme_ns_release helpers Christoph Hellwig
2021-04-09  2:48     ` Chaitanya Kulkarni
2021-04-08 12:08   ` [PATCH 12/13] nvme: let namespace probing continue for unsupported features Christoph Hellwig
2021-04-08 22:42     ` Keith Busch
2021-04-09  5:39       ` Christoph Hellwig
2021-04-09  5:47         ` Keith Busch
2021-04-09  5:53           ` Christoph Hellwig
2021-04-08 12:08   ` [PATCH 13/13] nvme: introduce generic per-namespace chardev Christoph Hellwig
2021-04-08 16:56     ` Keith Busch
2021-04-08 17:00       ` Christoph Hellwig
2021-04-09  6:14       ` Christoph Hellwig
2021-04-09 14:29         ` Keith Busch
2021-04-09 14:35           ` Christoph Hellwig
2021-04-09  7:29     ` Minwoo Im [this message]
2021-04-09  7:54       ` Christoph Hellwig
2021-04-09  8:02         ` Minwoo Im
2021-04-09  9:52           ` Christoph Hellwig
2021-04-09 11:24             ` Minwoo Im
2021-04-12  7:44               ` Christoph Hellwig
2021-04-12 11:52                 ` Javier Gonz??lez
2021-04-08 22:43   ` nvme ioctl refactor and generic per-namespace char device Keith Busch
2021-04-09 17:45   ` Javier Gonz??lez
2021-04-10  6:46   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210409072901.GA2085@localhost \
    --to=minwoo.im.dev@gmail.com \
    --cc=hch@lst.de \
    --cc=javier.gonz@samsung.com \
    --cc=joshiiitr@gmail.com \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox