FreeBSD ZFS
The Zettabyte File System

sys/vdev.h

Go to the documentation of this file.
00001 /*
00002  * CDDL HEADER START
00003  *
00004  * The contents of this file are subject to the terms of the
00005  * Common Development and Distribution License (the "License").
00006  * You may not use this file except in compliance with the License.
00007  *
00008  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
00009  * or http://www.opensolaris.org/os/licensing.
00010  * See the License for the specific language governing permissions
00011  * and limitations under the License.
00012  *
00013  * When distributing Covered Code, include this CDDL HEADER in each
00014  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
00015  * If applicable, add the following below this CDDL HEADER, with the
00016  * fields enclosed by brackets "[]" replaced with your own identifying
00017  * information: Portions Copyright [yyyy] [name of copyright owner]
00018  *
00019  * CDDL HEADER END
00020  */
00021 
00022 /*
00023  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
00024  * Copyright (c) 2012 by Delphix. All rights reserved.
00025  */
00026 
00027 #ifndef _SYS_VDEV_H
00028 #define _SYS_VDEV_H
00029 
00030 #include <sys/spa.h>
00031 #include <sys/zio.h>
00032 #include <sys/dmu.h>
00033 #include <sys/space_map.h>
00034 #include <sys/fs/zfs.h>
00035 
00036 #ifdef  __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 typedef enum vdev_dtl_type {
00041         DTL_MISSING,    
00042         DTL_PARTIAL,    
00043         DTL_SCRUB,      
00044         DTL_OUTAGE,     
00045         DTL_TYPES
00046 } vdev_dtl_type_t;
00047 
00048 extern boolean_t zfs_nocacheflush;
00049 extern boolean_t zfs_notrim;
00050 
00051 extern int vdev_open(vdev_t *);
00052 extern void vdev_open_children(vdev_t *);
00053 extern boolean_t vdev_uses_zvols(vdev_t *);
00054 extern int vdev_validate(vdev_t *, boolean_t);
00055 extern void vdev_close(vdev_t *);
00056 extern int vdev_create(vdev_t *, uint64_t txg, boolean_t isreplace);
00057 extern void vdev_reopen(vdev_t *);
00058 extern int vdev_validate_aux(vdev_t *vd);
00059 extern zio_t *vdev_probe(vdev_t *vd, zio_t *pio);
00060 
00061 extern boolean_t vdev_is_bootable(vdev_t *vd);
00062 extern vdev_t *vdev_lookup_top(spa_t *spa, uint64_t vdev);
00063 extern vdev_t *vdev_lookup_by_guid(vdev_t *vd, uint64_t guid);
00064 extern void vdev_dtl_dirty(vdev_t *vd, vdev_dtl_type_t d,
00065     uint64_t txg, uint64_t size);
00066 extern boolean_t vdev_dtl_contains(vdev_t *vd, vdev_dtl_type_t d,
00067     uint64_t txg, uint64_t size);
00068 extern boolean_t vdev_dtl_empty(vdev_t *vd, vdev_dtl_type_t d);
00069 extern void vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg,
00070     int scrub_done);
00071 extern boolean_t vdev_dtl_required(vdev_t *vd);
00072 extern boolean_t vdev_resilver_needed(vdev_t *vd,
00073     uint64_t *minp, uint64_t *maxp);
00074 
00075 extern void vdev_hold(vdev_t *);
00076 extern void vdev_rele(vdev_t *);
00077 
00078 extern int vdev_metaslab_init(vdev_t *vd, uint64_t txg);
00079 extern void vdev_metaslab_fini(vdev_t *vd);
00080 extern void vdev_metaslab_set_size(vdev_t *);
00081 extern void vdev_expand(vdev_t *vd, uint64_t txg);
00082 extern void vdev_split(vdev_t *vd);
00083 
00084 
00085 extern void vdev_get_stats(vdev_t *vd, vdev_stat_t *vs);
00086 extern void vdev_clear_stats(vdev_t *vd);
00087 extern void vdev_stat_update(zio_t *zio, uint64_t psize);
00088 extern void vdev_scan_stat_init(vdev_t *vd);
00089 extern void vdev_propagate_state(vdev_t *vd);
00090 extern void vdev_set_state(vdev_t *vd, boolean_t isopen, vdev_state_t state,
00091     vdev_aux_t aux);
00092 
00093 extern void vdev_space_update(vdev_t *vd,
00094     int64_t alloc_delta, int64_t defer_delta, int64_t space_delta);
00095 
00096 extern uint64_t vdev_psize_to_asize(vdev_t *vd, uint64_t psize);
00097 
00098 extern int vdev_fault(spa_t *spa, uint64_t guid, vdev_aux_t aux);
00099 extern int vdev_degrade(spa_t *spa, uint64_t guid, vdev_aux_t aux);
00100 extern int vdev_online(spa_t *spa, uint64_t guid, uint64_t flags,
00101     vdev_state_t *);
00102 extern int vdev_offline(spa_t *spa, uint64_t guid, uint64_t flags);
00103 extern void vdev_clear(spa_t *spa, vdev_t *vd);
00104 
00105 extern boolean_t vdev_is_dead(vdev_t *vd);
00106 extern boolean_t vdev_readable(vdev_t *vd);
00107 extern boolean_t vdev_writeable(vdev_t *vd);
00108 extern boolean_t vdev_allocatable(vdev_t *vd);
00109 extern boolean_t vdev_accessible(vdev_t *vd, zio_t *zio);
00110 
00111 extern void vdev_cache_init(vdev_t *vd);
00112 extern void vdev_cache_fini(vdev_t *vd);
00113 extern int vdev_cache_read(zio_t *zio);
00114 extern void vdev_cache_write(zio_t *zio);
00115 extern void vdev_cache_purge(vdev_t *vd);
00116 
00117 extern void vdev_queue_init(vdev_t *vd);
00118 extern void vdev_queue_fini(vdev_t *vd);
00119 extern zio_t *vdev_queue_io(zio_t *zio);
00120 extern void vdev_queue_io_done(zio_t *zio);
00121 
00122 extern void vdev_config_dirty(vdev_t *vd);
00123 extern void vdev_config_clean(vdev_t *vd);
00124 extern int vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg,
00125     boolean_t);
00126 
00127 extern void vdev_state_dirty(vdev_t *vd);
00128 extern void vdev_state_clean(vdev_t *vd);
00129 
00130 typedef enum vdev_config_flag {
00131         VDEV_CONFIG_SPARE = 1 << 0,
00132         VDEV_CONFIG_L2CACHE = 1 << 1,
00133         VDEV_CONFIG_REMOVING = 1 << 2
00134 } vdev_config_flag_t;
00135 
00136 extern void vdev_top_config_generate(spa_t *spa, nvlist_t *config);
00137 extern nvlist_t *vdev_config_generate(spa_t *spa, vdev_t *vd,
00138     boolean_t getstats, vdev_config_flag_t flags);
00139 
00140 /*
00141  * Label routines
00142  */
00143 struct uberblock;
00144 extern uint64_t vdev_label_offset(uint64_t psize, int l, uint64_t offset);
00145 extern int vdev_label_number(uint64_t psise, uint64_t offset);
00146 extern nvlist_t *vdev_label_read_config(vdev_t *vd, uint64_t txg);
00147 extern void vdev_uberblock_load(vdev_t *, struct uberblock *, nvlist_t **);
00148 
00149 typedef enum {
00150         VDEV_LABEL_CREATE,      
00151         VDEV_LABEL_REPLACE,     
00152         VDEV_LABEL_SPARE,       
00153         VDEV_LABEL_REMOVE,      
00154         VDEV_LABEL_L2CACHE,     
00155         VDEV_LABEL_SPLIT        
00156 } vdev_labeltype_t;
00157 
00158 extern int vdev_label_init(vdev_t *vd, uint64_t txg, vdev_labeltype_t reason);
00159 
00160 #ifdef  __cplusplus
00161 }
00162 #endif
00163 
00164 #endif  /* _SYS_VDEV_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines