Skip to contentSkip to conversation

nvme-fc: release admin tagset if init fails

PATCH Applied Chaitanya Kulkarni 4 participants 7 messages Dec 20, 2025 – Jan 9

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-fc: release admin tagset if init fails

nvme_fabrics creates an NVMe/FC controller in following path:

    nvmf_dev_write()
      -> nvmf_create_ctrl()
        -> nvme_fc_create_ctrl()
          -> nvme_fc_init_ctrl()

nvme_fc_init_ctrl() allocates the admin blk-mq resources right after nvme_add_ctrl() succeeds. If any of the subsequent steps fail (changing the controller state, scheduling connect work, etc.), we jump to the fail_ctrl path, which tears down the controller references but never frees the admin queue/tag set. The leaked blk-mq allocations match the kmemleak report seen during blktests nvme/fc.

Check ctrl->ctrl.admin_tagset in the fail_ctrl path and call nvme_remove_admin_tag_set() when it is set so that all admin queue allocations are reclaimed whenever controller setup aborts.

---
 drivers/nvme/host/fc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/nvme/host/fc.c +2 -0
index bc455fa98246..6948de3f438a 100644
@@ -3587,6 +3587,8 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
 
 	ctrl->ctrl.opts = NULL;
 
+	if (ctrl->ctrl.admin_tagset)
+		nvme_remove_admin_tag_set(&ctrl->ctrl);
 	/* initiate nvme ctrl ref counting teardown */
 	nvme_uninit_ctrl(&ctrl->ctrl);
 
Signature · 1 line
2.40.0
#1 lore raw
Quoted 14 lines · Chaitanya Kulkarni

nvme_fabrics creates an NVMe/FC controller in following path:

     nvmf_dev_write()
       -> nvmf_create_ctrl()
         -> nvme_fc_create_ctrl()
           -> nvme_fc_init_ctrl()

nvme_fc_init_ctrl() allocates the admin blk-mq resources right after nvme_add_ctrl() succeeds. If any of the subsequent steps fail (changing the controller state, scheduling connect work, etc.), we jump to the fail_ctrl path, which tears down the controller references but never frees the admin queue/tag set. The leaked blk-mq allocations match the kmemleak report seen during blktests nvme/fc.

Quoted 7 lines

Check ctrl->ctrl.admin_tagset in the fail_ctrl path and call nvme_remove_admin_tag_set() when it is set so that all admin queue allocations are reclaimed whenever controller setup aborts.

---

Gentle ping on this before it gets lost ...

-ck

#2 lore raw

Hi Yi,

Was there a specific nvme/fc blktest case that triggered this call trace?  Or, was this observed after stress running all nvme/fc blktests in a loop?

Regards,
Justin Tee

#3 lore raw
Quoted 9 lines · Justin Tee

Hi Yi,

Was there a specific nvme/fc blktest case that triggered this call trace?  Or, was this observed after stress running all nvme/fc blktests in a loop?

Regards,
Justin Tee

thanks for looking into this, it was observed when Yi reported the issue.

Irrespective of whether it is repro issue, it's still a bug ?

Can you please provide review comments ?

-ck

#4 lore raw
Quoted 5 lines

thanks for looking into this, it was observed when Yi reported the issue.

Irrespective of whether it is repro issue, it's still a bug ?

Can you please provide review comments ?

Yes, agreed after reviewing the current goto fail_ctrl path that there is a missing nvme_remove_admin_tag_set.  I can provide the Reviewed-by stamp.

I guess I’d prefer if we can prove this resolves the issue Yi reported.  If Yi could re-rerun nvme-fc blktests on the original failing setup with this patch, that would be great to confirm.

Thanks,
Justin

maintainer Applied
#6 lore raw
In reply to Chaitanya Kulkarni
Quoted 14 lines · Chaitanya Kulkarni

nvme_fabrics creates an NVMe/FC controller in following path:

    nvmf_dev_write()
      -> nvmf_create_ctrl()
        -> nvme_fc_create_ctrl()
          -> nvme_fc_init_ctrl()

nvme_fc_init_ctrl() allocates the admin blk-mq resources right after nvme_add_ctrl() succeeds. If any of the subsequent steps fail (changing the controller state, scheduling connect work, etc.), we jump to the fail_ctrl path, which tears down the controller references but never frees the admin queue/tag set. The leaked blk-mq allocations match the kmemleak report seen during blktests nvme/fc.

Quoted 3 lines

Check ctrl->ctrl.admin_tagset in the fail_ctrl path and call nvme_remove_admin_tag_set() when it is set so that all admin queue allocations are reclaimed whenever controller setup aborts.

Thanks, applied.