chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
journal: sort data items of entries by offset
[elogind.git]
/
src
/
journal
/
journal-file.c
diff --git
a/src/journal/journal-file.c
b/src/journal/journal-file.c
index e778e1c67c19a5f798a6bdd4291557e6272eeeba..ba04d1667b11dbda2f1eac5163252eff15773efb 100644
(file)
--- a/
src/journal/journal-file.c
+++ b/
src/journal/journal-file.c
@@
-260,8
+260,7
@@
static int journal_file_verify_header(JournalFile *f) {
f->compress = JOURNAL_HEADER_COMPRESSED(f->header);
f->compress = JOURNAL_HEADER_COMPRESSED(f->header);
- if (f->writable)
- f->seal = JOURNAL_HEADER_SEALED(f->header);
+ f->seal = JOURNAL_HEADER_SEALED(f->header);
return 0;
}
return 0;
}
@@
-1054,6
+1053,16
@@
void journal_file_post_change(JournalFile *f) {
log_error("Failed to truncate file to its own size: %m");
}
log_error("Failed to truncate file to its own size: %m");
}
+static int entry_item_cmp(const void *_a, const void *_b) {
+ const EntryItem *a = _a, *b = _b;
+
+ if (le64toh(a->object_offset) < le64toh(b->object_offset))
+ return -1;
+ if (le64toh(a->object_offset) > le64toh(b->object_offset))
+ return 1;
+ return 0;
+}
+
int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const struct iovec iovec[], unsigned n_iovec, uint64_t *seqnum, Object **ret, uint64_t *offset) {
unsigned i;
EntryItem *items;
int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const struct iovec iovec[], unsigned n_iovec, uint64_t *seqnum, Object **ret, uint64_t *offset) {
unsigned i;
EntryItem *items;
@@
-1098,6
+1107,10
@@
int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const st
items[i].hash = o->data.hash;
}
items[i].hash = o->data.hash;
}
+ /* Order by the position on disk, in order to improve seek
+ * times for rotating media. */
+ qsort(items, n_iovec, sizeof(EntryItem), entry_item_cmp);
+
r = journal_file_append_entry_internal(f, ts, xor_hash, items, n_iovec, seqnum, ret, offset);
journal_file_post_change(f);
r = journal_file_append_entry_internal(f, ts, xor_hash, items, n_iovec, seqnum, ret, offset);
journal_file_post_change(f);
@@
-2012,6
+2025,7
@@
int journal_file_open(
bool newly_created = false;
assert(fname);
bool newly_created = false;
assert(fname);
+ assert(ret);
if ((flags & O_ACCMODE) != O_RDONLY &&
(flags & O_ACCMODE) != O_RDWR)
if ((flags & O_ACCMODE) != O_RDONLY &&
(flags & O_ACCMODE) != O_RDWR)
@@
-2156,9
+2170,7
@@
int journal_file_open(
if (r < 0)
goto fail;
if (r < 0)
goto fail;
- if (ret)
- *ret = f;
-
+ *ret = f;
return 0;
fail:
return 0;
fail: