Re: [PATCH] sendfile removal

2007-06-04 Thread Fengguang Wu
On Mon, Jun 04, 2007 at 10:05:35AM +0200, Jens Axboe wrote: > On Mon, Jun 04 2007, Fengguang Wu wrote: > > Hi Jens, > > > > This is another try, still not in a comfortable state though. > > //Busy waiting is possible for interleaved reads. > > A few random comments... > > Adding an internal flag

Re: [PATCH] sendfile removal

2007-06-04 Thread Jens Axboe
On Mon, Jun 04 2007, Fengguang Wu wrote: > Hi Jens, > > This is another try, still not in a comfortable state though. > //Busy waiting is possible for interleaved reads. A few random comments... Adding an internal flag is fine, but please put it at the upper end of the spectrum. So, use (1 << 31

Re: [PATCH] sendfile removal

2007-06-03 Thread Fengguang Wu
Hi Jens, This is another try, still not in a comfortable state though. //Busy waiting is possible for interleaved reads. Fengguang --- In non-block splicing read, return EAGAIN once for possible I/O waits. It avoids busy waiting by checking (ra.prev_index != index) in __generic_file_splice_read

Re: [PATCH] sendfile removal

2007-06-03 Thread Fengguang Wu
On Sun, Jun 03, 2007 at 09:05:08PM +0800, Fengguang Wu wrote: > In non-block splicing, return EAGAIN once for all possible I/O waits. > > It works by checking (ra.prev_index != index) in > __generic_file_splice_read(). Another reader on the same fd will at > worst cause a few more splice syscalls

Re: [PATCH] sendfile removal

2007-06-03 Thread Fengguang Wu
On Sat, Jun 02, 2007 at 08:40:04AM -0700, Linus Torvalds wrote: > On Sat, 2 Jun 2007, Jens Axboe wrote: > Your suggested: > > > if ((flags & SPLICE_F_NONBLOCK) && spd.nr_pages) { > > if (TestSetPageLocked(page)) > > break; > > } else > >

Re: [PATCH] sendfile removal

2007-06-02 Thread Jens Axboe
On Sat, Jun 02 2007, Linus Torvalds wrote: > > > On Sat, 2 Jun 2007, Jens Axboe wrote: > > > > splice() WILL return EAGAIN, but in that case it should have triggered > > the read-ahead and thus started some IO. > > That's not enough. > > If the IO has already been started, splice needs to wait.

Re: [PATCH] sendfile removal

2007-06-02 Thread Linus Torvalds
On Sat, 2 Jun 2007, Jens Axboe wrote: > > splice() WILL return EAGAIN, but in that case it should have triggered > the read-ahead and thus started some IO. That's not enough. If the IO has already been started, splice needs to wait. > For the from-file case, see __generic_file_splice_read(). s

Re: [PATCH] sendfile removal

2007-06-02 Thread Jens Axboe
On Fri, Jun 01 2007, H. Peter Anvin wrote: > > So there's a few things to take away from this: > > > > - regular file access MUST NOT return EAGAIN just because a page isn't > >in the cache. Doing so is simply a bug. No ifs, buts or maybe's about > >it! > > > >Busy-looping is NOT A

Re: [PATCH] sendfile removal

2007-06-02 Thread Jens Axboe
On Fri, Jun 01 2007, Linus Torvalds wrote: > > > On Fri, 1 Jun 2007, H. Peter Anvin wrote: > > > > Fair enough. Unix has traditionally not acknowledged the possibility of > > nonblocking I/O on conventional files, for some odd reason. > > It's not odd at all. > > If you return EAGAIN, you had

Re: [PATCH] sendfile removal

2007-06-01 Thread H. Peter Anvin
Linus Torvalds wrote: > And the thing is, neither poll nor select work on regular files. And no, > that is _not_ just an implementation issue. It's very fundamental: neither > poll nor select get the file offset to wait for! > > And that file offset is _critical_ for a regular file, in a way it

Re: [PATCH] sendfile removal

2007-06-01 Thread Eric Dumazet
Linus Torvalds a écrit : On Fri, 1 Jun 2007, H. Peter Anvin wrote: Fair enough. Unix has traditionally not acknowledged the possibility of nonblocking I/O on conventional files, for some odd reason. It's not odd at all. If you return EAGAIN, you had better have a way to _wait_ for that EAGA

Re: [PATCH] sendfile removal

2007-06-01 Thread Pádraig Brady
H. Peter Anvin wrote: > Eric Dumazet wrote: >> As I said, this new non blocking feature on the input side (disk), is >> nice and usefull. (For people scared by splice() syscall :) ) >> >> Just have to mention it is a change of behavior, and documentation >> probably needs to reflect this change. "S

Re: [PATCH] sendfile removal

