* Btrfs clone support in copy operations
@ 2016-07-05 19:06 Kieran Colford
2016-07-05 23:39 ` sbaugh
0 siblings, 1 reply; 3+ 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] 3+ messages in thread
* Re: Btrfs clone support in copy operations
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
0 siblings, 1 reply; 3+ messages in thread
From: sbaugh @ 2016-07-05 23:39 UTC (permalink / raw)
To: emacs-devel
Kieran Colford <kieran@kcolford.com> writes:
> + /* 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
Perhaps you should use the FICLONE flag, which doesn't mention
BTRFS. (and is conceivably filesystem independent - I think XFS supports
it?)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Btrfs clone support in copy operations
2016-07-05 23:39 ` sbaugh
@ 2016-07-06 0:57 ` Paul Eggert
0 siblings, 0 replies; 3+ messages in thread
From: Paul Eggert @ 2016-07-06 0:57 UTC (permalink / raw)
To: sbaugh, Kieran Colford; +Cc: emacs-devel
Thanks for the suggestion. I've created a bug report for this
suggestion, Bug#23904. You can view its current status here:
http://bugs.gnu.org/23904
or add to the thread by sending email to 23904@debbugs.gnu.org.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-06 0:57 UTC | newest]
Thread overview: 3+ 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
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).