usr/src/uts/common/fs/zfs/sys/spa.h
author Matthew Ahrens <mahrens@delphix.com>
Sat, 30 Jun 2012 13:00:47 -0700
changeset 13743 95aba6e49b9f
parent 13700 2889e2596bd6
child 13869 921a99998bb4
permissions -rw-r--r--
2882 implement libzfs_core 2883 changing "canmount" property to "on" should not always remount dataset 2900 "zfs snapshot" should be able to create multiple, arbitrary snapshots at once Reviewed by: George Wilson <[email protected]> Reviewed by: Chris Siden <[email protected]> Reviewed by: Garrett D'Amore <[email protected]> Reviewed by: Bill Pijewski <[email protected]> Reviewed by: Dan Kruchinin <[email protected]> Approved by: Eric Schrock <[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
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
     5
 * Common Development and Distribution License (the "License").
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
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
/*
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
    22
 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13514
diff changeset
    23
 * Copyright (c) 2012 by Delphix. All rights reserved.
13514
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13379
diff changeset
    24
 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
789
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_SPA_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
#define	_SYS_SPA_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
#include <sys/avl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
#include <sys/zfs_context.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
#include <sys/nvpair.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
#include <sys/sysmacros.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
#include <sys/types.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    35
#include <sys/fs/zfs.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    37
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
extern "C" {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
 * Forward references that lots of things need.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
typedef struct spa spa_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
typedef struct vdev vdev_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    46
typedef struct metaslab metaslab_t;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
    47
typedef struct metaslab_group metaslab_group_t;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
    48
typedef struct metaslab_class metaslab_class_t;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
    49
typedef struct zio zio_t;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
typedef struct zilog zilog_t;
5450
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5363
diff changeset
    51
typedef struct spa_aux_vdev spa_aux_vdev_t;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
    52
typedef struct ddt ddt_t;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
    53
typedef struct ddt_entry ddt_entry_t;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    54
struct dsl_pool;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
    55
struct dsl_dataset;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    56
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
 * General-purpose 32-bit and 64-bit bitfield encodings.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
#define	BF32_DECODE(x, low, len)	P2PHASE((x) >> (low), 1U << (len))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    61
#define	BF64_DECODE(x, low, len)	P2PHASE((x) >> (low), 1ULL << (len))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    62
#define	BF32_ENCODE(x, low, len)	(P2PHASE((x), 1U << (len)) << (low))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    63
#define	BF64_ENCODE(x, low, len)	(P2PHASE((x), 1ULL << (len)) << (low))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    65
#define	BF32_GET(x, low, len)		BF32_DECODE(x, low, len)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
#define	BF64_GET(x, low, len)		BF64_DECODE(x, low, len)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    67
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
#define	BF32_SET(x, low, len, val)	\
2856
6f4d5ee1906a 6463348 ZFS code could be more portable
nd150628
parents: 2676
diff changeset
    69
	((x) ^= BF32_ENCODE((x >> low) ^ (val), low, len))
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
#define	BF64_SET(x, low, len, val)	\
2856
6f4d5ee1906a 6463348 ZFS code could be more portable
nd150628
parents: 2676
diff changeset
    71
	((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len))
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    73
#define	BF32_GET_SB(x, low, len, shift, bias)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    74
	((BF32_GET(x, low, len) + (bias)) << (shift))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    75
#define	BF64_GET_SB(x, low, len, shift, bias)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
	((BF64_GET(x, low, len) + (bias)) << (shift))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    78
#define	BF32_SET_SB(x, low, len, shift, bias, val)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    79
	BF32_SET(x, low, len, ((val) >> (shift)) - (bias))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
#define	BF64_SET_SB(x, low, len, shift, bias, val)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
	BF64_SET(x, low, len, ((val) >> (shift)) - (bias))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    82
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    83
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    84
 * We currently support nine block sizes, from 512 bytes to 128K.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    85
 * We could go higher, but the benefits are near-zero and the cost
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    86
 * of COWing a giant block to modify one byte would become excessive.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    87
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    88
#define	SPA_MINBLOCKSHIFT	9
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    89
#define	SPA_MAXBLOCKSHIFT	17
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    90
#define	SPA_MINBLOCKSIZE	(1ULL << SPA_MINBLOCKSHIFT)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    91
#define	SPA_MAXBLOCKSIZE	(1ULL << SPA_MAXBLOCKSHIFT)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    92
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    93
#define	SPA_BLOCKSIZES		(SPA_MAXBLOCKSHIFT - SPA_MINBLOCKSHIFT + 1)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    94
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    95
/*
7497
f6c6be3b6154 6733970 assertion failure in dbuf_dirty() via spa_sync_nvlist()
Tim Haley <Tim.Haley@Sun.COM>
parents: 7214
diff changeset
    96
 * Size of block to hold the configuration data (a packed nvlist)
f6c6be3b6154 6733970 assertion failure in dbuf_dirty() via spa_sync_nvlist()
Tim Haley <Tim.Haley@Sun.COM>
parents: 7214
diff changeset
    97
 */
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13514
diff changeset
    98
#define	SPA_CONFIG_BLOCKSIZE	(1ULL << 14)
7497
f6c6be3b6154 6733970 assertion failure in dbuf_dirty() via spa_sync_nvlist()
Tim Haley <Tim.Haley@Sun.COM>
parents: 7214
diff changeset
    99
f6c6be3b6154 6733970 assertion failure in dbuf_dirty() via spa_sync_nvlist()
Tim Haley <Tim.Haley@Sun.COM>
parents: 7214
diff changeset
   100
