Re: splice() from /dev/zero to a pipe does not work (5.9+)

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

 



On Fri, May 07, 2021 at 12:06:31PM -0700, Linus Torvalds wrote:

> That said - looking at the current 'pipe_zero()', it uses
> 'push_pipe()' to actually allocation regular pages, and then clear
> them.
> 
> Which is basically what a generic_file_splice_read() would do, and it
> feels incredibly pointless and stupid to me.
> 
> I *think* we should be able to just do something like
> 
>     len = size;
>     while (len > 0) {
>         struct pipe_buffer *buf;
>         unsigned int tail = pipe->tail;
>         unsigned int head = pipe->head;
>         unsigned int mask = pipe->ring_size - 1;
> 
>         if (pipe_full(head, tail, pipe->max_usage))
>             break;
>         buf = &pipe->bufs[iter_head & p_mask];
>         buf->ops = &zero_pipe_buf_ops;
>         buf->page = ZERO_PAGE(0);
>         buf->offset = 0;
>         buf->len = min_t(ssize_t, len, PAGE_SIZE);
>         len -= buf->len;
>         pipe->head = head+1;
>     }
>     return size - len;
> 
> but honestly, I haven't thought a lot about it.
> 
> Al? This is another of those "right up your alley" things.

Umm...  That would do wonders to anything that used to do
copy_to_user()/clear_user()/copy_to_user() and got converted
to copy_to_iter()/iov_iter_zero()/copy_to_iter()...

Are you sure we can shove zero page into pipe, anyway?
IIRC, get_page()/put_page() on that is not allowed, and
I'm not at all sure that nothing in e.g. fuse splice-related
logics would go ahead an do just that.  Or am I confused
about the page refcounting for those?



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux