[PATCH nvme-cli 4/1] fabrics: re-read the discovery log page when a discovery controller reconnected
Sagi Grimberg
sagi at grimberg.me
Wed Sep 7 07:24:11 PDT 2022
When using persistent discovery controllers, if the discovery
controller loses connectivity and manage to reconnect after a while,
we need to retrieve again the discovery log page in order to learn
about possible changes that may have occurred during this time as
discovery log change events were lost.
So we pass notify_rediscover for persistent discovery controllers (if
the kernel supports this argument). Upon reception of a udev
EVENT=rediscover we can kickstart discovery on the existing discovery
controller device node that generated the event.
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
fabrics.c | 15 ++++++++++++++-
.../udev-rules/70-nvmf-autoconnect.rules.in | 7 +++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/fabrics.c b/fabrics.c
index 43ca5f422d3d..0cb5d9da6cbf 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -144,6 +144,7 @@ static nvme_ctrl_t __create_discover_ctrl(nvme_root_t r, nvme_host_t h,
{
nvme_ctrl_t c;
int tmo, ret;
+ bool supported;
c = nvme_create_ctrl(r, trcfg->subsysnqn, trcfg->transport,
trcfg->traddr, trcfg->host_traddr,
@@ -154,6 +155,14 @@ static nvme_ctrl_t __create_discover_ctrl(nvme_root_t r, nvme_host_t h,
nvme_ctrl_set_discovery_ctrl(c, true);
tmo = set_discovery_kato(cfg);
+ ret = nvmf_check_param_support("notify_rediscover", &supported);
+ if (ret)
+ return NULL;
+ if (supported) {
+ printf("cfg->notify_rediscover %d\n", cfg->notify_rediscover);
+ cfg->notify_rediscover = persistent;
+ }
+
errno = 0;
ret = nvmf_add_ctrl(h, c, cfg);
@@ -390,8 +399,12 @@ static int __discover(nvme_ctrl_t c, struct nvme_fabrics_config *defcfg,
if (strcmp(nvme_ctrl_get_transport(c), nvmf_trtype_str(e->trtype)))
continue;
- if (e->subtype == NVME_NQN_DISC)
+ if (e->subtype == NVME_NQN_DISC) {
set_discovery_kato(defcfg);
+ defcfg->notify_rediscover = true;
+ } else {
+ defcfg->notify_rediscover = false;
+ }
errno = 0;
child = nvmf_connect_disc_entry(h, e, defcfg,
diff --git a/nvmf-autoconnect/udev-rules/70-nvmf-autoconnect.rules.in b/nvmf-autoconnect/udev-rules/70-nvmf-autoconnect.rules.in
index 434cc080ffe3..93e438863672 100644
--- a/nvmf-autoconnect/udev-rules/70-nvmf-autoconnect.rules.in
+++ b/nvmf-autoconnect/udev-rules/70-nvmf-autoconnect.rules.in
@@ -17,3 +17,10 @@ ACTION=="change", SUBSYSTEM=="nvme", ENV{NVME_AEN}=="0x70f002",\
ACTION=="change", SUBSYSTEM=="fc", ENV{FC_EVENT}=="nvmediscovery", \
ENV{NVMEFC_HOST_TRADDR}=="*", ENV{NVMEFC_TRADDR}=="*", \
RUN+="@SYSTEMCTL@ --no-block start nvmf-connect at --device=none\t--transport=fc\t--traddr=$env{NVMEFC_TRADDR}\t--trsvcid=none\t--host-traddr=$env{NVMEFC_HOST_TRADDR}.service"
+
+# A discovery controller just (re)connected, re-read the discovery log change to
+# check if there were any changes since it was last connected.
+ACTION=="change", SUBSYSTEM=="nvme", ENV{NVME_EVENT}=="rediscover", ATTR{cntrltype}=="discovery", \
+ ENV{NVME_TRTYPE}=="*", ENV{NVME_TRADDR}=="*", \
+ ENV{NVME_TRSVCID}=="*", ENV{NVME_HOST_TRADDR}=="*", \
+ RUN+="@SYSTEMCTL@ --no-block start nvmf-connect at --device=$kernel\t--transport=$env{NVME_TRTYPE}\t--traddr=$env{NVME_TRADDR}\t--trsvcid=$env{NVME_TRSVCID}\t--host-traddr=$env{NVME_HOST_TRADDR}.service"
--
2.34.1
More information about the Linux-nvme
mailing list