fs: pipe -- Take into account requested @len in iter_file_splice_write
PATCH 1/1 fs: pipe -- Take into account requested @len in iter_file_splice_write
Currently iter_file_splice_write pushes into the output IOVs as much as it can, so that if one previously pushed into pipe 8K of data and then try to fetch 4K -- he get the complete 8K instead.
Lest count how many bytes were requested by a caller and stop looping once request is complete.
---
Al, take a look please, hope I didn't do something stupid. Here was a testcase https://lkml.org/lkml/2014/5/27/167
fs/splice.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/splice.c +4 -4
@@ -979,14 +979,14 @@ iter_file_splice_write(struct pipe_inodebreak ; } } - +/* build the vector */ -for (n =0 , idx = pipe->curbuf; n < pipe->nrbufs; n++, idx++) { +for (n =0 , idx = pipe->curbuf; count < sd.total_len && n < pipe->nrbufs; n++, idx++) {struct pipe_buffer *buf = pipe->bufs + idx;size_t this_len = buf->len; -if (this_len > sd.total_len) - this_len = sd.total_len; +if (this_len + count > sd.total_len) + this_len = sd.total_len - count;if (idx == pipe->buffers -1 ) idx =-1 ;
Quoted 8 lines · Cyrill Gorcunov
Currently
iter_file_splice_writepushes into the output IOVs as much as it can, so that if one previously pushed into pipe 8K of data and then try to fetch 4K -- he get the complete 8K instead.Lest count how many bytes were requested by a caller and stop looping once request is complete.
Signed-off-by Cyrill Gorcunov <[email protected]>
Ping?