views:

158

answers:

2

The man page for the splice system call says that splice may fail and set errno to EINVAL if:

Target file system doesn't support splicing; neither of the descriptors refers to a pipe; or offset given for non-seekable device

Which file systems support splicing?

+1  A: 

Accordding to this, EXT3 does. It seems that you might be out of luck with any FUSE file system.

Carlos Valiente
+7  A: 

My original answer was partially incorrect, this is a major rewrite.

Linux 2.6.30.10 and below

In Linux 2.6.30.10 and older, splice returns EINVAL when the source or target filesystem does not support splicing. Here are the filesystems that do support splicing:

  • in read mode: adfs, affs, afs, bfs, btrfs, coda, ecryptfs, exofs, ext2, ext3, ext4, fat, fuse, hpfs, jffs2, jfs, minix, nfs, nilfs2, ntfs, ocfs2, omfs, qnx4, reiserfs, smbfs, sysv, ubifs, udf, ufs.
  • in write mode: exofs, ext2, ext3, ext4, jfs, ocfs2, reiserfs, ubifs.

Details follow. Support for splicing in determined in the do_splice_to() function in the "file to pipe" case and in the do_splice_from() function in the "pipe to file" case. It is done by checking whether the relevant struct file_operations contains .splice_read or .splice_write, respectively. In order to produce the above lists of filesystems, I've grepped fs/*/file.c for .splice_read and .splice_write.

Linux 2.6.31 and above

Starting with Linux 2.6.31, all the filesystems support splicing both in read and write modes.

Details follow. When a filesystem does not have .splice_read or .splice_write in its struct file_operations, a fallback function is used: default_file_splice_read and default_file_splice_write, respectively. See do_splice_to() and do_splice_from() for implementations. Note: EINVAL may still be returned for other reasons listed in the documentation.

Bolo
I've noticed that starting from Linux 2.6.31 there's a fallback splicing for every filesystem. Hence a major rewrite.
Bolo
So Linux 2.6.31 and above support splicing to/from a FUSE filesystem as well?
Daniel Trebbien
@Daniel Yes, if I understand the kernel code correctly.
Bolo
@Daniel I've successfully run the code from this question: http://stackoverflow.com/questions/1580923/ on my Linux 2.6.32-23 with fuse filesystem (via sshfs) as target.
Bolo