From: Lennart Poettering Date: Tue, 1 Sep 2020 21:04:29 +0000 (+0200) Subject: tree-wide: copy hardlinks wherever we deal with possibly large OS-style trees X-Git-Tag: v247-rc1~260^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=652d90407a1ddad890b03cf273420e70c1ae2748;p=thirdparty%2Fsystemd.git tree-wide: copy hardlinks wherever we deal with possibly large OS-style trees Fixes: #7382 --- diff --git a/src/basic/btrfs-util.c b/src/basic/btrfs-util.c index 7de77707373..43a58918e9d 100644 --- a/src/basic/btrfs-util.c +++ b/src/basic/btrfs-util.c @@ -1654,7 +1654,10 @@ int btrfs_subvol_snapshot_fd_full( } else if (r < 0) return r; - r = copy_directory_fd_full(old_fd, new_path, COPY_MERGE|COPY_REFLINK|COPY_SAME_MOUNT|(FLAGS_SET(flags, BTRFS_SNAPSHOT_SIGINT) ? COPY_SIGINT : 0), progress_path, progress_bytes, userdata); + r = copy_directory_fd_full( + old_fd, new_path, + COPY_MERGE|COPY_REFLINK|COPY_SAME_MOUNT|COPY_HARDLINKS|(FLAGS_SET(flags, BTRFS_SNAPSHOT_SIGINT) ? COPY_SIGINT : 0), + progress_path, progress_bytes, userdata); if (r < 0) goto fallback_fail; diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c index d203ac0bd4d..a98e883afa9 100644 --- a/src/machine/machine-dbus.c +++ b/src/machine/machine-dbus.c @@ -1066,7 +1066,7 @@ finish: int bus_machine_method_copy(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *src, *dest, *host_path, *container_path, *host_basename, *container_basename, *container_dirname; _cleanup_close_pair_ int errno_pipe_fd[2] = { -1, -1 }; - CopyFlags copy_flags = COPY_REFLINK|COPY_MERGE; + CopyFlags copy_flags = COPY_REFLINK|COPY_MERGE|COPY_HARDLINKS; _cleanup_close_ int hostfd = -1; Machine *m = userdata; bool copy_from; diff --git a/src/partition/repart.c b/src/partition/repart.c index f5015b73a13..d647d3d5e43 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -2609,9 +2609,17 @@ static int do_copy_files(Partition *p, const char *fs) { if (pfd < 0) return log_error_errno(pfd, "Failed to open parent directory of target: %m"); - r = copy_tree_at(sfd, ".", pfd, basename(*target), UID_INVALID, GID_INVALID, COPY_REFLINK|COPY_MERGE|COPY_REPLACE|COPY_SIGINT); + r = copy_tree_at( + sfd, ".", + pfd, basename(*target), + UID_INVALID, GID_INVALID, + COPY_REFLINK|COPY_MERGE|COPY_REPLACE|COPY_SIGINT|COPY_HARDLINKS); } else - r = copy_tree_at(sfd, ".", tfd, ".", UID_INVALID, GID_INVALID, COPY_REFLINK|COPY_MERGE|COPY_REPLACE|COPY_SIGINT); + r = copy_tree_at( + sfd, ".", + tfd, ".", + UID_INVALID, GID_INVALID, + COPY_REFLINK|COPY_MERGE|COPY_REPLACE|COPY_SIGINT|COPY_HARDLINKS); if (r < 0) return log_error_errno(r, "Failed to copy %s%s to %s: %m", strempty(arg_root), *source, *target); } else { diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 5a0a5a58672..b0b8fe8e712 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -1540,7 +1540,7 @@ static int copy_files(Item *i) { dfd, bn, i->uid_set ? i->uid : UID_INVALID, i->gid_set ? i->gid : GID_INVALID, - COPY_REFLINK | COPY_MERGE_EMPTY | COPY_MAC_CREATE); + COPY_REFLINK | COPY_MERGE_EMPTY | COPY_MAC_CREATE | COPY_HARDLINKS); if (r < 0) { struct stat a, b;