Skip to contentSkip to conversation

xfs_io: implement 'copy_range' command

PATCH In review Anna Schumaker 2 participants 2 messages Jul 1, 2016 – Jul 20, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_io: implement 'copy_range' command

Implements a new xfs_io command, named 'copy_range', which is supposed to be used to copy a range of data from one file to another.

---
 configure.ac          |   1 +
 include/builddefs.in  |   1 +
 io/Makefile           |   5 ++
 io/copy_file_range.c  | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++
 io/init.c             |   1 +
 io/io.h               |   6 ++
 m4/package_libcdev.m4 |  17 ++++++
 7 files changed, 179 insertions(+)
 create mode 100644 io/copy_file_range.c
configure.ac +1 -0
index 83f9020..464b314 100644
@@ -122,6 +122,7 @@ AC_HAVE_GETMNTINFO
 AC_HAVE_FALLOCATE
 AC_HAVE_FIEMAP
 AC_HAVE_PREADV
+AC_HAVE_COPY_FILE_RANGE
 AC_HAVE_SYNC_FILE_RANGE
 AC_HAVE_MNTENT
 AC_HAVE_FLS
include/builddefs.in +1 -0
index b5ce336..7153d7a 100644
@@ -102,6 +102,7 @@ HAVE_GETMNTINFO = @have_getmntinfo@
 HAVE_FALLOCATE = @have_fallocate@
 HAVE_FIEMAP = @have_fiemap@
 HAVE_PREADV = @have_preadv@
+HAVE_COPY_FILE_RANGE = @have_copy_file_range@
 HAVE_SYNC_FILE_RANGE = @have_sync_file_range@
 HAVE_READDIR = @have_readdir@
 HAVE_MNTENT = @have_mntent@
io/Makefile +5 -0
index 0b53f41..62bc03b 100644
@@ -59,6 +59,11 @@ CFILES += inject.c resblks.c
 LCFLAGS += -DHAVE_INJECT -DHAVE_RESBLKS
 endif
 
+ifeq ($(HAVE_COPY_FILE_RANGE),yes)
+CFILES += copy_file_range.c
+LCFLAGS += -DHAVE_COPY_FILE_RANGE
+endif
+
 ifeq ($(HAVE_SYNC_FILE_RANGE),yes)
 CFILES += sync_file_range.c
 LCFLAGS += -DHAVE_SYNC_FILE_RANGE
io/copy_file_range.c new file +148 -0

148 lines not on this page · raw message

io/init.c +1 -0
index 51f1f5c..efe7390 100644
@@ -56,6 +56,7 @@ init_commands(void)
 {
 	attr_init();
 	bmap_init();
+	copy_range_init();
 	fadvise_init();
 	file_init();
 	flink_init();
io/io.h +6 -0
index 172b1f8..2bc7ac4 100644
@@ -150,6 +150,12 @@ extern void		fiemap_init(void);
 #define fiemap_init()	do { } while (0)
 #endif
 
+#ifdef HAVE_COPY_FILE_RANGE
+extern void		copy_range_init(void);
+#else
+#define copy_range_init()	do { } while (0)
+#endif
+
 #ifdef HAVE_SYNC_FILE_RANGE
 extern void		sync_range_init(void);
 #else
m4/package_libcdev.m4 +17 -0
index 0165310..7a847e9 100644
@@ -154,6 +154,23 @@ AC_DEFUN([AC_HAVE_PREADV],
   ])
 
 #
+# Check if we have a copy_file_range system call (Linux)
+#
+AC_DEFUN([AC_HAVE_COPY_FILE_RANGE],
+  [ AC_MSG_CHECKING([for copy_file_range])
+    AC_TRY_LINK([
+#define _GNU_SOURCE
+#include <sys/syscall.h>
+#include <unistd.h>
+    ], [
+         syscall(__NR_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)
+  ])
+
+#
 # Check if we have a sync_file_range libc call (Linux)
 #
 AC_DEFUN([AC_HAVE_SYNC_FILE_RANGE],
Signature · 6 lines
2.9.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#1 lore raw
Quoted 4 lines · Anna Schumaker

Implements a new xfs_io command, named 'copy_range', which is supposed to be used to copy a range of data from one file to another.

Hi Anna, I've just pulled this in, and I noticed that it's missing a man page update. Can you send a patch for man/man8/xfs_io.8 that documents the copy_range command?

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs