zio_impl.h revision ea8dc4b6d2251b437950c0056bc626b311c73c27
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Common Development and Distribution License (the "License").
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * or http://www.opensolaris.org/os/licensing.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Use is subject to license terms.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifndef _ZIO_IMPL_H
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define _ZIO_IMPL_H
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#pragma ident "%Z%%M% %I% %E% SMI"
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/zfs_context.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/zio.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifdef __cplusplus
fa9e4066f08beec538e775443c5be79dd423fcabahrensextern "C" {
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * I/O Groups: pipeline stage definitions.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum zio_stage {
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_OPEN = 0, /* RWFCI */
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_WAIT_CHILDREN_READY, /* RWFCI */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_WRITE_COMPRESS, /* -W--- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_CHECKSUM_GENERATE, /* -W--- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_GANG_PIPELINE, /* -WFC- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_GET_GANG_HEADER, /* -WFC- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_REWRITE_GANG_MEMBERS, /* -W--- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_FREE_GANG_MEMBERS, /* --F-- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_CLAIM_GANG_MEMBERS, /* ---C- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_DVA_ALLOCATE, /* -W--- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_DVA_FREE, /* --F-- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_DVA_CLAIM, /* ---C- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_GANG_CHECKSUM_GENERATE, /* -W--- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_READY, /* RWFCI */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_DVA_TRANSLATE, /* RW--- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_VDEV_IO_SETUP, /* RW--I */
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_VDEV_IO_START, /* RW--I */
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_VDEV_IO_DONE, /* RW--I */
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_VDEV_IO_ASSESS, /* RW--I */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_WAIT_CHILDREN_DONE, /* RWFCI */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_CHECKSUM_VERIFY, /* R---- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_READ_GANG_MEMBERS, /* R---- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_READ_DECOMPRESS, /* R---- */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_STAGE_DONE /* RWFCI */
fa9e4066f08beec538e775443c5be79dd423fcabahrens} zio_stage_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The stages for which there's some performance value in going async.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When compression is enabled, ZIO_STAGE_WRITE_COMPRESS is ORed in as well.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_ASYNC_PIPELINE_STAGES \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_CHECKSUM_GENERATE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_VDEV_IO_DONE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_CHECKSUM_VERIFY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_READ_DECOMPRESS))
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_VDEV_IO_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_VDEV_IO_SETUP) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_VDEV_IO_START) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_VDEV_IO_DONE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_VDEV_IO_ASSESS))
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_READ_PHYS_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_OPEN) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_WAIT_CHILDREN_READY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_READY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_VDEV_IO_PIPELINE | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_WAIT_CHILDREN_DONE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_CHECKSUM_VERIFY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_DONE))
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_READ_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_DVA_TRANSLATE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_READ_PHYS_PIPELINE)
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_WRITE_PHYS_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_OPEN) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_WAIT_CHILDREN_READY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_CHECKSUM_GENERATE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_READY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_VDEV_IO_PIPELINE | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_WAIT_CHILDREN_DONE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_DONE))
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_WRITE_COMMON_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_DVA_TRANSLATE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_WRITE_PHYS_PIPELINE)
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_WRITE_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_WRITE_COMPRESS) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_WRITE_COMMON_PIPELINE)
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_GANG_STAGES \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_GET_GANG_HEADER) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_REWRITE_GANG_MEMBERS) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_FREE_GANG_MEMBERS) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_CLAIM_GANG_MEMBERS) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_GANG_CHECKSUM_GENERATE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_READ_GANG_MEMBERS))
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_REWRITE_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_GANG_PIPELINE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_GET_GANG_HEADER) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_REWRITE_GANG_MEMBERS) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_GANG_CHECKSUM_GENERATE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_WRITE_COMMON_PIPELINE)
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_WRITE_ALLOCATE_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_DVA_ALLOCATE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_WRITE_COMMON_PIPELINE)
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_GANG_FREE_STAGES \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_GET_GANG_HEADER) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_FREE_GANG_MEMBERS))
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_FREE_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_OPEN) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_WAIT_CHILDREN_READY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_GANG_PIPELINE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_GET_GANG_HEADER) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_FREE_GANG_MEMBERS) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_DVA_FREE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_READY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_WAIT_CHILDREN_DONE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_DONE))
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_CLAIM_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_OPEN) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_WAIT_CHILDREN_READY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_GANG_PIPELINE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_GET_GANG_HEADER) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_CLAIM_GANG_MEMBERS) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_DVA_CLAIM) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_READY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_WAIT_CHILDREN_DONE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_DONE))
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_IOCTL_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_OPEN) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_WAIT_CHILDREN_READY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_READY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_VDEV_IO_PIPELINE | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_WAIT_CHILDREN_DONE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_DONE))
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_WAIT_FOR_CHILDREN_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_WAIT_CHILDREN_READY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_READY) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_WAIT_CHILDREN_DONE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_DONE))
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_WAIT_FOR_CHILDREN_DONE_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((1U << ZIO_STAGE_WAIT_CHILDREN_DONE) | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (1U << ZIO_STAGE_DONE))
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_VDEV_CHILD_PIPELINE \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (ZIO_WAIT_FOR_CHILDREN_DONE_PIPELINE | \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_VDEV_IO_PIPELINE)
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZIO_ERROR_PIPELINE_MASK \
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_WAIT_FOR_CHILDREN_PIPELINE
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensstruct zio_transform {
fa9e4066f08beec538e775443c5be79dd423fcabahrens void *zt_data;
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zt_size;
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zt_bufsize;
fa9e4066f08beec538e775443c5be79dd423fcabahrens zio_transform_t *zt_next;
fa9e4066f08beec538e775443c5be79dd423fcabahrens};
fa9e4066f08beec538e775443c5be79dd423fcabahrens
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrockextern void zio_inject_init(void);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrockextern void zio_inject_fini(void);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifdef __cplusplus
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif /* _ZIO_IMPL_H */