1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 06:25:37 +03:00

journal: when copying journal file to undo NOCOW flag, go via fd

We have the journal file open already, hence reference it via the fd
insted of the file name. After all, some other tool might have
renamed/deleted it already.

Let's not actually reuse the fd though, since we want a separate file
offset for the copying, hence just make it simply and reopen via
/proc/self/fd/.

Follow-up for d71ece3f0b
This commit is contained in:
Lennart Poettering 2022-02-02 15:21:27 +01:00
parent be496d6a9b
commit 5d04cec867

View File

@ -192,7 +192,7 @@ static void managed_journal_file_set_offline_internal(ManagedJournalFile *f) {
log_debug_errno(r, "Failed to re-enable copy-on-write for %s: %m, rewriting file", f->file->path); log_debug_errno(r, "Failed to re-enable copy-on-write for %s: %m, rewriting file", f->file->path);
r = copy_file_atomic(f->file->path, f->file->path, f->file->mode, 0, FS_NOCOW_FL, COPY_REPLACE | COPY_FSYNC | COPY_HOLES); r = copy_file_atomic(FORMAT_PROC_FD_PATH(f->file->fd), f->file->path, f->file->mode, 0, FS_NOCOW_FL, COPY_REPLACE | COPY_FSYNC | COPY_HOLES);
if (r < 0) { if (r < 0) {
log_debug_errno(r, "Failed to rewrite %s: %m", f->file->path); log_debug_errno(r, "Failed to rewrite %s: %m", f->file->path);
continue; continue;