Page MenuHomeFreeBSD

cp: Expect EINTR while copying
ClosedPublic

Authored by des on Sat, Feb 7, 5:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Feb 13, 3:48 AM
Unknown Object (File)
Thu, Feb 12, 2:48 AM
Unknown Object (File)
Wed, Feb 11, 7:55 PM
Unknown Object (File)
Wed, Feb 11, 7:15 AM
Unknown Object (File)
Wed, Feb 11, 4:13 AM
Unknown Object (File)
Wed, Feb 11, 12:01 AM
Unknown Object (File)
Tue, Feb 10, 11:19 PM
Unknown Object (File)
Tue, Feb 10, 6:54 AM
Subscribers

Details

Summary

Both copy_file_range() and copy_fallback() can be interrupted before
they have read anything at all, in which case they return -1 and set
errno to EINTR. If that happens, we should retry, not fail.

MFC after: 1 week
PR: 293028

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Sat, Feb 7, 5:34 PM

hang on, that won't actually work, brb

This is probably correct. However, I'd like to see two other things:

  • A reproduction case
  • An audit of the rest of the base system for other utilities that make the same mistake, like install(1).

This is probably correct. However, I'd like to see two other things:

  • A reproduction case
  • An audit of the rest of the base system for other utilities that make the same mistake, like install(1).

The reproducing case is timing dependent. I came up with the discrepancy when a user on the forums interrupted a cp operation with a du and cp bailed out.

I will troll the base system for similar cases.

The reproducing case is timing dependent. I came up with the discrepancy when a user on the forums interrupted a cp operation with a du and cp bailed out.

Do you at least know what fuse file system he was using, and what options it was mounted with?

The reproducing case is timing dependent. I came up with the discrepancy when a user on the forums interrupted a cp operation with a du and cp bailed out.

Do you at least know what fuse file system he was using, and what options it was mounted with?

NTFS. I just asked the user for flags.

The reproducing case is timing dependent. I came up with the discrepancy when a user on the forums interrupted a cp operation with a du and cp bailed out.

Do you at least know what fuse file system he was using, and what options it was mounted with?

NTFS. I just asked the user for flags.

NTFS uses libfuse-2. That version doesn't even support FUSE_COPY_FILE_RANGE. So my guess is that vn_copy_file_range did one read and then one write. The write went through fuse_vnop_write, but then it blocked, because the FUSE daemon was processing other commands. So no FUSE_WRITE operation ever got sent to userspace. Then something sent a signal to the process. So the fusefs module abandoned the write operation, returning EINTR, and vn_copy_file_range faithfully returned it to userspace.

This revision is now accepted and ready to land.Wed, Feb 11, 3:16 PM
This revision was automatically updated to reflect the committed changes.