daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
803fb7
From a6db5931947acb807b37cac9c832d68cd66fbc2a Mon Sep 17 00:00:00 2001
803fb7
From: Jan Janssen <medhefgo@web.de>
803fb7
Date: Fri, 1 May 2015 15:15:16 +0200
803fb7
Subject: [PATCH] journalctl: Improve boot ID lookup
803fb7
803fb7
This method should greatly improve offset based lookup, by simply jumping
803fb7
from one boot to the next boot. It starts at the journal head to get the
803fb7
a boot ID, makes a _BOOT_ID match and then comes from the opposite
803fb7
journal direction (tail) to get to the end that boot. After flushing the matches
803fb7
and advancing the journal from that exact position, we arrive at the start
803fb7
of next boot. Rinse and repeat.
803fb7
803fb7
This is faster than the old method of aggregating the full boot listing just
803fb7
so we can jump to a specific boot, which can be a real pain on big journals
803fb7
just for a mere "-b -1" case.
803fb7
803fb7
As an additional benefit --list-boots should improve slightly too, because
803fb7
it does less seeking.
803fb7
803fb7
Note that there can be a change in boot order with this lookup method
803fb7
because it will use the order of boots in the journal, not the realtime stamp
803fb7
stored in them. That's arguably better, though.
803fb7
Another deficiency is that it will get confused with boots interleaving in the
803fb7
journal, therefore, it will refuse operation in --merge, --file and --directory mode.
803fb7
803fb7
https://bugs.freedesktop.org/show_bug.cgi?id=72601
803fb7
803fb7
Conflicts:
803fb7
	src/journal/journalctl.c
803fb7
803fb7
Cherry-picked from: 596a23293d28f93843aef86721b90043e74d3081
803fb7
Related: #1318994
803fb7
---
803fb7
 src/journal/journalctl.c | 7 +++----
803fb7
 1 file changed, 3 insertions(+), 4 deletions(-)
803fb7
803fb7
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
803fb7
index f60e6415f..c7a19f236 100644
803fb7
--- a/src/journal/journalctl.c
803fb7
+++ b/src/journal/journalctl.c
803fb7
@@ -1166,11 +1166,10 @@ static int add_boot(sd_journal *j) {
803fb7
                 const char *reason = (r == 0) ? "No such boot ID in journal" : strerror(-r);
803fb7
 
803fb7
                 if (sd_id128_is_null(arg_boot_id))
803fb7
-                        log_error("Data from the specified boot (%+i) is not available: %s",
803fb7
-                                  arg_boot_offset, reason);
803fb7
+                        log_error("Failed to look up boot %+i: %s", arg_boot_offset, reason);
803fb7
                 else
803fb7
-                        log_error("Data from the specified boot ("SD_ID128_FORMAT_STR") is not available: %s",
803fb7
-                                  SD_ID128_FORMAT_VAL(arg_boot_id), reason);
803fb7
+                        log_error("Failed to look up boot ID "SD_ID128_FORMAT_STR"%+i: %s",
803fb7
+                                  SD_ID128_FORMAT_VAL(arg_boot_id), arg_boot_offset, reason);
803fb7
 
803fb7
                 return r == 0 ? -ENODATA : r;
803fb7
         }