zio.h revision c55e05cb35da47582b7afd38734d2f0d9c6deb40
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
#ifndef _ZIO_H
#define _ZIO_H
#include <sys/zfs_context.h>
#include <sys/zio_impl.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Embedded checksum
*/
#define ZEC_MAGIC 0x210da7ab10c7a11ULL
typedef struct zio_eck {
} zio_eck_t;
/*
* Gang block headers are self-checksumming and contain an array
* of block pointers.
*/
#define SPA_GANGBLOCKSIZE SPA_MINBLOCKSIZE
#define SPA_GBH_NBLKPTRS ((SPA_GANGBLOCKSIZE - \
#define SPA_GBH_FILLER ((SPA_GANGBLOCKSIZE - \
sizeof (zio_eck_t) - \
(SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\
sizeof (uint64_t))
typedef struct zio_gbh {
enum zio_checksum {
ZIO_CHECKSUM_INHERIT = 0,
};
#define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON
#define ZIO_CHECKSUM_MASK 0xffULL
#define ZIO_DEDUPCHECKSUM ZIO_CHECKSUM_SHA256
#define ZIO_DEDUPDITTO_MIN 100
enum zio_compress {
ZIO_COMPRESS_INHERIT = 0,
};
/* N.B. when altering this value, also change BOOTFS_COMPRESS_VALID below */
#define ZIO_COMPRESS_DEFAULT ZIO_COMPRESS_OFF
#define BOOTFS_COMPRESS_VALID(compress) \
((compress) == ZIO_COMPRESS_LZJB || \
(compress) == ZIO_COMPRESS_LZ4 || \
((compress) == ZIO_COMPRESS_ON && \
ZIO_COMPRESS_ON_VALUE == ZIO_COMPRESS_LZJB) || \
(compress) == ZIO_COMPRESS_OFF)
#define ZIO_FAILURE_MODE_WAIT 0
#define ZIO_FAILURE_MODE_CONTINUE 1
#define ZIO_FAILURE_MODE_PANIC 2
#define ZIO_PRIORITY_NOW (zio_priority_table[0])
#define ZIO_PRIORITY_TABLE_SIZE 12
#define ZIO_PIPELINE_CONTINUE 0x100
#define ZIO_PIPELINE_STOP 0x101
enum zio_flag {
/*
* Flags inherited by gang, ddt, and vdev children,
* and that must be equal for two zios to aggregate
*/
ZIO_FLAG_DONT_AGGREGATE = 1 << 0,
/*
* Flags inherited by ddt, gang, and vdev children.
*/
/*
* Flags inherited by vdev children.
*/
/*
* Flags not inherited by any children.
*/
};
#define ZIO_FLAG_MUSTSUCCEED 0
#define ZIO_DDT_CHILD_FLAGS(zio) \
#define ZIO_GANG_CHILD_FLAGS(zio) \
#define ZIO_VDEV_CHILD_FLAGS(zio) \
enum zio_child {
ZIO_CHILD_VDEV = 0,
};
enum zio_wait_type {
ZIO_WAIT_READY = 0,
};
/*
* We'll take the unused errnos, 'EBADE' and 'EBADR' (from the Convergent
* graveyard) to indicate checksum errors and fragmentation.
*/
extern char *zio_type_name[ZIO_TYPES];
/*
* A bookmark is a four-tuple <objset, object, level, blkid> that uniquely
* identifies any block in the pool. By convention, the meta-objset (MOS)
* is objset 0, and the meta-dnode is object 0. This covers all blocks
* except root blocks and ZIL blocks, which are defined as follows:
*
* Root blocks (objset_phys_t) are object 0, level -1: <objset, 0, -1, 0>.
* ZIL blocks are bookmarked <objset, 0, -2, blkid == ZIL sequence number>.
* dmu_sync()ed ZIL data blocks are bookmarked <objset, object, -2, blkid>.
*
* Note: this structure is called a bookmark because its original purpose
* was to remember where to resume a pool-wide traverse.
*
* Note: this structure is passed between userland and the kernel.
* Therefore it must not change size or alignment between 32/64 bit
* compilation options.
*/
typedef struct zbookmark {
} zbookmark_t;
{ \
}
#define ZB_DESTROYED_OBJSET (-1ULL)
#define ZB_ROOT_OBJECT (0ULL)
#define ZB_ROOT_LEVEL (-1LL)
#define ZB_ROOT_BLKID (0ULL)
#define ZB_ZIL_OBJECT (0ULL)
#define ZB_ZIL_LEVEL (-2LL)
#define ZB_IS_ZERO(zb) \
#define ZB_IS_ROOT(zb) \
typedef struct zio_prop {
enum zio_checksum zp_checksum;
enum zio_compress zp_compress;
} zio_prop_t;
typedef struct zio_cksum_report zio_cksum_report_t;
const void *good_data);
struct zio_bad_cksum; /* defined in zio_checksum.h */
struct dnode_phys;
struct zio_cksum_report {
struct zio_cksum_report *zcr_next;
void *zcr_cbdata;
/* internal use only */
};
void *arg);
typedef struct zio_vsd_ops {
typedef struct zio_gang_node {
typedef struct zio_transform {
void *zt_orig_data;
struct zio_transform *zt_next;
/*
* The io_reexecute flags are distinct from io_flags because the child must
* be able to propagate them to the parent. The normal io_flags are local
* to the zio, not protected by any lock, and not modifiable by children;
* the reexecute flags are protected by io_lock, modifiable by children,
* and always propagated -- even when ZIO_FLAG_DONT_PROPAGATE is set.
*/
#define ZIO_REEXECUTE_NOW 0x01
#define ZIO_REEXECUTE_SUSPEND 0x02
typedef struct zio_link {
} zio_link_t;
struct zio {
/* Core information about this I/O */
enum zio_child io_child_type;
int io_cmd;
/* Callback info */
void *io_private;
/* Data represented by this I/O */
void *io_data;
void *io_orig_data;
/* Stuff for the vdev stack */
void *io_vsd;
const zio_vsd_ops_t *io_vsd_ops;
/* Internal pipeline state */
enum zio_stage io_pipeline;
enum zio_flag io_orig_flags;
enum zio_stage io_orig_stage;
enum zio_stage io_orig_pipeline;
int io_error;
void *io_executor;
void *io_waiter;
/* FMA state */
/* Taskq dispatching state */
};
extern void zio_resubmit_stage_async(void *);
enum zio_checksum parent);
enum zio_compress parent);
/*
* Initial setup and teardown.
*/
extern void zio_init(void);
extern void zio_fini(void);
/*
* Fault injection
*/
struct zinject_record;
extern uint32_t zio_injection_enabled;
struct zinject_record *record);
struct zinject_record *record);
extern int zio_clear_fault(int id);
/*
* Checksum ereport functions
*/
/* If we have the good data in hand, this function can be used */
/* Called from spa_sync(), but primarily an injection handler */
/* zbookmark functions */
#ifdef __cplusplus
}
#endif
#endif /* _ZIO_H */