From 1126825bb0f70493cc1c1023c7e2c92491d19c99 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Tue, 8 Apr 2025 15:59:28 +0200 Subject: [PATCH] fabrics: retry connect command on EINTR Recent changes in the nvme-tcp transport started to return EINTR due to a signal while reading from a socket. The transport could retry the operation but so far this hasn't been implemented. Thus we retry in userpace the connect call when EINTR is returned. Signed-off-by: Daniel Wagner --- meson.build | 14 ++++++++++++++ src/nvme/fabrics.c | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 58b4cc2c5..6cf1e9df5 100644 --- a/meson.build +++ b/meson.build @@ -243,6 +243,20 @@ else conf.set('fallthrough', 'do {} while (0) /* fallthrough */') endif +if cc.has_function('TEMP_FAILURE_RETRY', prefix : '#include ') + conf.set('TFR', 'TEMP_FAILURE_RETRY') +else + conf.set('TFR(exp)', ''' \ +({ \ + long int __result = 0; \ + do { \ + __result = (long int)(exp); \ + } while ((__result == -1) && (errno == EINTR)); \ + __result; \ +}) +''') +endif + ################################################################################ substs = configuration_data() substs.set('NAME', meson.project_name()) diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index 6aa62eea5..cd82e7530 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -814,7 +814,7 @@ static int __nvmf_add_ctrl(nvme_root_t r, const char *argstr) nvme_msg(r, LOG_DEBUG, "connect ctrl, '%.*s'\n", (int)strcspn(argstr,"\n"), argstr); - ret = write(fd, argstr, len); + ret = TFR(write(fd, argstr, len)); if (ret != len) { nvme_msg(r, LOG_INFO, "Failed to write to %s: %s\n", nvmf_dev, strerror(errno));