1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_FS_ZFS_H 27 #define _SYS_FS_ZFS_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #include <sys/types.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* 38 * Types and constants shared between userland and the kernel. 39 */ 40 41 /* 42 * Each dataset can be one of the following types. These constants can be 43 * combined into masks that can be passed to various functions. 44 */ 45 typedef enum { 46 ZFS_TYPE_FILESYSTEM = 0x1, 47 ZFS_TYPE_SNAPSHOT = 0x2, 48 ZFS_TYPE_VOLUME = 0x4 49 } zfs_type_t; 50 51 #define ZFS_TYPE_ANY \ 52 (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) 53 54 /* 55 * Properties are identified by these constants. They are arranged in order of 56 * how they should be displayed by 'zfs get'. If you make any changes to this 57 * list, be sure to update the property table in usr/src/common/zfs/zfs_prop.c. 58 */ 59 typedef enum { 60 ZFS_PROP_INVAL = -1, 61 ZFS_PROP_TYPE, 62 ZFS_PROP_CREATION, 63 ZFS_PROP_USED, 64 ZFS_PROP_AVAILABLE, 65 ZFS_PROP_REFERENCED, 66 ZFS_PROP_COMPRESSRATIO, 67 ZFS_PROP_MOUNTED, 68 ZFS_PROP_ORIGIN, 69 ZFS_PROP_QUOTA, 70 ZFS_PROP_RESERVATION, 71 ZFS_PROP_VOLSIZE, 72 ZFS_PROP_VOLBLOCKSIZE, 73 ZFS_PROP_RECORDSIZE, 74 ZFS_PROP_MOUNTPOINT, 75 ZFS_PROP_SHARENFS, 76 ZFS_PROP_CHECKSUM, 77 ZFS_PROP_COMPRESSION, 78 ZFS_PROP_ATIME, 79 ZFS_PROP_DEVICES, 80 ZFS_PROP_EXEC, 81 ZFS_PROP_SETUID, 82 ZFS_PROP_READONLY, 83 ZFS_PROP_ZONED, 84 ZFS_PROP_SNAPDIR, 85 ZFS_PROP_ACLMODE, 86 ZFS_PROP_ACLINHERIT, 87 /* 88 * The following properties are not exposed to the user, but are 89 * accessible by libzfs clients. 90 */ 91 ZFS_PROP_CREATETXG, 92 ZFS_PROP_NAME, 93 ZFS_NPROP_ALL 94 } zfs_prop_t; 95 96 #define ZFS_NPROP_VISIBLE ZFS_PROP_CREATETXG 97 98 #define ZFS_PROP_VALUE "value" 99 #define ZFS_PROP_SOURCE "source" 100 101 /* 102 * The following functions are shared between libzfs and the kernel. 103 */ 104 zfs_prop_t zfs_name_to_prop(const char *); 105 int zfs_prop_readonly(zfs_prop_t); 106 const char *zfs_prop_default_string(zfs_prop_t); 107 uint64_t zfs_prop_default_numeric(zfs_prop_t); 108 109 /* 110 * The following are configuration names used in the nvlist describing a pool's 111 * configuration. 112 */ 113 #define ZPOOL_CONFIG_VERSION "version" 114 #define ZPOOL_CONFIG_POOL_NAME "name" 115 #define ZPOOL_CONFIG_POOL_STATE "state" 116 #define ZPOOL_CONFIG_POOL_TXG "txg" 117 #define ZPOOL_CONFIG_POOL_GUID "pool_guid" 118 #define ZPOOL_CONFIG_CREATE_TXG "create_txg" 119 #define ZPOOL_CONFIG_TOP_GUID "top_guid" 120 #define ZPOOL_CONFIG_POOL_HEALTH "pool_health" 121 #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" 122 #define ZPOOL_CONFIG_TYPE "type" 123 #define ZPOOL_CONFIG_CHILDREN "children" 124 #define ZPOOL_CONFIG_ID "id" 125 #define ZPOOL_CONFIG_GUID "guid" 126 #define ZPOOL_CONFIG_PATH "path" 127 #define ZPOOL_CONFIG_DEVID "devid" 128 #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" 129 #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" 130 #define ZPOOL_CONFIG_ASHIFT "ashift" 131 #define ZPOOL_CONFIG_ASIZE "asize" 132 #define ZPOOL_CONFIG_DTL "DTL" 133 #define ZPOOL_CONFIG_STATS "stats" 134 #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" 135 #define ZPOOL_CONFIG_OFFLINE "offline" 136 137 #define VDEV_TYPE_ROOT "root" 138 #define VDEV_TYPE_MIRROR "mirror" 139 #define VDEV_TYPE_REPLACING "replacing" 140 #define VDEV_TYPE_RAIDZ "raidz" 141 #define VDEV_TYPE_DISK "disk" 142 #define VDEV_TYPE_FILE "file" 143 #define VDEV_TYPE_MISSING "missing" 144 145 /* 146 * This is needed in userland to report the minimum necessary device size. 147 */ 148 #define SPA_MINDEVSIZE (64ULL << 20) 149 150 /* 151 * The location of the pool configuration repository, shared between kernel and 152 * userland. 153 */ 154 #define ZPOOL_CACHE_DIR "/etc/zfs" 155 #define ZPOOL_CACHE_FILE "zpool.cache" 156 #define ZPOOL_CACHE_TMP ".zpool.cache" 157 158 #define ZPOOL_CACHE ZPOOL_CACHE_DIR "/" ZPOOL_CACHE_FILE 159 160 /* 161 * vdev states are ordered from least to most healthy. 162 * A vdev that's CANT_OPEN or below is considered unusable. 163 */ 164 typedef enum vdev_state { 165 VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ 166 VDEV_STATE_CLOSED, /* Not currently open */ 167 VDEV_STATE_OFFLINE, /* Not allowed to open */ 168 VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ 169 VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ 170 VDEV_STATE_HEALTHY /* Presumed good */ 171 } vdev_state_t; 172 173 /* 174 * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field 175 * of the vdev stats structure uses these constants to distinguish why. 176 */ 177 typedef enum vdev_aux { 178 VDEV_AUX_NONE, /* no error */ 179 VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ 180 VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ 181 VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ 182 VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ 183 VDEV_AUX_TOO_SMALL, /* vdev size is too small */ 184 VDEV_AUX_BAD_LABEL /* the label is OK but invalid */ 185 } vdev_aux_t; 186 187 /* 188 * pool state. The following states are written to disk as part of the normal 189 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED. The remaining states are 190 * software abstractions used at various levels to communicate pool state. 191 */ 192 typedef enum pool_state { 193 POOL_STATE_ACTIVE = 0, /* In active use */ 194 POOL_STATE_EXPORTED, /* Explicitly exported */ 195 POOL_STATE_DESTROYED, /* Explicitly destroyed */ 196 POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ 197 POOL_STATE_UNAVAIL, /* Internal libzfs state */ 198 POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ 199 } pool_state_t; 200 201 /* 202 * Scrub types. 203 */ 204 typedef enum pool_scrub_type { 205 POOL_SCRUB_NONE, 206 POOL_SCRUB_RESILVER, 207 POOL_SCRUB_EVERYTHING, 208 POOL_SCRUB_TYPES 209 } pool_scrub_type_t; 210 211 /* 212 * ZIO types. Needed to interpret vdev statistics below. 213 */ 214 typedef enum zio_type { 215 ZIO_TYPE_NULL = 0, 216 ZIO_TYPE_READ, 217 ZIO_TYPE_WRITE, 218 ZIO_TYPE_FREE, 219 ZIO_TYPE_CLAIM, 220 ZIO_TYPE_IOCTL, 221 ZIO_TYPES 222 } zio_type_t; 223 224 /* 225 * Vdev statistics. Note: all fields should be 64-bit because this 226 * is passed between kernel and userland as an nvlist uint64 array. 227 */ 228 typedef struct vdev_stat { 229 hrtime_t vs_timestamp; /* time since vdev load */ 230 uint64_t vs_state; /* vdev state */ 231 uint64_t vs_aux; /* see vdev_aux_t */ 232 uint64_t vs_alloc; /* space allocated */ 233 uint64_t vs_space; /* total capacity */ 234 uint64_t vs_rsize; /* replaceable dev size */ 235 uint64_t vs_ops[ZIO_TYPES]; /* operation count */ 236 uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */ 237 uint64_t vs_read_errors; /* read errors */ 238 uint64_t vs_write_errors; /* write errors */ 239 uint64_t vs_checksum_errors; /* checksum errors */ 240 uint64_t vs_self_healed; /* self-healed bytes */ 241 uint64_t vs_scrub_type; /* pool_scrub_type_t */ 242 uint64_t vs_scrub_complete; /* completed? */ 243 uint64_t vs_scrub_examined; /* bytes examined; top */ 244 uint64_t vs_scrub_repaired; /* bytes repaired; leaf */ 245 uint64_t vs_scrub_errors; /* errors during scrub */ 246 uint64_t vs_scrub_start; /* UTC scrub start time */ 247 uint64_t vs_scrub_end; /* UTC scrub end time */ 248 } vdev_stat_t; 249 250 #define ZFS_DRIVER "zfs" 251 #define ZFS_DEV "/dev/zfs" 252 253 /* 254 * zvol paths. Irritatingly, the devfsadm interfaces want all these 255 * paths without the /dev prefix, but for some things, we want the 256 * /dev prefix. Below are the names without /dev. 257 */ 258 #define ZVOL_DEV_DIR "zvol/dsk" 259 #define ZVOL_RDEV_DIR "zvol/rdsk" 260 261 /* 262 * And here are the things we need with /dev, etc. in front of them. 263 */ 264 #define ZVOL_PSEUDO_DEV "/devices/pseudo/zvol@0:" 265 #define ZVOL_FULL_DEV_DIR "/dev/" ZVOL_DEV_DIR 266 267 #define ZVOL_PROP_NAME "name" 268 269 /* 270 * /dev/zfs ioctl numbers. 271 */ 272 #define ZFS_IOC ('Z' << 8) 273 274 typedef enum zfs_ioc { 275 ZFS_IOC_POOL_CREATE = ZFS_IOC, 276 ZFS_IOC_POOL_DESTROY, 277 ZFS_IOC_POOL_IMPORT, 278 ZFS_IOC_POOL_EXPORT, 279 ZFS_IOC_POOL_CONFIGS, 280 ZFS_IOC_POOL_GUID, 281 ZFS_IOC_POOL_STATS, 282 ZFS_IOC_POOL_TRYIMPORT, 283 ZFS_IOC_POOL_SCRUB, 284 ZFS_IOC_POOL_FREEZE, 285 ZFS_IOC_VDEV_ADD, 286 ZFS_IOC_VDEV_REMOVE, 287 ZFS_IOC_VDEV_ONLINE, 288 ZFS_IOC_VDEV_OFFLINE, 289 ZFS_IOC_VDEV_ATTACH, 290 ZFS_IOC_VDEV_DETACH, 291 ZFS_IOC_VDEV_SETPATH, 292 ZFS_IOC_OBJSET_STATS, 293 ZFS_IOC_DATASET_LIST_NEXT, 294 ZFS_IOC_SNAPSHOT_LIST_NEXT, 295 ZFS_IOC_SET_PROP, 296 ZFS_IOC_SET_QUOTA, 297 ZFS_IOC_SET_RESERVATION, 298 ZFS_IOC_SET_VOLSIZE, 299 ZFS_IOC_SET_VOLBLOCKSIZE, 300 ZFS_IOC_CREATE_MINOR, 301 ZFS_IOC_REMOVE_MINOR, 302 ZFS_IOC_CREATE, 303 ZFS_IOC_DESTROY, 304 ZFS_IOC_ROLLBACK, 305 ZFS_IOC_RENAME, 306 ZFS_IOC_RECVBACKUP, 307 ZFS_IOC_SENDBACKUP 308 } zfs_ioc_t; 309 310 #ifdef __cplusplus 311 } 312 #endif 313 314 #endif /* _SYS_FS_ZFS_H */ 315