Skip to content

Conversation

@hreinecke
Copy link
Collaborator

Calling nvme_reconfigure_ctrl() requires some attributes to be cleared and other to remain constant. This patchset documents the scope of the controller attributes, and also ensures that the code does not trip over an empty 'name' attribute (which is volatile and only set after 'connect' succeeded).

Fixes: #951

Separate out __nvme_deconfigure_ctrl() to make clear which attributes are
to be saved during nvme_reconfigure_ctrl().

Signed-off-by: Hannes Reinecke <[email protected]>
The 'address' attribute is required in nvme_reconfigure_ctrl(), so
we need to update it before calling the function and must not modify
it in nvme_reconfigure_ctrl().

Signed-off-by: Hannes Reinecke <[email protected]>
The controller attributes have a different scope across reconfiguration;
some are immutable, some persist across reconfiguration, and some will
be reset when calling nvme_reconfigure_ctrl().

Signed-off-by: Hannes Reinecke <[email protected]>
…lers

When a controller is disconnected it will just clear the volatile attributes,
but remain part of the tree structure. So when traversing the tree one could
access a disconnected controller, but then c->name is NULL.
So fixup all places calling nvme_ctrl_get_name() to ensure that they don't
crash on an empty name.

Signed-off-by: Hannes Reinecke <[email protected]>
@hreinecke hreinecke changed the title Rework controller reconfiguation Rework controller reconfiguration Sep 3, 2025
if (ret < 0)
return ret;

FREE_CTRL_ATTR(c->address);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't nvme_init_ctrl called only once and thus c->address should be NULL at this point anyway?

@igaw
Copy link
Collaborator

igaw commented Nov 3, 2025

The tests will not pass with this change (meson test -C .build tree -v):

before:

test_lookup:
  ctrls created:
    ctrl0 0x0x28b04a90: tcp 192.168.1.1 192.168.1.20 (null) 4420 [PASS]
    ctrl1 0x0x28b04c90: tcp 192.168.1.1 192.168.1.20 (null) 4421 [PASS]
    ctrl2 0x0x28b05020: tcp 192.168.1.2 192.168.1.20 eth1 4420 [PASS]
    ctrl3 0x0x28b05240: tcp 192.168.1.2 192.168.1.20 eth1 4421 [PASS]
    ctrl4 0x0x28b05460: rdma 192.168.1.3 192.168.1.20 (null) (null) [PASS]
    ctrl5 0x0x28b05640: rdma 192.168.1.4 192.168.1.20 (null) (null) [PASS]
    ctrl6 0x0x28b05820: fc nn-0x201700a09890f5bf:pn-0x201900a09890f5bf nn-0x200000109b579ef3:pn-0x100000109b579ef3 (null) (null) [PASS]
    ctrl7 0x0x28b05a00: fc nn-0x201700a09890f5bf:pn-0x201900a09890f5bf nn-0x200000109b579ef6:pn-0x100000109b579ef6 (null) (null) [PASS]

  lookup controller:
                                      ctrl0 0x0x28b04a90: tcp 192.168.1.1 192.168.1.20 (null) 4420
      4420                         -> ctrl0 0x0x28b04a90: tcp 192.168.1.1 192.168.1.20 (null) 4420 [PASS]
      4420 192.168.1.20            -> ctrl0 0x0x28b04a90: tcp 192.168.1.1 192.168.1.20 (null) 4420 [PASS]

after:

test_lookup:
  ctrls created:
    ctrl0 0x0x3ff75a90: tcp 192.168.1.1 192.168.1.20 (null) 4420 [PASS]
    ctrl1 0x0x3ff75c90: tcp 192.168.1.1 192.168.1.20 (null) 4421 [PASS]
    ctrl2 0x0x3ff75e90: tcp 192.168.1.2 192.168.1.20 eth1 4420 [PASS]
    ctrl3 0x0x3ff760b0: tcp 192.168.1.2 192.168.1.20 eth1 4421 [PASS]
    ctrl4 0x0x3ff762d0: rdma 192.168.1.3 192.168.1.20 (null) (null) [PASS]
    ctrl5 0x0x3ff764b0: rdma 192.168.1.4 192.168.1.20 (null) (null) [PASS]
    ctrl6 0x0x3ff76690: fc nn-0x201700a09890f5bf:pn-0x201900a09890f5bf nn-0x200000109b579ef3:pn-0x100000109b579ef3 (null) (null) [PASS]
    ctrl7 0x0x3ff76870: fc nn-0x201700a09890f5bf:pn-0x201900a09890f5bf nn-0x200000109b579ef6:pn-0x100000109b579ef6 (null) (null) [PASS]

  lookup controller:
                                      ctrl0 0x0x3ff75a90: tcp 192.168.1.1 192.168.1.20 (null) 4420
      4420                         ->       0x0x3ff76a90: tcp 192.168.1.1 (null) (null) 4420 [FAILED]
      4420 192.168.1.20            ->       0x0x3ff76c70: tcp 192.168.1.1 192.168.1.20 (null) 4420 [FAILED]

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.

nvme_disconnect_ctrl followed by a lookup will crash

2 participants