copy: drop COPY_REFLINK
Reflinking is a safe optimization whenever the source and destination are regular, seekable files on a filesystem that supports cloning. Requiring each caller to opt in through COPY_REFLINK adds flag plumbing without changing the necessary fallback behavior. Drop COPY_REFLINK, renumber the remaining flags, and have copy_bytes_full() unconditionally try FICLONE or FICLONERANGE before entering its normal copy loop. Isolate the clone attempt and its file-offset bookkeeping in a helper so copy_bytes_full() only has to handle its cloned, unavailable, and error results. A successful clone therefore completes in one operation, while an unsupported or rejected clone falls back to progress-limited copy_file_range(), sendfile(), or buffered copying. Keep the public reflink helpers for operations that specifically require clone semantics. Existing test-copy coverage exercises both bounded and unbounded regular-file copies through copy_bytes_full(). Signed-off-by: Daan De Meyer <daan@amutable.com>
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
28b1e4ea16
commit
5a12005c83
@@ -384,7 +384,7 @@ static int process_locale(int rfd, sd_varlink **mute_console_link) {
|
||||
return log_error_errno(r, "Failed to check if directory file descriptor is root: %m");
|
||||
|
||||
if (arg_copy_locale && r == 0) {
|
||||
r = copy_file_atomic_at(AT_FDCWD, etc_locale_conf(), pfd, f, 0644, COPY_REFLINK);
|
||||
r = copy_file_atomic_at(AT_FDCWD, etc_locale_conf(), pfd, f, 0644, /* copy_flags= */ 0);
|
||||
if (r != -ENOENT) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to copy host's /etc/locale.conf: %m");
|
||||
@@ -526,7 +526,7 @@ static int process_keymap(int rfd, sd_varlink **mute_console_link) {
|
||||
return log_error_errno(r, "Failed to check if directory file descriptor is root: %m");
|
||||
|
||||
if (arg_copy_keymap && r == 0) {
|
||||
r = copy_file_atomic_at(AT_FDCWD, etc_vconsole_conf(), pfd, f, 0644, COPY_REFLINK);
|
||||
r = copy_file_atomic_at(AT_FDCWD, etc_vconsole_conf(), pfd, f, 0644, /* copy_flags= */ 0);
|
||||
if (r != -ENOENT) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to copy host's /etc/vconsole.conf: %m");
|
||||
|
||||
Reference in New Issue
Block a user