[PATCH] copy_file_range: New function to copy file data
Florian Weimer
fweimer@redhat.com
Thu Nov 23 16:23:00 GMT 2017
On 11/23/2017 04:46 PM, Andreas Schwab wrote:
> On Nov 23 2017, Florian Weimer <fweimer@redhat.com> wrote:
>
>> On 11/23/2017 04:39 PM, Andreas Schwab wrote:
>>> On Nov 23 2017, Florian Weimer <fweimer@redhat.com> wrote:
>>>
>>>>> I don't think write can ever return 0 when writing more than zero bytes.
>>>>
>>>> I can drop the check. With the Linux VFS layer, it is difficult to tell
>>>> whether this condition can ever happen, and if it does, we would likely
>>>> enter an infinite loop without the check.
>>> > Or we get the real error in the next loop.
>>
>> Tradition has it that it's a replacement for the ENOSPC condition,
>
> A short write, yes, but not a zero write.
Looking at _IO_new_file_write in libio/fileops.c (which is where a call
to fwrite eventually ends up if the buffer is full):
_IO_ssize_t to_do = n;
while (to_do > 0)
{
_IO_ssize_t count = (__builtin_expect (f->_flags2
& _IO_FLAGS2_NOTCANCEL, 0)
? __write_nocancel (f->_fileno, data, to_do)
: __write (f->_fileno, data, to_do));
if (count < 0)
{
f->_flags |= _IO_ERR_SEEN;
break;
}
to_do -= count;
data = (void *) ((char *) data + count);
}
I see that we do not have a count == 0 special case there, so I'm going
to drop the check from copy_file_range, as you proposed.
Thanks,
Florian
More information about the Libc-alpha
mailing list