xref: /onnv-gate/usr/src/uts/common/fs/zfs/sys/vdev.h (revision 11958)
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 /*
2211422SMark.Musante@Sun.COM  * Copyright 2010 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 *);
5010588SEric.Taylor@Sun.COM extern void vdev_open_children(vdev_t *);
5110588SEric.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 
73*11958SGeorge.Wilson@Sun.COM extern void vdev_hold(vdev_t *);
74*11958SGeorge.Wilson@Sun.COM extern void vdev_rele(vdev_t *);
75*11958SGeorge.Wilson@Sun.COM 
761544Seschrock extern int vdev_metaslab_init(vdev_t *vd, uint64_t txg);
77789Sahrens extern void vdev_metaslab_fini(vdev_t *vd);
789816SGeorge.Wilson@Sun.COM extern void vdev_metaslab_set_size(vdev_t *);
799816SGeorge.Wilson@Sun.COM extern void vdev_expand(vdev_t *vd, uint64_t txg);
8011422SMark.Musante@Sun.COM extern void vdev_split(vdev_t *vd);
8111422SMark.Musante@Sun.COM 
82789Sahrens 
83789Sahrens extern void vdev_get_stats(vdev_t *vd, vdev_stat_t *vs);
845450Sbrendan extern void vdev_clear_stats(vdev_t *vd);
857754SJeff.Bonwick@Sun.COM extern void vdev_stat_update(zio_t *zio, uint64_t psize);
86789Sahrens extern void vdev_scrub_stat_update(vdev_t *vd, pool_scrub_type_t type,
87789Sahrens     boolean_t complete);
881775Sbillm extern void vdev_propagate_state(vdev_t *vd);
891544Seschrock extern void vdev_set_state(vdev_t *vd, boolean_t isopen, vdev_state_t state,
901544Seschrock     vdev_aux_t aux);
91789Sahrens 
9210922SJeff.Bonwick@Sun.COM extern void vdev_space_update(vdev_t *vd,
9310922SJeff.Bonwick@Sun.COM     int64_t alloc_delta, int64_t defer_delta, int64_t space_delta);
94789Sahrens 
95789Sahrens extern uint64_t vdev_psize_to_asize(vdev_t *vd, uint64_t psize);
96789Sahrens 
9710817SEric.Schrock@Sun.COM extern int vdev_fault(spa_t *spa, uint64_t guid, vdev_aux_t aux);
9810817SEric.Schrock@Sun.COM extern int vdev_degrade(spa_t *spa, uint64_t guid, vdev_aux_t aux);
994451Seschrock extern int vdev_online(spa_t *spa, uint64_t guid, uint64_t flags,
1004451Seschrock     vdev_state_t *);
1014451Seschrock extern int vdev_offline(spa_t *spa, uint64_t guid, uint64_t flags);
1027754SJeff.Bonwick@Sun.COM extern void vdev_clear(spa_t *spa, vdev_t *vd);
103789Sahrens 
1047754SJeff.Bonwick@Sun.COM extern boolean_t vdev_is_dead(vdev_t *vd);
1057754SJeff.Bonwick@Sun.COM extern boolean_t vdev_readable(vdev_t *vd);
1067754SJeff.Bonwick@Sun.COM extern boolean_t vdev_writeable(vdev_t *vd);
1077980SGeorge.Wilson@Sun.COM extern boolean_t vdev_allocatable(vdev_t *vd);
1087754SJeff.Bonwick@Sun.COM extern boolean_t vdev_accessible(vdev_t *vd, zio_t *zio);
109789Sahrens 
110789Sahrens extern void vdev_cache_init(vdev_t *vd);
111789Sahrens extern void vdev_cache_fini(vdev_t *vd);
112789Sahrens extern int vdev_cache_read(zio_t *zio);
113789Sahrens extern void vdev_cache_write(zio_t *zio);
1144451Seschrock extern void vdev_cache_purge(vdev_t *vd);
115789Sahrens 
116789Sahrens extern void vdev_queue_init(vdev_t *vd);
117789Sahrens extern void vdev_queue_fini(vdev_t *vd);
118789Sahrens extern zio_t *vdev_queue_io(zio_t *zio);
119789Sahrens extern void vdev_queue_io_done(zio_t *zio);
120789Sahrens 
121789Sahrens extern void vdev_config_dirty(vdev_t *vd);
122789Sahrens extern void vdev_config_clean(vdev_t *vd);
1239725SEric.Schrock@Sun.COM extern int vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg,
1249725SEric.Schrock@Sun.COM     boolean_t);
1257754SJeff.Bonwick@Sun.COM 
1267754SJeff.Bonwick@Sun.COM extern void vdev_state_dirty(vdev_t *vd);
1277754SJeff.Bonwick@Sun.COM extern void vdev_state_clean(vdev_t *vd);
128789Sahrens 
12910594SGeorge.Wilson@Sun.COM extern void vdev_top_config_generate(spa_t *spa, nvlist_t *config);
1302082Seschrock extern nvlist_t *vdev_config_generate(spa_t *spa, vdev_t *vd,
1315450Sbrendan     boolean_t getstats, boolean_t isspare, boolean_t isl2cache);
132789Sahrens 
133789Sahrens /*
134789Sahrens  * Label routines
135789Sahrens  */
136789Sahrens struct uberblock;
137789Sahrens extern uint64_t vdev_label_offset(uint64_t psize, int l, uint64_t offset);
1386615Sgw25295 extern int vdev_label_number(uint64_t psise, uint64_t offset);
139789Sahrens extern nvlist_t *vdev_label_read_config(vdev_t *vd);
140789Sahrens extern void vdev_uberblock_load(zio_t *zio, vdev_t *vd, struct uberblock *ub);
1413377Seschrock 
1423377Seschrock typedef enum {
1433377Seschrock 	VDEV_LABEL_CREATE,	/* create/add a new device */
1443377Seschrock 	VDEV_LABEL_REPLACE,	/* replace an existing device */
1453377Seschrock 	VDEV_LABEL_SPARE,	/* add a new hot spare */
1465450Sbrendan 	VDEV_LABEL_REMOVE,	/* remove an existing device */
14711422SMark.Musante@Sun.COM 	VDEV_LABEL_L2CACHE,	/* add an L2ARC cache device */
14811422SMark.Musante@Sun.COM 	VDEV_LABEL_SPLIT	/* generating new label for split-off dev */
1493377Seschrock } vdev_labeltype_t;
1503377Seschrock 
1513377Seschrock extern int vdev_label_init(vdev_t *vd, uint64_t txg, vdev_labeltype_t reason);
152789Sahrens 
153789Sahrens #ifdef	__cplusplus
154789Sahrens }
155789Sahrens #endif
156789Sahrens 
157789Sahrens #endif	/* _SYS_VDEV_H */
158