linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Changli Gao <xiaosuo@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Matthew Wilcox <matthew@wil.cx>,
	Miklos Szeredi <mszeredi@suse.cz>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Changli Gao <xiaosuo@gmail.com>
Subject: [PATCH v2 3/4]: sendfile: remove flags paramter of do_splice_direct()
Date: Wed, 26 May 2010 22:44:14 +0800	[thread overview]
Message-ID: <1274885054-15698-1-git-send-email-xiaosuo@gmail.com> (raw)

remove flags paramter of do_splice_direct().

the flags parameter of do_splice_direct() doesn't mean non-block read of
in file, but non-block read/write of pipe. As the reader and writer of process
internal pipe is the process itself, we don't need this flags.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
----
 fs/read_write.c    |   15 ++-------------
 fs/splice.c        |   19 +++----------------
 include/linux/fs.h |    2 +-
 3 files changed, 6 insertions(+), 30 deletions(-)
diff --git a/fs/read_write.c b/fs/read_write.c
index 113386d..0688e05 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -796,7 +796,7 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
 	struct inode * in_inode, * out_inode;
 	loff_t pos;
 	ssize_t retval;
-	int fput_needed_in, fput_needed_out, fl;
+	int fput_needed_in, fput_needed_out;
 
 	/*
 	 * Get input file, and verify that it is ok..
@@ -846,18 +846,7 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
 		count = max - pos;
 	}
 
-	fl = 0;
-#if 0
-	/*
-	 * We need to debate whether we can enable this or not. The
-	 * man page documents EAGAIN return for the output at least,
-	 * and the application is arguably buggy if it doesn't expect
-	 * EAGAIN on a non-blocking file descriptor.
-	 */
-	if (in_file->f_flags & O_NONBLOCK)
-		fl = SPLICE_F_NONBLOCK;
-#endif
-	retval = do_splice_direct(in_file, ppos, out_file, count, fl);
+	retval = do_splice_direct(in_file, ppos, out_file, count);
 
 	if (retval > 0) {
 		add_rchar(current, retval);
diff --git a/fs/splice.c b/fs/splice.c
index eb602cb..57172ca 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1125,7 +1125,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
 	long ret, bytes;
 	umode_t i_mode;
 	size_t len;
-	int i, flags;
+	int i;
 
 	/*
 	 * We require the input being a regular file, as we don't want to
@@ -1162,29 +1162,18 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
 	ret = 0;
 	bytes = 0;
 	len = sd->total_len;
-	flags = sd->flags;
-
-	/*
-	 * Don't block on output, we have to drain the direct pipe.
-	 */
-	sd->flags &= ~SPLICE_F_NONBLOCK;
 
 	while (len) {
 		size_t read_len;
 		loff_t pos = sd->pos, prev_pos = pos;
 
-		ret = do_splice_to(in, &pos, pipe, len, flags);
+		ret = do_splice_to(in, &pos, pipe, len, 0);
 		if (unlikely(ret <= 0))
 			goto out_release;
 
 		read_len = ret;
 		sd->total_len = read_len;
 
-		/*
-		 * NOTE: nonblocking mode only applies to the input. We
-		 * must not do the output in nonblocking mode as then we
-		 * could get stuck data in the internal pipe:
-		 */
 		ret = actor(pipe, sd);
 		if (unlikely(ret <= 0)) {
 			sd->pos = prev_pos;
@@ -1242,7 +1231,6 @@ static int direct_splice_actor(struct pipe_inode_info *pipe,
  * @ppos:	input file offset
  * @out:	file to splice to
  * @len:	number of bytes to splice
- * @flags:	splice modifier flags
  *
  * Description:
  *    For use by do_sendfile(). splice can easily emulate sendfile, but
@@ -1252,12 +1240,11 @@ static int direct_splice_actor(struct pipe_inode_info *pipe,
  *
  */
 long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
-		      size_t len, unsigned int flags)
+		      size_t len)
 {
 	struct splice_desc sd = {
 		.len		= len,
 		.total_len	= len,
-		.flags		= flags,
 		.pos		= *ppos,
 		.u.file		= out,
 	};
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4079ef9..eb86433 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2224,7 +2224,7 @@ extern ssize_t generic_file_splice_write(struct pipe_inode_info *,
 extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
 		struct file *out, loff_t *, size_t len, unsigned int flags);
 extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
-		size_t len, unsigned int flags);
+		size_t len);
 
 extern void
 file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);

             reply	other threads:[~2010-05-26 14:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-26 14:44 Changli Gao [this message]
2010-05-28  9:40 ` [PATCH v2 3/4]: sendfile: remove flags paramter of do_splice_direct() Miklos Szeredi
2010-05-28 10:06   ` Changli Gao
2010-05-29  1:59     ` Changli Gao
2010-05-29 16:20       ` Steven Rostedt
2010-05-29 23:58         ` Changli Gao
2010-05-30  0:39           ` Steven Rostedt
2010-05-30  3:25             ` Changli Gao

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=1274885054-15698-1-git-send-email-xiaosuo@gmail.com \
    --to=xiaosuo@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=mszeredi@suse.cz \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).