/*
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   101
 * The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   102
 * The ASIZE encoding should be at least 64 times larger (6 more bits)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   103
 * to support up to 4-way RAID-Z mirror mode with worst-case gang block
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   104
 * overhead, three DVAs per bp, plus one more bit in case we do anything
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   105
 * else that expands the ASIZE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   106
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   107
#define	SPA_LSIZEBITS		16	/* LSIZE up to 32M (2^16 * 512)	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   108
#define	SPA_PSIZEBITS		16	/* PSIZE up to 32M (2^16 * 512)	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   109
#define	SPA_ASIZEBITS		24	/* ASIZE up to 64 times larger	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   110
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   111
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   112
 * All SPA data is represented by 128-bit data virtual addresses (DVAs).
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   113
 * The members of the dva_t should be considered opaque outside the SPA.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   114
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   115
typedef struct dva {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   116
	uint64_t	dva_word[2];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   117
} dva_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   118
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   119
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   120
 * Each block has a 256-bit checksum -- strong enough for cryptographic hashes.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   121
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   122
typedef struct zio_cksum {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   123
	uint64_t	zc_word[4];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   124
} zio_cksum_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   125
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   126
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   127
 * Each block is described by its DVAs, time of birth, checksum, etc.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   128
 * The word-by-word, bit-by-bit layout of the blkptr is as follows:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   129
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   130
 *	64	56	48	40	32	24	16	8	0
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   131
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   132
 * 0	|		vdev1		| GRID  |	  ASIZE		|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   133
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   134
 * 1	|G|			 offset1				|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   135
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   136
 * 2	|		vdev2		| GRID  |	  ASIZE		|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   137
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   138
 * 3	|G|			 offset2				|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   139
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   140
 * 4	|		vdev3		| GRID  |	  ASIZE		|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   141
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   142
 * 5	|G|			 offset3				|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   143
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   144
 * 6	|BDX|lvl| type	| cksum | comp	|     PSIZE	|     LSIZE	|
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   145
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   146
 * 7	|			padding					|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   147
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   148
 * 8	|			padding					|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   149
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   150
 * 9	|			physical birth txg			|
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   151
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   152
 * a	|			logical birth txg			|
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   153
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   154
 * b	|			fill count				|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   155
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   156
 * c	|			checksum[0]				|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   157
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   158
 * d	|			checksum[1]				|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   159
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   160
 * e	|			checksum[2]				|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   161
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   162
 * f	|			checksum[3]				|
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   163
 *	+-------+-------+-------+-------+-------+-------+-------+-------+
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   164
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   165
 * Legend:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   166
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   167
 * vdev		virtual device ID
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   168
 * offset	offset into virtual device
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   169
 * LSIZE	logical size
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   170
 * PSIZE	physical size (after compression)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   171
 * ASIZE	allocated size (including RAID-Z parity and gang block headers)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   172
 * GRID		RAID-Z layout information (reserved for future use)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   173
 * cksum	checksum function
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   174
 * comp		compression function
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   175
 * G		gang block indicator
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   176
 * B		byteorder (endianness)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   177
 * D		dedup
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   178
 * X		unused
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   179
 * lvl		level of indirection
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   180
 * type		DMU object type
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   181
 * phys birth	txg of block allocation; zero if same as logical birth txg
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   182
 * log. birth	transaction group in which the block was logically born
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   183
 * fill count	number of non-zero blocks under this bp
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   184
 * checksum[4]	256-bit checksum of the data this bp describes
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   185
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   186
#define	SPA_BLKPTRSHIFT	7		/* blkptr_t is 128 bytes	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   187
#define	SPA_DVAS_PER_BP	3		/* Number of DVAs in a bp	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   188
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   189
typedef struct blkptr {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   190
	dva_t		blk_dva[SPA_DVAS_PER_BP]; /* Data Virtual Addresses */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   191
	uint64_t	blk_prop;	/* size, compression, type, etc	    */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   192
	uint64_t	blk_pad[2];	/* Extra space for the future	    */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   193
	uint64_t	blk_phys_birth;	/* txg when block was allocated	    */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   194
	uint64_t	blk_birth;	/* transaction group at birth	    */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   195
	uint64_t	blk_fill;	/* fill count			    */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   196
	zio_cksum_t	blk_cksum;	/* 256-bit checksum		    */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   197
} blkptr_t;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   198
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   199
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   200
 * Macros to get and set fields in a bp or DVA.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   201
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   202
#define	DVA_GET_ASIZE(dva)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   203
	BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   204
#define	DVA_SET_ASIZE(dva, x)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   205
	BF64_SET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0, x)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   206
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   207
#define	DVA_GET_GRID(dva)	BF64_GET((dva)->dva_word[0], 24, 8)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   208
#define	DVA_SET_GRID(dva, x)	BF64_SET((dva)->dva_word[0], 24, 8, x)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   209
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   210
#define	DVA_GET_VDEV(dva)	BF64_GET((dva)->dva_word[0], 32, 32)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   211
#define	DVA_SET_VDEV(dva, x)	BF64_SET((dva)->dva_word[0], 32, 32, x)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   212
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   213
#define	DVA_GET_OFFSET(dva)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   214
	BF64_GET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   215
#define	DVA_SET_OFFSET(dva, x)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   216
	BF64_SET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0, x)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   217
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   218
#define	DVA_GET_GANG(dva)	BF64_GET((dva)->dva_word[1], 63, 1)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   219
#define	DVA_SET_GANG(dva, x)	BF64_SET((dva)->dva_word[1], 63, 1, x)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   220
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   221
#define	BP_GET_LSIZE(bp)	\
10800
469478b180d9 6880764 fsync on zfs is broken if writes are greater than 32kb on a hard crash and no log attached
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 10685
diff changeset
   222
	BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   223
#define	BP_SET_LSIZE(bp, x)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   224
	BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   225
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   226
#define	BP_GET_PSIZE(bp)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   227
	BF64_GET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   228
