spa.h revision 6ce0521ac291be36119f359237066c4fb8088683
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_SPA_H
#define _SYS_SPA_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/zfs_context.h>
#include <sys/sysmacros.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Forward references that lots of things need.
*/
typedef struct metaslab metaslab_t;
typedef struct traverse_handle traverse_handle_t;
struct dsl_pool;
/*
* General-purpose 32-bit and 64-bit bitfield encodings.
*/
/*
* We currently support nine block sizes, from 512 bytes to 128K.
* We could go higher, but the benefits are near-zero and the cost
* of COWing a giant block to modify one byte would become excessive.
*/
#define SPA_MINBLOCKSHIFT 9
#define SPA_MAXBLOCKSHIFT 17
/*
* The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB.
* The ASIZE encoding should be at least 64 times larger (6 more bits)
* to support up to 4-way RAID-Z mirror mode with worst-case gang block
* overhead, three DVAs per bp, plus one more bit in case we do anything
* else that expands the ASIZE.
*/
/*
* All SPA data is represented by 128-bit data virtual addresses (DVAs).
* The members of the dva_t should be considered opaque outside the SPA.
*/
typedef struct dva {
} dva_t;
/*
* Each block has a 256-bit checksum -- strong enough for cryptographic hashes.
*/
typedef struct zio_cksum {
} zio_cksum_t;
/*
* Each block is described by its DVAs, time of birth, checksum, etc.
* The word-by-word, bit-by-bit layout of the blkptr is as follows:
*
* 64 56 48 40 32 24 16 8 0
* +-------+-------+-------+-------+-------+-------+-------+-------+
* 0 | vdev1 | GRID | ASIZE |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* 1 |G| offset1 |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* 2 | vdev2 | GRID | ASIZE |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* 3 |G| offset2 |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* 4 | vdev3 | GRID | ASIZE |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* 5 |G| offset3 |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* 6 |E| lvl | type | cksum | comp | PSIZE | LSIZE |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* 7 | padding |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* 8 | padding |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* 9 | padding |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* a | birth txg |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* b | fill count |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* c | checksum[0] |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* d | checksum[1] |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* e | checksum[2] |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* f | checksum[3] |
* +-------+-------+-------+-------+-------+-------+-------+-------+
*
* Legend:
*
* vdev virtual device ID
* offset offset into virtual device
* LSIZE logical size
* PSIZE physical size (after compression)
* ASIZE allocated size (including RAID-Z parity and gang block headers)
* GRID RAID-Z layout information (reserved for future use)
* cksum checksum function
* comp compression function
* G gang block indicator
* E endianness
* type DMU object type
* lvl level of indirection
* birth txg transaction group in which the block was born
* fill count number of non-zero blocks under this bp
* checksum[4] 256-bit checksum of the data this bp describes
*/
typedef struct blkptr {
} blkptr_t;
/*
* Macros to get and set fields in a bp or DVA.
*/
#define DVA_GET_ASIZE(dva) \
#define DVA_SET_ASIZE(dva, x) \
#define DVA_GET_OFFSET(dva) \
#define DVA_SET_OFFSET(dva, x) \
#define BP_GET_LSIZE(bp) \
(BP_IS_HOLE(bp) ? 0 : \
#define BP_SET_LSIZE(bp, x) \
#define BP_GET_PSIZE(bp) \
#define BP_SET_PSIZE(bp, x) \
#define BP_GET_ASIZE(bp) \
#define BP_GET_UCSIZE(bp) \
#define BP_GET_NDVAS(bp) \
#define BP_COUNT_GANG(bp) \
{ \
}
{ \
}
/*
* Note: the byteorder is either 0 or -1, both of which are palindromes.
* This simplifies the endianness handling a bit.
*/
#ifdef _BIG_ENDIAN
#define ZFS_HOST_BYTEORDER (0ULL)
#else
#define ZFS_HOST_BYTEORDER (-1ULL)
#endif
#define BP_SPRINTF_LEN 320
#define BP_GET_BUFC_TYPE(bp) \
/*
* Routines found in spa.c
*/
/* state manipulation functions */
extern int spa_destroy(char *pool);
#define SPA_ASYNC_REMOVE 0x01
#define SPA_ASYNC_RESILVER_DONE 0x02
#define SPA_ASYNC_SCRUB 0x04
#define SPA_ASYNC_RESILVER 0x08
#define SPA_ASYNC_CONFIG_UPDATE 0x10
/* device manipulation */
int replacing);
/* spare state (which is global across all pools) */
/* scrubbing */
/* spa syncing */
extern void spa_sync_allpools(void);
/*
* SPA configuration functions in spa_config.c
*/
#define SPA_CONFIG_UPDATE_POOL 0
#define SPA_CONFIG_UPDATE_VDEVS 1
extern void spa_config_sync(void);
extern void spa_config_load(void);
int getstats);
/*
* Miscellaneous SPA routines in spa_misc.c
*/
/* Namespace manipulation */
/* Refcount functions */
/* Pool configuration lock */
/* Accessor functions */
struct metaslab_class;
extern int spa_busy(void);
/* Miscellaneous support routines */
extern char *spa_strdup(const char *);
extern void spa_strfree(char *);
extern void spa_evict_all(void);
/* history logging */
typedef enum history_log_type {
typedef struct history_arg {
const char *ha_history_str;
char ha_zone[MAXPATHLEN];
extern char *spa_his_ievent_table[];
char *his_buf);
/* error handling */
struct zbookmark;
struct zio;
/* Initialization and termination */
extern void spa_fini(void);
/* properties */
/* asynchronous event notification */
#ifdef ZFS_DEBUG
if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
} \
#else
#endif
extern int spa_mode; /* mode, e.g. FREAD | FWRITE */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SPA_H */