* [PATCH] nvmet: configfs: use ctrl->instance to track passthru subsystems
@ 2023-12-18 19:03 Evan Burgess
2023-12-18 23:13 ` Keith Busch
2023-12-19 5:22 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Evan Burgess @ 2023-12-18 19:03 UTC (permalink / raw
To: Christoph Hellwig, Chaitanya Kulkarni, sagi@grimberg.me
Cc: linux-nvme@lists.infradead.org
To prevent enabling more than one passthrough subsystem per NVMe
controller, passthru.c maintains an xarray indexed by cntlid values.
Passthrough for a given nvmet subsystem cannot be enabled by configfs
if the subsystem's passthru_ctrl->cntlid value is already accounted
for in the xarray.
However, according to the NVMe spec (rev 2.0c, p.145), "The Controller
ID (CNTLID) value returned in the Identify Controller data structure
may be used to uniquely identify a controller within an NVM subsystem,"
meaning that cntlid values are not guaranteed to be globally unique
across multiple subsystems. Instead, the cntlid only uniquely
identifies multiple controllers _within_ a subsystem.
As a result, multiple unique & valid NVMe targets can be blocked from
enabling passthrough at the same time if their controllers share cntlid
values, a behavior allowed by the spec. Fix this by indexing the xarray
with passthru_ctrl->instance values, which are allocated per
controller by IDA and thus should be truly unique.
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Evan Burgess <evan.burgess@seagate.com>
---
drivers/nvme/target/passthru.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
index 9fe07d7efa96..f2d963e1fe94 100644
--- a/drivers/nvme/target/passthru.c
+++ b/drivers/nvme/target/passthru.c
@@ -602,7 +602,7 @@ int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys)
goto out_put_file;
}
- old = xa_cmpxchg(&passthru_subsystems, ctrl->cntlid, NULL,
+ old = xa_cmpxchg(&passthru_subsystems, ctrl->instance, NULL,
subsys, GFP_KERNEL);
if (xa_is_err(old)) {
ret = xa_err(old);
@@ -635,7 +635,7 @@ int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys)
static void __nvmet_passthru_ctrl_disable(struct nvmet_subsys *subsys)
{
if (subsys->passthru_ctrl) {
- xa_erase(&passthru_subsystems, subsys->passthru_ctrl->cntlid);
+ xa_erase(&passthru_subsystems, subsys->passthru_ctrl->instance);
module_put(subsys->passthru_ctrl->ops->module);
nvme_put_ctrl(subsys->passthru_ctrl);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nvmet: configfs: use ctrl->instance to track passthru subsystems
2023-12-18 19:03 [PATCH] nvmet: configfs: use ctrl->instance to track passthru subsystems Evan Burgess
@ 2023-12-18 23:13 ` Keith Busch
2023-12-19 5:22 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2023-12-18 23:13 UTC (permalink / raw
To: Evan Burgess
Cc: Christoph Hellwig, Chaitanya Kulkarni, sagi@grimberg.me,
linux-nvme@lists.infradead.org
On Mon, Dec 18, 2023 at 07:03:32PM +0000, Evan Burgess wrote:
>
> To prevent enabling more than one passthrough subsystem per NVMe
> controller, passthru.c maintains an xarray indexed by cntlid values.
> Passthrough for a given nvmet subsystem cannot be enabled by configfs
> if the subsystem's passthru_ctrl->cntlid value is already accounted
> for in the xarray.
>
> However, according to the NVMe spec (rev 2.0c, p.145), "The Controller
> ID (CNTLID) value returned in the Identify Controller data structure
> may be used to uniquely identify a controller within an NVM subsystem,"
> meaning that cntlid values are not guaranteed to be globally unique
> across multiple subsystems. Instead, the cntlid only uniquely
> identifies multiple controllers _within_ a subsystem.
>
> As a result, multiple unique & valid NVMe targets can be blocked from
> enabling passthrough at the same time if their controllers share cntlid
> values, a behavior allowed by the spec. Fix this by indexing the xarray
> with passthru_ctrl->instance values, which are allocated per
> controller by IDA and thus should be truly unique.
>
> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
> Signed-off-by: Evan Burgess <evan.burgess@seagate.com>
Thank you, applied to nvme-6.8.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvmet: configfs: use ctrl->instance to track passthru subsystems
2023-12-18 19:03 [PATCH] nvmet: configfs: use ctrl->instance to track passthru subsystems Evan Burgess
2023-12-18 23:13 ` Keith Busch
@ 2023-12-19 5:22 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2023-12-19 5:22 UTC (permalink / raw
To: Evan Burgess
Cc: Christoph Hellwig, Chaitanya Kulkarni, sagi@grimberg.me,
linux-nvme@lists.infradead.org
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-19 5:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-18 19:03 [PATCH] nvmet: configfs: use ctrl->instance to track passthru subsystems Evan Burgess
2023-12-18 23:13 ` Keith Busch
2023-12-19 5:22 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).