Skip to content

libnvme: do not delete existing config files when an install fails - #4483

Merged
igaw merged 3 commits into
linux-nvme:masterfrom
martin-belanger:config-emit-hostid
Dec 2, 2026
Merged

igaw merged 3 commits into
linux-nvme:masterfrom
martin-belanger:config-emit-hostid

Conversation

@martin-belanger

@martin-belanger martin-belanger commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Two fixes in the config emitter, and a cleanup:

  • "nvme config create -q " without "-I" wrote a [Host] section the reader rejects, so every later read of the configuration failed. The emitter now takes the hostid from a UUID-based hostnqn, as nvme connect does, and rejects any other hostnqn without a hostid.
  • A failed install removed every destination file, also files it had not replaced yet. "nvme config create" always installs with force, so a failed write deleted drop-ins of a working configuration. Only the temporary files are removed now.
  • fabrics.c had a static copy of libnvme_hostid_from_hostnqn(). It now uses the shared function.

The first two commits each add a test that fails without the fix. The third moves the existing unit test to the shared function.

Martin Belanger added 2 commits November 30, 2026 07:18
The config reader rejects a [Host] section with a hostnqn and no
hostid. "nvme config create -q <hostnqn>" without "-I" wrote such a
section, and every later read of the configuration failed.

Take the hostid from a UUID-based hostnqn, as nvme connect does.
Reject any other hostnqn without a hostid.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
On failure, libnvmf_config_emit_install() removed every destination
file, also files it had not replaced yet. "nvme config create" always
installs with force, so a failed write (ENOSPC, EIO) deleted drop-ins
of a working configuration.

Remove only the temporary files.

Fixes: b5f6b15 ("libnvme/config: add the configuration write side")
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
libnvmf_context_set_hostnqn() had its own copy of
libnvme_hostid_from_hostnqn(). Use the shared function, and remove
its duplicate declaration from private-tree.h.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
@igaw
igaw merged commit e20a86a into linux-nvme:master Dec 2, 2026
39 checks passed
@igaw

igaw commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

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