summaryrefslogtreecommitdiff
path: root/src/import
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-04-27 20:37:50 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2023-04-28 00:57:03 +0100
commitb640e274a7c363a2b6394c9dce5671d9404d2e2a (patch)
treec19180439582ff18879d13ef8964228e9cccd042 /src/import
parentfafded0ce0902e948cdeeaa6a12609a28d9c3ded (diff)
downloadsystemd-b640e274a7c363a2b6394c9dce5671d9404d2e2a.tar.gz
copy: Introduce reflink() and reflink_full()
The kernel has had filesystem independent reflink ioctls for a while now, let's try to use them and fall back to the btrfs specific ones if they're not supported.
Diffstat (limited to 'src/import')
-rw-r--r--src/import/export-raw.c4
-rw-r--r--src/import/import-raw.c2
-rw-r--r--src/import/qcow2-util.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/import/export-raw.c b/src/import/export-raw.c
index 44181fd9b2..5c9c2bbcd9 100644
--- a/src/import/export-raw.c
+++ b/src/import/export-raw.c
@@ -138,7 +138,7 @@ static int raw_export_process(RawExport *e) {
* reflink source to destination directly. Let's see
* if this works. */
- r = btrfs_reflink(e->input_fd, e->output_fd);
+ r = reflink(e->input_fd, e->output_fd);
if (r >= 0) {
r = 0;
goto finish;
@@ -257,7 +257,7 @@ static int reflink_snapshot(int fd, const char *path) {
(void) unlink(t);
}
- r = btrfs_reflink(fd, new_fd);
+ r = reflink(fd, new_fd);
if (r < 0) {
safe_close(new_fd);
return r;
diff --git a/src/import/import-raw.c b/src/import/import-raw.c
index 3765b514bb..4c9a30292b 100644
--- a/src/import/import-raw.c
+++ b/src/import/import-raw.c
@@ -335,7 +335,7 @@ static int raw_import_try_reflink(RawImport *i) {
if ((uint64_t) p != (uint64_t) i->buffer_size)
return 0;
- r = btrfs_reflink(i->input_fd, i->output_fd);
+ r = reflink(i->input_fd, i->output_fd);
if (r >= 0)
return 1;
diff --git a/src/import/qcow2-util.c b/src/import/qcow2-util.c
index fe2b535087..9addb5c555 100644
--- a/src/import/qcow2-util.c
+++ b/src/import/qcow2-util.c
@@ -69,7 +69,7 @@ static int copy_cluster(
ssize_t l;
int r;
- r = btrfs_clone_range(sfd, soffset, dfd, doffset, cluster_size);
+ r = reflink_full(sfd, soffset, dfd, doffset, cluster_size);
if (r >= 0)
return r;