From c3401c2317b64e378be42172de5f67bc840a9a50 Mon Sep 17 00:00:00 2001 From: Yury Kurlykov Date: Mon, 16 Dec 2019 12:05:55 +1000 Subject: [PATCH] Add journal file specification Notice that it's still in WIP status. --- journal_file.md | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/journal_file.md b/journal_file.md index deca720..10dee54 100644 --- a/journal_file.md +++ b/journal_file.md @@ -2,3 +2,76 @@ ## Specification +1. `JRNL` file signature (4 bytes) +2. The offset to the first transaction (8 bytes) +3. The offset to the last transaction (8 bytes) +4. Transactions + 1. Previous transaction offset (8 bytes) + 2. Next transaction offset (8 bytes) + 3. Creation date in Unix timestamp format (8 bytes) + 4. Transaction flags (1 byte) + 5. Operations list + 1. Transaction type (1 byte) + 2. Transaction data size (4 bytes) + 3. Transaction data + +## Transactions + +### Flags + +**TODO**. Now there is the only option -- `JRNL_COMPLETE` on bit 0. + +### Consistency + +If the last transaction was not written completely, journal rollback is started. +That means that it will be cleaned since it has not even been written to storage. + +If the last transaction is complete in journal but not in storage (flag `JRNL_COMPLETE` is +not set), redo is being done. That means the transaction starts again since the journal is +consistent. + +### Operations + +There are several operation types: + +1. Page allocation (`0x01`) +2. Page modification (`0x02`) +3. Page removal (`0x03`) +4. Transaction rollback (`0xFE`) +5. Transaction completion (`0xFF`) + +#### Page allocation + +This operation contains this data: + +1. Allocated page offset (8 bytes) +2. Last free page offset before operation (8 bytes) +3. Last free page offset after operation (8 bytes) + +24 bytes in summary. + +#### Page modification + +This operation contains this data: + +1. Modified page offset (8 bytes) +2. Modified page data offset (2 bytes) +3. Modified page data size (2 bytes) +4. 'Before' data image +5. 'After' data image + +12 bytes on header + 2 * (`par. 3`) bytes in summary. +Can't be more than 131084. + +#### Page removal + +This operation contains this data: + +1. Removed page offset (8 bytes) +2. Last free page offset before operation (8 bytes) + +16 bytes in summary. + +#### Transaction rollback/completion + +This operation *may* contain data. By default it does not. \ No newline at end of file