Skip to content

Commit f4a01fa

Browse files
committed
logging: retry ioctl on EINTR return value
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 <[email protected]>
1 parent 31aa468 commit f4a01fa

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

meson.build

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,20 @@ else
183183
conf.set('fallthrough', 'do {} while (0) /* fallthrough */')
184184
endif
185185

186+
if cc.has_function('TEMP_FAILURE_RETRY', prefix : '#include <errno.h>')
187+
conf.set('TFR', 'TEMP_FAILURE_RETRY')
188+
else
189+
conf.set('TFR(exp)', ''' \
190+
({ \
191+
long int __result = 0; \
192+
do { \
193+
__result = (long int)(exp); \
194+
} while ((__result == -1) && (errno == EINTR)); \
195+
__result; \
196+
})
197+
''')
198+
endif
199+
186200
configure_file(
187201
output: 'config.h',
188202
configuration: conf

util/logging.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <sys/syslog.h>
88
#include <sys/time.h>
99
#include <linux/types.h>
10+
#include <errno.h>
1011

1112
#include <libnvme.h>
1213

@@ -96,7 +97,7 @@ int nvme_submit_passthru(int fd, unsigned long ioctl_cmd,
9697
if (log_level >= LOG_DEBUG)
9798
gettimeofday(&start, NULL);
9899

99-
err = ioctl(fd, ioctl_cmd, cmd);
100+
err = TFR(ioctl(fd, ioctl_cmd, cmd));
100101

101102
if (log_level >= LOG_DEBUG) {
102103
gettimeofday(&end, NULL);
@@ -122,7 +123,7 @@ int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd,
122123
gettimeofday(&start, NULL);
123124

124125

125-
err = ioctl(fd, ioctl_cmd, cmd);
126+
err = TFR(ioctl(fd, ioctl_cmd, cmd));
126127

127128
if (log_level >= LOG_DEBUG) {
128129
gettimeofday(&end, NULL);

0 commit comments

Comments
 (0)