Skip to contentSkip to conversation

xfs_io: add copy_file_range command

PATCH New Zach Brown 1 participant 1 message Apr 10, 2015

lore
Share & tools
lore

Zach Brown

author
#0 lore raw

PATCH 1/1 xfs_io: add copy_file_range command

Add support for the copy_file_range() syscall that is being developed. The xfs_io interface for the syscall is based on sendfile -- it writes to the current file from a referenced path or other open file number.

This patch short circuits autoconf detection of the libc wrapper and manually calls the raw syscall. This would all be removed once the syscall is fully merged and supported.

---
 configure.ac          |   1 +
 include/builddefs.in  |   1 +
 io/Makefile           |   8 ++
 io/copy_file_range.c  | 242 ++++++++++++++++++++++++++++++++++++++++++++++++++
 io/init.c             |   1 +
 io/io.h               |   6 ++
 m4/package_libcdev.m4 |  11 +++
 7 files changed, 270 insertions(+)
 create mode 100644 io/copy_file_range.c
configure.ac +1 -0
index ae17c68..a2c3597 100644
@@ -113,6 +113,7 @@ AC_HAVE_PREADV
 AC_HAVE_SYNC_FILE_RANGE
 AC_HAVE_BLKID_TOPO($enable_blkid)
 AC_HAVE_READDIR
+AC_HAVE_COPY_FILE_RANGE
 
 AC_CHECK_SIZEOF([long])
 AC_CHECK_SIZEOF([char *])
include/builddefs.in +1 -0
index 944bcf6..e118f54 100644
@@ -104,6 +104,7 @@ HAVE_FIEMAP = @have_fiemap@
 HAVE_PREADV = @have_preadv@
 HAVE_SYNC_FILE_RANGE = @have_sync_file_range@
 HAVE_READDIR = @have_readdir@
+HAVE_COPY_FILE_RANGE = @have_copy_file_range@
 
 GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall 
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
io/Makefile +8 -0
index a08a782..a2c5f2c 100644
@@ -45,6 +45,14 @@ else
 LSRCFILES += sendfile.c
 endif
 
+# XXX devel hack, flip back to ifeq once libc has wrappers
+ifneq ($(HAVE_COPY_FILE_RANGE),yes)
+CFILES += copy_file_range.c
+LCFLAGS += -DHAVE_COPY_FILE_RANGE
+else
+LSRCFILES += copy_file_range.c
+endif
+
 ifeq ($(HAVE_FIEMAP),yes)
 CFILES += fiemap.c
 LCFLAGS += -DHAVE_FIEMAP
io/copy_file_range.c new file +242 -0

242 lines not on this page · raw message

io/init.c +1 -0
index 1b07518..e716bc4 100644
@@ -83,6 +83,7 @@ init_commands(void)
 	sync_init();
 	sync_range_init();
 	truncate_init();
+	copy_file_range_init();
 }
 
 static int
io/io.h +6 -0
index db8b513..3411be1 100644
@@ -159,3 +159,9 @@ extern void		readdir_init(void);
 #else
 #define readdir_init()		do { } while (0)
 #endif
+
+#ifdef HAVE_COPY_FILE_RANGE
+extern void		copy_file_range_init(void);
+#else
+#define copy_file_range_init()		do { } while (0)
+#endif
m4/package_libcdev.m4 +11 -0
index 919ae0a..794fa57 100644
@@ -202,3 +202,14 @@ AC_DEFUN([AC_HAVE_READDIR],
     AC_SUBST(have_readdir)
   ])
 
+AC_DEFUN([AC_HAVE_COPY_FILE_RANGE],
+  [ AC_MSG_CHECKING([for copy_file_range])
+    AC_TRY_LINK([
+#include <unistd.h>
+    ], [
+         copy_file_range(0, 0, 0, 0, 0, 0);
+    ],	have_copy_file_range=yes
+	AC_MSG_RESULT(yes),
+	AC_MSG_RESULT(no))
+    AC_SUBST(have_copy_file_range)
+  ])
Signature · 1 line
2.1.0