All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Jesse Taube <jtaubepe@redhat.com>, linux-nvme@lists.infradead.org
Cc: linux-scsi@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	Justin Tee <justin.tee@broadcom.com>,
	Naresh Gottumukkala <nareshgottumukkala83@gmail.com>,
	Paul Ely <paul.ely@broadcom.com>,
	Chaitanya Kulkarni <kch@nvidia.com>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Nilesh Javali <njavali@marvell.com>,
	GR-QLogic-Storage-Upstream@marvell.com,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	John Meneghini <jmeneghi@redhat.com>,
	Bryan Gurney <bgurney@redhat.com>,
	Chris Leech <cleech@redhat.com>,
	"Ewan D . Milne" <emilne@redhat.com>,
	shinichiro.kawasaki@wdc.com, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org
Subject: Re: [PATCH v2 7/7] nvme: fcloop: Add set_marginal_rport to sysfs
Date: Mon, 21 Sep 2026 16:02:52 +0200	[thread overview]
Message-ID: <ab97f32b-31dd-4975-a8b2-b445110ae3a9@suse.de> (raw)
In-Reply-To: <20260902200547.184734-8-jtaubepe@redhat.com>

On 9/2/26 10:05 PM, Jesse Taube wrote:
> To allow testing of multipath failover, add a sysfs attribute to set a
> remote port as marginal. This will allow the fcloop LLDD to set the
> marginal flag on a remote port, simulating a marginal link.
> 
> Example:
> Turn on marginal for a remote port matching wwnn and wwpn:
> `echo 'wwnn=0x200000109b5f2956,wwpn=0x100000109b5f2956,marginal=1' >
> /sys/class/fcloop/ctl/set_marginal_rport`
> 
> Turn off marginal for a remote port matching wwnn and wwpn:
> `echo 'wwnn=0x200000109b5f2956,wwpn=0x100000109b5f2956,marginal=0' >
> /sys/class/fcloop/ctl/set_marginal_rport`
> 
> Suggested-by: John Meneghini <jmeneghi@redhat.com>
> Signed-off-by: Jesse Taube <jtaubepe@redhat.com>
> V10 -> V1:
>   - New patch
> V1 -> V2:
>   - Fix reference count leak in error path
> ---
>   drivers/nvme/target/fcloop.c | 50 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 50 insertions(+)
> 
> diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
> index b63af3b643a6..9977c2a71bd5 100644
> --- a/drivers/nvme/target/fcloop.c
> +++ b/drivers/nvme/target/fcloop.c
> @@ -6,6 +6,7 @@
>   #include <linux/module.h>
>   #include <linux/parser.h>
>   #include <uapi/scsi/fc/fc_fs.h>
> +#include <uapi/scsi/fc/fc_els.h>
>   
>   #include "../host/nvme.h"
>   #include "../target/nvmet.h"
> @@ -21,6 +22,7 @@ enum {
>   	NVMF_OPT_FCADDR		= 1 << 3,
>   	NVMF_OPT_LPWWNN		= 1 << 4,
>   	NVMF_OPT_LPWWPN		= 1 << 5,
> +	NVMF_OPT_MARGINAL	= 1 << 6,
>   };
>   
>   struct fcloop_ctrl_options {
> @@ -31,6 +33,7 @@ struct fcloop_ctrl_options {
>   	u32			fcaddr;
>   	u64			lpwwnn;
>   	u64			lpwwpn;
> +	u32			marginal;
>   };
>   
>   static const match_table_t opt_tokens = {
> @@ -40,6 +43,7 @@ static const match_table_t opt_tokens = {
>   	{ NVMF_OPT_FCADDR,	"fcaddr=%x"	},
>   	{ NVMF_OPT_LPWWNN,	"lpwwnn=%s"	},
>   	{ NVMF_OPT_LPWWPN,	"lpwwpn=%s"	},
> +	{ NVMF_OPT_MARGINAL,	"marginal=%d"	},
>   	{ NVMF_OPT_ERR,		NULL		}
>   };
>   
> @@ -120,6 +124,13 @@ fcloop_parse_options(struct fcloop_ctrl_options *opts,
>   			}
>   			opts->lpwwpn = token64;
>   			break;
> +		case NVMF_OPT_MARGINAL:
> +			if (match_int(args, &token)) {
> +				ret = -EINVAL;
> +				goto out_free_options;
> +			}
> +			opts->marginal = token;
> +			break;
>   		default:
>   			pr_warn("unknown parameter or missing value '%s'\n", p);
>   			ret = -EINVAL;
> @@ -199,6 +210,9 @@ fcloop_parse_nm_options(struct device *dev, u64 *nname, u64 *pname,
>   
>   #define TGTPORT_OPTS	(NVMF_OPT_WWNN | NVMF_OPT_WWPN)
>   
> +#define MARGINAL_OPTS	(NVMF_OPT_WWNN | NVMF_OPT_WWPN | \
> +			 NVMF_OPT_MARGINAL)
> +
>   
>   static DEFINE_SPINLOCK(fcloop_lock);
>   static LIST_HEAD(fcloop_lports);
> @@ -1663,6 +1677,40 @@ fcloop_set_cmd_drop(struct device *dev, struct device_attribute *attr,
>   	return count;
>   }
>   
> +static ssize_t
> +fcloop_set_marginal_rport(struct device *dev, struct device_attribute *attr,
> +		const char *buf, size_t count)
> +{
> +	struct fcloop_nport *nport;
> +	struct fcloop_ctrl_options opts = {};
> +	unsigned long flags;
> +	int ret;
> +
> +	ret = fcloop_parse_options(&opts, buf);
> +	if (ret)
> +		return ret;
> +
> +	/* everything there ? */
> +	if ((opts.mask & MARGINAL_OPTS) != MARGINAL_OPTS)
> +		return -EINVAL;
> +
> +	nport = fcloop_nport_lookup(opts.wwnn, opts.wwpn);
> +	if (!nport)
> +		return -ENOENT;
> +
> +	spin_lock_irqsave(&fcloop_lock, flags);
> +	if (!nport->rport || !nport->rport->remoteport) {
> +		spin_unlock_irqrestore(&fcloop_lock, flags);
> +		fcloop_nport_put(nport);
> +		return -ENOENT;
> +	}
> +
> +	nvme_fc_set_remoteport_fpin(nport->rport->remoteport, opts.marginal);
> +	spin_unlock_irqrestore(&fcloop_lock, flags);
> +	fcloop_nport_put(nport);
> +
> +	return count;
> +}
>   
>   static DEVICE_ATTR(add_local_port, 0200, NULL, fcloop_create_local_port);
>   static DEVICE_ATTR(del_local_port, 0200, NULL, fcloop_delete_local_port);
> @@ -1671,6 +1719,7 @@ static DEVICE_ATTR(del_remote_port, 0200, NULL, fcloop_delete_remote_port);
>   static DEVICE_ATTR(add_target_port, 0200, NULL, fcloop_create_target_port);
>   static DEVICE_ATTR(del_target_port, 0200, NULL, fcloop_delete_target_port);
>   static DEVICE_ATTR(set_cmd_drop, 0200, NULL, fcloop_set_cmd_drop);
> +static DEVICE_ATTR(set_marginal_rport, 0200, NULL, fcloop_set_marginal_rport);
>   
>   static struct attribute *fcloop_dev_attrs[] = {
>   	&dev_attr_add_local_port.attr,
> @@ -1680,6 +1729,7 @@ static struct attribute *fcloop_dev_attrs[] = {
>   	&dev_attr_add_target_port.attr,
>   	&dev_attr_del_target_port.attr,
>   	&dev_attr_set_cmd_drop.attr,
> +	&dev_attr_set_marginal_rport.attr,
>   	NULL
>   };
>   
Please don't make it a fabrics option. Setting is via sysfs is 
sufficient seeing it's for testing only.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich


  reply	other threads:[~2026-09-21 14:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 20:05 [PATCH v2 0/7] nvme-fc: FPIN link integrity handling Jesse Taube
2026-09-02 20:05 ` [PATCH v2 1/7] nvme: add NVME_CTRL_MARGINAL flag Jesse Taube
2026-09-21 13:59   ` Hannes Reinecke
2026-09-02 20:05 ` [PATCH v2 2/7] nvme-multipath: numa support for marginal paths Jesse Taube
2026-09-02 20:05 ` [PATCH v2 3/7] nvme-multipath: queue-depth " Jesse Taube
2026-09-02 20:05 ` [PATCH v2 4/7] nvme-multipath: round-robin " Jesse Taube
2026-09-02 20:05 ` [PATCH v2 5/7] nvme: sysfs: emit the marginal path state in show_state() Jesse Taube
2026-09-02 20:05 ` [PATCH v2 6/7] nvme-fc: add nvme_fc_set_remoteport_fpin() Jesse Taube
2026-09-02 20:05 ` [PATCH v2 7/7] nvme: fcloop: Add set_marginal_rport to sysfs Jesse Taube
2026-09-21 14:02   ` Hannes Reinecke [this message]
2026-09-23 14:56     ` Jesse Taube
2026-09-23 15:34       ` Hannes Reinecke
2026-09-23 16:16         ` Jesse Taube
2026-09-25  5:09           ` Hannes Reinecke
2026-09-28 15:08             ` Jesse Taube

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=ab97f32b-31dd-4975-a8b2-b445110ae3a9@suse.de \
    --to=hare@suse.de \
    --cc=GR-QLogic-Storage-Upstream@marvell.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=axboe@kernel.dk \
    --cc=bgurney@redhat.com \
    --cc=cleech@redhat.com \
    --cc=corbet@lwn.net \
    --cc=emilne@redhat.com \
    --cc=gustavoars@kernel.org \
    --cc=hch@lst.de \
    --cc=jmeneghi@redhat.com \
    --cc=jtaubepe@redhat.com \
    --cc=justin.tee@broadcom.com \
    --cc=kbusch@kernel.org \
    --cc=kch@nvidia.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nareshgottumukkala83@gmail.com \
    --cc=njavali@marvell.com \
    --cc=paul.ely@broadcom.com \
    --cc=sagi@grimberg.me \
    --cc=shinichiro.kawasaki@wdc.com \
    --cc=skhan@linuxfoundation.org \
    /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.