Re: git: 35b7759c05cb - main - cp: Fix build without VM_AND_BUFFER_CACHE_SYNCHRONIZED.

From: Rick Macklem <rmacklem_at_uoguelph.ca>
Date: Tue, 30 Aug 2022 15:41:59 UTC
Mateusz Guzik <mjguzik@gmail.com> wrote:
> On 8/30/22, Alexander Motin <mav@freebsd.org> wrote:
>> On 30.08.2022 11:02, Rick Macklem wrote:
>>> Mateusz Guzik <mjguzik@gmail.com> wrote:
>>>> On 8/30/22, Alexander Motin <mav@freebsd.org> wrote:
>>>>> The branch main has been updated by mav:
>>>>>
>>>>> URL:
>>>>> https://cgit.FreeBSD.org/src/commit/?id=35b7759c05cbc65c06d87141da79f0f80af0f458
>>>>>
>>>>> commit 35b7759c05cbc65c06d87141da79f0f80af0f458
>>>>> Author:     Alexander Motin <mav@FreeBSD.org>
>>>>> AuthorDate: 2022-08-30 14:51:21 +0000
>>>>> Commit:     Alexander Motin <mav@FreeBSD.org>
>>>>> CommitDate: 2022-08-30 14:51:21 +0000
>>>>>
>>>>>      cp: Fix build without VM_AND_BUFFER_CACHE_SYNCHRONIZED.
>>>>>
>>>>>      It allows to not use mmap() for small files, which is not helpful
>>>>>      in case of ZFS.  Should be no functional change.
>>>>>
>>>>
>>>> This should be of no use thanks to copy_file_range
>>> cp does not use copy_file_range(2) for small files, if I recall
>>> correctly.
>>
>> Right.  I tried to look for motivation, but history of this file goes
>> back to 4.4 Lite. :)  I wonder whether copy_file_range(2) for UFS does
>> something clever, like this mmap() to avoid additional memory copy.
It does not at this time. Unless both files are on the same file system and
the file system provides a custom VOP_COPY_FILE_RANGE() { only NFS has
one at this time }, it simply uses vn_rdwr() to do the file system I/O.

A custom VOP_COPY_FILE_RANGE() can be implemented for file systems,
if there is a better way for that file system.

>>  For
>> ZFS though it cause big problem with buffer cache squeezing ARC to
>> absolute minimum.  So if there is agreement to modernize this, I'd
>> completely support it.
>>
>> --
>> Alexander Motin
>>
>
>The way I see it userspace cannot do it any faster.
>
>Especially with the zfs considerations it makes sense to straight up
>copy_file_range if you can and let the kernel figure out what to do in
>a sensible manner. Thought I have no idea if zfs is currently handled
>in such a way. Someone(tm) should look into it.
I've added asomers@, since he did the commit to cp so that
it used copy_file_range(2) and left it doing small files using mmap(2).

rick

--
Mateusz Guzik <mjguzik gmail.com>