All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Minwoo Im <minwoo.im.dev@gmail.com>,
	Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>
Cc: Kanchan Joshi <joshiiitr@gmail.com>,
	Javier Gonz??lez <javier.gonz@samsung.com>,
	linux-nvme@lists.infradead.org
Subject: [PATCH 10/13] nvme: move nvme_ns_head_ops to multipath.c
Date: Thu,  8 Apr 2021 14:08:39 +0200	[thread overview]
Message-ID: <20210408120842.1450092-11-hch@lst.de> (raw)
In-Reply-To: <20210408120842.1450092-1-hch@lst.de>

Move the multipath block_device_operations to multipath.c, where they
belong.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/core.c      | 31 ++++---------------------------
 drivers/nvme/host/multipath.c | 25 ++++++++++++++++++++++++-
 drivers/nvme/host/nvme.h      |  5 ++++-
 3 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 9637f2e5e9232c..0072df1dfd54c7 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -549,12 +549,12 @@ static void nvme_free_ns_head(struct kref *ref)
 	kfree(head);
 }
 
-static bool nvme_tryget_ns_head(struct nvme_ns_head *head)
+bool nvme_tryget_ns_head(struct nvme_ns_head *head)
 {
 	return kref_get_unless_zero(&head->ref);
 }
 
-static void nvme_put_ns_head(struct nvme_ns_head *head)
+void nvme_put_ns_head(struct nvme_ns_head *head)
 {
 	kref_put(&head->ref, nvme_free_ns_head);
 }
@@ -1511,7 +1511,7 @@ static void nvme_release(struct gendisk *disk, fmode_t mode)
 	nvme_put_ns(ns);
 }
 
-static int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo)
+int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo)
 {
 	/* some standard values */
 	geo->heads = 1 << 6;
@@ -1937,7 +1937,7 @@ static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type type
 	return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release);
 }
 
-static const struct pr_ops nvme_pr_ops = {
+const struct pr_ops nvme_pr_ops = {
 	.pr_register	= nvme_pr_register,
 	.pr_reserve	= nvme_pr_reserve,
 	.pr_release	= nvme_pr_release,
@@ -1978,18 +1978,6 @@ static const struct block_device_operations nvme_bdev_ops = {
 };
 
 #ifdef CONFIG_NVME_MULTIPATH
-static int nvme_ns_head_open(struct block_device *bdev, fmode_t mode)
-{
-	if (!nvme_tryget_ns_head(bdev->bd_disk->private_data))
-		return -ENXIO;
-	return 0;
-}
-
-static void nvme_ns_head_release(struct gendisk *disk, fmode_t mode)
-{
-	nvme_put_ns_head(disk->private_data);
-}
-
 struct nvme_ctrl *nvme_find_get_live_ctrl(struct nvme_subsystem *subsys)
 {
 	struct nvme_ctrl *ctrl;
@@ -2009,17 +1997,6 @@ struct nvme_ctrl *nvme_find_get_live_ctrl(struct nvme_subsystem *subsys)
 	mutex_unlock(&nvme_subsystems_lock);
 	return ctrl;
 }
-
-const struct block_device_operations nvme_ns_head_ops = {
-	.owner		= THIS_MODULE,
-	.submit_bio	= nvme_ns_head_submit_bio,
-	.open		= nvme_ns_head_open,
-	.release	= nvme_ns_head_release,
-	.ioctl		= nvme_ns_head_ioctl,
-	.getgeo		= nvme_getgeo,
-	.report_zones	= nvme_report_zones,
-	.pr_ops		= &nvme_pr_ops,
-};
 #endif /* CONFIG_NVME_MULTIPATH */
 
 static int nvme_wait_ready(struct nvme_ctrl *ctrl, u64 cap, bool enabled)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 0f42b7e94ce3f3..2bbc1685799d44 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -294,7 +294,7 @@ static bool nvme_available_path(struct nvme_ns_head *head)
 	return false;
 }
 
-blk_qc_t nvme_ns_head_submit_bio(struct bio *bio)
+static blk_qc_t nvme_ns_head_submit_bio(struct bio *bio)
 {
 	struct nvme_ns_head *head = bio->bi_bdev->bd_disk->private_data;
 	struct device *dev = disk_to_dev(head->disk);
@@ -334,6 +334,29 @@ blk_qc_t nvme_ns_head_submit_bio(struct bio *bio)
 	return ret;
 }
 
+static int nvme_ns_head_open(struct block_device *bdev, fmode_t mode)
+{
+	if (!nvme_tryget_ns_head(bdev->bd_disk->private_data))
+		return -ENXIO;
+	return 0;
+}
+
+static void nvme_ns_head_release(struct gendisk *disk, fmode_t mode)
+{
+	nvme_put_ns_head(disk->private_data);
+}
+
+const struct block_device_operations nvme_ns_head_ops = {
+	.owner		= THIS_MODULE,
+	.submit_bio	= nvme_ns_head_submit_bio,
+	.open		= nvme_ns_head_open,
+	.release	= nvme_ns_head_release,
+	.ioctl		= nvme_ns_head_ioctl,
+	.getgeo		= nvme_getgeo,
+	.report_zones	= nvme_report_zones,
+	.pr_ops		= &nvme_pr_ops,
+};
+
 static void nvme_requeue_work(struct work_struct *work)
 {
 	struct nvme_ns_head *head =
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index d41c9ceeafa1b8..c6102ce83bb405 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -656,6 +656,8 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
 struct nvme_ns *nvme_get_ns_from_disk(struct gendisk *disk,
 		struct nvme_ns_head **head, int *srcu_idx);
 void nvme_put_ns_from_disk(struct nvme_ns_head *head, int idx);
+bool nvme_tryget_ns_head(struct nvme_ns_head *head);
+void nvme_put_ns_head(struct nvme_ns_head *head);
 struct nvme_ctrl *nvme_find_get_live_ctrl(struct nvme_subsystem *subsys);
 int nvme_ioctl(struct block_device *bdev, fmode_t mode,
 		unsigned int cmd, unsigned long arg);
@@ -663,8 +665,10 @@ int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode,
 		unsigned int cmd, unsigned long arg);
 long nvme_dev_ioctl(struct file *file, unsigned int cmd,
 		unsigned long arg);
+int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo);
 
 extern const struct attribute_group *nvme_ns_id_attr_groups[];
+extern const struct pr_ops nvme_pr_ops;
 extern const struct block_device_operations nvme_ns_head_ops;
 
 #ifdef CONFIG_NVME_MULTIPATH
@@ -688,7 +692,6 @@ void nvme_mpath_stop(struct nvme_ctrl *ctrl);
 bool nvme_mpath_clear_current_path(struct nvme_ns *ns);
 void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl);
 struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
-blk_qc_t nvme_ns_head_submit_bio(struct bio *bio);
 
 static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
 {
-- 
2.30.1


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

  parent reply	other threads:[~2021-04-08 12:22 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   ` Christoph Hellwig [this message]
2021-04-09  2:47     ` [PATCH 10/13] nvme: move nvme_ns_head_ops to multipath.c 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
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=20210408120842.1450092-11-hch@lst.de \
    --to=hch@lst.de \
    --cc=javier.gonz@samsung.com \
    --cc=joshiiitr@gmail.com \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=minwoo.im.dev@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.