vdev.h revision fa9e4066f08beec538e775443c5be79dd423fcab
1fa9e406ahrens/*
2fa9e406ahrens * CDDL HEADER START
3fa9e406ahrens *
4fa9e406ahrens * The contents of this file are subject to the terms of the
5fa9e406ahrens * Common Development and Distribution License, Version 1.0 only
6fa9e406ahrens * (the "License").  You may not use this file except in compliance
7fa9e406ahrens * with the License.
8fa9e406ahrens *
9fa9e406ahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10fa9e406ahrens * or http://www.opensolaris.org/os/licensing.
11fa9e406ahrens * See the License for the specific language governing permissions
12fa9e406ahrens * and limitations under the License.
13fa9e406ahrens *
14fa9e406ahrens * When distributing Covered Code, include this CDDL HEADER in each
15fa9e406ahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16fa9e406ahrens * If applicable, add the following below this CDDL HEADER, with the
17fa9e406ahrens * fields enclosed by brackets "[]" replaced with your own identifying
18fa9e406ahrens * information: Portions Copyright [yyyy] [name of copyright owner]
19fa9e406ahrens *
20fa9e406ahrens * CDDL HEADER END
21fa9e406ahrens */
22fa9e406ahrens/*
23fa9e406ahrens * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24fa9e406ahrens * Use is subject to license terms.
25fa9e406ahrens */
26fa9e406ahrens
27fa9e406ahrens#ifndef _SYS_VDEV_H
28fa9e406ahrens#define	_SYS_VDEV_H
29fa9e406ahrens
30fa9e406ahrens#pragma ident	"%Z%%M%	%I%	%E% SMI"
31fa9e406ahrens
32fa9e406ahrens#include <sys/spa.h>
33fa9e406ahrens#include <sys/zio.h>
34fa9e406ahrens#include <sys/dmu.h>
35fa9e406ahrens#include <sys/space_map.h>
36fa9e406ahrens#include <sys/fs/zfs.h>
37fa9e406ahrens
38fa9e406ahrens#ifdef	__cplusplus
39fa9e406ahrensextern "C" {
40fa9e406ahrens#endif
41fa9e406ahrens
42fa9e406ahrens/*
43fa9e406ahrens * Vdev knobs.
44fa9e406ahrens */
45fa9e406ahrenstypedef struct vdev_knob {
46fa9e406ahrens	char		*vk_name;		/* knob name		*/
47fa9e406ahrens	char		*vk_desc;		/* knob description	*/
48fa9e406ahrens	uint64_t	vk_min;			/* minimum legal value	*/
49fa9e406ahrens	uint64_t	vk_max;			/* maximum legal value	*/
50fa9e406ahrens	uint64_t	vk_default;		/* default value	*/
51fa9e406ahrens	size_t		vk_offset;		/* offset into vdev_t	*/
52fa9e406ahrens} vdev_knob_t;
53fa9e406ahrens
54fa9e406ahrens/*
55fa9e406ahrens * Fault injection modes.
56fa9e406ahrens */
57fa9e406ahrens#define	VDEV_FAULT_NONE		0
58fa9e406ahrens#define	VDEV_FAULT_RANDOM	1
59fa9e406ahrens#define	VDEV_FAULT_COUNT	2
60fa9e406ahrens
61fa9e406ahrensextern int vdev_open(vdev_t *);
62fa9e406ahrensextern void vdev_close(vdev_t *);
63fa9e406ahrensextern int vdev_create(vdev_t *, uint64_t txg);
64fa9e406ahrensextern void vdev_init(vdev_t *, uint64_t txg);
65fa9e406ahrensextern void vdev_reopen(vdev_t *, zio_t **zq);
66fa9e406ahrens
67fa9e406ahrensextern vdev_t *vdev_lookup_top(spa_t *spa, uint64_t vdev);
68fa9e406ahrensextern vdev_t *vdev_lookup_by_path(vdev_t *vd, const char *path);
69fa9e406ahrensextern vdev_t *vdev_lookup_by_guid(vdev_t *vd, uint64_t guid);
70fa9e406ahrensextern void vdev_dtl_dirty(space_map_t *sm, uint64_t txg, uint64_t size);
71fa9e406ahrensextern int vdev_dtl_contains(space_map_t *sm, uint64_t txg, uint64_t size);
72fa9e406ahrensextern void vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg,
73fa9e406ahrens    int scrub_done);
74fa9e406ahrens
75fa9e406ahrensextern const char *vdev_description(vdev_t *vd);
76fa9e406ahrens
77fa9e406ahrensextern void vdev_metaslab_init(vdev_t *vd, uint64_t txg);
78fa9e406ahrensextern void vdev_metaslab_fini(vdev_t *vd);
79fa9e406ahrens
80fa9e406ahrensextern void vdev_get_stats(vdev_t *vd, vdev_stat_t *vs);
81fa9e406ahrensextern void vdev_stat_update(zio_t *zio);
82fa9e406ahrensextern void vdev_scrub_stat_update(vdev_t *vd, pool_scrub_type_t type,
83fa9e406ahrens    boolean_t complete);
84fa9e406ahrensextern void vdev_checksum_error(zio_t *zio, vdev_t *vd);
85fa9e406ahrensextern int vdev_getspec(spa_t *spa, uint64_t vdev, char **vdev_spec);
86fa9e406ahrensextern void vdev_set_state(vdev_t *vd, vdev_state_t state, vdev_aux_t aux);
87fa9e406ahrens
88fa9e406ahrensextern void vdev_space_update(vdev_t *vd, uint64_t space_delta,
89fa9e406ahrens    uint64_t alloc_delta);
90fa9e406ahrens
91fa9e406ahrensextern uint64_t vdev_psize_to_asize(vdev_t *vd, uint64_t psize);
92fa9e406ahrens
93fa9e406ahrensextern void vdev_io_start(zio_t *zio);
94fa9e406ahrensextern void vdev_io_done(zio_t *zio);
95fa9e406ahrens
96fa9e406ahrensextern int vdev_online(spa_t *spa, const char *path);
97fa9e406ahrensextern int vdev_offline(spa_t *spa, const char *path);
98fa9e406ahrens
99fa9e406ahrensextern int vdev_error_setup(spa_t *spa, const char *path, int mode, int mask,
100fa9e406ahrens    uint64_t arg);
101fa9e406ahrensextern int vdev_error_inject(vdev_t *vd, zio_t *zio);
102fa9e406ahrensextern int vdev_is_dead(vdev_t *vd);
103fa9e406ahrens
104fa9e406ahrensextern void vdev_cache_init(vdev_t *vd);
105fa9e406ahrensextern void vdev_cache_fini(vdev_t *vd);
106fa9e406ahrensextern int vdev_cache_read(zio_t *zio);
107fa9e406ahrensextern void vdev_cache_write(zio_t *zio);
108fa9e406ahrens
109fa9e406ahrensextern void vdev_queue_init(vdev_t *vd);
110fa9e406ahrensextern void vdev_queue_fini(vdev_t *vd);
111fa9e406ahrensextern zio_t *vdev_queue_io(zio_t *zio);
112fa9e406ahrensextern void vdev_queue_io_done(zio_t *zio);
113fa9e406ahrens
114fa9e406ahrensextern vdev_knob_t *vdev_knob_next(vdev_knob_t *vk);
115fa9e406ahrens
116fa9e406ahrensextern void vdev_config_dirty(vdev_t *vd);
117fa9e406ahrensextern void vdev_config_clean(vdev_t *vd);
118fa9e406ahrens
119fa9e406ahrensextern nvlist_t *vdev_config_generate(vdev_t *vd, int getstats);
120fa9e406ahrens
121fa9e406ahrens/*
122fa9e406ahrens * Label routines
123fa9e406ahrens */
124fa9e406ahrensstruct uberblock;
125fa9e406ahrensextern uint64_t vdev_label_offset(uint64_t psize, int l, uint64_t offset);
126fa9e406ahrensextern nvlist_t *vdev_label_read_config(vdev_t *vd);
127fa9e406ahrensextern void vdev_uberblock_load(zio_t *zio, vdev_t *vd, struct uberblock *ub);
128fa9e406ahrensint vdev_label_init(vdev_t *vd, uint64_t create_txg);
129fa9e406ahrensextern int spa_sync_labels(spa_t *spa, uint64_t txg);
130fa9e406ahrens
131fa9e406ahrens#ifdef	__cplusplus
132fa9e406ahrens}
133fa9e406ahrens#endif
134fa9e406ahrens
135fa9e406ahrens#endif	/* _SYS_VDEV_H */
136