Skip to contentSkip to conversation

fs: pipe -- Take into account requested @len in iter_file_splice_write

PATCH In review Cyrill Gorcunov 1 participant 2 messages May 30, 2014 – Jun 3, 2014 VFS

lore
Share & tools
lore
#0 lore raw

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.

CC Al Viro <[email protected]>
CC Andrew Morton <[email protected]>
CC "Kirill A. Shutemov" <[email protected]>
CC Pavel Emelyanov <[email protected]>

---

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
Index: linux-2.6.git/fs/splice.c
===================================================================
@@ -979,14 +979,14 @@ iter_file_splice_write(struct pipe_inode
 				break;
 			}
 		}
-				
+
 		/* 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;
#1 lore raw
Quoted 8 lines · Cyrill Gorcunov

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.

Ping?