#define	BP_SET_PSIZE(bp, x)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   229
	BF64_SET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1, x)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   230
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   231
#define	BP_GET_COMPRESS(bp)		BF64_GET((bp)->blk_prop, 32, 8)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   232
#define	BP_SET_COMPRESS(bp, x)		BF64_SET((bp)->blk_prop, 32, 8, x)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   233
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   234
#define	BP_GET_CHECKSUM(bp)		BF64_GET((bp)->blk_prop, 40, 8)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   235
#define	BP_SET_CHECKSUM(bp, x)		BF64_SET((bp)->blk_prop, 40, 8, x)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   236
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   237
#define	BP_GET_TYPE(bp)			BF64_GET((bp)->blk_prop, 48, 8)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   238
#define	BP_SET_TYPE(bp, x)		BF64_SET((bp)->blk_prop, 48, 8, x)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   239
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   240
#define	BP_GET_LEVEL(bp)		BF64_GET((bp)->blk_prop, 56, 5)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   241
#define	BP_SET_LEVEL(bp, x)		BF64_SET((bp)->blk_prop, 56, 5, x)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   242
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   243
#define	BP_GET_PROP_BIT_61(bp)		BF64_GET((bp)->blk_prop, 61, 1)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   244
#define	BP_SET_PROP_BIT_61(bp, x)	BF64_SET((bp)->blk_prop, 61, 1, x)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   245
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   246
#define	BP_GET_DEDUP(bp)		BF64_GET((bp)->blk_prop, 62, 1)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   247
#define	BP_SET_DEDUP(bp, x)		BF64_SET((bp)->blk_prop, 62, 1, x)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   248
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   249
#define	BP_GET_BYTEORDER(bp)		(0 - BF64_GET((bp)->blk_prop, 63, 1))
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   250
#define	BP_SET_BYTEORDER(bp, x)		BF64_SET((bp)->blk_prop, 63, 1, x)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   251
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   252
#define	BP_PHYSICAL_BIRTH(bp)		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   253
	((bp)->blk_phys_birth ? (bp)->blk_phys_birth : (bp)->blk_birth)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   254
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   255
#define	BP_SET_BIRTH(bp, logical, physical)	\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   256
{						\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   257
	(bp)->blk_birth = (logical);		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   258
	(bp)->blk_phys_birth = ((logical) == (physical) ? 0 : (physical)); \
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   259
}
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   260
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   261
#define	BP_GET_ASIZE(bp)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   262
	(DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1807
diff changeset
   263
		DVA_GET_ASIZE(&(bp)->blk_dva[2]))
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1807
diff changeset
   264
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1807
diff changeset
   265
#define	BP_GET_UCSIZE(bp) \
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13514
diff changeset
   266
	((BP_GET_LEVEL(bp) > 0 || DMU_OT_IS_METADATA(BP_GET_TYPE(bp))) ? \
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   267
	BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp))
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   268
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   269
#define	BP_GET_NDVAS(bp)	\
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   270
	(!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   271
	!!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   272
	!!DVA_GET_ASIZE(&(bp)->blk_dva[2]))
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   273
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   274
#define	BP_COUNT_GANG(bp)	\
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   275
	(DVA_GET_GANG(&(bp)->blk_dva[0]) + \
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   276
	DVA_GET_GANG(&(bp)->blk_dva[1]) + \
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   277
	DVA_GET_GANG(&(bp)->blk_dva[2]))
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   278
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   279
#define	DVA_EQUAL(dva1, dva2)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   280
	((dva1)->dva_word[1] == (dva2)->dva_word[1] && \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   281
	(dva1)->dva_word[0] == (dva2)->dva_word[0])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   282
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   283
#define	BP_EQUAL(bp1, bp2)	\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   284
	(BP_PHYSICAL_BIRTH(bp1) == BP_PHYSICAL_BIRTH(bp2) &&	\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   285
	DVA_EQUAL(&(bp1)->blk_dva[0], &(bp2)->blk_dva[0]) &&	\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   286
	DVA_EQUAL(&(bp1)->blk_dva[1], &(bp2)->blk_dva[1]) &&	\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   287
	DVA_EQUAL(&(bp1)->blk_dva[2], &(bp2)->blk_dva[2]))
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   288
3093
71525e4187d5 6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents: 2926
diff changeset
   289
#define	ZIO_CHECKSUM_EQUAL(zc1, zc2) \
71525e4187d5 6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents: 2926
diff changeset
   290
	(0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \
71525e4187d5 6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents: 2926
diff changeset
   291
	((zc1).zc_word[1] - (zc2).zc_word[1]) | \
71525e4187d5 6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents: 2926
diff changeset
   292
	((zc1).zc_word[2] - (zc2).zc_word[2]) | \
71525e4187d5 6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents: 2926
diff changeset
   293
	((zc1).zc_word[3] - (zc2).zc_word[3])))
71525e4187d5 6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents: 2926
diff changeset
   294
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   295
#define	DVA_IS_VALID(dva)	(DVA_GET_ASIZE(dva) != 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   296
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   297
#define	ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3)	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   298
{						\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   299
	(zcp)->zc_word[0] = w0;			\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   300
	(zcp)->zc_word[1] = w1;			\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   301
	(zcp)->zc_word[2] = w2;			\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   302
	(zcp)->zc_word[3] = w3;			\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   303
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   304
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   305
#define	BP_IDENTITY(bp)		(&(bp)->blk_dva[0])
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   306
#define	BP_IS_GANG(bp)		DVA_GET_GANG(BP_IDENTITY(bp))
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   307
#define	BP_IS_HOLE(bp)		((bp)->blk_birth == 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   308
11670
1d964fb5d948 6595532 ZIL is too talkative
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11422
diff changeset
   309
/* BP_IS_RAIDZ(bp) assumes no block compression */
1d964fb5d948 6595532 ZIL is too talkative
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11422
diff changeset
   310
#define	BP_IS_RAIDZ(bp)		(DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \
1d964fb5d948 6595532 ZIL is too talkative
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11422
diff changeset
   311
				BP_GET_PSIZE(bp))
