提交 0fe51ff2 编写于 作者: J James Smart 提交者: Sagi Grimberg

nvme-fabrics: rework nvmf_get_address() for variable options

Revise nvmf_get_address() string to account for not all options being
present.
Signed-off-by: NJames Smart <james.smart@broadcom.com>
Acked-by: NJohannes Thumshirn <jth@kernel.org>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NSagi Grimberg <sagi@grimberg.me>
上级 005043ac
......@@ -109,8 +109,16 @@ static void nvmf_host_put(struct nvmf_host *host)
*/
int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size)
{
return snprintf(buf, size, "traddr=%s,trsvcid=%s\n",
ctrl->opts->traddr, ctrl->opts->trsvcid);
int len = 0;
if (ctrl->opts->mask & NVMF_OPT_TRADDR)
len += snprintf(buf, size, "traddr=%s", ctrl->opts->traddr);
if (ctrl->opts->mask & NVMF_OPT_TRSVCID)
len += snprintf(buf + len, size - len, "%strsvcid=%s",
(len) ? "," : "", ctrl->opts->trsvcid);
len += snprintf(buf + len, size - len, "\n");
return len;
}
EXPORT_SYMBOL_GPL(nvmf_get_address);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册