sd-journal: always fallback to find entry by realtime
Consider the following situation: - There are two journal files (x and y), that contains entries for two boots (X and Y). - The journal file x contains entries of the boot X, and y contains entries of Y. - Nevertheless x does not contains entries of boot Y, it contains the _BOOT_ID= data object of boot Y. Of course, the data object is not referenced by any entries in the journal file x. In such situation, when the current location of sd_journal is the head of journal y, that is, the first entry of the boot Y, sd_journal_previous() failed without this change, and 'journalctl --boot -NUM' for boot X failed. Fixes #29275.
This commit is contained in:
@@ -3351,10 +3351,8 @@ int journal_file_move_to_entry_by_monotonic(
|
||||
assert(f);
|
||||
|
||||
r = find_data_object_by_boot_id(f, boot_id, &o, NULL);
|
||||
if (r < 0)
|
||||
if (r <= 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
return -ENOENT;
|
||||
|
||||
return generic_array_bisect_plus_one(
|
||||
f,
|
||||
@@ -3546,10 +3544,8 @@ int journal_file_move_to_entry_by_monotonic_for_data(
|
||||
|
||||
/* First, seek by time */
|
||||
r = find_data_object_by_boot_id(f, boot_id, &o, &b);
|
||||
if (r < 0)
|
||||
if (r <= 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
return -ENOENT;
|
||||
|
||||
r = generic_array_bisect_plus_one(f,
|
||||
le64toh(o->data.entry_offset),
|
||||
|
||||
@@ -667,7 +667,7 @@ static int find_location_for_match(
|
||||
return journal_file_move_to_entry_by_seqnum_for_data(f, d, j->current_location.seqnum, direction, ret, offset);
|
||||
if (j->current_location.monotonic_set) {
|
||||
r = journal_file_move_to_entry_by_monotonic_for_data(f, d, j->current_location.boot_id, j->current_location.monotonic, direction, ret, offset);
|
||||
if (r != -ENOENT)
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
/* The data object might have been invalidated. */
|
||||
@@ -762,7 +762,7 @@ static int find_location_with_matches(
|
||||
return journal_file_move_to_entry_by_seqnum(f, j->current_location.seqnum, direction, ret, offset);
|
||||
if (j->current_location.monotonic_set) {
|
||||
r = journal_file_move_to_entry_by_monotonic(f, j->current_location.boot_id, j->current_location.monotonic, direction, ret, offset);
|
||||
if (r != -ENOENT)
|
||||
if (r != 0)
|
||||
return r;
|
||||
}
|
||||
if (j->current_location.realtime_set)
|
||||
|
||||
Reference in New Issue
Block a user