Skip to content

Commit

Permalink
nbft: Pause logging for expected connection failures
Browse files Browse the repository at this point in the history
For unavailable SSNSs, pause logging to make connection
attempts truly silent.

Kernel errors are still being logged, e.g.
  nvme nvme8: failed to connect socket: -110

Signed-off-by: Tomas Bzatek <[email protected]>
  • Loading branch information
tbzatek authored and igaw committed Mar 19, 2024
1 parent ba523ea commit 6350a0a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions nbft.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ int discover_from_nbft(nvme_root_t r, char *hostnqn_arg, char *hostid_arg,
for (ss = entry->nbft->subsystem_ns_list; ss && *ss; ss++)
for (i = 0; i < (*ss)->num_hfis; i++) {
nvme_ctrl_t cl;
int saved_log_level;
bool saved_log_pid;
bool saved_log_tstamp;

hfi = (*ss)->hfis[i];
if (hostnqn_arg)
Expand Down Expand Up @@ -159,9 +162,24 @@ int discover_from_nbft(nvme_root_t r, char *hostnqn_arg, char *hostid_arg,
goto out_free;
}

/* Pause logging for unavailable SSNSs */
if ((*ss)->unavailable && verbose < 1) {
saved_log_level = nvme_get_logging_level(r,
&saved_log_pid,
&saved_log_tstamp);
nvme_init_logging(r, -1, false, false);
}

errno = 0;
ret = nvmf_add_ctrl(h, c, cfg);

/* Resume logging */
if ((*ss)->unavailable && verbose < 1)
nvme_init_logging(r,
saved_log_level,
saved_log_pid,
saved_log_tstamp);

/*
* In case this SSNS was marked as 'unavailable' and
* the connection attempt failed again, ignore it.
Expand Down

0 comments on commit 6350a0a

Please sign in to comment.