FreeBSD ZFS
The Zettabyte File System
Functions

spa_history.c File Reference

Routines to manage the on-disk history log. More...

#include <sys/spa.h>
#include <sys/spa_impl.h>
#include <sys/zap.h>
#include <sys/dsl_synctask.h>
#include <sys/dmu_tx.h>
#include <sys/dmu_objset.h>
#include <sys/utsname.h>
#include <sys/sunddi.h>
#include "zfs_comutil.h"
#include <sys/cmn_err.h>
#include <sys/zone.h>
Include dependency graph for spa_history.c:

Go to the source code of this file.

Functions

static uint64_t spa_history_log_to_phys (uint64_t log_off, spa_history_phys_t *shpp)
 convert a logical offset to physical
void spa_history_create_obj (spa_t *spa, dmu_tx_t *tx)
static int spa_history_advance_bof (spa_t *spa, spa_history_phys_t *shpp)
 Change 'sh_bof' to the beginning of the next record.
static int spa_history_write (spa_t *spa, void *buf, uint64_t len, spa_history_phys_t *shpp, dmu_tx_t *tx)
static char * spa_history_zone ()
static void spa_history_log_sync (void *arg1, void *arg2, dmu_tx_t *tx)
 Write out a history event.
int spa_history_log (spa_t *spa, const char *history_str, history_log_type_t what)
 Write out a history event.
int spa_history_get (spa_t *spa, uint64_t *offp, uint64_t *len, char *buf)
 Read out the command history.
static void log_internal (history_internal_events_t event, spa_t *spa, dmu_tx_t *tx, const char *fmt, va_list adx)
void spa_history_log_internal (history_internal_events_t event, spa_t *spa, dmu_tx_t *tx, const char *fmt,...)
void spa_history_log_version (spa_t *spa, history_internal_events_t event)

Detailed Description

Routines to manage the on-disk history log.

The history log is stored as a dmu object containing <packed record length, record nvlist> tuples.

Where "record nvlist" is a nvlist containing uint64_ts and strings, and "packed record length" is the packed length of the "record nvlist" stored as a little endian uint64_t.

The log is implemented as a ring buffer, though the original creation of the pool ('zpool create') is never overwritten.

The history log is tracked as object 'spa_t::spa_history'. The bonus buffer of 'spa_history' stores the offsets for logging/retrieving history as 'spa_history_phys_t'. 'sh_pool_create_len' is the ending offset in bytes of where the 'zpool create' record is stored. This allows us to never overwrite the original creation of the pool. 'sh_phys_max_off' is the physical ending offset in bytes of the log. This tells you the length of the buffer. 'sh_eof' is the logical EOF (in bytes). Whenever a record is added, 'sh_eof' is incremented by the the size of the record. 'sh_eof' is never decremented. 'sh_bof' is the logical BOF (in bytes). This is where the consumer should start reading from after reading in the 'zpool create' portion of the log.

'sh_records_lost' keeps track of how many records have been overwritten and permanently lost.

Definition in file spa_history.c.


Function Documentation

static void log_internal ( history_internal_events_t  event,
spa_t spa,
dmu_tx_t tx,
const char *  fmt,
va_list  adx 
) [static]

Definition at line 435 of file spa_history.c.

static int spa_history_advance_bof ( spa_t spa,
spa_history_phys_t shpp 
) [static]

Change 'sh_bof' to the beginning of the next record.

Definition at line 122 of file spa_history.c.

void spa_history_create_obj ( spa_t spa,
dmu_tx_t tx 
)

Definition at line 85 of file spa_history.c.

int spa_history_get ( spa_t spa,
uint64_t *  offp,
uint64_t *  len,
char *  buf 
)

Read out the command history.

Definition at line 341 of file spa_history.c.

int spa_history_log ( spa_t spa,
const char *  history_str,
history_log_type_t  what 
)

Write out a history event.

Definition at line 304 of file spa_history.c.

void spa_history_log_internal ( history_internal_events_t  event,
spa_t spa,
dmu_tx_t tx,
const char *  fmt,
  ... 
)

Definition at line 474 of file spa_history.c.

static void spa_history_log_sync ( void *  arg1,
void *  arg2,
dmu_tx_t tx 
) [static]

Write out a history event.

Definition at line 197 of file spa_history.c.

static uint64_t spa_history_log_to_phys ( uint64_t  log_off,
spa_history_phys_t shpp 
) [static]

convert a logical offset to physical

Definition at line 75 of file spa_history.c.

void spa_history_log_version ( spa_t spa,
history_internal_events_t  event 
)

Definition at line 499 of file spa_history.c.

static int spa_history_write ( spa_t spa,
void *  buf,
uint64_t  len,
spa_history_phys_t shpp,
dmu_tx_t tx 
) [static]

Definition at line 149 of file spa_history.c.

static char* spa_history_zone ( ) [static]

Definition at line 182 of file spa_history.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines