nvme-fc: release admin tagset if init fails
Subsystems (2)
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
@@ -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
Quoted 14 lines · Chaitanya Kulkarni
nvme_fabricscreates 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 afternvme_add_ctrl()succeeds. If any of the subsequent steps fail (changing the controller state, scheduling connect work, etc.), we jump to thefail_ctrlpath, 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_tagsetin thefail_ctrlpath and callnvme_remove_admin_tag_set()when it is set so that all admin queue allocations are reclaimed whenever controller setup aborts.Reported-by Yi Zhang <[email protected]>Signed-off-by Chaitanya Kulkarni <[email protected]>---
Gentle ping on this before it gets lost ...
-ck
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
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
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
Regards,
Justin
Quoted 14 lines · Chaitanya Kulkarni
nvme_fabricscreates 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 afternvme_add_ctrl()succeeds. If any of the subsequent steps fail (changing the controller state, scheduling connect work, etc.), we jump to thefail_ctrlpath, 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_tagsetin thefail_ctrlpath and callnvme_remove_admin_tag_set()when it is set so that all admin queue allocations are reclaimed whenever controller setup aborts.
Thanks, applied.