Skip to content

libnvme: merge attr accessor files into one shared set - #3796

Merged
igaw merged 1 commit into
linux-nvme:masterfrom
martin-belanger:attr-accessors-merge
Aug 10, 2026
Merged

libnvme: merge attr accessor files into one shared set#3796
igaw merged 1 commit into
linux-nvme:masterfrom
martin-belanger:attr-accessors-merge

Conversation

@martin-belanger

Copy link
Copy Markdown

No functional change. This is the follow-on to #3787 (todo #55, part 2): merges the four per-struct lazy-attribute accessor file sets (ctrl-attrs.*, path-attrs.*, ns-attrs.*, subsys-attrs.*) into one shared attr-accessors.* set, and consolidates the hand-written OS-specific loader files the same way.

Generated files: attr-accessors.{c,h,i} (one merged output per kind instead of four), plus attr-accessors-{linux,win}.c for the one spec (PATH_ATTRS) with real per-OS getter divergence. attr-accessors.ld merges the four old LIBNVME_{CTRL,PATH,NS,SUBSYS}_ATTRS_3 tags into one LIBNVME_ATTR_ACCESSORS_3.

Hand-written files: eight *-attrs-custom-*.c loader files collapse to two, attr-accessors-custom-{linux,win}.c. Along the way, dropped the separate *-custom-fabrics.c/*-custom-no-fabrics.c pair entirely -- CONFIG_FABRICS is never defined on Windows (want_fabrics in the top-level meson.build is gated on host_system == 'linux'), so attr-accessors-custom-win.c just hand-writes the no-op loader body directly with no #ifdef, and Linux's real #ifdef CONFIG_FABRICS/#else branch is inlined in attr-accessors-custom-linux.c instead of reaching for a file for one function.

generate_attr_accessors.py now merges every ATTR_SPECS entry's output into one shared file per kind (one preamble, not four) instead of one file set per spec -- mirrors the "concatenate parts under one shared preamble" pattern generate_accessors.py already uses for multiple structs from one annotated header. attr_accessors_specs.py spreads a _SHARED dict of filenames into every spec so they can't drift apart by typo; main() also asserts they agree before generating anything.

Verified the generated output is identical to before the merge (same function/symbol sets, diffed programmatically, not just inspected) before writing anything into the tree. Full build (default, -Dwerror=true, -Dfabrics=disabled), meson test, -Dcheck-accessors=true, and live checks against real hardware (nvme list, list-subsys, Python bindings) all pass.

No functional change. Merge the four per-struct lazy-attribute
accessor file sets (ctrl-attrs.*, path-attrs.*, ns-attrs.*,
subsys-attrs.*) into one shared attr-accessors.* set, and the eight
hand-written OS-specific loader files down to two,
attr-accessors-custom-{linux,win}.c.

generate_attr_accessors.py now merges every ATTR_SPECS entry into one
shared output file per kind, mirroring the same pattern
generate_accessors.py already uses for multiple structs from one
annotated header.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
@igaw
igaw merged commit 93420fb into linux-nvme:master Aug 10, 2026
32 of 33 checks passed
@igaw

igaw commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Very nice. This looks really good. Thanks!

@martin-belanger
martin-belanger deleted the attr-accessors-merge branch August 10, 2026 16:30
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