From c7ef4b9f1ae66ac4ad7e8934e10f0e753252383f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 4 Mar 2025 04:49:18 +0900 Subject: [PATCH] copy: slightly optimize around chattr_fd() --- src/shared/copy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shared/copy.c b/src/shared/copy.c index 789ed00181d..55518d6dffb 100644 --- a/src/shared/copy.c +++ b/src/shared/copy.c @@ -1487,7 +1487,7 @@ int copy_file_at_full( if (r < 0) return r; - if (chattr_mask != 0) + if ((chattr_mask & CHATTR_EARLY_FL) != 0) (void) chattr_fd(fdt, chattr_flags, chattr_mask & CHATTR_EARLY_FL); r = copy_bytes_full(fdf, fdt, UINT64_MAX, copy_flags & ~COPY_LOCK_BSD, NULL, NULL, progress_bytes, userdata); @@ -1504,7 +1504,7 @@ int copy_file_at_full( } unsigned nocow = FLAGS_SET(copy_flags, COPY_NOCOW_AFTER) ? FS_NOCOW_FL : 0; - if ((chattr_mask | nocow) != 0) + if (((chattr_mask & ~CHATTR_EARLY_FL) | nocow) != 0) (void) chattr_fd(fdt, chattr_flags | nocow, (chattr_mask & ~CHATTR_EARLY_FL) | nocow); if (copy_flags & (COPY_FSYNC|COPY_FSYNC_FULL)) { @@ -1570,7 +1570,7 @@ int copy_file_atomic_at_full( if (r < 0) return r; - if (chattr_mask != 0) + if ((chattr_mask & CHATTR_EARLY_FL) != 0) (void) chattr_fd(fdt, chattr_flags, chattr_mask & CHATTR_EARLY_FL); r = copy_file_fd_at_full(dir_fdf, from, fdt, copy_flags, progress_bytes, userdata); @@ -1593,7 +1593,7 @@ int copy_file_atomic_at_full( t = mfree(t); unsigned nocow = FLAGS_SET(copy_flags, COPY_NOCOW_AFTER) ? FS_NOCOW_FL : 0; - if ((chattr_mask | nocow) != 0) + if (((chattr_mask & ~CHATTR_EARLY_FL) | nocow) != 0) (void) chattr_fd(fdt, chattr_flags | nocow, (chattr_mask & ~CHATTR_EARLY_FL) | nocow); r = close_nointr(TAKE_FD(fdt)); /* even if this fails, the fd is now invalidated */ -- 2.47.3