usr/src/uts/common/fs/zfs/sys/zil_impl.h
author Mark J Musante <Mark.Musante@Sun.COM>
Mon, 03 May 2010 09:07:08 -0600
changeset 12294 2a74b443e6b1
parent 11670 1d964fb5d948
child 12699 36aebb51164a
permissions -rw-r--r--
PSARC/2010/108 zil synchronicity 6280630 zil synchronicity Contributed by Robert Milkowski <[email protected]>
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
1807
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1141
diff changeset
     5
 * Common Development and Distribution License (the "License").
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1141
diff changeset
     6
 * You may not use this file except in compliance with the License.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     7
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    11
 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    12
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    18
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    19
 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    20
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    21
/*
12294
2a74b443e6b1 PSARC/2010/108 zil synchronicity
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11670
diff changeset
    22
 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    23
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
12294
2a74b443e6b1 PSARC/2010/108 zil synchronicity
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11670
diff changeset
    25
/* Portions Copyright 2010 Robert Milkowski */
2a74b443e6b1 PSARC/2010/108 zil synchronicity
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11670
diff changeset
    26
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
#ifndef	_SYS_ZIL_IMPL_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
#define	_SYS_ZIL_IMPL_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
#include <sys/zil.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
#include <sys/dmu_objset.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
extern "C" {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    35
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    37
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
 * Log write buffer.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
typedef struct lwb {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
	zilog_t		*lwb_zilog;	/* back pointer to log struct */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
	blkptr_t	lwb_blk;	/* on disk address of this log blk */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
	int		lwb_nused;	/* # used bytes in buffer */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
	int		lwb_sz;		/* size of block and buffer */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
	char		*lwb_buf;	/* log write buffer */
2237
45affe88ed99 6416482 filebench oltp workload hangs in zfs
maybee
parents: 1807
diff changeset
    46
	zio_t		*lwb_zio;	/* zio for this buffer */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
    47
	dmu_tx_t	*lwb_tx;	/* tx for log block allocation */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    48
	uint64_t	lwb_max_txg;	/* highest txg in this lwb */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    49
	list_node_t	lwb_node;	/* zilog->zl_lwb_list linkage */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
} lwb_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    51
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    52
/*
5688
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 3063
diff changeset
    53
 * Vdev flushing: during a zil_commit(), we build up an AVL tree of the vdevs
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 3063
diff changeset
    54
 * we've touched so we know which ones need a write cache flush at the end.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    55
 */
5688
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 3063
diff changeset
    56
typedef struct zil_vdev_node {
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 3063
diff changeset
    57
	uint64_t	zv_vdev;	/* vdev to be flushed */
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 3063
diff changeset
    58
	avl_node_t	zv_node;	/* AVL tree linkage */
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 3063
diff changeset
    59
} zil_vdev_node_t;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
11670
1d964fb5d948 6595532 ZIL is too talkative
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 10922
diff changeset
    61
#define	ZIL_PREV_BLKS 16
1d964fb5d948 6595532 ZIL is too talkative
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 10922
diff changeset
    62
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    63
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
 * Stable storage intent log management structure.  One per dataset.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    65
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
struct zilog {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    67
	kmutex_t	zl_lock;	/* protects most zilog_t fields */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
	struct dsl_pool	*zl_dmu_pool;	/* DSL pool */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    69
	spa_t		*zl_spa;	/* handle for read/write log */
1807
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1141
diff changeset
    70
	const zil_header_t *zl_header;	/* log header buffer */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    71
	objset_t	*zl_os;		/* object set we're logging */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
	zil_get_data_t	*zl_get_data;	/* callback to get object content */
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
    73
	zio_t		*zl_root_zio;	/* log writer root zio */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
    74
	uint64_t	zl_itx_seq;	/* next in-core itx sequence number */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
    75
	uint64_t	zl_lr_seq;	/* on-disk log record sequence number */
3063
b252896b372b 6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents: 2638
diff changeset
    76
	uint64_t	zl_commit_seq;	/* committed upto this number */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
    77
	uint64_t	zl_commit_lr_seq; /* last committed on-disk lr seq */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    78
	uint64_t	zl_destroy_txg;	/* txg of last zil_destroy() */
8227
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 5688
diff changeset
    79
	uint64_t	zl_replayed_seq[TXG_SIZE]; /* last replayed rec seq */
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 5688
diff changeset
    80
	uint64_t	zl_replaying_seq; /* current replay seq number */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
	uint32_t	zl_suspend;	/* log suspend count */
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
    82
	kcondvar_t	zl_cv_writer;	/* log writer thread completion */
1807
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1141
diff changeset
    83
	kcondvar_t	zl_cv_suspend;	/* log suspend completion */
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1141
diff changeset
    84
	uint8_t		zl_suspending;	/* log is currently suspending */
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1141
diff changeset
    85
	uint8_t		zl_keep_first;	/* keep first log block in destroy */
8227
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 5688
diff changeset
    86
	uint8_t		zl_replay;	/* replaying records while set */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    87
	uint8_t		zl_stop_sync;	/* for debugging */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    88
	uint8_t		zl_writer;	/* boolean: write setup in progress */
10310
ba87b3315737 PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 9401
diff changeset
    89
	uint8_t		zl_logbias;	/* latency or throughput */
12294
2a74b443e6b1 PSARC/2010/108 zil synchronicity
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11670
diff changeset
    90
	uint8_t		zl_sync;	/* synchronous or asynchronous */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
    91
	int		zl_parse_error;	/* last zil_parse() error */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
    92
	uint64_t	zl_parse_blk_seq; /* highest blk seq on last parse */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
    93
	uint64_t	zl_parse_lr_seq; /* highest lr seq on last parse */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
    94
	uint64_t	zl_parse_blk_count; /* number of blocks parsed */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
    95
	uint64_t	zl_parse_lr_count; /* number of log records parsed */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    96
	list_t		zl_itx_list;	/* in-memory itx list */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    97
	uint64_t	zl_itx_list_sz;	/* total size of records on list */
1141
ca4bb9237a10 6354547 sticky log buf size
perrin
parents: 789
diff changeset
    98
	uint64_t	zl_cur_used;	/* current commit log size used */
ca4bb9237a10 6354547 sticky log buf size
perrin
parents: 789
diff changeset
    99
	uint64_t	zl_prev_used;	/* previous commit log size used */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   100
	list_t		zl_lwb_list;	/* in-flight log write list */
5688
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 3063
diff changeset
   101
	kmutex_t	zl_vdev_lock;	/* protects zl_vdev_tree */
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 3063
diff changeset
   102
	avl_tree_t	zl_vdev_tree;	/* vdevs to flush in zil_commit() */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   103
	taskq_t		*zl_clean_taskq; /* runs lwb and itx clean tasks */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
   104
	avl_tree_t	zl_bp_tree;	/* track bps during log parse */
3063
b252896b372b 6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents: 2638
diff changeset
   105
	clock_t		zl_replay_time;	/* lbolt of when replay started */
b252896b372b 6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents: 2638
diff changeset
   106
	uint64_t	zl_replay_blks;	/* number of log blocks replayed */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
   107
	zil_header_t	zl_old_header;	/* debugging aid */
11670
1d964fb5d948 6595532 ZIL is too talkative
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 10922
diff changeset
   108
	uint_t		zl_prev_blks[ZIL_PREV_BLKS]; /* size - sector rounded */
1d964fb5d948 6595532 ZIL is too talkative
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 10922
diff changeset
   109
	uint_t		zl_prev_rotor;	/* rotor for zl_prev[] */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   110
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   111
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
   112
typedef struct zil_bp_node {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   113
	dva_t		zn_dva;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   114
	avl_node_t	zn_node;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10310
diff changeset
   115
} zil_bp_node_t;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   116
11670
1d964fb5d948 6595532 ZIL is too talkative
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 10922
diff changeset
   117
#define	ZIL_MAX_LOG_DATA (SPA_MAXBLOCKSIZE - sizeof (zil_chain_t) - \
9401
afae664f76f6 6773224 zvol_log_write() is inefficient
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 8227
diff changeset
   118
    sizeof (lr_write_t))
afae664f76f6 6773224 zvol_log_write() is inefficient
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 8227
diff changeset
   119
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   120
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   121
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   122
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   123
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   124
#endif	/* _SYS_ZIL_IMPL_H */