public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] fs: pipe -- Take into account requested @len in iter_file_splice_write
@ 2014-05-30 20:33 Cyrill Gorcunov
  2014-06-03 10:19 ` Cyrill Gorcunov
  0 siblings, 1 reply; 2+ messages in thread
From: Cyrill Gorcunov @ 2014-05-30 20:33 UTC (permalink / raw)
  To: Al Viro; +Cc: LKML, Andrew Morton, Kirill A. Shutemov, Pavel Emelyanov

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.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Al Viro <viro@ZenIV.linux.org.uk>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
CC: Pavel Emelyanov <xemul@parallels.com>
---

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(-)

Index: linux-2.6.git/fs/splice.c
===================================================================
--- linux-2.6.git.orig/fs/splice.c
+++ 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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] fs: pipe -- Take into account requested @len in iter_file_splice_write
  2014-05-30 20:33 [PATCH -next] fs: pipe -- Take into account requested @len in iter_file_splice_write Cyrill Gorcunov
@ 2014-06-03 10:19 ` Cyrill Gorcunov
  0 siblings, 0 replies; 2+ messages in thread
From: Cyrill Gorcunov @ 2014-06-03 10:19 UTC (permalink / raw)
  To: Al Viro, LKML, Andrew Morton, Kirill A. Shutemov, Pavel Emelyanov

On Sat, May 31, 2014 at 12:33:32AM +0400, Cyrill Gorcunov wrote:
> 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.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>

Ping?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-03 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-30 20:33 [PATCH -next] fs: pipe -- Take into account requested @len in iter_file_splice_write Cyrill Gorcunov
2014-06-03 10:19 ` Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox