pstore2
Classes | Macros | Functions | Variables
file_header.hpp File Reference

The file header and footer member functions. More...

#include <atomic>
#include "pstore/core/address.hpp"
#include "pstore/core/uuid.hpp"
#include "pstore/serialize/types.hpp"
Include dependency graph for file_header.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pstore::serialize::serializer< extent< T > >
 A specialization which teaches the serialization framework how to read and write instances of extent. More...
 
class  pstore::header
 The data store file header. More...
 
struct  pstore::header::body
 Represents the portion of the header structure which is covered by the computed CRC value. More...
 
struct  pstore::lock_block
 The lock-block is a small struct placed immediately after the file header which is used by the transaction lock. More...
 
struct  pstore::trailer
 The transaction footer structure. More...
 
struct  pstore::trailer::body
 Represents the portion of the trailer structure which is covered by the computed CRC value. More...
 

Macros

#define PSTORE_INDICES
 
#define X(a)   a,
 

Functions

 pstore::PSTORE_STATIC_ASSERT (offsetof(header::body, signature1)==0)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(header::body, signature2)==4)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(header::body, version)==8)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(header::body, header_size)==12)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(header::body, id)==16)
 
 pstore::PSTORE_STATIC_ASSERT (sizeof(header::body)==32)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(header, a)==0)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(header, crc)==32)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(header, footer_pos)==40)
 
 pstore::PSTORE_STATIC_ASSERT (alignof(header)==8)
 
 pstore::PSTORE_STATIC_ASSERT (sizeof(header)==48)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(lock_block, vacuum_lock)==0)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(lock_block, transaction_lock)==8)
 
 pstore::PSTORE_STATIC_ASSERT (alignof(lock_block)==8)
 
 pstore::PSTORE_STATIC_ASSERT (sizeof(lock_block)==16)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(trailer::body, signature1)==0)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(trailer::body, generation)==8)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(trailer::body, unused1)==12)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(trailer::body, size)==16)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(trailer::body, time)==24)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(trailer::body, prev_generation)==32)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(trailer::body, index_records)==40)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(trailer::body, unused2)==88)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(trailer::body, unused3)==92)
 
 pstore::PSTORE_STATIC_ASSERT (alignof(trailer::body)==8)
 
 pstore::PSTORE_STATIC_ASSERT (sizeof(trailer::body)==96)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(trailer, a)==0)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(trailer, crc)==96)
 
 pstore::PSTORE_STATIC_ASSERT (offsetof(trailer, signature2)==104)
 
 pstore::PSTORE_STATIC_ASSERT (alignof(trailer)==8)
 
 pstore::PSTORE_STATIC_ASSERT (sizeof(trailer)==112)
 

Variables

constexpr auto pstore::leader_size = sizeof (header) + sizeof (lock_block)
 

Detailed Description

The file header and footer member functions.

The capacity of an individual segment is defined by offset_number_bits (i.e. the largest offset that we can encode before we need to start again with a new segment). This is 4Mb, which is considerably smaller than I'd like because of the fact that the Windows virtual memory system resizes the underlying file to match to ....

The initial state of the file is shown below. The file simply contains its header structure an an inital (empty) transaction (t0).

store_file_format_t0.svg

The header and footer types are pstore::header and pstore::trailer repectively. The state of the file after the first transaction (t1) has been committed:

store_file_format_t1.svg

A thread connecting to the data store uses the pstore::header::footer_pos value to find the most recent completed transaction; this is an instance of pstore::trailer and marks the end of the data associated with that transaction.

Macro Definition Documentation

◆ PSTORE_INDICES

#define PSTORE_INDICES
Value:
X (compilation) \
X (debug_line_header) \
X (fragment) \
X (name) \
X (path) \
X (write)