|
|
be52b9f |
From c17f7d8a60e17af4abb63668756f9237db3b9634 Mon Sep 17 00:00:00 2001
|
|
|
670c702 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
670c702 |
Date: Thu, 6 Jun 2013 22:28:05 -0400
|
|
|
51b11df |
Subject: [PATCH] journal: remember last direction of search and keep offset
|
|
|
51b11df |
cache
|
|
|
670c702 |
|
|
|
670c702 |
The fields in JournalFile are moved around to avoid wasting
|
|
|
670c702 |
7 bytes because of alignment.
|
|
|
670c702 |
---
|
|
|
670c702 |
TODO | 3 ---
|
|
|
670c702 |
src/journal/journal-file.h | 18 +++++++++++-------
|
|
|
670c702 |
src/journal/sd-journal.c | 11 +++++------
|
|
|
670c702 |
3 files changed, 16 insertions(+), 16 deletions(-)
|
|
|
670c702 |
|
|
|
670c702 |
diff --git a/TODO b/TODO
|
|
|
674ca7d |
index 4f5af140f0..55d70f7acd 100644
|
|
|
670c702 |
--- a/TODO
|
|
|
670c702 |
+++ b/TODO
|
|
|
be52b9f |
@@ -36,9 +36,6 @@ Features:
|
|
|
670c702 |
|
|
|
670c702 |
* investigate endianess issues of UUID vs. GUID
|
|
|
670c702 |
|
|
|
670c702 |
-* see if we can fix https://bugs.freedesktop.org/show_bug.cgi?id=63672
|
|
|
670c702 |
- without dropping the location cache entirely.
|
|
|
670c702 |
-
|
|
|
670c702 |
* dbus: when a unit failed to load (i.e. is in UNIT_ERROR state), we
|
|
|
670c702 |
should be able to safely try another attempt when the bus call LoadUnit() is invoked.
|
|
|
670c702 |
|
|
|
670c702 |
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
|
|
|
674ca7d |
index 7b1cd42854..5cc2c2d28d 100644
|
|
|
670c702 |
--- a/src/journal/journal-file.h
|
|
|
670c702 |
+++ b/src/journal/journal-file.h
|
|
|
670c702 |
@@ -42,10 +42,14 @@ typedef struct JournalMetrics {
|
|
|
670c702 |
uint64_t keep_free;
|
|
|
670c702 |
} JournalMetrics;
|
|
|
670c702 |
|
|
|
670c702 |
+typedef enum direction {
|
|
|
670c702 |
+ DIRECTION_UP,
|
|
|
670c702 |
+ DIRECTION_DOWN
|
|
|
670c702 |
+} direction_t;
|
|
|
670c702 |
+
|
|
|
670c702 |
typedef struct JournalFile {
|
|
|
670c702 |
int fd;
|
|
|
670c702 |
- char *path;
|
|
|
670c702 |
- struct stat last_stat;
|
|
|
670c702 |
+
|
|
|
670c702 |
mode_t mode;
|
|
|
670c702 |
|
|
|
670c702 |
int flags;
|
|
|
670c702 |
@@ -56,6 +60,11 @@ typedef struct JournalFile {
|
|
|
670c702 |
|
|
|
670c702 |
bool tail_entry_monotonic_valid;
|
|
|
670c702 |
|
|
|
670c702 |
+ direction_t last_direction;
|
|
|
670c702 |
+
|
|
|
670c702 |
+ char *path;
|
|
|
670c702 |
+ struct stat last_stat;
|
|
|
670c702 |
+
|
|
|
670c702 |
Header *header;
|
|
|
670c702 |
HashItem *data_hash_table;
|
|
|
670c702 |
HashItem *field_hash_table;
|
|
|
670c702 |
@@ -90,11 +99,6 @@ typedef struct JournalFile {
|
|
|
670c702 |
#endif
|
|
|
670c702 |
} JournalFile;
|
|
|
670c702 |
|
|
|
670c702 |
-typedef enum direction {
|
|
|
670c702 |
- DIRECTION_UP,
|
|
|
670c702 |
- DIRECTION_DOWN
|
|
|
670c702 |
-} direction_t;
|
|
|
670c702 |
-
|
|
|
670c702 |
int journal_file_open(
|
|
|
670c702 |
const char *fname,
|
|
|
670c702 |
int flags,
|
|
|
670c702 |
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
|
|
|
674ca7d |
index c21712b7c4..c74b4a22cd 100644
|
|
|
670c702 |
--- a/src/journal/sd-journal.c
|
|
|
670c702 |
+++ b/src/journal/sd-journal.c
|
|
|
be52b9f |
@@ -101,7 +101,8 @@ static void init_location(Location *l, LocationType type, JournalFile *f, Object
|
|
|
670c702 |
l->seqnum_set = l->realtime_set = l->monotonic_set = l->xor_hash_set = true;
|
|
|
670c702 |
}
|
|
|
670c702 |
|
|
|
670c702 |
-static void set_location(sd_journal *j, LocationType type, JournalFile *f, Object *o, uint64_t offset) {
|
|
|
670c702 |
+static void set_location(sd_journal *j, LocationType type, JournalFile *f, Object *o,
|
|
|
670c702 |
+ direction_t direction, uint64_t offset) {
|
|
|
670c702 |
assert(j);
|
|
|
670c702 |
assert(type == LOCATION_DISCRETE || type == LOCATION_SEEK);
|
|
|
670c702 |
assert(f);
|
|
|
be52b9f |
@@ -109,12 +110,10 @@ static void set_location(sd_journal *j, LocationType type, JournalFile *f, Objec
|
|
|
670c702 |
|
|
|
670c702 |
init_location(&j->current_location, type, f, o);
|
|
|
670c702 |
|
|
|
670c702 |
- if (j->current_file)
|
|
|
670c702 |
- j->current_file->current_offset = 0;
|
|
|
670c702 |
-
|
|
|
670c702 |
j->current_file = f;
|
|
|
670c702 |
j->current_field = 0;
|
|
|
670c702 |
|
|
|
670c702 |
+ f->last_direction = direction;
|
|
|
670c702 |
f->current_offset = offset;
|
|
|
670c702 |
}
|
|
|
670c702 |
|
|
|
be52b9f |
@@ -826,7 +825,7 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc
|
|
|
670c702 |
assert(j);
|
|
|
670c702 |
assert(f);
|
|
|
670c702 |
|
|
|
670c702 |
- if (f->current_offset > 0) {
|
|
|
670c702 |
+ if (f->last_direction == direction && f->current_offset > 0) {
|
|
|
670c702 |
cp = f->current_offset;
|
|
|
670c702 |
|
|
|
670c702 |
r = journal_file_move_to_object(f, OBJECT_ENTRY, cp, &c);
|
|
|
be52b9f |
@@ -923,7 +922,7 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
|
|
|
670c702 |
if (r < 0)
|
|
|
670c702 |
return r;
|
|
|
670c702 |
|
|
|
670c702 |
- set_location(j, LOCATION_DISCRETE, new_file, o, new_offset);
|
|
|
670c702 |
+ set_location(j, LOCATION_DISCRETE, new_file, o, direction, new_offset);
|
|
|
670c702 |
|
|
|
670c702 |
return 1;
|
|
|
670c702 |
}
|