]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: Don't explicity disable copy-on-write when copying images 33825/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 24 Jul 2024 13:04:43 +0000 (15:04 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 25 Jul 2024 09:56:07 +0000 (11:56 +0200)
Since the copy helpers now copy file attributes as well, let's not
explicitly disable copy-on-write anymore when we copy an image. If
the source already has copy-on-write disabled, the copy will have it
disabled as well. Otherwise, the copy will also have copy-on-write
enabled.

This makes sure that reflinks always work as reflink is only supported
if both source and target are copy-on-write or both source and target
are not copy-on-write.

src/core/exec-invoke.c
src/nspawn/nspawn.c
src/shared/discover-image.c

index 8c7e29f17a449fddfdb9c5001fdea9d2ae97307d..c7082f9e2e65d5b1a5bdcb28209e27a8374a5de3 100644 (file)
@@ -2893,16 +2893,6 @@ static int setup_ephemeral(
                 if (fd < 0)
                         return log_debug_errno(fd, "Failed to copy image %s to %s: %m",
                                                *root_image, new_root);
-
-                /* A root image might be subject to lots of random writes so let's try to disable COW on it
-                 * which tends to not perform well in combination with lots of random writes.
-                 *
-                 * Note: btrfs actually isn't impressed by us setting the flag after making the reflink'ed
-                 * copy, but we at least want to make the intention clear.
-                 */
-                r = chattr_fd(fd, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
-                if (r < 0)
-                        log_debug_errno(r, "Failed to disable copy-on-write for %s, ignoring: %m", new_root);
         } else {
                 assert(*root_directory);
 
index 01c3a432a579e77432349eb7fd26015b32c8dd05..5c7b1568584ef9ef662e13356f18b1ff67da08f2 100644 (file)
@@ -6072,10 +6072,8 @@ static int run(int argc, char *argv[]) {
 
                         {
                                 BLOCK_SIGNALS(SIGINT);
-                                r = copy_file_full(arg_image, np, O_EXCL, arg_read_only ? 0400 : 0600,
-                                                   FS_NOCOW_FL, FS_NOCOW_FL,
-                                                   COPY_REFLINK|COPY_CRTIME|COPY_SIGINT,
-                                                   NULL, NULL);
+                                r = copy_file(arg_image, np, O_EXCL, arg_read_only ? 0400 : 0600,
+                                              COPY_REFLINK|COPY_CRTIME|COPY_SIGINT);
                         }
                         if (r == -EINTR) {
                                 log_error_errno(r, "Interrupted while copying image file to %s, removed again.", np);
index dd78a013aaf26c49d3b94ff6c1c21b27477c0dac..1386452203f11e6528a2f178594fa88810a2d200 100644 (file)
@@ -1205,8 +1205,7 @@ int image_clone(Image *i, const char *new_name, bool read_only) {
         case IMAGE_RAW:
                 new_path = strjoina("/var/lib/machines/", new_name, ".raw");
 
-                r = copy_file_atomic_full(i->path, new_path, read_only ? 0444 : 0644, FS_NOCOW_FL, FS_NOCOW_FL,
-                                          COPY_REFLINK|COPY_CRTIME, NULL, NULL);
+                r = copy_file_atomic(i->path, new_path, read_only ? 0444 : 0644, COPY_REFLINK|COPY_CRTIME);
                 break;
 
         case IMAGE_BLOCK: