usermode/library/mcore/src/log/phlog_tornbit.h File Reference

Physical log implemented using a torn-bit per word to detect torn words. More...

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <result.h>
#include <list.h>
#include "../hal/pcm_i.h"
#include "log_i.h"

Go to the source code of this file.

Classes

struct  m_phlog_tornbit_nvmd_s
struct  m_phlog_tornbit_s

Defines

#define CHUNK_SIZE   64
#define TORN_MASK   0x8000000000000000LLU
#define TORN_MASKC   0x7FFFFFFFFFFFFFFFLLU
#define TORNBIT_ZERO   0x0000000000000000LLU
#define TORNBIT_ONE   0x8000000000000000LLU
#define LF_TORNBIT   TORN_MASK
#define LF_HEAD_MASK   0x00000000FFFFFFFFLLU

Typedefs

typedef m_phlog_tornbit_s m_phlog_tornbit_t
typedef m_phlog_tornbit_nvmd_s m_phlog_tornbit_nvmd_t

Functions

uint64_t load_nt_word (void *addr)
m_result_t m_phlog_tornbit_format (pcm_storeset_t *set, m_phlog_tornbit_nvmd_t *nvmd, pcm_word_t *nvphlog, int type)
 Formats the non-volatile physical log for reuse.
m_result_t m_phlog_tornbit_alloc (m_phlog_tornbit_t **phlog_tornbitp)
 Allocates a volatile log structure.
m_result_t m_phlog_tornbit_init (m_phlog_tornbit_t *phlog, m_phlog_tornbit_nvmd_t *nvmd, pcm_word_t *nvphlog)
 Initializes the volatile log descriptor using the non-volatile metadata referenced by log_dsc.
m_result_t m_phlog_tornbit_check_consistency (m_phlog_tornbit_nvmd_t *nvmd, pcm_word_t *nvphlog, uint64_t *stable_tail)
 Check the consistency of the non-volatile log and find the consistent stable region starting from the head.
m_result_t m_phlog_tornbit_prepare_truncate (m_log_dsc_t *log_dsc)
m_result_t m_phlog_tornbit_truncate_async (pcm_storeset_t *set, m_phlog_tornbit_t *phlog)
 Truncates the log up to the read_index point.


Detailed Description

Physical log implemented using a torn-bit per word to detect torn words.

NON-VOLATILE PHYSICAL LOG FORMAT:

+----------------------------------------------------------+ | 64-bit WORD | +-------------------------------+--------+-----------------+ | Byte 7 | ... | Byte 0 | +---+---+---+---+---+---+---+---+--------+---+-----+---+---+ |b63|b62|b61|b60|b59|b58|b57|b56| |b07| ... |b01|b00| +---+---+---+---+---+---+---+---+--------+---+-----+---+---+ | T | Payload | +---+------------------------------------------------------+

INVARIANTS:

1. Head and tail always advance by the number of buffer entries.

For example if cache-line size is 64 bytes and word is 64-bits, then the buffer has 8 entries to ensuere that there would always be a complete cacheline to write to the hardware WC buffer. Since buffer has 8 entries, we advance head and tail by 8 entries as well. In the case when we flush the log, the buffer might not be full. We still flush 8 entries even if the buffer is full and we advance tail by 8. This simplifies and makes bounds checking faster by requiring less conditions (less branches, no-memory fences).

2. todo: state the rest of the invariants

TERMINOLOGY:

Atomic log fragment: a region of the log guaranteed to be made persistent.

Definition in file phlog_tornbit.h.


Generated on Sat Apr 23 11:43:36 2011 for Mnemosyne by  doxygen 1.4.7