2007-06-01 Thread Linus Torvalds
On Fri, 1 Jun 2007, H. Peter Anvin wrote: > > Fair enough. Unix has traditionally not acknowledged the possibility of > nonblocking I/O on conventional files, for some odd reason. It's not odd at all. If you return EAGAIN, you had better have a way to _wait_ for that EAGAIN to go away, other

Re: [PATCH] sendfile removal

2007-06-01 Thread H. Peter Anvin
Eric Dumazet wrote: > > As I said, this new non blocking feature on the input side (disk), is > nice and usefull. (For people scared by splice() syscall :) ) > > Just have to mention it is a change of behavior, and documentation > probably needs to reflect this change. "Since linux 2.6.23, sendfi

Re: [PATCH] sendfile removal

2007-06-01 Thread Jens Axboe
On Thu, May 31 2007, Jens Axboe wrote: > > This change is wrong. loop or any existing user of ->sendfile absolutely > > needs to go through a file operations vector so that file-system specific > > actions such as locking are performed. This is required at least for the > > clustered filesystems

Re: [PATCH] sendfile removal (nfsd update)

2007-06-01 Thread Jens Axboe
On Fri, Jun 01 2007, Jens Axboe wrote: > On Fri, Jun 01 2007, Neil Brown wrote: > > > > Ok, here is a patch that makes nfsd use splice instead of sendfile. > > It appears to both compile and work. > > > > Some observations: > > - __splice_from_pipe wants a "struct file*" and I wanted to pass a

Re: [PATCH] sendfile removal

2007-06-01 Thread Eric Dumazet
H. Peter Anvin a écrit : Jens Axboe wrote: I would personally argue that sendfile() blocking on an O_NONBLOCK desriptor, as opposed to returning EAGAIN, is a bug, and a fairly serious such. I agree, but it's still a change in behaviour. Even if we consider the app buggy (it is), can we potentia

Re: [PATCH] sendfile removal

2007-05-31 Thread H. Peter Anvin
Jens Axboe wrote: >>> >> I would personally argue that sendfile() blocking on an O_NONBLOCK >> desriptor, as opposed to returning EAGAIN, is a bug, and a fairly >> serious such. > > I agree, but it's still a change in behaviour. Even if we consider the > app buggy (it is), can we potentially break

Re: [PATCH] sendfile removal (nfsd update)

2007-05-31 Thread Jens Axboe
On Fri, Jun 01 2007, Neil Brown wrote: > > Ok, here is a patch that makes nfsd use splice instead of sendfile. > It appears to both compile and work. > > Some observations: > - __splice_from_pipe wants a "struct file*" and I wanted to pass a > "struct svcrqst *". Maybe it should take a voi

Re: [PATCH] sendfile removal

2007-05-31 Thread Jens Axboe
On Thu, May 31 2007, H. Peter Anvin wrote: > Jens Axboe wrote: > >> > >>> - retval = in_file->f_op->sendfile(in_file, ppos, count, file_send_actor, > >>> out_file); > >>> + fl = 0; > >>> + if (in_file->f_flags & O_NONBLOCK) > >>> + fl = SPLICE_F_NONBLOCK; > >>> + > >>> + retval = do_spl

Re: [PATCH] sendfile removal

2007-05-31 Thread H. Peter Anvin
Jens Axboe wrote: >> >>> - retval = in_file->f_op->sendfile(in_file, ppos, count, file_send_actor, >>> out_file); >>> + fl = 0; >>> + if (in_file->f_flags & O_NONBLOCK) >>> + fl = SPLICE_F_NONBLOCK; >>> + >>> + retval = do_splice_direct(in_file, ppos, out_file, count, fl); >>

Re: [PATCH] sendfile removal (nfsd update)

2007-05-31 Thread Neil Brown
Ok, here is a patch that makes nfsd use splice instead of sendfile. It appears to both compile and work. Some observations: - __splice_from_pipe wants a "struct file*" and I wanted to pass a "struct svcrqst *". Maybe it should take a void * ? - It also wants a *ppos which I had no use fo

Re: [PATCH] sendfile removal

2007-05-31 Thread Jens Axboe
On Thu, May 31 2007, Hugh Dickins wrote: > On Thu, 31 May 2007, Jens Axboe wrote: > > > > This patch removes the ->sendfile() hook from the file_operations > > structure, and replaces the sys_sendfile() mechanism to be based on > > ->splice_read() instead. There should be no functional changes. >

Re: [PATCH] sendfile removal

2007-05-31 Thread Jens Axboe
On Thu, May 31 2007, Tom Zanussi wrote: > On Thu, 2007-05-31 at 12:33 +0200, Jens Axboe wrote: > > Hi, > > > > This patch removes the ->sendfile() hook from the file_operations > > structure, and replaces the sys_sendfile() mechanism to be based on > > ->splice_read() instead. There should be no f

Re: [PATCH] sendfile removal

