nvme: Default to well-known tr_svcid values when not specified#1128
Conversation
In case the transport_svcid argument is NULL, supply sane default values. For the TCP and RDMA transport it means port 4420 for I/O controllers and 8009 for discovery controllers, distinguished by the subsystem NQN specified. This may change default behaviour slightly from previous libblockdev versions as the behaviour was mostly undefined (from libblockdev side).
Summary of ChangesHello @tbzatek, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant improvement to NVMe-over-Fabrics connection handling by establishing well-defined default Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces default values for transport_svcid when connecting to NVMe-oF targets. The implementation for the tcp transport is correct, but it seems to diverge from the stated intent for the rdma transport, which should also use a different port for discovery controllers. I've suggested a code change to align the implementation with the description and simplify the logic. I've also provided suggestions to clarify the updated documentation, which is currently a bit ambiguous.
| if (g_strcmp0 (transport, "tcp") == 0) { | ||
| if (g_strcmp0 (subsysnqn, NVME_DISC_SUBSYS_NAME) == 0) | ||
| transport_svcid = G_STRINGIFY (NVME_DISC_IP_PORT); | ||
| else | ||
| transport_svcid = G_STRINGIFY (NVME_RDMA_IP_PORT); | ||
| } else | ||
| if (g_strcmp0(transport, "rdma") == 0) | ||
| transport_svcid = G_STRINGIFY (NVME_RDMA_IP_PORT); |
There was a problem hiding this comment.
The current implementation for setting the default transport_svcid doesn't seem to match the intent described in the pull request description for the rdma transport. The description states that for both tcp and rdma, the port should be 8009 for discovery controllers. However, the code only implements this for tcp and always defaults to 4420 for rdma.
Additionally, the code structure can be simplified to avoid repetition and improve clarity. The else if chain is also formatted in a confusing way.
I suggest refactoring this block to correctly handle both tcp and rdma transports consistently, which also makes the code more readable and maintainable.
if (g_strcmp0(transport, "tcp") == 0 || g_strcmp0(transport, "rdma") == 0) {
if (g_strcmp0(subsysnqn, NVME_DISC_SUBSYS_NAME) == 0)
transport_svcid = G_STRINGIFY(NVME_DISC_IP_PORT);
else
transport_svcid = G_STRINGIFY(NVME_RDMA_IP_PORT);
}| * @transport: The network fabric used for a NVMe-over-Fabrics network. | ||
| * @transport_addr: (nullable): The network address of the Controller. For transports using IP addressing (e.g. `rdma`) this should be an IP-based address. | ||
| * @transport_svcid: (nullable): The transport service id. For transports using IP addressing (e.g. `rdma`) this field is the port number. By default, the IP port number for the `RDMA` transport is `4420`. | ||
| * @transport_svcid: (nullable): The transport service ID. For transports using IP addressing (e.g. `tcp`, `rdma`) this field is the port number. The default port number for the `tcp` and `rdma` transports is `4420` and `8009` respectively when the well-known Discovery NQN is specified. |
There was a problem hiding this comment.
The updated documentation for @transport_svcid is a bit ambiguous. The use of 'respectively' could be misinterpreted to mean port 4420 for tcp and 8009 for rdma. A clearer phrasing would explicitly state which port is for I/O controllers and which is for discovery controllers.
* @transport_svcid: (nullable): The transport service ID. For transports using IP addressing (e.g. `tcp`, `rdma`) this field is the port number. For `tcp` and `rdma` transports, this defaults to port `4420` for I/O controllers and `8009` for discovery controllers.
There was a problem hiding this comment.
I know, that's what I do.
| * @transport: The network fabric used for a NVMe-over-Fabrics network. | ||
| * @transport_addr: (nullable): The network address of the Controller. For transports using IP addressing (e.g. `rdma`) this should be an IP-based address. | ||
| * @transport_svcid: (nullable): The transport service id. For transports using IP addressing (e.g. `rdma`) this field is the port number. By default, the IP port number for the `RDMA` transport is `4420`. | ||
| * @transport_svcid: (nullable): The transport service ID. For transports using IP addressing (e.g. `tcp`, `rdma`) this field is the port number. The default port number for the `tcp` and `rdma` transports is `4420` and `8009` respectively when the well-known Discovery NQN is specified. |
There was a problem hiding this comment.
The updated documentation for @transport_svcid is a bit ambiguous. The use of 'respectively' could be misinterpreted to mean port 4420 for tcp and 8009 for rdma. A clearer phrasing would explicitly state which port is for I/O controllers and which is for discovery controllers. This should be consistent with the documentation in nvme.api.
* @transport_svcid: (nullable): The transport service ID. For transports using IP addressing (e.g. `tcp`, `rdma`) this field is the port number. For `tcp` and `rdma` transports, this defaults to port `4420` for I/O controllers and `8009` for discovery controllers.a54ce02
into
storaged-project:master
In case the transport_svcid argument is NULL, supply sane default values. For the TCP and RDMA transport it means port 4420 for I/O controllers and 8009 for discovery controllers, distinguished by the subsystem NQN specified.
This may change default behaviour slightly from previous libblockdev versions as the behaviour was mostly undefined (from libblockdev side).
This should be added to the release notes: "
bd_nvme_connect()now defaults to port 4420 or 8009 for discovery NQN respectively when the transport_svcid argument is not specified.".