naccyde / rpms / systemd

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