anitazha / rpms / systemd

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