cli/libnvme: add --idempotent and --devid-file to nvme connect#3573
cli/libnvme: add --idempotent and --devid-file to nvme connect#3573martin-belanger wants to merge 3 commits into
Conversation
Give a caller that manages a fabrics connection as a supervised process (e.g. a systemd transient unit) a way to recover the kernel-assigned device name later, e.g. to disconnect. Writing it from inside libnvmf_connect() means every path out with a live controller -- freshly connected, found already connected in the topology already scanned, or found already connected only after a kernel-race rescan -- reuses the same controller-matching logic libnvme already relies on, rather than a caller re-deriving it. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
nvme-discoverd manages each fabrics connection as a systemd transient unit whose ExecStart is "nvme connect". Without --idempotent, a connect that races with an existing connection exits 1 and fails the unit even though the target is reachable. --devid-file names the file libnvmf_connect() writes the kernel-assigned device name to, so the unit's ExecStop can find it again to disconnect. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
6c87db5 to
2d9774a
Compare
RUNDIR was join_paths(prefix, get_option('rundir')), so any build
without an explicit -Drundir=/run override (this project's own
scripts/build.sh included) silently got <prefix>/run instead of the
real /run tmpfs -- e.g. /usr/local/run on a stock local build. /run is
not an install path: its location is fixed system-wide by the kernel
and the FHS on most distributions, the same reason systemd hardcodes
it rather than deriving it from --prefix. Some distributions still
only provide the legacy /var/run path, though, so rundir stays a
configurable option -- it just must never scale with --prefix. Test
isolation is a separate, already-solved runtime concern
(libnvme_set_test_base_dir()/LIBNVME_TEST_BASE_DIR), so joining it to
--prefix bought nothing but a second way to get this wrong.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2d9774a to
125c84d
Compare
|
Can take a quick timeout and figure out if we really need Couldn't we first try to make |
|
On $ mkdir /tmp/test
$ mkdir /tmp/test
mkdir: cannot create directory ‘/tmp/test’: File exists
$ mkdir -p /tmp/testHmm, with this in mind |
|
I looked into this before adding
I still think #3474 is worth doing for the common case (no duplicates, static addressing) — it just doesn't cover the general case, so I'd rather keep |
Prep patch for nvme-discoverd (not yet upstreamed). discoverd manages each fabrics connection as a systemd transient unit whose
ExecStart=isnvme connect:--idempotentexits 0 when the target is already connected, instead of 1 — otherwise a harmless race with an existing connection fails the unit.--devid-file FILEnames a filelibnvmf_connect()writes the kernel-assigned device name (e.g.nvme0) to on success, so the unit'sExecStop=can find it again to disconnect.Three commits:
--idempotentand--devid-filetonvme connect— the CLI options themselves.RUNDIRfrom--prefix— found while testing:RUNDIRwasjoin_paths(prefix, get_option('rundir')), so any build silently got<prefix>/runinstead of the real/runtmpfs./runisn't an install path, so it's now hardcoded, the same way systemd does it.