emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#60489: closed (Programs should exit after EIO from FICLONE or copy_f


From: GNU bug Tracking System
Subject: bug#60489: closed (Programs should exit after EIO from FICLONE or copy_file_range())
Date: Fri, 06 Jan 2023 14:48:02 +0000

Your message dated Fri, 6 Jan 2023 14:47:43 +0000
with message-id <cf472241-03f0-1247-f3b0-a03295e6e6a3@draigBrady.com>
and subject line Re: bug#60489: Programs should exit after EIO from FICLONE or 
copy_file_range()
has caused the debbugs.gnu.org bug report #60489,
regarding Programs should exit after EIO from FICLONE or copy_file_range()
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
60489: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60489
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: Programs should exit after EIO from FICLONE or copy_file_range() Date: Sun, 1 Jan 2023 22:36:20 -0800 User-agent: Mutt/1.5.24 (2015-08-30)
Because Debian coreutils 9.1-1 "cp" silently falls back to copy_file_range()
after FICLONE reports EIO, "cp" can transfer incorrect bytes.  Linux syscalls
having a file descriptor parameter report EIO after a fault in the underlying
device.  The affected file is not recoverable in the general case, but syscall
outcomes after the EIO don't reflect that.  For example, consider FICLONE
returning EIO for a fault during source file writeback.  The kernel will mark
"clean" the affected page cache entries and clear the EIO state.  If the page
cache evicts those pages, their file offsets revert to the last written-back
values if any, else zeros.  If userspace issues a syscall that bypasses the
page cache, like copy_file_range() or another FICLONE, that syscall clones the
last written-back state or zeroes.  See
https://lore.kernel.org/linux-xfs/20221108172436.GA3613139@rfd.leadboat.com
for a "cp" and "cat" test script, background, and discussion.

I recommend instead reporting the EIO and terminating when FICLONE or
copy_file_range() fails with EIO.  One could argue that ENOSPC also warrants
termination, since no fallback reduces space usage.  For other errno values,
fallback to the next transfer strategy, like today.  An alternative would be
to fallback from FICLONE to copy_file_range() only after known-appropriate
errors EBADF, EINVAL, EOPNOTSUPP, ETXTBSY, and EXDEV.  That alternative wins
if future FICLONE reports an additional termination-deserving errno value.
Since just EIO needs termination today, I bet new errno values are more likely
than not to deserve fallback.  What do you think?

Thanks,
nm



--- End Message ---
--- Begin Message --- Subject: Re: bug#60489: Programs should exit after EIO from FICLONE or copy_file_range() Date: Fri, 6 Jan 2023 14:47:43 +0000 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.0
On 02/01/2023 16:22, Pádraig Brady wrote:
On 02/01/2023 13:28, Andreas Schwab wrote:
On Jan 02 2023, Pádraig Brady wrote:

+          /* Note error set is consistent with copy_file_range().  */
+          bool no_clone_attempted = errno == ENOSYS || is_ENOTSUP (errno)
+                                    || errno == EINVAL || errno == EBADF
+                                    || errno == EXDEV || errno == ETXTBSY;

Should this be refactored to avoid duplication?

Yes good call.
We should also refactor the handling of clone failure
to also apply to the usage of fclonefileat() on macOS.

Updated patch attached.

Pushed.

Marking this as done.

thanks,
Pádraig



--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]