diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-12-16 21:03:36 +0100 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2014-12-18 12:17:20 +0100 |
commit | 6573ef05a3cbe15949acfbbf1ad03726068907bd (patch) | |
tree | cb3d38ce419ba37de77b8cb358e82883573d8e22 /src/journal/journal-file.c | |
parent | 1fc605b0e130149a44abfa38c33f4535cfe548ea (diff) |
journal: keep per-JournalFile location info during iteration
In next_beyond_location() when we find a candidate entry in a journal
file, save its location information in struct JournalFile.
The purpose of remembering the locations of candidate entries is to be
able to save work in the next iteration. This patch does only the
remembering part.
LOCATION_SEEK means the location identifies a candidate entry.
When a winner is picked from among candidates, it becomes
LOCATION_DISCRETE.
LOCATION_TAIL here signifies we've iterated the file to the end (or the
beginning in the case of reversed direction).
Diffstat (limited to 'src/journal/journal-file.c')
-rw-r--r-- | src/journal/journal-file.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 8cbdbb9f96..7b9815c69f 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -1929,7 +1929,24 @@ int journal_file_move_to_entry_by_monotonic( } void journal_file_reset_location(JournalFile *f) { + f->location_type = LOCATION_HEAD; f->current_offset = 0; + f->current_seqnum = 0; + f->current_realtime = 0; + f->current_monotonic = 0; + zero(f->current_boot_id); + f->current_xor_hash = 0; +} + +void journal_file_save_location(JournalFile *f, direction_t direction, Object *o, uint64_t offset) { + f->last_direction = direction; + f->location_type = LOCATION_SEEK; + f->current_offset = offset; + f->current_seqnum = le64toh(o->entry.seqnum); + f->current_realtime = le64toh(o->entry.realtime); + f->current_monotonic = le64toh(o->entry.monotonic); + f->current_boot_id = o->entry.boot_id; + f->current_xor_hash = le64toh(o->entry.xor_hash); } int journal_file_next_entry( |