journal: Fix disabling NO_COW on btrfs filesystems
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 3 Dec 2021 10:06:36 +0000 (11:06 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 6 Dec 2021 21:17:41 +0000 (22:17 +0100)
commitd71ece3f0b85c7a3decc50143b68ac07fc5831ae
treeabe6f1ed1054cdfafe2c21db412f289960d89789
parent5a980196ab7a8a4291c18effc5054fa6198a24a2
journal: Fix disabling NO_COW on btrfs filesystems

Disabling NOCOW when data has been written to a file doesn't work.
Instead, when we're done writing to a journal file (after archiving),
let's rewrite the file with COW enabled. This also takes care of
properly defragmenting the file.

With zstd compression level 3, journal files are compressed to 12%
of their original size with default journal settings.

As rewriting the file might take a while since we also do an fsync()
after the rewrite, this work is done in the offline thread to avoid
blocking the journald event loop.
src/journal/journald-file.c
src/libsystemd/sd-journal/journal-file.c
src/libsystemd/sd-journal/journal-file.h