journal: Introduce journald-file.c for journal file write related logic
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 30 Nov 2021 15:18:56 +0000 (16:18 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 6 Dec 2021 21:17:38 +0000 (22:17 +0100)
commit035b0f8fe8c1883b17d864f15f99846ab206099d
treeb163a7dec28beb6a6c468f08d71b5bbe05faceff
parentef6bb4dd3e3bb9c210c310026b4d827a46acc762
journal: Introduce journald-file.c for journal file write related logic

Currently, all the logic related to writing journal files lives in
journal-file.c which is part of libsystemd (sd-journal). Because it's
part of libsystemd, we can't depend on any code from src/shared.

To allow using code from src/shared when writing journal files, let's
gradually move the write related logic from journal-file.c to
journald-file.c in src/journal. This directory is not part of libsystemd
and as such can use code from src/shared.

We can safely remove any journal write related logic from libsystemd as
it's not used by any public APIs in libsystemd.

This commit introduces the new file along with the JournaldFile struct
which wraps an instance of JournalFile. The goal is to gradually move
more functions from journal-file.c and fields from JournalFile to
journald-file.c and JournaldFile respectively.

This commit also modifies all call sites that write journal files to
use JournaldFile instead of JournalFile. All sd-journal tests that
write journal files are moved to src/journal so they can make use of
journald-file.c.

Because the deferred closes logic is only used by journald, we move it
out of journal-file.c as well. In journal_file_open(), we would wait for
any remaining deferred closes for the file we're about to open to complete
before continuing if the file was not newly created. In journald_file_open(),
we call this logic unconditionally since it stands that if a file is newly
created, it can't have any outstanding deferred closes.

No changes in behavior are introduced aside from the earlier execution
of waiting for any deferred closes to complete when opening a new journal
file.
25 files changed:
meson.build
src/journal-remote/journal-remote-write.c
src/journal-remote/journal-remote-write.h
src/journal-remote/journal-remote.c
src/journal-remote/meson.build
src/journal/journald-file.c [new file with mode: 0644]
src/journal/journald-file.h [new file with mode: 0644]
src/journal/journald-server.c
src/journal/journald-server.h
src/journal/journald.c
src/journal/meson.build
src/journal/test-journal-flush.c [new file with mode: 0644]
src/journal/test-journal-interleaving.c [new file with mode: 0644]
src/journal/test-journal-stream.c [new file with mode: 0644]
src/journal/test-journal-verify.c [new file with mode: 0644]
src/journal/test-journal.c [new file with mode: 0644]
src/libsystemd/meson.build
src/libsystemd/sd-journal/journal-file.c
src/libsystemd/sd-journal/journal-file.h
src/libsystemd/sd-journal/sd-journal.c
src/libsystemd/sd-journal/test-journal-flush.c [deleted file]
src/libsystemd/sd-journal/test-journal-interleaving.c [deleted file]
src/libsystemd/sd-journal/test-journal-stream.c [deleted file]
src/libsystemd/sd-journal/test-journal-verify.c [deleted file]
src/libsystemd/sd-journal/test-journal.c [deleted file]