ITER_PIPE: allocate buffers as we go in copy-to-pipe primitives
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 14 Jun 2022 17:53:53 +0000 (13:53 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 9 Aug 2022 02:37:17 +0000 (22:37 -0400)
commit8fad7767edcfd3f93e0d9985cb2dc1db270b8719
tree87018b8809edaa081c98a00fd11a252b4ec685b9
parent47b7fcae419dc940e3fb8e58088a5b80ad813bbf
ITER_PIPE: allocate buffers as we go in copy-to-pipe primitives

New helper: append_pipe().  Extends the last buffer if possible,
allocates a new one otherwise.  Returns page and offset in it
on success, NULL on failure.  iov_iter is advanced past the
data we've got.

Use that instead of push_pipe() in copy-to-pipe primitives;
they get simpler that way.  Handling of short copy (in "mc" one)
is done simply by iov_iter_revert() - iov_iter is in consistent
state after that one, so we can use that.

[Fix for braino caught by Liu Xinpeng <liuxp11@chinatelecom.cn> folded in]
[another braino fix, this time in copy_pipe_to_iter() and pipe_zero();
caught by testcase from Hugh Dickins]

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
lib/iov_iter.c