FreeBSD ZFS
The Zettabyte File System
Functions | Variables

txg.c File Reference

Pool-wide transaction groups. More...

#include <sys/zfs_context.h>
#include <sys/txg_impl.h>
#include <sys/dmu_impl.h>
#include <sys/dmu_tx.h>
#include <sys/dsl_pool.h>
#include <sys/dsl_scan.h>
#include <sys/callb.h>
Include dependency graph for txg.c:

Go to the source code of this file.

Functions

static void txg_sync_thread (void *arg)
static void txg_quiesce_thread (void *arg)
 SYSCTL_DECL (_vfs_zfs)
 SYSCTL_NODE (_vfs_zfs, OID_AUTO, txg, CTLFLAG_RW, 0,"ZFS TXG")
 TUNABLE_INT ("vfs.zfs.txg.timeout",&zfs_txg_timeout)
 SYSCTL_INT (_vfs_zfs_txg, OID_AUTO, timeout, CTLFLAG_RW,&zfs_txg_timeout, 0,"Maximum seconds worth of delta per txg")
void txg_init (dsl_pool_t *dp, uint64_t txg)
 Prepares the txg subsystem.
void txg_fini (dsl_pool_t *dp)
 Closes down the txg subsystem.
void txg_sync_start (dsl_pool_t *dp)
 Starts syncing transaction groups.
static void txg_thread_enter (tx_state_t *tx, callb_cpr_t *cpr)
static void txg_thread_exit (tx_state_t *tx, callb_cpr_t *cpr, kthread_t **tpp)
static void txg_thread_wait (tx_state_t *tx, callb_cpr_t *cpr, kcondvar_t *cv, uint64_t time)
void txg_sync_stop (dsl_pool_t *dp)
 Stops syncing transaction groups.
uint64_t txg_hold_open (dsl_pool_t *dp, txg_handle_t *th)
void txg_rele_to_quiesce (txg_handle_t *th)
void txg_register_callbacks (txg_handle_t *th, list_t *tx_callbacks)
void txg_rele_to_sync (txg_handle_t *th)
static void txg_quiesce (dsl_pool_t *dp, uint64_t txg)
 Blocks until all transactions in the group are released.
static void txg_do_callbacks (void *arg)
static void txg_dispatch_callbacks (dsl_pool_t *dp, uint64_t txg)
 Dispatch the commit callbacks registered on this txg.
void txg_delay (dsl_pool_t *dp, uint64_t txg, int ticks)
 Delay this thread by 'ticks' if we are still in the open transaction group and there is already a waiting txg quiesing or quiesced.
void txg_wait_synced (dsl_pool_t *dp, uint64_t txg)
 Wait until the given transaction group has finished syncing.
void txg_wait_open (dsl_pool_t *dp, uint64_t txg)
 Wait until the given transaction group, or one after it, is the open transaction group.
boolean_t txg_stalled (dsl_pool_t *dp)
 Are we waiting for the syncing transaction to complete?
boolean_t txg_sync_waiting (dsl_pool_t *dp)
void txg_list_create (txg_list_t *tl, size_t offset)
 Per-txg object lists.
void txg_list_destroy (txg_list_t *tl)
boolean_t txg_list_empty (txg_list_t *tl, uint64_t txg)
int txg_list_add (txg_list_t *tl, void *p, uint64_t txg)
 Add an entry to the list.
int txg_list_add_tail (txg_list_t *tl, void *p, uint64_t txg)
 Add an entry to the end of the list (walks list to find end).
void * txg_list_remove (txg_list_t *tl, uint64_t txg)
 Remove the head of the list and return it.
void * txg_list_remove_this (txg_list_t *tl, void *p, uint64_t txg)
 Remove a specific item from the list and return it.
int txg_list_member (txg_list_t *tl, void *p, uint64_t txg)
void * txg_list_head (txg_list_t *tl, uint64_t txg)
 Walk a txg list - only safe if you know it's not changing.
void * txg_list_next (txg_list_t *tl, void *p, uint64_t txg)

Variables

int zfs_txg_timeout = 5
 max seconds worth of delta per txg

Detailed Description

Pool-wide transaction groups.

Definition in file txg.c.


Function Documentation

SYSCTL_DECL ( _vfs_zfs  )
SYSCTL_INT ( _vfs_zfs_txg  ,
OID_AUTO  ,
timeout  ,
CTLFLAG_RW  ,
zfs_txg_timeout,
,
"Maximum seconds worth of delta per txg"   
)
SYSCTL_NODE ( _vfs_zfs  ,
OID_AUTO  ,
txg  ,
CTLFLAG_RW  ,
,
"ZFS TXG"   
)
TUNABLE_INT ( "vfs.zfs.txg.timeout"  ,
zfs_txg_timeout 
)
void txg_delay ( dsl_pool_t dp,
uint64_t  txg,
int  ticks 
)

Delay this thread by 'ticks' if we are still in the open transaction group and there is already a waiting txg quiesing or quiesced.

Delay the caller by the specified number of ticks or until the txg closes (whichever comes first).

Abort the delay if this txg stalls or enters the quiesing state.

