public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* splice between non-pipe (tcp socket) fds
@ 2009-09-22  6:23 Марк Коренберг
  2009-09-22  6:24 ` Марк Коренберг
  2009-09-23  7:33 ` Enrik Berkhan
  0 siblings, 2 replies; 3+ messages in thread
From: Марк Коренберг @ 2009-09-22  6:23 UTC (permalink / raw)
  To: linux-kernel

I want splice() to work with two tcp sockets().I think to implement
this. Two questions:

1. Is any work in this direction?
2. Why this functionality does not implemented now? any difficulties?

I think API should consist of 2 main functions:
1. detach available buffers from fd1 (and save info in some struct)
2. attach buffers to fd2 (from this struct)
this functions should be called under some lock to guarantee
atomicity. if something happen, return buffers back to original file.

I mean, that, for example, skb_splice_bits should not splice into
pipe..... it should splice skb into list of kernel buffers independent
from the "type" of fd (socket, file, and so on...)


At now, I think that the most quick way to acheive my results,  is to
create intermediate temporary pipe inside kernel and splice from
non-pipe fd to pipe, and than from pipe to second non-pipe fd.

Is this method appropriate, as you think ?

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

* Re: splice between non-pipe (tcp socket) fds
  2009-09-22  6:23 splice between non-pipe (tcp socket) fds Марк Коренберг
@ 2009-09-22  6:24 ` Марк Коренберг
  2009-09-23  7:33 ` Enrik Berkhan
  1 sibling, 0 replies; 3+ messages in thread
From: Марк Коренберг @ 2009-09-22  6:24 UTC (permalink / raw)
  To: linux-kernel

Please add me to CC in this thread.

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

* Re: splice between non-pipe (tcp socket) fds
  2009-09-22  6:23 splice between non-pipe (tcp socket) fds Марк Коренберг
  2009-09-22  6:24 ` Марк Коренберг
@ 2009-09-23  7:33 ` Enrik Berkhan
  1 sibling, 0 replies; 3+ messages in thread
From: Enrik Berkhan @ 2009-09-23  7:33 UTC (permalink / raw)
  To: Марк Коренберг
  Cc: linux-kernel

Марк Коренберг wrote:
> I want splice() to work with two tcp sockets().I think to implement
> this. Two questions:

This works already by introducing a pipe between the two:

while (0 < (len = splice(sock1, 0, pipe, 0, max_len, some_flags)))
   splice(pipe, 0, sock2, 0, len, some_flags);

Just like with read(2) and write(2), but without copy to/from userspace.

> 1. Is any work in this direction?
> 2. Why this functionality does not implemented now? any difficulties?
> 
> I think API should consist of 2 main functions:
> 1. detach available buffers from fd1 (and save info in some struct)
> 2. attach buffers to fd2 (from this struct)
> this functions should be called under some lock to guarantee
> atomicity. if something happen, return buffers back to original file.

What about full duplex?

> At now, I think that the most quick way to acheive my results,  is to
> create intermediate temporary pipe inside kernel and splice from
> non-pipe fd to pipe, and than from pipe to second non-pipe fd.

Have a look at the "sendfile emulation" in fs/splice.c. Maybe you can
generalize that in some way or the other.

Enrik


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

end of thread, other threads:[~2009-09-23  7:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-22  6:23 splice between non-pipe (tcp socket) fds Марк Коренберг
2009-09-22  6:24 ` Марк Коренберг
2009-09-23  7:33 ` Enrik Berkhan

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