Skip to contentSkip to conversation

xfs_io: support splice data between two files

PATCH New Zorro Lang 1 participant 1 message Dec 8, 2018

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH 1/1 xfs_io: support splice data between two files

Add splice command into xfs_io, by calling splice(2) system call.

---

Hi,

As subject, I'd like to add splice into xfs_io, then will try to add it splice testing into fsstress. Last week we find a XFS regression by doing splice test on overlayfs over XFS. So I think, although copy_file_range maybe do splice if there's not clone_range can be used, but we'd better have a separate splice command/test.

Thanks,
Zorro

 io/Makefile       |   2 +-
 io/init.c         |   1 +
 io/io.h           |   1 +
 io/splice.c       | 194 ++++++++++++++++++++++++++++++++++++++++++++++
 man/man8/xfs_io.8 |  26 +++++++
 5 files changed, 223 insertions(+), 1 deletion(-)
 create mode 100644 io/splice.c
io/Makefile +1 -1
index 484e2b5a..06d21dd5 100644
@@ -12,7 +12,7 @@ CFILES = init.c \
 	attr.c bmap.c crc32cselftest.c cowextsize.c encrypt.c file.c freeze.c \
 	fsync.c getrusage.c imap.c inject.c label.c link.c mmap.c open.c \
 	parent.c pread.c prealloc.c pwrite.c reflink.c resblks.c scrub.c \
-	seek.c shutdown.c stat.c swapext.c sync.c truncate.c utimes.c
+	seek.c shutdown.c splice.c stat.c swapext.c sync.c truncate.c utimes.c
 
 LLDLIBS = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG) $(LIBPTHREAD)
 LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG)
io/init.c +1 -0
index 83f08f2d..fc191aa7 100644
@@ -79,6 +79,7 @@ init_commands(void)
 	seek_init();
 	sendfile_init();
 	shutdown_init();
+	splice_init();
 	stat_init();
 	swapext_init();
 	sync_init();
io/io.h +1 -0
index 6469179e..9a0b71f0 100644
@@ -110,6 +110,7 @@ extern void		quit_init(void);
 extern void		resblks_init(void);
 extern void		seek_init(void);
 extern void		shutdown_init(void);
+extern void		splice_init(void);
 extern void		stat_init(void);
 extern void		swapext_init(void);
 extern void		sync_init(void);
io/splice.c new file +194 -0

194 lines not on this page · raw message

man/man8/xfs_io.8 +26 -0
index f1099c32..8fb2c0b9 100644
@@ -782,6 +782,32 @@ bytes of data.
 .RE
 .PD
 .TP
+.BI "splice  [ \-C ] [ \-q ] [\-m] infile [src_offset dst_offset length]"
+On filesystems that support the
+.BR splice (2)
+system call, splice data from the
+.I infile
+into the open file. If
+.IR src_offset ,
+.IR dst_offset ,
+and
+.I length
+are omitted the contents of infile will be copied to the beginning of the
+open file, overwriting any data already there.
+.RS 1.0i
+.PD 0
+.TP 0.4i
+.B \-C
+Print timing statistics in a condensed format.
+.TP
+.B \-q
+Do not print timing statistics at all.
+.TP
+.B \-m
+Enable SPLICE_F_MOVE flag, attempt to move pages instead of copying.
+.RE
+.PD
+.TP
 .BI utimes " atime_sec atime_nsec mtime_sec mtime_nsec"
 The utimes command changes the atime and mtime of the current file.
 sec uses UNIX timestamp notation and is the seconds elapsed since
Signature · 1 line
2.17.2