1d964fb5d948 6595532 ZIL is too talkative
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11422
diff changeset
   312
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   313
#define	BP_ZERO(bp)				\
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   314
{						\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   315
	(bp)->blk_dva[0].dva_word[0] = 0;	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   316
	(bp)->blk_dva[0].dva_word[1] = 0;	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   317
	(bp)->blk_dva[1].dva_word[0] = 0;	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   318
	(bp)->blk_dva[1].dva_word[1] = 0;	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   319
	(bp)->blk_dva[2].dva_word[0] = 0;	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   320
	(bp)->blk_dva[2].dva_word[1] = 0;	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   321
	(bp)->blk_prop = 0;			\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   322
	(bp)->blk_pad[0] = 0;			\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   323
	(bp)->blk_pad[1] = 0;			\
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   324
	(bp)->blk_phys_birth = 0;		\
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   325
	(bp)->blk_birth = 0;			\
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   326
	(bp)->blk_fill = 0;			\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   327
	ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0);	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   328
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   329
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   330
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   331
 * Note: the byteorder is either 0 or -1, both of which are palindromes.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   332
 * This simplifies the endianness handling a bit.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   333
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   334
#ifdef _BIG_ENDIAN
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   335
#define	ZFS_HOST_BYTEORDER	(0ULL)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   336
#else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   337
#define	ZFS_HOST_BYTEORDER	(-1ULL)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   338
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   339
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   340
#define	BP_SHOULD_BYTESWAP(bp)	(BP_GET_BYTEORDER(bp) != ZFS_HOST_BYTEORDER)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   341
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   342
#define	BP_SPRINTF_LEN	320
896
f5270e6bd04d 6348089 panic in dbuf_remove_ref
maybee
parents: 789
diff changeset
   343
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   344
/*
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   345
 * This macro allows code sharing between zfs, libzpool, and mdb.
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   346
 * 'func' is either snprintf() or mdb_snprintf().
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   347
 * 'ws' (whitespace) can be ' ' for single-line format, '\n' for multi-line.
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   348
 */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   349
#define	SPRINTF_BLKPTR(func, ws, buf, bp, type, checksum, compress)	\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   350
{									\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   351
	static const char *copyname[] =					\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   352
	    { "zero", "single", "double", "triple" };			\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   353
	int size = BP_SPRINTF_LEN;					\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   354
	int len = 0;							\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   355
	int copies = 0;							\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   356
									\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   357
	if (bp == NULL) {						\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   358
		len = func(buf + len, size - len, "<NULL>");		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   359
	} else if (BP_IS_HOLE(bp)) {					\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   360
		len = func(buf + len, size - len, "<hole>");		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   361
	} else {							\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   362
		for (int d = 0; d < BP_GET_NDVAS(bp); d++) {		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   363
			const dva_t *dva = &bp->blk_dva[d];		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   364
			if (DVA_IS_VALID(dva))				\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   365
				copies++;				\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   366
			len += func(buf + len, size - len,		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   367
			    "DVA[%d]=<%llu:%llx:%llx>%c", d,		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   368
			    (u_longlong_t)DVA_GET_VDEV(dva),		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   369
			    (u_longlong_t)DVA_GET_OFFSET(dva),		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   370
			    (u_longlong_t)DVA_GET_ASIZE(dva),		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   371
			    ws);					\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   372
		}							\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   373
		if (BP_IS_GANG(bp) &&					\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   374
		    DVA_GET_ASIZE(&bp->blk_dva[2]) <=			\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   375
		    DVA_GET_ASIZE(&bp->blk_dva[1]) / 2)			\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   376
			copies--;					\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   377
		len += func(buf + len, size - len,			\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   378
		    "[L%llu %s] %s %s %s %s %s %s%c"			\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   379
		    "size=%llxL/%llxP birth=%lluL/%lluP fill=%llu%c"	\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   380
		    "cksum=%llx:%llx:%llx:%llx",			\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   381
		    (u_longlong_t)BP_GET_LEVEL(bp),			\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   382
		    type,						\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   383
		    checksum,						\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   384
		    compress,						\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   385
		    BP_GET_BYTEORDER(bp) == 0 ? "BE" : "LE",		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   386
		    BP_IS_GANG(bp) ? "gang" : "contiguous",		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   387
		    BP_GET_DEDUP(bp) ? "dedup" : "unique",		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   388
		    copyname[copies],					\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   389
		    ws,							\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   390
		    (u_longlong_t)BP_GET_LSIZE(bp),			\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   391
		    (u_longlong_t)BP_GET_PSIZE(bp),			\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   392
		    (u_longlong_t)bp->blk_birth,			\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   393
		    (u_longlong_t)BP_PHYSICAL_BIRTH(bp),		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   394
		    (u_longlong_t)bp->blk_fill,				\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   395
		    ws,							\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   396
		    (u_longlong_t)bp->blk_cksum.zc_word[0],		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   397
		    (u_longlong_t)bp->blk_cksum.zc_word[1],		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   398
		    (u_longlong_t)bp->blk_cksum.zc_word[2],		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   399
		    (u_longlong_t)bp->blk_cksum.zc_word[3]);		\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   400
	}								\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   401
	ASSERT(len < size);						\
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   402
}
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   403
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   404
#include <sys/dmu.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   405
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 3093
diff changeset
   406
#define	BP_GET_BUFC_TYPE(bp)						\
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13514
diff changeset
   407
	(((BP_GET_LEVEL(bp) > 0) || (DMU_OT_IS_METADATA(BP_GET_TYPE(bp)))) ? \
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13514
diff changeset
   408
	ARC_BUFC_METADATA : ARC_BUFC_DATA)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   409
11422
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
   410
typedef enum spa_import_type {
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
   411
	SPA_IMPORT_EXISTING,
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
   412
	SPA_IMPORT_ASSEMBLE
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
   413
} spa_import_type_t;
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
   414
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   415
/* state manipulation functions */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   416
extern int spa_open(const char *pool, spa_t **, void *tag);
10921
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
   417
extern int spa_open_rewind(const char *pool, spa_t **, void *tag,
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
   418
    nvlist_t *policy, nvlist_t **config);
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13514
diff changeset
   419
