summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-01-26 16:49:36 +0100
committerLennart Poettering <lennart@poettering.net>2023-02-21 10:47:53 +0100
commit9204fc642acef5cfc3a411fdec3ce9a5fd9f8d37 (patch)
tree714e364dc766868d2391532cc88cb9ad2ed222c9 /src/journal
parent512f2da5c7009bbc72ce2167badd50c06aa0037a (diff)
downloadsystemd-9204fc642acef5cfc3a411fdec3ce9a5fd9f8d37.tar.gz
journal-file: don't update boot_id in journal header on open
The header of the journal file contains a boot ID field that is currently updated whenever we open the journal file. This is not ideal: pretty often we want to archive a journal file, and need to open it for that. Archiving a foreign journal file should not mark it as ours, it should just change the status flag in the file header. The boot ID in the header is aleady rewritten whenever we write a journal entry to the file anyway, hence all this patch effectively does is slightly "delay" when the boot ID in the header is updated: instead of immediately on open it is updated on the first entry that is written. Net effect: archived journal files don't all look like they were written to on a boot newer then they actually were And more importantly: the "tail_entry_monotonic" field suddenly becomes useful, since we know which boot it belongs to. Generally, monotonic timestamps without boot ID information are useless, and this fixes it. A new (compatible) header flag marks file where the boot_id can be understood this way. This can be used by code that wants to make use of the "tail_entry_monotonic" field to ensure it actually can do so safely. This also renames the structure definition in journal-def accordingly, to indicate we now follow the stricter semantics for it.
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/test-journal-interleaving.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c
index 55d717da31..7fec6d9eea 100644
--- a/src/journal/test-journal-interleaving.c
+++ b/src/journal/test-journal-interleaving.c
@@ -230,7 +230,7 @@ static void test_sequence_numbers_one(void) {
assert_se(one->file->header->state == STATE_ONLINE);
assert_se(!sd_id128_equal(one->file->header->file_id, one->file->header->machine_id));
- assert_se(!sd_id128_equal(one->file->header->file_id, one->file->header->boot_id));
+ assert_se(!sd_id128_equal(one->file->header->file_id, one->file->header->tail_entry_boot_id));
assert_se(sd_id128_equal(one->file->header->file_id, one->file->header->seqnum_id));
memcpy(&seqnum_id, &one->file->header->seqnum_id, sizeof(sd_id128_t));
@@ -241,7 +241,7 @@ static void test_sequence_numbers_one(void) {
assert_se(two->file->header->state == STATE_ONLINE);
assert_se(!sd_id128_equal(two->file->header->file_id, one->file->header->file_id));
assert_se(sd_id128_equal(one->file->header->machine_id, one->file->header->machine_id));
- assert_se(sd_id128_equal(one->file->header->boot_id, one->file->header->boot_id));
+ assert_se(sd_id128_equal(one->file->header->tail_entry_boot_id, one->file->header->tail_entry_boot_id));
assert_se(sd_id128_equal(one->file->header->seqnum_id, one->file->header->seqnum_id));
append_number(two, 3, &seqnum);