Skip to content

libnvme: move fabrics-only helpers to util-fabrics.c#3301

Merged
igaw merged 1 commit intolinux-nvme:masterfrom
martin-belanger:util-fabrics
Apr 21, 2026
Merged

libnvme: move fabrics-only helpers to util-fabrics.c#3301
igaw merged 1 commit intolinux-nvme:masterfrom
martin-belanger:util-fabrics

Conversation

@martin-belanger
Copy link
Copy Markdown

@martin-belanger martin-belanger commented Apr 21, 2026

Summary

  • libnvmf_exat_ptr_next() and libnvme_getifaddrs() were compiled unconditionally even in PCIe-only/embedded builds that disable the fabrics layer. This patch moves them to a new util-fabrics.c which is only compiled when want_fabrics is set (in meson.build).
  • libnvme_getifaddrs() is renamed to libnvmf_getifaddrs() to reflect that it is a fabrics-only function (consistent with the libnvmf_ prefix convention).
  • The nvmf_exat_len() and nvmf_exat_size() static inlines, along with the libnvmf_getifaddrs() declaration, are moved from private.h to private-fabrics.h for the same reason.
  • The include guard in util.c is simplified from #if defined(HAVE_NETDB) || defined(CONFIG_FABRICS) to #ifdef HAVE_NETDB now that CONFIG_FABRICS is no longer needed there.

This is low-hanging fruit — a small, self-contained first step toward a cleaner fabrics/PCIe separation. More work is needed in tree.c, which still contains several #ifdef CONFIG_FABRICS blocks (TCP-specific match functions, libnvme_iface_matching_addr(), etc.) that belong in a future tree-fabrics.c. That follow-up is more invasive and will be handled separately.

Test plan

  • Builds cleanly with meson setup .build && meson compile -C .build
  • Builds cleanly with fabrics disabled: meson setup .build -Dfabrics=disabled
  • Unit tests pass: meson test -C .build

@martin-belanger martin-belanger force-pushed the util-fabrics branch 3 times, most recently from d5782a1 to a0e0151 Compare April 21, 2026 15:04
Comment thread libnvme/src/nvme/util-fabrics.c Outdated
Comment thread libnvme/src/nvme/private-fabrics.h Outdated
Comment thread libnvme/src/nvme/private-fabrics.h Outdated
libnvmf_exat_ptr_next(), libnvmf_getifaddrs() (renamed from
libnvme_getifaddrs()), and the libnvmf_exat_len()/libnvmf_exat_size()
static inlines (renamed from nvmf_exat_len()/nvmf_exat_size()) are
only meaningful in fabrics-capable builds. Moving them out of util.c
and private.h into util-fabrics.c and private-fabrics.h keeps the
fabrics footprint contained and ensures PCIe-only/embedded builds do
not pull in this code.

util-fabrics.c is compiled only when want_fabrics is set, which
implies CONFIG_FABRICS is always defined, so no guard is needed around
libnvmf_getifaddrs() in that file.

While at it, simplify the util.c include guard from:
  #if defined(HAVE_NETDB) || defined(CONFIG_FABRICS)
to:
  #ifdef HAVE_NETDB
since CONFIG_FABRICS was only needed for libnvme_getifaddrs(), which
is now in util-fabrics.c.

Signed-off-by: Martin Belanger <Martin.Belanger@dell.com>
Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@igaw igaw merged commit eead61f into linux-nvme:master Apr 21, 2026
28 of 29 checks passed
@igaw
Copy link
Copy Markdown
Collaborator

igaw commented Apr 21, 2026

Thanks!

@martin-belanger martin-belanger deleted the util-fabrics branch April 21, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants