xref: /onnv-gate/usr/src/uts/common/fs/zfs/sys/vdev.h (revision 8241)
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 /*
226615Sgw25295  * Copyright 2008 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 
39*8241SJeff.Bonwick@Sun.COM typedef enum vdev_dtl_type {
40*8241SJeff.Bonwick@Sun.COM 	DTL_MISSING,	/* 0% replication: no copies of the data */
41*8241SJeff.Bonwick@Sun.COM 	DTL_PARTIAL,	/* less than 100% replication: some copies missing */
42*8241SJeff.Bonwick@Sun.COM 	DTL_SCRUB,	/* unable to fully repair during scrub/resilver */
43*8241SJeff.Bonwick@Sun.COM 	DTL_OUTAGE,	/* temporarily missing (used to attempt detach) */
44*8241SJeff.Bonwick@Sun.COM 	DTL_TYPES
45*8241SJeff.Bonwick@Sun.COM } vdev_dtl_type_t;
46*8241SJeff.Bonwick@Sun.COM 
472986Sek110237 extern boolean_t zfs_nocacheflush;
482986Sek110237 
49789Sahrens extern int vdev_open(vdev_t *);
501986Seschrock extern int vdev_validate(vdev_t *);
51789Sahrens extern void vdev_close(vdev_t *);
522082Seschrock extern int vdev_create(vdev_t *, uint64_t txg, boolean_t isreplace);
531585Sbonwick extern void vdev_init(vdev_t *, uint64_t txg);
541544Seschrock extern void vdev_reopen(vdev_t *);
555450Sbrendan extern int vdev_validate_aux(vdev_t *vd);
567754SJeff.Bonwick@Sun.COM extern zio_t *vdev_probe(vdev_t *vd, zio_t *pio);
57789Sahrens 
587042Sgw25295 extern boolean_t vdev_is_bootable(vdev_t *vd);
59789Sahrens extern vdev_t *vdev_lookup_top(spa_t *spa, uint64_t vdev);
60789Sahrens extern vdev_t *vdev_lookup_by_guid(vdev_t *vd, uint64_t guid);
61*8241SJeff.Bonwick@Sun.COM extern void vdev_dtl_dirty(vdev_t *vd, vdev_dtl_type_t d,
62*8241SJeff.Bonwick@Sun.COM     uint64_t txg, uint64_t size);
63*8241SJeff.Bonwick@Sun.COM extern boolean_t vdev_dtl_contains(vdev_t *vd, vdev_dtl_type_t d,
64*8241SJeff.Bonwick@Sun.COM     uint64_t txg, uint64_t size);
65*8241SJeff.Bonwick@Sun.COM extern boolean_t vdev_dtl_empty(vdev_t *vd, vdev_dtl_type_t d);
66789Sahrens extern void vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg,
67789Sahrens     int scrub_done);
68*8241SJeff.Bonwick@Sun.COM extern boolean_t vdev_dtl_required(vdev_t *vd);
697046Sahrens extern boolean_t vdev_resilver_needed(vdev_t *vd,
707046Sahrens     uint64_t *minp, uint64_t *maxp);
71789Sahrens 
721544Seschrock extern int vdev_metaslab_init(vdev_t *vd, uint64_t txg);
73789Sahrens extern void vdev_metaslab_fini(vdev_t *vd);
74789Sahrens 
75789Sahrens extern void vdev_get_stats(vdev_t *vd, vdev_stat_t *vs);
765450Sbrendan extern void vdev_clear_stats(vdev_t *vd);
777754SJeff.Bonwick@Sun.COM extern void vdev_stat_update(zio_t *zio, uint64_t psize);
78789Sahrens extern void vdev_scrub_stat_update(vdev_t *vd, pool_scrub_type_t type,
79789Sahrens     boolean_t complete);
80789Sahrens extern int vdev_getspec(spa_t *spa, uint64_t vdev, char **vdev_spec);
811775Sbillm extern void vdev_propagate_state(vdev_t *vd);
821544Seschrock extern void vdev_set_state(vdev_t *vd, boolean_t isopen, vdev_state_t state,
831544Seschrock     vdev_aux_t aux);
84789Sahrens 
852082Seschrock extern void vdev_space_update(vdev_t *vd, int64_t space_delta,
865450Sbrendan     int64_t alloc_delta, boolean_t update_root);
87789Sahrens 
88789Sahrens extern uint64_t vdev_psize_to_asize(vdev_t *vd, uint64_t psize);
89789Sahrens 
904451Seschrock extern int vdev_fault(spa_t *spa, uint64_t guid);
914451Seschrock extern int vdev_degrade(spa_t *spa, uint64_t guid);
924451Seschrock extern int vdev_online(spa_t *spa, uint64_t guid, uint64_t flags,
934451Seschrock     vdev_state_t *);
944451Seschrock extern int vdev_offline(spa_t *spa, uint64_t guid, uint64_t flags);
957754SJeff.Bonwick@Sun.COM extern void vdev_clear(spa_t *spa, vdev_t *vd);
96789Sahrens 
977754SJeff.Bonwick@Sun.COM extern boolean_t vdev_is_dead(vdev_t *vd);
987754SJeff.Bonwick@Sun.COM extern boolean_t vdev_readable(vdev_t *vd);
997754SJeff.Bonwick@Sun.COM extern boolean_t vdev_writeable(vdev_t *vd);
1007980SGeorge.Wilson@Sun.COM extern boolean_t vdev_allocatable(vdev_t *vd);
1017754SJeff.Bonwick@Sun.COM extern boolean_t vdev_accessible(vdev_t *vd, zio_t *zio);
102789Sahrens 
103789Sahrens extern void vdev_cache_init(vdev_t *vd);
104789Sahrens extern void vdev_cache_fini(vdev_t *vd);
105789Sahrens extern int vdev_cache_read(zio_t *zio);
106789Sahrens extern void vdev_cache_write(zio_t *zio);
1074451Seschrock extern void vdev_cache_purge(vdev_t *vd);
108789Sahrens 
109789Sahrens extern void vdev_queue_init(vdev_t *vd);
110789Sahrens extern void vdev_queue_fini(vdev_t *vd);
111789Sahrens extern zio_t *vdev_queue_io(zio_t *zio);
112789Sahrens extern void vdev_queue_io_done(zio_t *zio);
113789Sahrens 
114789Sahrens extern void vdev_config_dirty(vdev_t *vd);
115789Sahrens extern void vdev_config_clean(vdev_t *vd);
1167754SJeff.Bonwick@Sun.COM extern int vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg);
1177754SJeff.Bonwick@Sun.COM 
1187754SJeff.Bonwick@Sun.COM extern void vdev_state_dirty(vdev_t *vd);
1197754SJeff.Bonwick@Sun.COM extern void vdev_state_clean(vdev_t *vd);
120789Sahrens 
1212082Seschrock extern nvlist_t *vdev_config_generate(spa_t *spa, vdev_t *vd,
1225450Sbrendan     boolean_t getstats, boolean_t isspare, boolean_t isl2cache);
123789Sahrens 
124789Sahrens /*
125789Sahrens  * Label routines
126789Sahrens  */
127789Sahrens struct uberblock;
128789Sahrens extern uint64_t vdev_label_offset(uint64_t psize, int l, uint64_t offset);
1296615Sgw25295 extern int vdev_label_number(uint64_t psise, uint64_t offset);
130789Sahrens extern nvlist_t *vdev_label_read_config(vdev_t *vd);
131789Sahrens extern void vdev_uberblock_load(zio_t *zio, vdev_t *vd, struct uberblock *ub);
1323377Seschrock 
1333377Seschrock typedef enum {
1343377Seschrock 	VDEV_LABEL_CREATE,	/* create/add a new device */
1353377Seschrock 	VDEV_LABEL_REPLACE,	/* replace an existing device */
1363377Seschrock 	VDEV_LABEL_SPARE,	/* add a new hot spare */
1375450Sbrendan 	VDEV_LABEL_REMOVE,	/* remove an existing device */
1385450Sbrendan 	VDEV_LABEL_L2CACHE	/* add an L2ARC cache device */
1393377Seschrock } vdev_labeltype_t;
1403377Seschrock 
1413377Seschrock extern int vdev_label_init(vdev_t *vd, uint64_t txg, vdev_labeltype_t reason);
142789Sahrens 
143789Sahrens #ifdef	__cplusplus
144789Sahrens }
145789Sahrens #endif
146789Sahrens 
147789Sahrens #endif	/* _SYS_VDEV_H */
148