2007-05-31 Thread Christoph Hellwig
On Thu, May 31, 2007 at 06:06:19PM +0100, Hugh Dickins wrote: > Christoph already picked up on that, and it's of interest to shmem too: > loop over tmpfs in 2.6 was relying on shmem_file_sendfile, for which > the generic route is not good enough. > > If we're giving a .splice_read to everything wh

Re: [PATCH] sendfile removal

2007-05-31 Thread Hugh Dickins
On Thu, 31 May 2007, Jens Axboe wrote: > > This patch removes the ->sendfile() hook from the file_operations > structure, and replaces the sys_sendfile() mechanism to be based on > ->splice_read() instead. There should be no functional changes. > > Work to be done: > > - The ext2 xip support nee

Re: [PATCH] sendfile removal

2007-05-31 Thread Tom Zanussi
On Thu, 2007-05-31 at 12:33 +0200, Jens Axboe wrote: > Hi, > > This patch removes the ->sendfile() hook from the file_operations > structure, and replaces the sys_sendfile() mechanism to be based on > ->splice_read() instead. There should be no functional changes. > > Work to be done: > > - The

Re: [PATCH] sendfile removal

2007-05-31 Thread Jens Axboe
On Thu, May 31 2007, Neil Brown wrote: > On Thursday May 31, [EMAIL PROTECTED] wrote: > > On Thu, May 31 2007, Christoph Hellwig wrote: > > > On Thu, May 31, 2007 at 12:33:16PM +0200, Jens Axboe wrote: > > > > - nfds: The ->rq_sendfile_ok optimization is gone for now. I can't > > > > determine th

Re: [PATCH] sendfile removal

2007-05-31 Thread Neil Brown
On Thursday May 31, [EMAIL PROTECTED] wrote: > On Thu, May 31 2007, Christoph Hellwig wrote: > > On Thu, May 31, 2007 at 12:33:16PM +0200, Jens Axboe wrote: > > > - nfds: The ->rq_sendfile_ok optimization is gone for now. I can't > > > determine the value of it, but I'm assuming it's there for a

Re: [PATCH] sendfile removal

2007-05-31 Thread Jens Axboe
On Thu, May 31 2007, Christoph Hellwig wrote: > On Thu, May 31, 2007 at 12:33:16PM +0200, Jens Axboe wrote: > > - nfds: The ->rq_sendfile_ok optimization is gone for now. I can't > > determine the value of it, but I'm assuming it's there for a reason. > > Any chance this can be converted to spl

Re: [PATCH] sendfile removal

2007-05-31 Thread Jens Axboe
On Thu, May 31 2007, Carsten Otte wrote: > Jens Axboe wrote: > >Work to be done: > > > >- The ext2 xip support needs a splice_read() implementation, currently I > > just if 0'ed out the send xip_file_sendfile(). CC'ed Carsten, who > > seems to be the author of this code. > Yup. Will do the splice

Re: [PATCH] sendfile removal

2007-05-31 Thread Carsten Otte
Jens Axboe wrote: Work to be done: - The ext2 xip support needs a splice_read() implementation, currently I just if 0'ed out the send xip_file_sendfile(). CC'ed Carsten, who seems to be the author of this code. Yup. Will do the splice_read implementation for xip. Do you want to see it in sp

Re: [PATCH] sendfile removal

2007-05-31 Thread Christoph Hellwig
On Thu, May 31, 2007 at 12:33:16PM +0200, Jens Axboe wrote: > - nfds: The ->rq_sendfile_ok optimization is gone for now. I can't > determine the value of it, but I'm assuming it's there for a reason. > Any chance this can be converted to splice, or use something else than > ->sendfile()? CC'e

Re: [PATCH] sendfile removal

2007-05-31 Thread Jens Axboe
On Thu, May 31 2007, Eric Dumazet wrote: > On Thu, 31 May 2007 12:33:16 +0200 > Jens Axboe <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > This patch removes the ->sendfile() hook from the file_operations > > structure, and replaces the sys_sendfile() mechanism to be based on > > ->splice_read() ins

Re: [PATCH] sendfile removal

2007-05-31 Thread Jens Axboe
On Thu, May 31 2007, Jens Axboe wrote: > Hi, > > This patch removes the ->sendfile() hook from the file_operations > structure, and replaces the sys_sendfile() mechanism to be based on > ->splice_read() instead. There should be no functional changes. Forgot to mention, that the modified kernel of

Re: [PATCH] sendfile removal

2007-05-31 Thread Eric Dumazet
On Thu, 31 May 2007 12:33:16 +0200 Jens Axboe <[EMAIL PROTECTED]> wrote: > Hi, > > This patch removes the ->sendfile() hook from the file_operations > structure, and replaces the sys_sendfile() mechanism to be based on > ->splice_read() instead. There should be no functional changes. > > -