Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: wenxiong@linux.ibm.com
Cc: linux-nvme@lists.infradead.org, gjoyce@linux.ibm.com,
	wenxiong@us.ibm.com
Subject: Re: [PATCH] nvme: Add module reference counting for multipath nvme device
Date: Tue, 11 Aug 2026 13:12:35 -0600	[thread overview]
Message-ID: <ant0I66BcAugTyGX@kbusch-mbp> (raw)
In-Reply-To: <20260810235034.544797-1-wenxiong@linux.ibm.com>

On Mon, Aug 10, 2026 at 07:50:34PM -0400, wenxiong@linux.ibm.com wrote:
>  static int nvme_ns_head_open(struct gendisk *disk, blk_mode_t mode)
>  {
> -	if (!nvme_tryget_ns_head(disk->private_data))
> +	struct nvme_ns_head *head = disk->private_data;
> +	struct nvme_ns *ns;
> +	int srcu_idx;
> +
> +	if (!nvme_tryget_ns_head(head))
>  		return -ENXIO;
> +
> +	/* Get module reference from any available path */
> +	srcu_idx = srcu_read_lock(&head->srcu);
> +	ns = nvme_find_path(head);
> +	if (ns && !try_module_get(ns->ctrl->ops->module)) {
> +		srcu_read_unlock(&head->srcu, srcu_idx);
> +		nvme_put_ns_head(head);
> +		return -ENXIO;
> +	}
> +	srcu_read_unlock(&head->srcu, srcu_idx);
> +
>  	return 0;
>  }
>  
>  static void nvme_ns_head_release(struct gendisk *disk)
>  {
> -	nvme_put_ns_head(disk->private_data);
> +	struct nvme_ns_head *head = disk->private_data;
> +	struct nvme_ns *ns;
> +	int srcu_idx;
> +
> +	srcu_idx = srcu_read_lock(&head->srcu);
> +	ns = nvme_find_path(head);
> +	if (ns)
> +		module_put(ns->ctrl->ops->module);
> +	srcu_read_unlock(&head->srcu, srcu_idx);
> +
> +	nvme_put_ns_head(head);
>  }

The result of nvme_find_path() is just the current path at the moment,
so I don't think this is right.

I think you need the head to hold a module reference on every path the
head has, so the module_get/put should be in nvme_mpath_add_disk and
nvme_mpath_remove_disk.


  parent reply	other threads:[~2026-08-11 19:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 23:50 [PATCH] nvme: Add module reference counting for multipath nvme device wenxiong
2026-08-11 13:18 ` John Garry
2026-08-11 18:54   ` Wen Xiong
2026-08-12  8:43     ` John Garry
2026-08-11 19:12 ` Keith Busch [this message]
2026-08-11 20:33   ` Wen Xiong
2026-08-11 20:49     ` Keith Busch
2026-08-12  3:59       ` Wen Xiong

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=ant0I66BcAugTyGX@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=gjoyce@linux.ibm.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=wenxiong@linux.ibm.com \
    --cc=wenxiong@us.ibm.com \
    /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