extern int spa_get_stats(const char *pool, nvlist_t **config, char *altroot,
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13514
diff changeset
   420
    size_t buflen);
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4715
diff changeset
   421
extern int spa_create(const char *pool, nvlist_t *config, nvlist_t *props,
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
   422
    nvlist_t *zplprops);
7147
1e1d75c88283 6704717 ZFS mirrored root doesn't live up to expectations
taylor
parents: 7046
diff changeset
   423
extern int spa_import_rootpool(char *devpath, char *devid);
12961
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12470
diff changeset
   424
extern int spa_import(const char *pool, nvlist_t *config, nvlist_t *props,
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12470
diff changeset
   425
    uint64_t flags);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   426
extern nvlist_t *spa_tryimport(nvlist_t *tryconfig);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   427
extern int spa_destroy(char *pool);
8211
32722be6ad3b 6775357 ZFS should have a way to export a pool without touching anything
George Wilson <George.Wilson@Sun.COM>
parents: 7837
diff changeset
   428
extern int spa_export(char *pool, nvlist_t **oldconfig, boolean_t force,
32722be6ad3b 6775357 ZFS should have a way to export a pool without touching anything
George Wilson <George.Wilson@Sun.COM>
parents: 7837
diff changeset
   429
    boolean_t hardforce);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   430
extern int spa_reset(char *pool);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   431
extern void spa_async_request(spa_t *spa, int flag);
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6987
diff changeset
   432
extern void spa_async_unrequest(spa_t *spa, int flag);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   433
extern void spa_async_suspend(spa_t *spa);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   434
extern void spa_async_resume(spa_t *spa);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   435
extern spa_t *spa_inject_addref(char *pool);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   436
extern void spa_inject_delref(spa_t *spa);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   437
extern void spa_scan_stat_init(spa_t *spa);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   438
extern int spa_scan_get_stats(spa_t *spa, pool_scan_stat_t *ps);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   439
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   440
#define	SPA_ASYNC_CONFIG_UPDATE	0x01
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   441
#define	SPA_ASYNC_REMOVE	0x02
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   442
#define	SPA_ASYNC_PROBE		0x04
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   443
#define	SPA_ASYNC_RESILVER_DONE	0x08
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   444
#define	SPA_ASYNC_RESILVER	0x10
9816
847676ec1c5b PSARC 2008/353 zpool autoexpand property
George Wilson <George.Wilson@Sun.COM>
parents: 9790
diff changeset
   445
#define	SPA_ASYNC_AUTOEXPAND	0x20
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   446
#define	SPA_ASYNC_REMOVE_DONE	0x40
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   447
#define	SPA_ASYNC_REMOVE_STOP	0x80
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   448
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   449
/*
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   450
 * Controls the behavior of spa_vdev_remove().
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   451
 */
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   452
#define	SPA_REMOVE_UNSPARE	0x01
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   453
#define	SPA_REMOVE_DONE		0x02
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   454
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   455
/* device manipulation */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   456
extern int spa_vdev_add(spa_t *spa, nvlist_t *nvroot);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   457
extern int spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   458
    int replacing);
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8211
diff changeset
   459
extern int spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid,
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8211
diff changeset
   460
    int replace_done);
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1807
diff changeset
   461
extern int spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   462
extern boolean_t spa_vdev_remove_active(spa_t *spa);
1354
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 896
diff changeset
   463
extern int spa_vdev_setpath(spa_t *spa, uint64_t guid, const char *newpath);
9425
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8525
diff changeset
   464
extern int spa_vdev_setfru(spa_t *spa, uint64_t guid, const char *newfru);
11422
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
   465
extern int spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
   466
    nvlist_t *props, boolean_t exp);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   467
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1807
diff changeset
   468
/* spare state (which is global across all pools) */
3377
a2fa338530c1 6393525 vdev_reopen() should verify that it's still the same device
eschrock
parents: 3290
diff changeset
   469
extern void spa_spare_add(vdev_t *vd);
a2fa338530c1 6393525 vdev_reopen() should verify that it's still the same device
eschrock
parents: 3290
diff changeset
   470
extern void spa_spare_remove(vdev_t *vd);
7214
04c540040a32 6721908 A hot spare "in use" in an exported zpool, is stolen when a disk fails in an imported pool.
lling
parents: 7184
diff changeset
   471
extern boolean_t spa_spare_exists(uint64_t guid, uint64_t *pool, int *refcnt);
3377
a2fa338530c1 6393525 vdev_reopen() should verify that it's still the same device
eschrock
parents: 3290
diff changeset
   472
extern void spa_spare_activate(vdev_t *vd);
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1807
diff changeset
   473
5450
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5363
diff changeset
   474
/* L2ARC state (which is global across all pools) */
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5363
diff changeset
   475
extern void spa_l2cache_add(vdev_t *vd);
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5363
diff changeset
   476
extern void spa_l2cache_remove(vdev_t *vd);
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5363
diff changeset
   477
extern boolean_t spa_l2cache_exists(uint64_t guid, uint64_t *pool);
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5363
diff changeset
   478
extern void spa_l2cache_activate(vdev_t *vd);
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5363
diff changeset
   479
extern void spa_l2cache_drop(spa_t *spa);
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5363
diff changeset
   480
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   481
/* scanning */
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   482
extern int spa_scan(spa_t *spa, pool_scan_func_t func);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   483
extern int spa_scan_stop(spa_t *spa);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   484
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   485
/* spa syncing */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   486
extern void spa_sync(spa_t *spa, uint64_t txg); /* only for DMU use */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   487
extern void spa_sync_allpools(void);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   488
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   489
/*
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   490
 * DEFERRED_FREE must be large enough that regular blocks are not
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   491
 * deferred.  XXX so can't we change it back to 1?
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   492
 */
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   493
#define	SYNC_PASS_DEFERRED_FREE	2	/* defer frees after this pass */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   494
#define	SYNC_PASS_DONT_COMPRESS	4	/* don't compress after this pass */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   495
#define	SYNC_PASS_REWRITE	1	/* rewrite new bps after this pass */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   496
6987
877c018eb06c 6628282 arc_stats.arcstat_l2_writes_sent.value.ui64) == (arc_stats.arcstat_l2_writes_done.value.ui64)
brendan
parents: 6673
diff changeset
   497
