All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Pavel Emelyanov <xemul@parallels.com>
Subject: [PATCH -next] fs: pipe -- Take into account requested @len in iter_file_splice_write
Date: Sat, 31 May 2014 00:33:32 +0400	[thread overview]
Message-ID: <20140530203332.GA23463@moon> (raw)

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;

             reply	other threads:[~2014-05-30 20:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-30 20:33 Cyrill Gorcunov [this message]
2014-06-03 10:19 ` [PATCH -next] fs: pipe -- Take into account requested @len in iter_file_splice_write Cyrill Gorcunov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140530203332.GA23463@moon \
    --to=gorcunov@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=xemul@parallels.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.