all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Btrfs clone support in copy operations
@ 2016-07-05 19:06 Kieran Colford
  2016-07-05 23:39 ` sbaugh
  2016-07-06  0:49 ` bug#23904: " Paul Eggert
  0 siblings, 2 replies; 17+ messages in thread
From: Kieran Colford @ 2016-07-05 19:06 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]

I've put together a patch for supporting the btrfs clone operation for
copying

diff --git a/src/fileio.c b/src/fileio.c
index b1f9d3c..d7c1e6e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -21,6 +21,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <limits.h>
 #include <fcntl.h>
 #include "sysstdio.h"
+#include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -1988,6 +1989,16 @@ permissions.  */)
 	oldsize = out_st.st_size;
     }
 
+  /* Perform the O(1) btrfs clone operation, if possible. */
+#ifdef __linux__
+# undef BTRFS_IOCTL_MAGIC
+# define BTRFS_IOCTL_MAGIC 0x94
+# undef BTRFS_IOC_CLONE
+# define BTRFS_IOC_CLONE _IOW (BTRFS_IOCTL_MAGIC, 9, int)
+  if (ioctl (ofd, BTRFS_IOC_CLONE, ifd) == 0)
+    goto done_copy;
+#endif
+
   immediate_quit = 1;
   QUIT;
   while (true)
@@ -2011,6 +2022,8 @@ permissions.  */)
 
   immediate_quit = 0;
 
+ done_copy:
+
 #ifndef MSDOS
   /* Preserve the original file permissions, and if requested, also its
      owner and group.  */

-- 
Kieran Colford <kieran@kcolford.com>

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-09-12  2:35 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-05 19:06 Btrfs clone support in copy operations Kieran Colford
2016-07-05 23:39 ` sbaugh
2016-07-06  0:57   ` Paul Eggert
2016-07-06  0:49 ` bug#23904: " Paul Eggert
2016-07-06  2:45   ` Dmitry Antipov
2016-07-06  5:52     ` Helmut Eller
2016-07-06 11:48     ` Paul Eggert
2016-07-06 14:58       ` Eli Zaretskii
2016-07-06 15:08         ` Paul Eggert
2016-07-06 15:26           ` Eli Zaretskii
2016-07-06 17:32             ` Paul Eggert
2016-09-11  2:16               ` Paul Eggert
2016-09-11 15:25                 ` Eli Zaretskii
2016-09-11 17:17                   ` Paul Eggert
2016-09-11 19:20                     ` Eli Zaretskii
2016-09-11 22:44                       ` Paul Eggert
2016-09-12  2:35                         ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.