/* spa namespace global mutex */
877c018eb06c 6628282 arc_stats.arcstat_l2_writes_sent.value.ui64) == (arc_stats.arcstat_l2_writes_done.value.ui64)
brendan
parents: 6673
diff changeset
   498
extern kmutex_t spa_namespace_lock;
877c018eb06c 6628282 arc_stats.arcstat_l2_writes_sent.value.ui64) == (arc_stats.arcstat_l2_writes_done.value.ui64)
brendan
parents: 6673
diff changeset
   499
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   500
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   501
 * SPA configuration functions in spa_config.c
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   502
 */
1635
0ab1193d47cb 6398664 zpool detach: missing argument to error message causes core dump
bonwick
parents: 1544
diff changeset
   503
0ab1193d47cb 6398664 zpool detach: missing argument to error message causes core dump
bonwick
parents: 1544
diff changeset
   504
#define	SPA_CONFIG_UPDATE_POOL	0
0ab1193d47cb 6398664 zpool detach: missing argument to error message causes core dump
bonwick
parents: 1544
diff changeset
   505
#define	SPA_CONFIG_UPDATE_VDEVS	1
0ab1193d47cb 6398664 zpool detach: missing argument to error message causes core dump
bonwick
parents: 1544
diff changeset
   506
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
   507
extern void spa_config_sync(spa_t *, boolean_t, boolean_t);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   508
extern void spa_config_load(void);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   509
extern nvlist_t *spa_all_configs(uint64_t *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   510
extern void spa_config_set(spa_t *spa, nvlist_t *config);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   511
extern nvlist_t *spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   512
    int getstats);
1635
0ab1193d47cb 6398664 zpool detach: missing argument to error message causes core dump
bonwick
parents: 1544
diff changeset
   513
extern void spa_config_update(spa_t *spa, int what);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   514
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   515
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   516
 * Miscellaneous SPA routines in spa_misc.c
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   517
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   518
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   519
/* Namespace manipulation */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   520
extern spa_t *spa_lookup(const char *name);
10921
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
   521
extern spa_t *spa_add(const char *name, nvlist_t *config, const char *altroot);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   522
extern void spa_remove(spa_t *spa);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   523
extern spa_t *spa_next(spa_t *prev);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   524
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   525
/* Refcount functions */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   526
extern void spa_open_ref(spa_t *spa, void *tag);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   527
extern void spa_close(spa_t *spa, void *tag);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   528
extern boolean_t spa_refcount_zero(spa_t *spa);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   529
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
   530
#define	SCL_NONE	0x00
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   531
#define	SCL_CONFIG	0x01
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   532
#define	SCL_STATE	0x02
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   533
#define	SCL_L2ARC	0x04		/* hack until L2ARC 2.0 */
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   534
#define	SCL_ALLOC	0x08
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   535
#define	SCL_ZIO		0x10
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   536
#define	SCL_FREE	0x20
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   537
#define	SCL_VDEV	0x40
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   538
#define	SCL_LOCKS	7
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   539
#define	SCL_ALL		((1 << SCL_LOCKS) - 1)
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   540
#define	SCL_STATE_ALL	(SCL_STATE | SCL_L2ARC | SCL_ZIO)
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   541
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   542
/* Pool configuration locks */
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   543
extern int spa_config_tryenter(spa_t *spa, int locks, void *tag, krw_t rw);
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   544
extern void spa_config_enter(spa_t *spa, int locks, void *tag, krw_t rw);
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   545
extern void spa_config_exit(spa_t *spa, int locks, void *tag);
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   546
extern int spa_config_held(spa_t *spa, int locks, krw_t rw);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   547
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   548
/* Pool vdev add/remove lock */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   549
extern uint64_t spa_vdev_enter(spa_t *spa);
10594
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 10588
diff changeset
   550
extern uint64_t spa_vdev_config_enter(spa_t *spa);
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 10588
diff changeset
   551
extern void spa_vdev_config_exit(spa_t *spa, vdev_t *vd, uint64_t txg,
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 10588
diff changeset
   552
    int error, char *tag);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   553
