usr/src/uts/common/fs/zfs/sys/zio.h
author eschrock
Tue, 16 May 2006 11:20:11 -0700
changeset 1986 628267397204
parent 1807 35c8b566d7af
child 2981 b80f5da0b8ed
permissions -rw-r--r--
6424405 zpool import destroyed_pool can damage existing pool using same devices
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: 789
diff changeset
     5
 * Common Development and Distribution License (the "License").
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
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
/*
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    22
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    23
 * Use is subject to license terms.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    25
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    26
#ifndef _ZIO_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
#define	_ZIO_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
#pragma ident	"%Z%%M%	%I%	%E% SMI"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
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/spa.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
#include <sys/txg.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
#include <sys/avl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    35
#include <sys/dkio.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
#include <sys/fs/zfs.h>
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
    37
#include <sys/zio_impl.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
extern "C" {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
#define	ZBT_MAGIC	0x210da7ab10c7a11ULL	/* zio data bloc tail */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
typedef struct zio_block_tail {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    46
	uint64_t	zbt_magic;	/* for validation, endianness	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    47
	zio_cksum_t	zbt_cksum;	/* 256-bit checksum		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    48
} zio_block_tail_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    49
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    51
 * Gang block headers are self-checksumming and contain an array
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    52
 * of block pointers.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    53
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    54
#define	SPA_GANGBLOCKSIZE	SPA_MINBLOCKSIZE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    55
#define	SPA_GBH_NBLKPTRS	((SPA_GANGBLOCKSIZE - \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    56
	sizeof (zio_block_tail_t)) / sizeof (blkptr_t))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
#define	SPA_GBH_FILLER		((SPA_GANGBLOCKSIZE - \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
	sizeof (zio_block_tail_t) - \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
	(SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
	sizeof (uint64_t))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    61
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    62
#define	ZIO_GET_IOSIZE(zio)	\
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
    63
	(BP_IS_GANG((zio)->io_bp) ? \
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
	SPA_GANGBLOCKSIZE : BP_GET_PSIZE((zio)->io_bp))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    65
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
typedef struct zio_gbh {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    67
	blkptr_t		zg_blkptr[SPA_GBH_NBLKPTRS];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
	uint64_t		zg_filler[SPA_GBH_FILLER];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    69
	zio_block_tail_t	zg_tail;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
} zio_gbh_phys_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    71
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
enum zio_checksum {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    73
	ZIO_CHECKSUM_INHERIT = 0,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    74
	ZIO_CHECKSUM_ON,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    75
	ZIO_CHECKSUM_OFF,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
	ZIO_CHECKSUM_LABEL,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
	ZIO_CHECKSUM_GANG_HEADER,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    78
	ZIO_CHECKSUM_ZILOG,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    79
	ZIO_CHECKSUM_FLETCHER_2,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
	ZIO_CHECKSUM_FLETCHER_4,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
	ZIO_CHECKSUM_SHA256,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    82
	ZIO_CHECKSUM_FUNCTIONS
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    83
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    84
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    85
#define	ZIO_CHECKSUM_ON_VALUE	ZIO_CHECKSUM_FLETCHER_2
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    86
#define	ZIO_CHECKSUM_DEFAULT	ZIO_CHECKSUM_ON
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    87
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    88
enum zio_compress {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    89
	ZIO_COMPRESS_INHERIT = 0,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    90
	ZIO_COMPRESS_ON,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    91
	ZIO_COMPRESS_OFF,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    92
	ZIO_COMPRESS_LZJB,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    93
	ZIO_COMPRESS_FUNCTIONS
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    94
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    95
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    96
#define	ZIO_COMPRESS_ON_VALUE	ZIO_COMPRESS_LZJB
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    97
#define	ZIO_COMPRESS_DEFAULT	ZIO_COMPRESS_OFF
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    98
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    99
#define	ZIO_PRIORITY_NOW		(zio_priority_table[0])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   100
#define	ZIO_PRIORITY_SYNC_READ		(zio_priority_table[1])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   101
#define	ZIO_PRIORITY_SYNC_WRITE		(zio_priority_table[2])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   102
#define	ZIO_PRIORITY_ASYNC_READ		(zio_priority_table[3])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   103
#define	ZIO_PRIORITY_ASYNC_WRITE	(zio_priority_table[4])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   104
#define	ZIO_PRIORITY_FREE		(zio_priority_table[5])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   105
#define	ZIO_PRIORITY_CACHE_FILL		(zio_priority_table[6])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   106
#define	ZIO_PRIORITY_LOG_WRITE		(zio_priority_table[7])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   107
#define	ZIO_PRIORITY_RESILVER		(zio_priority_table[8])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   108
#define	ZIO_PRIORITY_SCRUB		(zio_priority_table[9])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   109
#define	ZIO_PRIORITY_TABLE_SIZE		10
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   110
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   111
#define	ZIO_FLAG_MUSTSUCCEED		0x00000
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   112
#define	ZIO_FLAG_CANFAIL		0x00001
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   113
#define	ZIO_FLAG_FAILFAST		0x00002
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   114
#define	ZIO_FLAG_CONFIG_HELD		0x00004
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   115
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   116
#define	ZIO_FLAG_DONT_CACHE		0x00010
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   117
#define	ZIO_FLAG_DONT_QUEUE		0x00020
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   118
#define	ZIO_FLAG_DONT_PROPAGATE		0x00040
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   119
#define	ZIO_FLAG_DONT_RETRY		0x00080
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   120
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   121
#define	ZIO_FLAG_PHYSICAL		0x00100
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   122
#define	ZIO_FLAG_IO_BYPASS		0x00200
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   123
#define	ZIO_FLAG_IO_REPAIR		0x00400
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   124
#define	ZIO_FLAG_SPECULATIVE		0x00800
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   125
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   126
#define	ZIO_FLAG_RESILVER		0x01000
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   127
#define	ZIO_FLAG_SCRUB			0x02000
1807
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1775
diff changeset
   128
#define	ZIO_FLAG_SCRUB_THREAD		0x04000
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1775
diff changeset
   129
#define	ZIO_FLAG_SUBBLOCK		0x08000
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   130
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   131
#define	ZIO_FLAG_NOBOOKMARK		0x10000
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   132
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   133
#define	ZIO_FLAG_GANG_INHERIT		\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   134
	(ZIO_FLAG_CANFAIL |		\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   135
	ZIO_FLAG_FAILFAST |		\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   136
	ZIO_FLAG_CONFIG_HELD |		\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   137
	ZIO_FLAG_DONT_RETRY |		\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   138
	ZIO_FLAG_IO_REPAIR |		\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   139
	ZIO_FLAG_SPECULATIVE |		\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   140
	ZIO_FLAG_RESILVER |		\
1807
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1775
diff changeset
   141
	ZIO_FLAG_SCRUB |		\
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1775
diff changeset
   142
	ZIO_FLAG_SCRUB_THREAD)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   143
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   144
#define	ZIO_FLAG_VDEV_INHERIT		\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   145
	(ZIO_FLAG_GANG_INHERIT |	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   146
	ZIO_FLAG_DONT_CACHE |		\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   147
	ZIO_FLAG_PHYSICAL)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   148
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   149
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   150
 * We'll take the unused errno 'EBADE' (from the Convergent graveyard)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   151
 * to indicate checksum errors.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   152
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   153
#define	ECKSUM	EBADE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   154
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   155
typedef struct zio zio_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   156
typedef void zio_done_func_t(zio_t *zio);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   157
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   158
extern uint8_t zio_priority_table[ZIO_PRIORITY_TABLE_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   159
extern char *zio_type_name[ZIO_TYPES];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   160
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   161
/*
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   162
 * A bookmark is a four-tuple <objset, object, level, blkid> that uniquely
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   163
 * identifies any block in the pool.  By convention, the meta-objset (MOS)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   164
 * is objset 0, the meta-dnode is object 0, the root block (osphys_t) is
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   165
 * level -1 of the meta-dnode, and intent log blocks (which are chained
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   166
 * off the root block) have blkid == sequence number.  In summary:
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   167
 *
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   168
 *	mos is objset 0
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   169
 *	meta-dnode is object 0
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   170
 *	root block is <objset, 0, -1, 0>
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   171
 *	intent log is <objset, 0, -1, ZIL sequence number>
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   172
 *
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   173
 * Note: this structure is called a bookmark because its first purpose was
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   174
 * to remember where to resume a pool-wide traverse.  The absolute ordering
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   175
 * for block visitation during traversal is defined in compare_bookmark().
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   176
 *
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   177
 * Note: this structure is passed between userland and the kernel.
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   178
 * Therefore it must not change size or alignment between 32/64 bit
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   179
 * compilation options.
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   180
 */
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   181
typedef struct zbookmark {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   182
	uint64_t	zb_objset;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   183
	uint64_t	zb_object;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   184
	int64_t		zb_level;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   185
	uint64_t	zb_blkid;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   186
} zbookmark_t;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   187
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   188
struct zio {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   189
	/* Core information about this I/O */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   190
	zio_t		*io_parent;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   191
	zio_t		*io_root;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   192
	spa_t		*io_spa;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   193
	zbookmark_t	io_bookmark;
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   194
	enum zio_checksum io_checksum;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   195
	enum zio_compress io_compress;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   196
	int		io_ndvas;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   197
	uint64_t	io_txg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   198
	blkptr_t	*io_bp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   199
	blkptr_t	io_bp_copy;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   200
	zio_t		*io_child;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   201
	zio_t		*io_sibling_prev;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   202
	zio_t		*io_sibling_next;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   203
	zio_transform_t *io_transform_stack;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   204
	zio_t		*io_logical;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   205
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   206
	/* Callback info */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   207
	zio_done_func_t	*io_done;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   208
	void		*io_private;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   209
	blkptr_t	io_bp_orig;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   210
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   211
	/* Data represented by this I/O */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   212
	void		*io_data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   213
	uint64_t	io_size;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   214
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   215
	/* Stuff for the vdev stack */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   216
	vdev_t		*io_vd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   217
	void		*io_vsd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   218
	uint64_t	io_offset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   219
	uint64_t	io_deadline;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   220
	uint64_t	io_timestamp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   221
	avl_node_t	io_offset_node;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   222
	avl_node_t	io_deadline_node;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   223
	avl_tree_t	*io_vdev_tree;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   224
	zio_t		*io_delegate_list;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   225
	zio_t		*io_delegate_next;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   226
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   227
	/* Internal pipeline state */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   228
	int		io_flags;
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   229
	enum zio_type	io_type;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   230
	enum zio_stage	io_stage;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   231
	uint8_t		io_stalled;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   232
	uint8_t		io_priority;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   233
	struct dk_callback io_dk_callback;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   234
	int		io_cmd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   235
	int		io_retries;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   236
	int		io_error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   237
	uint32_t	io_numerrors;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   238
	uint32_t	io_pipeline;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   239
	uint32_t	io_async_stages;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   240
	uint64_t	io_children_notready;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   241
	uint64_t	io_children_notdone;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   242
	void		*io_waiter;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   243
	kmutex_t	io_lock;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   244
	kcondvar_t	io_cv;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   245
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   246
	/* FMA state */
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   247
	uint64_t	io_ena;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   248
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   249
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   250
extern zio_t *zio_null(zio_t *pio, spa_t *spa,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   251
    zio_done_func_t *done, void *private, int flags);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   252
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   253
extern zio_t *zio_root(spa_t *spa,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   254
    zio_done_func_t *done, void *private, int flags);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   255
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   256
extern zio_t *zio_read(zio_t *pio, spa_t *spa, blkptr_t *bp, void *data,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   257
    uint64_t size, zio_done_func_t *done, void *private,
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   258
    int priority, int flags, zbookmark_t *zb);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   259
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   260
extern zio_t *zio_write(zio_t *pio, spa_t *spa, int checksum, int compress,
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
   261
    int ncopies, uint64_t txg, blkptr_t *bp, void *data, uint64_t size,
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   262
    zio_done_func_t *done, void *private, int priority, int flags,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   263
    zbookmark_t *zb);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   264
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   265
extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, int checksum,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   266
    uint64_t txg, blkptr_t *bp, void *data, uint64_t size,
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   267
    zio_done_func_t *done, void *private, int priority, int flags,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   268
    zbookmark_t *zb);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   269
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   270
extern zio_t *zio_free(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   271
    zio_done_func_t *done, void *private);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   272
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   273
extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   274
    zio_done_func_t *done, void *private);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   275
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   276
extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   277
    zio_done_func_t *done, void *private, int priority, int flags);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   278
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   279
extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   280
    uint64_t size, void *data, int checksum,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   281
    zio_done_func_t *done, void *private, int priority, int flags);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   282
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   283
extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   284
    uint64_t size, void *data, int checksum,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   285
    zio_done_func_t *done, void *private, int priority, int flags);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   286
