xref: /onnv-gate/usr/src/uts/common/fs/zfs/sys/vdev.h (revision 10588)
1789Sahrens /*
2789Sahrens  * CDDL HEADER START
3789Sahrens  *
4789Sahrens  * The contents of this file are subject to the terms of the
51485Slling  * Common Development and Distribution License (the "License").
61485Slling  * You may not use this file except in compliance with the License.
7789Sahrens  *
8789Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9789Sahrens  * or http://www.opensolaris.org/os/licensing.
10789Sahrens  * See the License for the specific language governing permissions
11789Sahrens  * and limitations under the License.
12789Sahrens  *
13789Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14789Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15789Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16789Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17789Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18789Sahrens  *
19789Sahrens  * CDDL HEADER END
20789Sahrens  */
21789Sahrens /*
229725SEric.Schrock@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23789Sahrens  * Use is subject to license terms.
24789Sahrens  */
25789Sahrens 
26789Sahrens #ifndef _SYS_VDEV_H
27789Sahrens #define	_SYS_VDEV_H
28789Sahrens 
29789Sahrens #include <sys/spa.h>
30789Sahrens #include <sys/zio.h>
31789Sahrens #include <sys/dmu.h>
32789Sahrens #include <sys/space_map.h>
33789Sahrens #include <sys/fs/zfs.h>
34789Sahrens 
35789Sahrens #ifdef	__cplusplus
36789Sahrens extern "C" {
37789Sahrens #endif
38789Sahrens 
398241SJeff.Bonwick@Sun.COM typedef enum vdev_dtl_type {
408241SJeff.Bonwick@Sun.COM 	DTL_MISSING,	/* 0% replication: no copies of the data */
418241SJeff.Bonwick@Sun.COM 	DTL_PARTIAL,	/* less than 100% replication: some copies missing */
428241SJeff.Bonwick@Sun.COM 	DTL_SCRUB,	/* unable to fully repair during scrub/resilver */
438241SJeff.Bonwick@Sun.COM 	DTL_OUTAGE,	/* temporarily missing (used to attempt detach) */
448241SJeff.Bonwick@Sun.COM 	DTL_TYPES
458241SJeff.Bonwick@Sun.COM } vdev_dtl_type_t;
468241SJeff.Bonwick@Sun.COM 
472986Sek110237 extern boolean_t zfs_nocacheflush;
482986Sek110237 
49789Sahrens extern int vdev_open(vdev_t *);
50*10588SEric.Taylor@Sun.COM extern void vdev_open_children(vdev_t *);
51*10588SEric.Taylor@Sun.COM extern boolean_t vdev_uses_zvols(vdev_t *);
521986Seschrock extern int vdev_validate(vdev_t *);
53789Sahrens extern void vdev_close(vdev_t *);
542082Seschrock extern int vdev_create(vdev_t *, uint64_t txg, boolean_t isreplace);
551544Seschrock extern void vdev_reopen(vdev_t *);
565450Sbrendan extern int vdev_validate_aux(vdev_t *vd);
577754SJeff.Bonwick@Sun.COM extern zio_t *vdev_probe(vdev_t *vd, zio_t *pio);
58789Sahrens 
597042Sgw25295 extern boolean_t vdev_is_bootable(vdev_t *vd);
60789Sahrens extern vdev_t *vdev_lookup_top(spa_t *spa, uint64_t vdev);
61789Sahrens extern vdev_t *vdev_lookup_by_guid(vdev_t *vd, uint64_t guid);
628241SJeff.Bonwick@Sun.COM extern void vdev_dtl_dirty(vdev_t *vd, vdev_dtl_type_t d,
638241SJeff.Bonwick@Sun.COM     uint64_t txg, uint64_t size);
648241SJeff.Bonwick@Sun.COM extern boolean_t vdev_dtl_contains(vdev_t *vd, vdev_dtl_type_t d,
658241SJeff.Bonwick@Sun.COM     uint64_t txg, uint64_t size);
668241SJeff.Bonwick@Sun.COM extern boolean_t vdev_dtl_empty(vdev_t *vd, vdev_dtl_type_t d);
67789Sahrens extern void vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg,
68789Sahrens     int scrub_done);
698241SJeff.Bonwick@Sun.COM extern boolean_t vdev_dtl_required(vdev_t *vd);
707046Sahrens extern boolean_t vdev_resilver_needed(vdev_t *vd,
717046Sahrens     uint64_t *minp, uint64_t *maxp);
72789Sahrens 
731544Seschrock extern int vdev_metaslab_init(vdev_t *vd, uint64_t txg);
74789Sahrens extern void vdev_metaslab_fini(vdev_t *vd);
759816SGeorge.Wilson@Sun.COM extern void vdev_metaslab_set_size(vdev_t *);
769816SGeorge.Wilson@Sun.COM extern void vdev_expand(vdev_t *vd, uint64_t txg);
77789Sahrens 
78789Sahrens extern void vdev_get_stats(vdev_t *vd, vdev_stat_t *vs);
795450Sbrendan extern void vdev_clear_stats(vdev_t *vd);
807754SJeff.Bonwick@Sun.COM extern void vdev_stat_update(zio_t *zio, uint64_t psize);
81789Sahrens extern void vdev_scrub_stat_update(vdev_t *vd, pool_scrub_type_t type,
82789Sahrens     boolean_t complete);
83789Sahrens extern int vdev_getspec(spa_t *spa, uint64_t vdev, char **vdev_spec);
841775Sbillm extern void vdev_propagate_state(vdev_t *vd);
851544Seschrock extern void vdev_set_state(vdev_t *vd, boolean_t isopen, vdev_state_t state,
861544Seschrock     vdev_aux_t aux);
87789Sahrens 
882082Seschrock extern void vdev_space_update(vdev_t *vd, int64_t space_delta,
895450Sbrendan     int64_t alloc_delta, boolean_t update_root);
90789Sahrens 
91789Sahrens extern uint64_t vdev_psize_to_asize(vdev_t *vd, uint64_t psize);
92789Sahrens 
934451Seschrock extern int vdev_fault(spa_t *spa, uint64_t guid);
944451Seschrock extern int vdev_degrade(spa_t *spa, uint64_t guid);
954451Seschrock extern int vdev_online(spa_t *spa, uint64_t guid, uint64_t flags,
964451Seschrock     vdev_state_t *);
974451Seschrock extern int vdev_offline(spa_t *spa, uint64_t guid, uint64_t flags);
987754SJeff.Bonwick@Sun.COM extern void vdev_clear(spa_t *spa, vdev_t *vd);
99789Sahrens 
1007754SJeff.Bonwick@Sun.COM extern boolean_t vdev_is_dead(vdev_t *vd);
1017754SJeff.Bonwick@Sun.COM extern boolean_t vdev_readable(vdev_t *vd);
1027754SJeff.Bonwick@Sun.COM extern boolean_t vdev_writeable(vdev_t *vd);
1037980SGeorge.Wilson@Sun.COM extern boolean_t vdev_allocatable(vdev_t *vd);
1047754SJeff.Bonwick@Sun.COM extern boolean_t vdev_accessible(vdev_t *vd, zio_t *zio);
105789Sahrens 
106789Sahrens extern void vdev_cache_init(vdev_t *vd);
107789Sahrens extern void vdev_cache_fini(vdev_t *vd);
108789Sahrens extern int vdev_cache_read(zio_t *zio);
109789Sahrens extern void vdev_cache_write(zio_t *zio);
1104451Seschrock extern void vdev_cache_purge(vdev_t *vd);
111789Sahrens 
112789Sahrens extern void vdev_queue_init(vdev_t *vd);
113789Sahrens extern void vdev_queue_fini(vdev_t *vd);
114789Sahrens extern zio_t *vdev_queue_io(zio_t *zio);
115789Sahrens extern void vdev_queue_io_done(zio_t *zio);
116789Sahrens 
117789Sahrens extern void vdev_config_dirty(vdev_t *vd);
118789Sahrens extern void vdev_config_clean(vdev_t *vd);
1199725SEric.Schrock@Sun.COM extern int vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg,
1209725SEric.Schrock@Sun.COM     boolean_t);
1217754SJeff.Bonwick@Sun.COM 
1227754SJeff.Bonwick@Sun.COM extern void vdev_state_dirty(vdev_t *vd);
1237754SJeff.Bonwick@Sun.COM extern void vdev_state_clean(vdev_t *vd);
124789Sahrens 
1252082Seschrock extern nvlist_t *vdev_config_generate(spa_t *spa, vdev_t *vd,
1265450Sbrendan     boolean_t getstats, boolean_t isspare, boolean_t isl2cache);
127789Sahrens 
128789Sahrens /*
129789Sahrens  * Label routines
130789Sahrens  */
131789Sahrens struct uberblock;
132789Sahrens extern uint64_t vdev_label_offset(uint64_t psize, int l, uint64_t offset);
1336615Sgw25295 extern int vdev_label_number(uint64_t psise, uint64_t offset);
134789Sahrens extern nvlist_t *vdev_label_read_config(vdev_t *vd);
135789Sahrens extern void vdev_uberblock_load(zio_t *zio, vdev_t *vd, struct uberblock *ub);
1363377Seschrock 
1373377Seschrock typedef enum {
1383377Seschrock 	VDEV_LABEL_CREATE,	/* create/add a new device */
1393377Seschrock 	VDEV_LABEL_REPLACE,	/* replace an existing device */
1403377Seschrock 	VDEV_LABEL_SPARE,	/* add a new hot spare */
1415450Sbrendan 	VDEV_LABEL_REMOVE,	/* remove an existing device */
1425450Sbrendan 	VDEV_LABEL_L2CACHE	/* add an L2ARC cache device */
1433377Seschrock } vdev_labeltype_t;
1443377Seschrock 
1453377Seschrock extern int vdev_label_init(vdev_t *vd, uint64_t txg, vdev_labeltype_t reason);
146789Sahrens 
147789Sahrens #ifdef	__cplusplus
148789Sahrens }
149789Sahrens #endif
150789Sahrens 
151789Sahrens #endif	/* _SYS_VDEV_H */
152