Definition at line 509 of file txg.c.

static void txg_dispatch_callbacks ( dsl_pool_t dp,
uint64_t  txg 
) [static]

Dispatch the commit callbacks registered on this txg.

If no callbacks are registered for a given TXG, nothing happens. This function creates a taskq for the associated pool, if needed.

Definition at line 343 of file txg.c.

static void txg_do_callbacks ( void *  arg) [static]

Definition at line 325 of file txg.c.

void txg_fini ( dsl_pool_t dp)

Closes down the txg subsystem.

Definition at line 96 of file txg.c.

uint64_t txg_hold_open ( dsl_pool_t dp,
txg_handle_t th 
)

Definition at line 231 of file txg.c.

void txg_init ( dsl_pool_t dp,
uint64_t  txg 
)

Prepares the txg subsystem.

Definition at line 60 of file txg.c.

int txg_list_add ( txg_list_t tl,
void *  p,
uint64_t  txg 
)

Add an entry to the list.

Returns:
0 if it's a new entry, 1 if it's already there.

Definition at line 631 of file txg.c.

int txg_list_add_tail ( txg_list_t tl,
void *  p,
uint64_t  txg 
)

Add an entry to the end of the list (walks list to find end).

Returns:
0 if it's a new entry, 1 if it's already there.

Definition at line 655 of file txg.c.

void txg_list_create ( txg_list_t tl,
size_t  offset 
)

Per-txg object lists.

Definition at line 596 of file txg.c.

void txg_list_destroy ( txg_list_t tl)

Definition at line 609 of file txg.c.

boolean_t txg_list_empty ( txg_list_t tl,
uint64_t  txg 
)

Definition at line 620 of file txg.c.

void* txg_list_head ( txg_list_t tl,
uint64_t  txg 
)

Walk a txg list - only safe if you know it's not changing.

Definition at line 739 of file txg.c.

int txg_list_member ( txg_list_t tl,
void *  p,
uint64_t  txg 
)

Definition at line 727 of file txg.c.

void* txg_list_next ( txg_list_t tl,
void *  p,
uint64_t  txg 
)

Definition at line 748 of file txg.c.

void* txg_list_remove ( txg_list_t tl,
uint64_t  txg 
)

Remove the head of the list and return it.

Definition at line 682 of file txg.c.

void* txg_list_remove_this ( txg_list_t tl,
void *  p,
uint64_t  txg 
)

Remove a specific item from the list and return it.

Definition at line 704 of file txg.c.

static void txg_quiesce ( dsl_pool_t dp,
uint64_t  txg 
) [static]

Blocks until all transactions in the group are released.

On exit, the transaction group has reached a stable state in which it can then be passed off to the syncing context.

Definition at line 289 of file txg.c.

static void txg_quiesce_thread ( void *  arg) [static]

Definition at line 459 of file txg.c.

void txg_register_callbacks ( txg_handle_t th,
list_t *  tx_callbacks 
)

Definition at line 257 of file txg.c.

void txg_rele_to_quiesce ( txg_handle_t th)

Definition at line 249 of file txg.c.

void txg_rele_to_sync ( txg_handle_t th)

Definition at line 268 of file txg.c.

boolean_t txg_stalled ( struct dsl_pool dp)

Are we waiting for the syncing transaction to complete?

Return values:
TRUEWe are "backed up" waiting for the syncing transaction to complete
FALSEOtherwise

Definition at line 577 of file txg.c.

void txg_sync_start ( dsl_pool_t dp)

Starts syncing transaction groups.

Definition at line 133 of file txg.c.

void txg_sync_stop ( dsl_pool_t dp)

Stops syncing transaction groups.

Definition at line 194 of file txg.c.

static void txg_sync_thread ( void *  arg) [static]

Definition at line 382 of file txg.c.

boolean_t txg_sync_waiting ( struct dsl_pool dp)
Returns:
TRUE if someone is waiting for the next txg to sync

Definition at line 584 of file txg.c.

static void txg_thread_enter ( tx_state_t tx,
callb_cpr_t *  cpr 
) [static]

Definition at line 160 of file txg.c.

static void txg_thread_exit ( tx_state_t tx,
callb_cpr_t *  cpr,
kthread_t **  tpp 
) [static]

Definition at line 167 of file txg.c.

static void txg_thread_wait ( tx_state_t tx,
callb_cpr_t *  cpr,
kcondvar_t *  cv,
uint64_t  time 
) [static]

Definition at line 178 of file txg.c.

void txg_wait_open ( struct dsl_pool dp,
uint64_t  txg 
)

Wait until the given transaction group, or one after it, is the open transaction group.

Try to make this happen as soon as possible (eg. kick off any necessary syncs immediately). If txg == 0, wait for the next open txg.

Definition at line 557 of file txg.c.

void txg_wait_synced ( struct dsl_pool dp,
uint64_t  txg 
)

Wait until the given transaction group has finished syncing.

Try to make this happen as soon as possible (eg. kick off any necessary syncs immediately). If txg==0, wait for the currently open txg to finish syncing.

Definition at line 534 of file txg.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines