You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* All offsets, sizes, time values, hashes (and most other numeric values) are 64bit unsigned integers in LE format.
75
75
* Offsets are always relative to the beginning of the file.
76
-
* The 64bit hash function used is [Jenkins lookup3](https://en.wikipedia.org/wiki/Jenkins_hash_function), more specifically jenkins_hashlittle2() with the first 32bit integer it returns as higher 32bit part of the 64bit value, and the second one uses as lower 32bit part.
76
+
* The 64bit hash function siphash24 is used for newer journal files. For older files [Jenkins lookup3](https://en.wikipedia.org/wiki/Jenkins_hash_function) is used, more specifically jenkins_hashlittle2() with the first 32bit integer it returns as higher 32bit part of the 64bit value, and the second one uses as lower 32bit part.
77
77
* All structures are aligned to 64bit boundaries and padded to multiples of 64bit
78
78
* The format is designed to be read and written via memory mapping using multiple mapped windows.
79
79
* All time values are stored in usec since the respective epoch.
@@ -174,6 +174,9 @@ _packed_ struct Header {
174
174
/* Added in 189 */
175
175
le64_t n_tags;
176
176
le64_t n_entry_arrays;
177
+
/* Added in 246 */
178
+
le64_t data_hash_chain_depth;
179
+
le64_t field_hash_chain_depth;
177
180
};
178
181
```
179
182
@@ -218,6 +221,16 @@ entry has been written yet.
218
221
**tail_entry_monotonic** is the monotonic timestamp of the last entry in the
219
222
file, referring to monotonic time of the boot identified by **boot_id**.
220
223
224
+
**data_hash_chain_depth** is a counter of the deepest chain in the data hash
225
+
table, minus one. This is updated whenever a chain is found that is longer than
226
+
the previous deepest chain found. Note that the counter is updated during hash
227
+
table lookups, as the chains are traversed. This counter is used to determine
228
+
when it is a good time to rotate the journal file, because hash collisions
229
+
became too frequent.
230
+
231
+
Similar, **field_hash_chain_depth** is a counter of the deepest chain in the
232
+
field hash table, minus one.
233
+
221
234
222
235
## Extensibility
223
236
@@ -238,20 +251,30 @@ unconditionally exist in all revisions of the file format, all fields starting
238
251
with "n_data" needs to be explicitly checked for via a size check, since they
239
252
were additions after the initial release.
240
253
241
-
Currently only two extensions flagged in the flags fields are known:
254
+
Currently only five extensions flagged in the flags fields are known:
242
255
243
256
```c
244
257
enum {
245
-
HEADER_INCOMPATIBLE_COMPRESSED = 1
258
+
HEADER_INCOMPATIBLE_COMPRESSED_XZ = 1 << 0,
259
+
HEADER_INCOMPATIBLE_COMPRESSED_LZ4 = 1 << 1,
260
+
HEADER_INCOMPATIBLE_KEYED_HASH = 1 << 2,
261
+
HEADER_INCOMPATIBLE_COMPRESSED_ZSTD = 1 << 3,
246
262
};
247
263
248
264
enum {
249
-
HEADER_COMPATIBLE_SEALED = 1
265
+
HEADER_COMPATIBLE_SEALED = 1 << 0,
250
266
};
251
267
```
252
268
253
-
HEADER_INCOMPATIBLE_COMPRESSED indicates that the file includes DATA objects
254
-
that are compressed using XZ.
269
+
HEADER_INCOMPATIBLE_COMPRESSED_XZ indicates that the file includes DATA objects
270
+
that are compressed using XZ. Similarly, HEADER_INCOMPATIBLE_COMPRESSED_LZ4
271
+
indicates that the file includes DATA objects that are compressed with the LZ4
272
+
algorithm. And HEADER_INCOMPATIBLE_COMPRESSED_ZSTD indicates that there are
273
+
objects compressed with ZSTD.
274
+
275
+
HEADER_INCOMPATIBLE_KEYED_HASH indicates that instead of the unkeyed Jenkins
276
+
hash function the keyed siphash24 hash function is used for the two hash
277
+
tables, see below.
255
278
256
279
HEADER_COMPATIBLE_SEALED indicates that the file includes TAG objects required
257
280
for Forward Secure Sealing.
@@ -308,9 +331,9 @@ structure gracefully. (Checking what you read is a pretty good idea out of
308
331
security considerations anyway.) This specifically includes checking offset
309
332
values, and that they point to valid objects, with valid sizes and of the type
310
333
and hash value expected. All code must be written with the fact in mind that a
311
-
file with inconsistent structure file might just be inconsistent temporarily,
312
-
and might become consistent later on. Payload OTOH requires less scrutiny, as
313
-
it should only be linked up (and hence visible to readers) after it was
334
+
file with inconsistent structure might just be inconsistent temporarily, and
335
+
might become consistent later on. Payload OTOH requires less scrutiny, as it
336
+
should only be linked up (and hence visible to readers) after it was
314
337
successfully written to memory (though not necessarily to disk). On non-local
315
338
file systems it is a good idea to verify the payload hashes when reading, in
316
339
order to avoid annoyances with mmap() inconsistencies.
@@ -319,8 +342,8 @@ Clients intending to show a live view of the journal should use inotify() for
319
342
this to watch for files changes. Since file writes done via mmap() do not
320
343
result in inotify() writers shall truncate the file to its current size after
321
344
writing one or more entries, which results in inotify events being
322
-
generated. Note that this is not used as transaction scheme (it doesn't protect
323
-
anything), but merely for triggering wakeups.
345
+
generated. Note that this is not used as a transaction scheme (it doesn't
346
+
protect anything), but merely for triggering wakeups.
324
347
325
348
Note that inotify will not work on network file systems if reader and writer
326
349
reside on different hosts. Readers which detect they are run on journal files
@@ -334,7 +357,9 @@ All objects carry a common header:
0 commit comments