usr/src/uts/common/fs/zfs/sys/txg.h
author ahrens
Mon, 09 Oct 2006 10:56:01 -0700
changeset 2885 c0259887ebbc
parent 789 b348f31ed315
child 6245 1a2a7cfb9f26
permissions -rw-r--r--
6460059 zfs destroy <snapshot> leaves behind kruft 6463788 'zfs recv -d' fails if some ancestors already exist 6464897 assertion failed: "BP_GET_COMPRESS(bp) == compress" zio.c, line:897 6472843 panic when write to zvol snapshot 6475506 panic in dmu_recvbackup due to NULL pointer dereference 6475942 need more assertions in dnode_destroy() 6477102 recvbackup ioctl does not advance file offset 6477103 read-only properties should be passed as nvlist 6477900 want more /etc/system tunables for ZFS performance analysis 6479497 ::abuf_find is broken
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     1
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     2
 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     3
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     5
 * Common Development and Distribution License, Version 1.0 only
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     6
 * (the "License").  You may not use this file except in compliance
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     7
 * with the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     8
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     9
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    10
 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    11
 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    12
 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    13
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    14
 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    15
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    16
 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    17
 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    18
 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    19
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    20
 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    21
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    22
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    23
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
 * Use is subject to license terms.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    25
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    26
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
#ifndef _SYS_TXG_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
#define	_SYS_TXG_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
#pragma ident	"%Z%%M%	%I%	%E% SMI"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
#include <sys/spa.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
#include <sys/zfs_context.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    35
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
extern "C" {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    37
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
#define	TXG_CONCURRENT_STATES	3	/* open, quiescing, syncing	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
#define	TXG_SIZE		4		/* next power of 2	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
#define	TXG_MASK		(TXG_SIZE - 1)	/* mask for size	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
#define	TXG_INITIAL		TXG_SIZE	/* initial txg 		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
#define	TXG_IDX			(txg & TXG_MASK)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
#define	TXG_WAIT		1ULL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    46
#define	TXG_NOWAIT		2ULL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    47
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    48
typedef struct tx_cpu tx_cpu_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    49
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
typedef struct txg_handle {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    51
	tx_cpu_t	*th_cpu;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    52
	uint64_t	th_txg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    53
} txg_handle_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    54
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    55
typedef struct txg_node {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    56
	struct txg_node	*tn_next[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
	uint8_t		tn_member[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
} txg_node_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
typedef struct txg_list {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    61
	kmutex_t	tl_lock;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    62
	size_t		tl_offset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    63
	txg_node_t	*tl_head[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
} txg_list_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    65
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
struct dsl_pool;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    67
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
extern void txg_init(struct dsl_pool *dp, uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    69
extern void txg_fini(struct dsl_pool *dp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
extern void txg_sync_start(struct dsl_pool *dp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    71
extern void txg_sync_stop(struct dsl_pool *dp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
extern uint64_t txg_hold_open(struct dsl_pool *dp, txg_handle_t *txghp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    73
extern void txg_rele_to_quiesce(txg_handle_t *txghp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    74
extern void txg_rele_to_sync(txg_handle_t *txghp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    75
extern void txg_suspend(struct dsl_pool *dp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
extern void txg_resume(struct dsl_pool *dp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    78
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    79
 * Wait until the given transaction group has finished syncing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
 * Try to make this happen as soon as possible (eg. kick off any
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
 * necessary syncs immediately).  If txg==0, wait for the currently open
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    82
 * txg to finish syncing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    83
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    84
extern void txg_wait_synced(struct dsl_pool *dp, uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    85
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    86
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    87
 * Wait until the given transaction group, or one after it, is
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    88
 * the open transaction group.  Try to make this happen as soon
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    89
 * as possible (eg. kick off any necessary syncs immediately).
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    90
 * If txg == 0, wait for the next open txg.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    91
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    92
extern void txg_wait_open(struct dsl_pool *dp, uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    93
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    94
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    95
 * Returns TRUE if we are "backed up" waiting for the syncing
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    96
 * transaction to complete; otherwise returns FALSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    97
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    98
extern int txg_stalled(struct dsl_pool *dp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    99
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   100
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   101
 * Per-txg object lists.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   102
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   103
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   104
#define	TXG_CLEAN(txg)	((txg) - 1)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   105
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   106
extern void txg_list_create(txg_list_t *tl, size_t offset);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   107
extern void txg_list_destroy(txg_list_t *tl);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   108
extern int txg_list_empty(txg_list_t *tl, uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   109
extern int txg_list_add(txg_list_t *tl, void *p, uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   110
extern void *txg_list_remove(txg_list_t *tl, uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   111
extern void *txg_list_remove_this(txg_list_t *tl, void *p, uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   112
extern int txg_list_member(txg_list_t *tl, void *p, uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   113
extern void *txg_list_head(txg_list_t *tl, uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   114
extern void *txg_list_next(txg_list_t *tl, void *p, uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   115
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   116
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   117
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   118
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   119
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   120
#endif	/* _SYS_TXG_H */