extern int spa_vdev_exit(spa_t *spa, vdev_t *vd, uint64_t txg, int error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   554
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   555
/* Pool vdev state change lock */
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
   556
extern void spa_vdev_state_enter(spa_t *spa, int oplock);
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   557
extern int spa_vdev_state_exit(spa_t *spa, vdev_t *vd, int error);
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   558
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   559
/* Log state */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   560
typedef enum spa_log_state {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   561
	SPA_LOG_UNKNOWN = 0,	/* unknown log state */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   562
	SPA_LOG_MISSING,	/* missing log(s) */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   563
	SPA_LOG_CLEAR,		/* clear the log(s) */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   564
	SPA_LOG_GOOD,		/* log(s) are good */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   565
} spa_log_state_t;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   566
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   567
extern spa_log_state_t spa_get_log_state(spa_t *spa);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   568
extern void spa_set_log_state(spa_t *spa, spa_log_state_t state);
11422
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
   569
extern int spa_offline_log(spa_t *spa);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   570
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   571
/* Log claim callback */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   572
extern void spa_claim_notify(zio_t *zio);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   573
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   574
/* Accessor functions */
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
   575
extern boolean_t spa_shutting_down(spa_t *spa);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   576
extern struct dsl_pool *spa_get_dsl(spa_t *spa);
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13514
diff changeset
   577
extern boolean_t spa_is_initializing(spa_t *spa);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   578
extern blkptr_t *spa_get_rootblkptr(spa_t *spa);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   579
extern void spa_set_rootblkptr(spa_t *spa, const blkptr_t *bp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   580
extern void spa_altroot(spa_t *, char *, size_t);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   581
extern int spa_sync_pass(spa_t *spa);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   582
extern char *spa_name(spa_t *spa);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   583
extern uint64_t spa_guid(spa_t *spa);
13514
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13379
diff changeset
   584
extern uint64_t spa_load_guid(spa_t *spa);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   585
extern uint64_t spa_last_synced_txg(spa_t *spa);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   586
extern uint64_t spa_first_txg(spa_t *spa);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   587
extern uint64_t spa_syncing_txg(spa_t *spa);
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1807
diff changeset
   588
extern uint64_t spa_version(spa_t *spa);
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
   589
extern pool_state_t spa_state(spa_t *spa);
11147
74e8c05021f1 6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents: 10956
diff changeset
   590
extern spa_load_state_t spa_load_state(spa_t *spa);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   591
extern uint64_t spa_freeze_txg(spa_t *spa);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   592
extern uint64_t spa_get_asize(spa_t *spa, uint64_t lsize);
10956
0c81acaaf614 6897693 deduplication can only go so far
George Wilson <George.Wilson@Sun.COM>
parents: 10922
diff changeset
   593
extern uint64_t spa_get_dspace(spa_t *spa);
0c81acaaf614 6897693 deduplication can only go so far
George Wilson <George.Wilson@Sun.COM>
parents: 10922
diff changeset
   594
extern void spa_update_dspace(spa_t *spa);
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   595
extern uint64_t spa_version(spa_t *spa);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   596
extern boolean_t spa_deflate(spa_t *spa);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   597
extern metaslab_class_t *spa_normal_class(spa_t *spa);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   598
extern metaslab_class_t *spa_log_class(spa_t *spa);
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1760
diff changeset
   599
extern int spa_max_replication(spa_t *spa);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11816
diff changeset
   600
extern int spa_prev_software_version(spa_t *spa);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   601
extern int spa_busy(void);
5329
33cb98223b2d PSARC 2007/567 zpool failmode property
gw25295
parents: 5094
diff changeset
   602
extern uint8_t spa_get_failmode(spa_t *spa);
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7497
diff changeset
   603
extern boolean_t spa_suspended(spa_t *spa);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   604
extern uint64_t spa_bootfs(spa_t *spa);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   605
extern uint64_t spa_delegation(spa_t *spa);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   606
extern objset_t *spa_meta_objset(spa_t *spa);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   607
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   608
/* Miscellaneous support routines */
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13514
diff changeset
   609
extern void spa_activate_mos_feature(spa_t *spa, const char *feature);
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13514
diff changeset
   610
extern void spa_deactivate_mos_feature(spa_t *spa, const char *feature);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   611
extern int spa_rename(const char *oldname, const char *newname);
13061
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 12961
diff changeset
   612
extern spa_t *spa_by_guid(uint64_t pool_guid, uint64_t device_guid);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   613
extern boolean_t spa_guid_exists(uint64_t pool_guid, uint64_t device_guid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   614
extern char *spa_strdup(const char *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   615
extern void spa_strfree(char *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   616
extern uint64_t spa_get_random(uint64_t range);
11422
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11147
diff changeset
   617
extern uint64_t spa_generate_guid(spa_t *spa);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   618
extern void sprintf_blkptr(char *buf, const blkptr_t *bp);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   619
extern void spa_freeze(spa_t *spa);
13514
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13379
diff changeset
   620
extern int spa_change_guid(spa_t *spa);
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4715
diff changeset
   621
extern void spa_upgrade(spa_t *spa, uint64_t version);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   622
extern void spa_evict_all(void);
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
   623
extern vdev_t *spa_lookup_by_guid(spa_t *spa, uint64_t guid,
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
   624
    boolean_t l2cache);
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1807
diff changeset
   625
extern boolean_t spa_has_spare(spa_t *, uint64_t guid);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   626
extern uint64_t dva_get_dsize_sync(spa_t *spa, const dva_t *dva);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   627
extern uint64_t bp_get_dsize_sync(spa_t *spa, const blkptr_t *bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   628
extern uint64_t bp_get_dsize(spa_t *spa, const blkptr_t *bp);
4620
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 4543
diff changeset
   629
extern boolean_t spa_has_slogs(spa_t *spa);
6673
be079d6124af 6697301 deadlock between ZFS and devfs can hang system
eschrock
parents: 6643
diff changeset
   630
extern boolean_t spa_is_root(spa_t *spa);
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8211
diff changeset
   631
extern boolean_t spa_writeable(spa_t *spa);
10921
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
   632
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8211
diff changeset
   633
extern int spa_mode(spa_t *spa);
10342
108f0058f837 6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents: 9946
diff changeset
   634
extern uint64_t strtonum(const char *str, char **nptr);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   635
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4527
diff changeset
   636
extern char *spa_his_ievent_table[];
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4527
diff changeset
   637
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2856
diff changeset
   638
extern void spa_history_create_obj(spa_t *spa, dmu_tx_t *tx);
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2856
diff changeset
   639
extern int spa_history_get(spa_t *spa, uint64_t *offset, uint64_t *len_read,
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2856
diff changeset
   640
    char *his_buf);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
   641
extern int spa_history_log(spa_t *spa, const char *his_buf);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
   642
extern int spa_history_log_nvl(spa_t *spa, nvlist_t *nvl);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
   643
extern void spa_history_log_version(spa_t *spa, const char *operation);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
   644
extern void spa_history_log_internal(spa_t *spa, const char *operation,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
   645
    dmu_tx_t *tx, const char *fmt, ...);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
   646
extern void spa_history_log_internal_ds(struct dsl_dataset *ds, const char *op,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
   647
    dmu_tx_t *tx, const char *fmt, ...);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
   648
extern void spa_history_log_internal_dd(dsl_dir_t *dd, const char *operation,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
   649
    dmu_tx_t *tx, const char *fmt, ...);
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2856
diff changeset
   650
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   651
/* error handling */
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   652
struct zbookmark;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   653
extern void spa_log_error(spa_t *spa, zio_t *zio);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   654
extern void zfs_ereport_post(const char *class, spa_t *spa, vdev_t *vd,
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   655
    zio_t *zio, uint64_t stateoroffset, uint64_t length);
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 3912
diff changeset
   656
extern void zfs_post_remove(spa_t *spa, vdev_t *vd);
10817
7dfde45252f0 6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10800
diff changeset
   657
extern void zfs_post_state_change(spa_t *spa, vdev_t *vd);
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 3912
diff changeset
   658
extern void zfs_post_autoreplace(spa_t *spa, vdev_t *vd);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   659
extern uint64_t spa_get_errlog_size(spa_t *spa);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   660
extern int spa_get_errlog(spa_t *spa, void *uaddr, size_t *count);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   661
extern void spa_errlog_rotate(spa_t *spa);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   662
extern void spa_errlog_drain(spa_t *spa);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   663
extern void spa_errlog_sync(spa_t *spa, uint64_t txg);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1354
diff changeset
   664
extern void spa_get_errlists(spa_t *spa, avl_tree_t *last, avl_tree_t *scrub);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   665
5810
9253e5eac38c 6649150 add kstats to the vdev cache
ek110237
parents: 5450
diff changeset
   666
/* vdev cache */
9253e5eac38c 6649150 add kstats to the vdev cache
ek110237
parents: 5450
diff changeset
   667
extern void vdev_cache_stat_init(void);
9253e5eac38c 6649150 add kstats to the vdev cache
ek110237
parents: 5450
diff changeset
   668
extern void vdev_cache_stat_fini(void);
9253e5eac38c 6649150 add kstats to the vdev cache
ek110237
parents: 5450
diff changeset
   669
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   670
/* Initialization and termination */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   671
extern void spa_init(int flags);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   672
extern void spa_fini(void);
6423
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 5810
diff changeset
   673
extern void spa_boot_init();
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   674
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3700
diff changeset
   675
/* properties */
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4715
diff changeset
   676
extern int spa_prop_set(spa_t *spa, nvlist_t *nvp);
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4715
diff changeset
   677
extern int spa_prop_get(spa_t *spa, nvlist_t **nvp);
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4715
diff changeset
   678
extern void spa_prop_clear_bootfs(spa_t *spa, uint64_t obj, dmu_tx_t *tx);
8525
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8241
diff changeset
   679
extern void spa_configfile_set(spa_t *, nvlist_t *, boolean_t);
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3700
diff changeset
   680
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 3912
diff changeset
   681
/* asynchronous event notification */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 3912
diff changeset
   682
extern void spa_event_notify(spa_t *spa, vdev_t *vdev, const char *name);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 3912
diff changeset
   683
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   684
#ifdef ZFS_DEBUG
3700
3a7e0afcf1b4 6523936 BAD TRAP: type=8 (#df Double fault) rp=fec266f8 addr=0
ek110237
parents: 3697
diff changeset
   685
#define	dprintf_bp(bp, fmt, ...) do {				\
3a7e0afcf1b4 6523936 BAD TRAP: type=8 (#df Double fault) rp=fec266f8 addr=0
ek110237
parents: 3697
diff changeset
   686
	if (zfs_flags & ZFS_DEBUG_DPRINTF) { 			\
3a7e0afcf1b4 6523936 BAD TRAP: type=8 (#df Double fault) rp=fec266f8 addr=0
ek110237
parents: 3697
diff changeset
   687
	char *__blkbuf = kmem_alloc(BP_SPRINTF_LEN, KM_SLEEP);	\
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
   688
	sprintf_blkptr(__blkbuf, (bp));				\
3700
3a7e0afcf1b4 6523936 BAD TRAP: type=8 (#df Double fault) rp=fec266f8 addr=0
ek110237
parents: 3697
diff changeset
   689
	dprintf(fmt " %s\n", __VA_ARGS__, __blkbuf);		\
3a7e0afcf1b4 6523936 BAD TRAP: type=8 (#df Double fault) rp=fec266f8 addr=0
ek110237
parents: 3697
diff changeset
   690
	kmem_free(__blkbuf, BP_SPRINTF_LEN);			\
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   691
	} \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   692
_NOTE(CONSTCOND) } while (0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   693
#else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   694
#define	dprintf_bp(bp, fmt, ...)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   695
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   696
13379
4df42cc92254 1051 zfs should handle imbalanced luns
George Wilson <George.Wilson@delphix.com>
parents: 13061
diff changeset
   697
extern boolean_t spa_debug_enabled(spa_t *spa);
4df42cc92254 1051 zfs should handle imbalanced luns
George Wilson <George.Wilson@delphix.com>
parents: 13061
diff changeset
   698
#define	spa_dbgmsg(spa, ...)			\
4df42cc92254 1051 zfs should handle imbalanced luns
George Wilson <George.Wilson@delphix.com>
parents: 13061
diff changeset
   699
{						\
4df42cc92254 1051 zfs should handle imbalanced luns
George Wilson <George.Wilson@delphix.com>
parents: 13061
diff changeset
   700
	if (spa_debug_enabled(spa))		\
4df42cc92254 1051 zfs should handle imbalanced luns
George Wilson <George.Wilson@delphix.com>
parents: 13061
diff changeset
   701
		zfs_dbgmsg(__VA_ARGS__);	\
4df42cc92254 1051 zfs should handle imbalanced luns
George Wilson <George.Wilson@delphix.com>
parents: 13061
diff changeset
   702
}
4df42cc92254 1051 zfs should handle imbalanced luns
George Wilson <George.Wilson@delphix.com>
parents: 13061
diff changeset
   703
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8211
diff changeset
   704
extern int spa_mode_global;			/* mode, e.g. FREAD | FWRITE */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   705
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   706
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   707
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   708
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   709
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   710
#endif	/* _SYS_SPA_H */