1807
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1775
diff changeset
   287
extern int zio_alloc_blk(spa_t *spa, uint64_t size, blkptr_t *bp, uint64_t txg);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   288
extern void zio_free_blk(spa_t *spa, blkptr_t *bp, uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   289
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   290
extern int zio_wait(zio_t *zio);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   291
extern void zio_nowait(zio_t *zio);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   292
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   293
extern void *zio_buf_alloc(size_t size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   294
extern void zio_buf_free(void *buf, size_t size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   295
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   296
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   297
 * Move an I/O to the next stage of the pipeline and execute that stage.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   298
 * There's no locking on io_stage because there's no legitimate way for
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   299
 * multiple threads to be attempting to process the same I/O.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   300
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   301
extern void zio_next_stage(zio_t *zio);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   302
extern void zio_next_stage_async(zio_t *zio);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   303
extern void zio_wait_children_done(zio_t *zio);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   304
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   305
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   306
 * Delegate I/O to a child vdev.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   307
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   308
extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   309
    uint64_t offset, void *data, uint64_t size, int type, int priority,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   310
    int flags, zio_done_func_t *done, void *private);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   311
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   312
extern void zio_vdev_io_bypass(zio_t *zio);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   313
extern void zio_vdev_io_reissue(zio_t *zio);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   314
extern void zio_vdev_io_redone(zio_t *zio);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   315
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   316
extern void zio_checksum_verified(zio_t *zio);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   317
extern void zio_set_gang_verifier(zio_t *zio, zio_cksum_t *zcp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   318
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   319
extern uint8_t zio_checksum_select(uint8_t child, uint8_t parent);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   320
extern uint8_t zio_compress_select(uint8_t child, uint8_t parent);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   321
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   322
boolean_t zio_should_retry(zio_t *zio);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   323
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   324
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   325
 * Initial setup and teardown.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   326
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   327
extern void zio_init(void);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   328
extern void zio_fini(void);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   329
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   330
/*
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   331
 * Fault injection
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   332
 */
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   333
struct zinject_record;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   334
extern uint32_t zio_injection_enabled;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   335
extern int zio_inject_fault(char *name, int flags, int *id,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   336
    struct zinject_record *record);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   337
extern int zio_inject_list_next(int *id, char *name, size_t buflen,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   338
    struct zinject_record *record);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   339
extern int zio_clear_fault(int id);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   340
extern int zio_handle_fault_injection(zio_t *zio, int error);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   341
extern int zio_handle_device_injection(vdev_t *vd, int error);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   342
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   343
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   344
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   345
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   346
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   347
#endif	/* _ZIO_H */