Re: Why "splice" doesn't splice between two non-pipes?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks, NeilBrown.

Current "man sendfile" from kernel man pages contradicts to itself. The section "DESCRIPTION" says: "In Linux kernels before 2.6.33, out_fd must refer to a socket.  Since Linux 2.6.33 it can be any file", and AFAIK this is right current info. But the section "NOTES" says: "In Linux 2.4 and earlier, out_fd could also refer to a regular file" and this confuses. Also, the "NOTES" says: "The Linux-specific splice(2) call supports transferring data between arbitrary files (e.g., a pair of sockets)". This is wrong, because one splice call cannot splice together two sockets. So, please fix the man. Probably you should double-check whole man and make sure that whole man is up-to-date.

Also, it seems "splice" and "sendfile" both are not universal. I. e. none of this calls can move info from any fd to any other fd. "splice" needs one fd to be pipe. "sendfile" needs input fd to be mmap-capable. So, why there is no such universal syscall?

I think there is a way to splice any fds: just use pipe in the middle, i. e. performing in the kernel "splice-pipe-splice". And this will be not-slower (and probably faster) than two splices and one pipe created in userspace.

Let's imagine I want to create ultra-fast dd (or cat) for recent Linux kernels, which can dd any fds (sockets, terminals, files, pipes, etc). I think then I should do the following:
1. Try to do splice on this fds. If this fails go to step 2.
2. Try to do sendfile on this fds. If this fails go to step 3.
3. makepipe and fork. Then two splices in this two processes. (Am I right? Or I should use threads? Or I should use async splices in one thread [Is there such splices?]? Or select?) If this fails go to step 4.
4. read-write loop.

Is my plan right?
If yes, why so difficult? Why not just create some syscall, which can perform all this in kernel? (Of course, I don't mean real creating new syscall, this may be just fixing splice or sendfile.)

==
Askar Safin��.n��������+%������w��{.n�����{���)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux