Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,20 @@ else
conf.set('fallthrough', 'do {} while (0) /* fallthrough */')
endif

if cc.has_function('TEMP_FAILURE_RETRY', prefix : '#include <errno.h>')
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)); \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we be stuck here for a very long time?

EINTR happens when a signal is received. For example, if someone types CTRL-C (SIGINT) to stop a process that seems stuck. With this, CTRL-C will have no effect. Just wondering if that's what we want.

Copy link
Copy Markdown
Collaborator Author

@igaw igaw Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a problem. Though I am not sure what /dev/nvme-fabrics does on SIGINT.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a problem. Though I am not sure what /dev/nvme-fabrics does on SIGINT.

Right! I remember being stuck on /dev/nvme-fabrics before and there is no way to get out. The kernel just doesn't allow interrupting operations on that device. So, maybe my comment does not apply here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And when nvme request are cancelled the syscall will also return EINTR.

So there are at least three sources/reasons for an EINTR. Don't know if we can handle this correctly in userspace.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a problem. Though I am not sure what /dev/nvme-fabrics does on SIGINT.

Right! I remember being stuck on /dev/nvme-fabrics before and there is no way to get out. The kernel just doesn't allow interrupting operations on that device. So, maybe my comment does not apply here.

Indeed, though I think it should be possible to handle SIGINTs, it's just not there yet.

Copy link
Copy Markdown
Collaborator Author

@igaw igaw Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a bit of refreshing my memory on signals, I don't think there is a real problem. The ctrl-c is translated to SIGINT which is then delivered to the process. The default handler for SIGINT is to terminate the process. That means when the syscall returns the default handler gets executed (terminate process) and thus the loop will not be run anymore.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the TFR macro from the open call, as this call shouldn't be a blocking call.

__result; \
})
''')
endif

################################################################################
substs = configuration_data()
substs.set('NAME', meson.project_name())
Expand Down
2 changes: 1 addition & 1 deletion src/nvme/fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down