mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
Update core ZFS code from build 121 to build 141.
This commit is contained in:
@@ -20,10 +20,11 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/* Portions Copyright 2010 Robert Milkowski */
|
||||
|
||||
#ifndef _SYS_FS_ZFS_H
|
||||
#define _SYS_FS_ZFS_H
|
||||
|
||||
@@ -86,12 +87,11 @@ typedef enum {
|
||||
ZFS_PROP_READONLY,
|
||||
ZFS_PROP_ZONED,
|
||||
ZFS_PROP_SNAPDIR,
|
||||
ZFS_PROP_ACLMODE,
|
||||
ZFS_PROP_PRIVATE, /* not exposed to user, temporary */
|
||||
ZFS_PROP_ACLINHERIT,
|
||||
ZFS_PROP_CREATETXG, /* not exposed to the user */
|
||||
ZFS_PROP_NAME, /* not exposed to the user */
|
||||
ZFS_PROP_CANMOUNT,
|
||||
ZFS_PROP_SHAREISCSI,
|
||||
ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */
|
||||
ZFS_PROP_XATTR,
|
||||
ZFS_PROP_NUMCLONES, /* not exposed to the user */
|
||||
@@ -116,6 +116,12 @@ typedef enum {
|
||||
ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */
|
||||
ZFS_PROP_DEFER_DESTROY,
|
||||
ZFS_PROP_USERREFS,
|
||||
ZFS_PROP_LOGBIAS,
|
||||
ZFS_PROP_UNIQUE, /* not exposed to the user */
|
||||
ZFS_PROP_OBJSETID, /* not exposed to the user */
|
||||
ZFS_PROP_DEDUP,
|
||||
ZFS_PROP_MLSLABEL,
|
||||
ZFS_PROP_SYNC,
|
||||
ZFS_NUM_PROPS
|
||||
} zfs_prop_t;
|
||||
|
||||
@@ -138,8 +144,6 @@ extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
|
||||
typedef enum {
|
||||
ZPOOL_PROP_NAME,
|
||||
ZPOOL_PROP_SIZE,
|
||||
ZPOOL_PROP_USED,
|
||||
ZPOOL_PROP_AVAILABLE,
|
||||
ZPOOL_PROP_CAPACITY,
|
||||
ZPOOL_PROP_ALTROOT,
|
||||
ZPOOL_PROP_HEALTH,
|
||||
@@ -152,6 +156,10 @@ typedef enum {
|
||||
ZPOOL_PROP_FAILUREMODE,
|
||||
ZPOOL_PROP_LISTSNAPS,
|
||||
ZPOOL_PROP_AUTOEXPAND,
|
||||
ZPOOL_PROP_DEDUPDITTO,
|
||||
ZPOOL_PROP_DEDUPRATIO,
|
||||
ZPOOL_PROP_FREE,
|
||||
ZPOOL_PROP_ALLOCATED,
|
||||
ZPOOL_NUM_PROPS
|
||||
} zpool_prop_t;
|
||||
|
||||
@@ -166,10 +174,27 @@ typedef enum {
|
||||
ZPROP_SRC_DEFAULT = 0x2,
|
||||
ZPROP_SRC_TEMPORARY = 0x4,
|
||||
ZPROP_SRC_LOCAL = 0x8,
|
||||
ZPROP_SRC_INHERITED = 0x10
|
||||
ZPROP_SRC_INHERITED = 0x10,
|
||||
ZPROP_SRC_RECEIVED = 0x20
|
||||
} zprop_source_t;
|
||||
|
||||
#define ZPROP_SRC_ALL 0x1f
|
||||
#define ZPROP_SRC_ALL 0x3f
|
||||
|
||||
#define ZPROP_SOURCE_VAL_RECVD "$recvd"
|
||||
#define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS"
|
||||
/*
|
||||
* Dataset flag implemented as a special entry in the props zap object
|
||||
* indicating that the dataset has received properties on or after
|
||||
* SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
|
||||
* just as it did in earlier versions, and thereafter, local properties are
|
||||
* preserved.
|
||||
*/
|
||||
#define ZPROP_HAS_RECVD "$hasrecvd"
|
||||
|
||||
typedef enum {
|
||||
ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
|
||||
ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
|
||||
} zprop_errflags_t;
|
||||
|
||||
typedef int (*zprop_func)(int, void *);
|
||||
|
||||
@@ -191,9 +216,10 @@ boolean_t zfs_prop_setonce(zfs_prop_t);
|
||||
const char *zfs_prop_to_name(zfs_prop_t);
|
||||
zfs_prop_t zfs_name_to_prop(const char *);
|
||||
boolean_t zfs_prop_user(const char *);
|
||||
boolean_t zfs_prop_userquota(const char *name);
|
||||
boolean_t zfs_prop_userquota(const char *);
|
||||
int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
|
||||
int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
|
||||
uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
|
||||
boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
|
||||
|
||||
/*
|
||||
@@ -206,6 +232,7 @@ uint64_t zpool_prop_default_numeric(zpool_prop_t);
|
||||
boolean_t zpool_prop_readonly(zpool_prop_t);
|
||||
int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
|
||||
int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
|
||||
uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
|
||||
|
||||
/*
|
||||
* Definitions for the Delegation.
|
||||
@@ -236,6 +263,8 @@ typedef enum {
|
||||
#define ZFS_DELEG_PERM_GID "gid"
|
||||
#define ZFS_DELEG_PERM_GROUPS "groups"
|
||||
|
||||
#define ZFS_MLSLABEL_DEFAULT "none"
|
||||
|
||||
#define ZFS_SMB_ACL_SRC "src"
|
||||
#define ZFS_SMB_ACL_TARGET "target"
|
||||
|
||||
@@ -245,6 +274,11 @@ typedef enum {
|
||||
ZFS_CANMOUNT_NOAUTO = 2
|
||||
} zfs_canmount_type_t;
|
||||
|
||||
typedef enum {
|
||||
ZFS_LOGBIAS_LATENCY = 0,
|
||||
ZFS_LOGBIAS_THROUGHPUT = 1
|
||||
} zfs_logbias_op_t;
|
||||
|
||||
typedef enum zfs_share_op {
|
||||
ZFS_SHARE_NFS = 0,
|
||||
ZFS_UNSHARE_NFS = 1,
|
||||
@@ -265,6 +299,12 @@ typedef enum zfs_cache_type {
|
||||
ZFS_CACHE_ALL = 2
|
||||
} zfs_cache_type_t;
|
||||
|
||||
typedef enum {
|
||||
ZFS_SYNC_STANDARD = 0,
|
||||
ZFS_SYNC_ALWAYS = 1,
|
||||
ZFS_SYNC_DISABLED = 2
|
||||
} zfs_sync_type_t;
|
||||
|
||||
|
||||
/*
|
||||
* On-disk version number.
|
||||
@@ -287,14 +327,22 @@ typedef enum zfs_cache_type {
|
||||
#define SPA_VERSION_16 16ULL
|
||||
#define SPA_VERSION_17 17ULL
|
||||
#define SPA_VERSION_18 18ULL
|
||||
#define SPA_VERSION_19 19ULL
|
||||
#define SPA_VERSION_20 20ULL
|
||||
#define SPA_VERSION_21 21ULL
|
||||
#define SPA_VERSION_22 22ULL
|
||||
#define SPA_VERSION_23 23ULL
|
||||
#define SPA_VERSION_24 24ULL
|
||||
#define SPA_VERSION_25 25ULL
|
||||
#define SPA_VERSION_26 26ULL
|
||||
/*
|
||||
* When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
|
||||
* format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
|
||||
* and do the appropriate changes. Also bump the version number in
|
||||
* usr/src/grub/capability.
|
||||
*/
|
||||
#define SPA_VERSION SPA_VERSION_18
|
||||
#define SPA_VERSION_STRING "18"
|
||||
#define SPA_VERSION SPA_VERSION_26
|
||||
#define SPA_VERSION_STRING "26"
|
||||
|
||||
/*
|
||||
* Symbolic names for the changes that caused a SPA_VERSION switch.
|
||||
@@ -311,7 +359,7 @@ typedef enum zfs_cache_type {
|
||||
#define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2
|
||||
#define SPA_VERSION_SPARES SPA_VERSION_3
|
||||
#define SPA_VERSION_RAIDZ2 SPA_VERSION_3
|
||||
#define SPA_VERSION_BPLIST_ACCOUNT SPA_VERSION_3
|
||||
#define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3
|
||||
#define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3
|
||||
#define SPA_VERSION_DNODE_BYTES SPA_VERSION_3
|
||||
#define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4
|
||||
@@ -334,6 +382,15 @@ typedef enum zfs_cache_type {
|
||||
#define SPA_VERSION_STMF_PROP SPA_VERSION_16
|
||||
#define SPA_VERSION_RAIDZ3 SPA_VERSION_17
|
||||
#define SPA_VERSION_USERREFS SPA_VERSION_18
|
||||
#define SPA_VERSION_HOLES SPA_VERSION_19
|
||||
#define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20
|
||||
#define SPA_VERSION_DEDUP SPA_VERSION_21
|
||||
#define SPA_VERSION_RECVD_PROPS SPA_VERSION_22
|
||||
#define SPA_VERSION_SLIM_ZIL SPA_VERSION_23
|
||||
#define SPA_VERSION_SA SPA_VERSION_24
|
||||
#define SPA_VERSION_SCAN SPA_VERSION_25
|
||||
#define SPA_VERSION_DIR_CLONES SPA_VERSION_26
|
||||
#define SPA_VERSION_DEADLISTS SPA_VERSION_26
|
||||
|
||||
/*
|
||||
* ZPL version - rev'd whenever an incompatible on-disk format change
|
||||
@@ -347,8 +404,9 @@ typedef enum zfs_cache_type {
|
||||
#define ZPL_VERSION_2 2ULL
|
||||
#define ZPL_VERSION_3 3ULL
|
||||
#define ZPL_VERSION_4 4ULL
|
||||
#define ZPL_VERSION ZPL_VERSION_4
|
||||
#define ZPL_VERSION_STRING "4"
|
||||
#define ZPL_VERSION_5 5ULL
|
||||
#define ZPL_VERSION ZPL_VERSION_5
|
||||
#define ZPL_VERSION_STRING "5"
|
||||
|
||||
#define ZPL_VERSION_INITIAL ZPL_VERSION_1
|
||||
#define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2
|
||||
@@ -356,6 +414,23 @@ typedef enum zfs_cache_type {
|
||||
#define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3
|
||||
#define ZPL_VERSION_SYSATTR ZPL_VERSION_3
|
||||
#define ZPL_VERSION_USERSPACE ZPL_VERSION_4
|
||||
#define ZPL_VERSION_SA ZPL_VERSION_5
|
||||
|
||||
/* Rewind request information */
|
||||
#define ZPOOL_NO_REWIND 1 /* No policy - default behavior */
|
||||
#define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */
|
||||
#define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */
|
||||
#define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */
|
||||
#define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */
|
||||
#define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */
|
||||
#define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */
|
||||
|
||||
typedef struct zpool_rewind_policy {
|
||||
uint32_t zrp_request; /* rewind behavior requested */
|
||||
uint64_t zrp_maxmeta; /* max acceptable meta-data errors */
|
||||
uint64_t zrp_maxdata; /* max acceptable data errors */
|
||||
uint64_t zrp_txg; /* specific txg to load */
|
||||
} zpool_rewind_policy_t;
|
||||
|
||||
/*
|
||||
* The following are configuration names used in the nvlist describing a pool's
|
||||
@@ -380,7 +455,8 @@ typedef enum zfs_cache_type {
|
||||
#define ZPOOL_CONFIG_ASHIFT "ashift"
|
||||
#define ZPOOL_CONFIG_ASIZE "asize"
|
||||
#define ZPOOL_CONFIG_DTL "DTL"
|
||||
#define ZPOOL_CONFIG_STATS "stats"
|
||||
#define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */
|
||||
#define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */
|
||||
#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
|
||||
#define ZPOOL_CONFIG_ERRCOUNT "error_count"
|
||||
#define ZPOOL_CONFIG_NOT_PRESENT "not_present"
|
||||
@@ -393,6 +469,17 @@ typedef enum zfs_cache_type {
|
||||
#define ZPOOL_CONFIG_PHYS_PATH "phys_path"
|
||||
#define ZPOOL_CONFIG_IS_LOG "is_log"
|
||||
#define ZPOOL_CONFIG_L2CACHE "l2cache"
|
||||
#define ZPOOL_CONFIG_HOLE_ARRAY "hole_array"
|
||||
#define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children"
|
||||
#define ZPOOL_CONFIG_IS_HOLE "is_hole"
|
||||
#define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram"
|
||||
#define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats"
|
||||
#define ZPOOL_CONFIG_DDT_STATS "ddt_stats"
|
||||
#define ZPOOL_CONFIG_SPLIT "splitcfg"
|
||||
#define ZPOOL_CONFIG_ORIG_GUID "orig_guid"
|
||||
#define ZPOOL_CONFIG_SPLIT_GUID "split_guid"
|
||||
#define ZPOOL_CONFIG_SPLIT_LIST "guid_list"
|
||||
#define ZPOOL_CONFIG_REMOVING "removing"
|
||||
#define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */
|
||||
#define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */
|
||||
#define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */
|
||||
@@ -406,6 +493,19 @@ typedef enum zfs_cache_type {
|
||||
#define ZPOOL_CONFIG_DEGRADED "degraded"
|
||||
#define ZPOOL_CONFIG_REMOVED "removed"
|
||||
#define ZPOOL_CONFIG_FRU "fru"
|
||||
#define ZPOOL_CONFIG_AUX_STATE "aux_state"
|
||||
|
||||
/* Rewind policy parameters */
|
||||
#define ZPOOL_REWIND_POLICY "rewind-policy"
|
||||
#define ZPOOL_REWIND_REQUEST "rewind-request"
|
||||
#define ZPOOL_REWIND_REQUEST_TXG "rewind-request-txg"
|
||||
#define ZPOOL_REWIND_META_THRESH "rewind-meta-thresh"
|
||||
#define ZPOOL_REWIND_DATA_THRESH "rewind-data-thresh"
|
||||
|
||||
/* Rewind data discovered */
|
||||
#define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts"
|
||||
#define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors"
|
||||
#define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind"
|
||||
|
||||
#define VDEV_TYPE_ROOT "root"
|
||||
#define VDEV_TYPE_MIRROR "mirror"
|
||||
@@ -414,6 +514,7 @@ typedef enum zfs_cache_type {
|
||||
#define VDEV_TYPE_DISK "disk"
|
||||
#define VDEV_TYPE_FILE "file"
|
||||
#define VDEV_TYPE_MISSING "missing"
|
||||
#define VDEV_TYPE_HOLE "hole"
|
||||
#define VDEV_TYPE_SPARE "spare"
|
||||
#define VDEV_TYPE_LOG "log"
|
||||
#define VDEV_TYPE_L2CACHE "l2cache"
|
||||
@@ -463,7 +564,9 @@ typedef enum vdev_aux {
|
||||
VDEV_AUX_SPARED, /* hot spare used in another pool */
|
||||
VDEV_AUX_ERR_EXCEEDED, /* too many errors */
|
||||
VDEV_AUX_IO_FAILURE, /* experienced I/O failure */
|
||||
VDEV_AUX_BAD_LOG /* cannot read log chain(s) */
|
||||
VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */
|
||||
VDEV_AUX_EXTERNAL, /* external diagnosis */
|
||||
VDEV_AUX_SPLIT_POOL /* vdev was split off into another pool */
|
||||
} vdev_aux_t;
|
||||
|
||||
/*
|
||||
@@ -484,14 +587,14 @@ typedef enum pool_state {
|
||||
} pool_state_t;
|
||||
|
||||
/*
|
||||
* Scrub types.
|
||||
* Scan Functions.
|
||||
*/
|
||||
typedef enum pool_scrub_type {
|
||||
POOL_SCRUB_NONE,
|
||||
POOL_SCRUB_RESILVER,
|
||||
POOL_SCRUB_EVERYTHING,
|
||||
POOL_SCRUB_TYPES
|
||||
} pool_scrub_type_t;
|
||||
typedef enum pool_scan_func {
|
||||
POOL_SCAN_NONE,
|
||||
POOL_SCAN_SCRUB,
|
||||
POOL_SCAN_RESILVER,
|
||||
POOL_SCAN_FUNCS
|
||||
} pool_scan_func_t;
|
||||
|
||||
/*
|
||||
* ZIO types. Needed to interpret vdev statistics below.
|
||||
@@ -506,6 +609,36 @@ typedef enum zio_type {
|
||||
ZIO_TYPES
|
||||
} zio_type_t;
|
||||
|
||||
/*
|
||||
* Pool statistics. Note: all fields should be 64-bit because this
|
||||
* is passed between kernel and userland as an nvlist uint64 array.
|
||||
*/
|
||||
typedef struct pool_scan_stat {
|
||||
/* values stored on disk */
|
||||
uint64_t pss_func; /* pool_scan_func_t */
|
||||
uint64_t pss_state; /* dsl_scan_state_t */
|
||||
uint64_t pss_start_time; /* scan start time */
|
||||
uint64_t pss_end_time; /* scan end time */
|
||||
uint64_t pss_to_examine; /* total bytes to scan */
|
||||
uint64_t pss_examined; /* total examined bytes */
|
||||
uint64_t pss_to_process; /* total bytes to process */
|
||||
uint64_t pss_processed; /* total processed bytes */
|
||||
uint64_t pss_errors; /* scan errors */
|
||||
|
||||
/* values not stored on disk */
|
||||
uint64_t pss_pass_exam; /* examined bytes per scan pass */
|
||||
uint64_t pss_pass_start; /* start time of a scan pass */
|
||||
} pool_scan_stat_t;
|
||||
|
||||
typedef enum dsl_scan_state {
|
||||
DSS_NONE,
|
||||
DSS_SCANNING,
|
||||
DSS_FINISHED,
|
||||
DSS_CANCELED,
|
||||
DSS_NUM_STATES
|
||||
} dsl_scan_state_t;
|
||||
|
||||
|
||||
/*
|
||||
* Vdev statistics. Note: all fields should be 64-bit because this
|
||||
* is passed between kernel and userland as an nvlist uint64 array.
|
||||
@@ -524,34 +657,49 @@ typedef struct vdev_stat {
|
||||
uint64_t vs_write_errors; /* write errors */
|
||||
uint64_t vs_checksum_errors; /* checksum errors */
|
||||
uint64_t vs_self_healed; /* self-healed bytes */
|
||||
uint64_t vs_scrub_type; /* pool_scrub_type_t */
|
||||
uint64_t vs_scrub_complete; /* completed? */
|
||||
uint64_t vs_scrub_examined; /* bytes examined; top */
|
||||
uint64_t vs_scrub_repaired; /* bytes repaired; leaf */
|
||||
uint64_t vs_scrub_errors; /* errors during scrub */
|
||||
uint64_t vs_scrub_start; /* UTC scrub start time */
|
||||
uint64_t vs_scrub_end; /* UTC scrub end time */
|
||||
uint64_t vs_scan_removing; /* removing? */
|
||||
uint64_t vs_scan_processed; /* scan processed bytes */
|
||||
} vdev_stat_t;
|
||||
|
||||
/*
|
||||
* DDT statistics. Note: all fields should be 64-bit because this
|
||||
* is passed between kernel and userland as an nvlist uint64 array.
|
||||
*/
|
||||
typedef struct ddt_object {
|
||||
uint64_t ddo_count; /* number of elments in ddt */
|
||||
uint64_t ddo_dspace; /* size of ddt on disk */
|
||||
uint64_t ddo_mspace; /* size of ddt in-core */
|
||||
} ddt_object_t;
|
||||
|
||||
typedef struct ddt_stat {
|
||||
uint64_t dds_blocks; /* blocks */
|
||||
uint64_t dds_lsize; /* logical size */
|
||||
uint64_t dds_psize; /* physical size */
|
||||
uint64_t dds_dsize; /* deflated allocated size */
|
||||
uint64_t dds_ref_blocks; /* referenced blocks */
|
||||
uint64_t dds_ref_lsize; /* referenced lsize * refcnt */
|
||||
uint64_t dds_ref_psize; /* referenced psize * refcnt */
|
||||
uint64_t dds_ref_dsize; /* referenced dsize * refcnt */
|
||||
} ddt_stat_t;
|
||||
|
||||
typedef struct ddt_histogram {
|
||||
ddt_stat_t ddh_stat[64]; /* power-of-two histogram buckets */
|
||||
} ddt_histogram_t;
|
||||
|
||||
#define ZVOL_DRIVER "zvol"
|
||||
#define ZFS_DRIVER "zfs"
|
||||
#define ZFS_DEV "/dev/zfs"
|
||||
|
||||
/*
|
||||
* zvol paths. Irritatingly, the devfsadm interfaces want all these
|
||||
* paths without the /dev prefix, but for some things, we want the
|
||||
* /dev prefix. Below are the names without /dev.
|
||||
*/
|
||||
#define ZVOL_DEV_DIR "zvol/dsk"
|
||||
#define ZVOL_RDEV_DIR "zvol/rdsk"
|
||||
|
||||
/*
|
||||
* And here are the things we need with /dev, etc. in front of them.
|
||||
*/
|
||||
/* general zvol path */
|
||||
#define ZVOL_DIR "/dev/zvol"
|
||||
/* expansion */
|
||||
#define ZVOL_PSEUDO_DEV "/devices/pseudo/zfs@0:"
|
||||
#define ZVOL_FULL_DEV_DIR "/dev/" ZVOL_DEV_DIR "/"
|
||||
/* for dump and swap */
|
||||
#define ZVOL_FULL_DEV_DIR ZVOL_DIR "/dsk/"
|
||||
#define ZVOL_FULL_RDEV_DIR ZVOL_DIR "/rdsk/"
|
||||
|
||||
#define ZVOL_PROP_NAME "name"
|
||||
#define ZVOL_DEFAULT_BLOCKSIZE 8192
|
||||
|
||||
/*
|
||||
* /dev/zfs ioctl numbers.
|
||||
@@ -566,7 +714,7 @@ typedef enum zfs_ioc {
|
||||
ZFS_IOC_POOL_CONFIGS,
|
||||
ZFS_IOC_POOL_STATS,
|
||||
ZFS_IOC_POOL_TRYIMPORT,
|
||||
ZFS_IOC_POOL_SCRUB,
|
||||
ZFS_IOC_POOL_SCAN,
|
||||
ZFS_IOC_POOL_FREEZE,
|
||||
ZFS_IOC_POOL_UPGRADE,
|
||||
ZFS_IOC_POOL_GET_HISTORY,
|
||||
@@ -582,8 +730,6 @@ typedef enum zfs_ioc {
|
||||
ZFS_IOC_DATASET_LIST_NEXT,
|
||||
ZFS_IOC_SNAPSHOT_LIST_NEXT,
|
||||
ZFS_IOC_SET_PROP,
|
||||
ZFS_IOC_CREATE_MINOR,
|
||||
ZFS_IOC_REMOVE_MINOR,
|
||||
ZFS_IOC_CREATE,
|
||||
ZFS_IOC_DESTROY,
|
||||
ZFS_IOC_ROLLBACK,
|
||||
@@ -604,7 +750,6 @@ typedef enum zfs_ioc {
|
||||
ZFS_IOC_POOL_GET_PROPS,
|
||||
ZFS_IOC_SET_FSACL,
|
||||
ZFS_IOC_GET_FSACL,
|
||||
ZFS_IOC_ISCSI_PERM_CHECK,
|
||||
ZFS_IOC_SHARE,
|
||||
ZFS_IOC_INHERIT_PROP,
|
||||
ZFS_IOC_SMB_ACL,
|
||||
@@ -613,17 +758,21 @@ typedef enum zfs_ioc {
|
||||
ZFS_IOC_USERSPACE_UPGRADE,
|
||||
ZFS_IOC_HOLD,
|
||||
ZFS_IOC_RELEASE,
|
||||
ZFS_IOC_GET_HOLDS
|
||||
ZFS_IOC_GET_HOLDS,
|
||||
ZFS_IOC_OBJSET_RECVD_PROPS,
|
||||
ZFS_IOC_VDEV_SPLIT
|
||||
} zfs_ioc_t;
|
||||
|
||||
/*
|
||||
* Internal SPA load state. Used by FMA diagnosis engine.
|
||||
*/
|
||||
typedef enum {
|
||||
SPA_LOAD_NONE, /* no load in progress */
|
||||
SPA_LOAD_OPEN, /* normal open */
|
||||
SPA_LOAD_IMPORT, /* import in progress */
|
||||
SPA_LOAD_TRYIMPORT /* tryimport in progress */
|
||||
SPA_LOAD_NONE, /* no load in progress */
|
||||
SPA_LOAD_OPEN, /* normal open */
|
||||
SPA_LOAD_IMPORT, /* import in progress */
|
||||
SPA_LOAD_TRYIMPORT, /* tryimport in progress */
|
||||
SPA_LOAD_RECOVER, /* recovery requested */
|
||||
SPA_LOAD_ERROR /* load failed */
|
||||
} spa_load_state_t;
|
||||
|
||||
/*
|
||||
@@ -686,7 +835,7 @@ typedef enum {
|
||||
/*
|
||||
* Note: This is encoded on-disk, so new events must be added to the
|
||||
* end, and unused events can not be removed. Be sure to edit
|
||||
* zpool_main.c: hist_event_table[].
|
||||
* libzfs_pool.c: hist_event_table[].
|
||||
*/
|
||||
typedef enum history_internal_events {
|
||||
LOG_NO_EVENT = 0,
|
||||
@@ -703,7 +852,7 @@ typedef enum history_internal_events {
|
||||
LOG_POOL_VDEV_OFFLINE,
|
||||
LOG_POOL_UPGRADE,
|
||||
LOG_POOL_CLEAR,
|
||||
LOG_POOL_SCRUB,
|
||||
LOG_POOL_SCAN,
|
||||
LOG_POOL_PROPSET,
|
||||
LOG_DS_CREATE,
|
||||
LOG_DS_CLONE,
|
||||
@@ -726,9 +875,10 @@ typedef enum history_internal_events {
|
||||
LOG_DS_UPGRADE,
|
||||
LOG_DS_REFQUOTA,
|
||||
LOG_DS_REFRESERV,
|
||||
LOG_POOL_SCRUB_DONE,
|
||||
LOG_POOL_SCAN_DONE,
|
||||
LOG_DS_USER_HOLD,
|
||||
LOG_DS_USER_RELEASE,
|
||||
LOG_POOL_SPLIT,
|
||||
LOG_END
|
||||
} history_internal_events_t;
|
||||
|
||||
|
||||
@@ -19,15 +19,12 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _ZFS_COMUTIL_H
|
||||
#define _ZFS_COMUTIL_H
|
||||
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
#include <sys/fs/zfs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -35,7 +32,12 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern boolean_t zfs_allocatable_devs(nvlist_t *nv);
|
||||
extern boolean_t zfs_allocatable_devs(nvlist_t *);
|
||||
extern void zpool_get_rewind_policy(nvlist_t *, zpool_rewind_policy_t *);
|
||||
|
||||
extern int zfs_zpl_version_map(int spa_version);
|
||||
extern int zfs_spa_version_map(int zpl_version);
|
||||
extern const char *zfs_history_event_names[LOG_END];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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
|
||||
* or http://www.opensolaris.org/os/licensing.
|
||||
* 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 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _ZFS_FLETCHER_H
|
||||
#define _ZFS_FLETCHER_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/spa.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* fletcher checksum functions
|
||||
*/
|
||||
|
||||
void fletcher_2_native(const void *, uint64_t, zio_cksum_t *);
|
||||
void fletcher_2_byteswap(const void *, uint64_t, zio_cksum_t *);
|
||||
void fletcher_4_native(const void *, uint64_t, zio_cksum_t *);
|
||||
void fletcher_4_byteswap(const void *, uint64_t, zio_cksum_t *);
|
||||
void fletcher_4_incremental_native(const void *, uint64_t,
|
||||
zio_cksum_t *);
|
||||
void fletcher_4_incremental_byteswap(const void *, uint64_t,
|
||||
zio_cksum_t *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ZFS_FLETCHER_H */
|
||||
@@ -19,15 +19,13 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _ZFS_PROP_H
|
||||
#define _ZFS_PROP_H
|
||||
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
#include <sys/fs/zfs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -79,6 +77,7 @@ typedef struct {
|
||||
/* "zfs get" help message */
|
||||
const zprop_index_t *pd_table; /* for index properties, a table */
|
||||
/* defining the possible values */
|
||||
size_t pd_table_size; /* number of entries in pd_table[] */
|
||||
} zprop_desc_t;
|
||||
|
||||
/*
|
||||
@@ -99,16 +98,16 @@ zprop_desc_t *zpool_prop_get_table(void);
|
||||
/*
|
||||
* Common routines to initialize property tables
|
||||
*/
|
||||
void register_impl(int, const char *, zprop_type_t, uint64_t,
|
||||
void zprop_register_impl(int, const char *, zprop_type_t, uint64_t,
|
||||
const char *, zprop_attr_t, int, const char *, const char *,
|
||||
boolean_t, boolean_t, const zprop_index_t *);
|
||||
void register_string(int, const char *, const char *, zprop_attr_t attr,
|
||||
int, const char *, const char *);
|
||||
void register_number(int, const char *, uint64_t, zprop_attr_t, int,
|
||||
void zprop_register_string(int, const char *, const char *,
|
||||
zprop_attr_t attr, int, const char *, const char *);
|
||||
void zprop_register_number(int, const char *, uint64_t, zprop_attr_t, int,
|
||||
const char *, const char *);
|
||||
void register_index(int, const char *, uint64_t, zprop_attr_t, int,
|
||||
void zprop_register_index(int, const char *, uint64_t, zprop_attr_t, int,
|
||||
const char *, const char *, const zprop_index_t *);
|
||||
void register_hidden(int, const char *, zprop_type_t, zprop_attr_t,
|
||||
void zprop_register_hidden(int, const char *, zprop_type_t, zprop_attr_t,
|
||||
int, const char *);
|
||||
|
||||
/*
|
||||
@@ -118,6 +117,7 @@ int zprop_iter_common(zprop_func, void *, boolean_t, boolean_t, zfs_type_t);
|
||||
int zprop_name_to_prop(const char *, zfs_type_t);
|
||||
int zprop_string_to_index(int, const char *, uint64_t *, zfs_type_t);
|
||||
int zprop_index_to_string(int, uint64_t, const char **, zfs_type_t);
|
||||
uint64_t zprop_random_value(int, uint64_t, zfs_type_t);
|
||||
const char *zprop_values(int, zfs_type_t);
|
||||
size_t zprop_width(int, boolean_t *, zfs_type_t);
|
||||
boolean_t zprop_valid_for_type(int, zfs_type_t);
|
||||
|
||||
@@ -19,12 +19,9 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
/*
|
||||
* This file is intended for functions that ought to be common between user
|
||||
* land (libzfs) and the kernel. When many common routines need to be shared
|
||||
@@ -33,11 +30,15 @@
|
||||
|
||||
#if defined(_KERNEL)
|
||||
#include <sys/systm.h>
|
||||
#else
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fs/zfs.h>
|
||||
#include <sys/int_limits.h>
|
||||
#include <sys/nvpair.h>
|
||||
#include "zfs_comutil.h"
|
||||
|
||||
/*
|
||||
* Are there allocatable vdevs?
|
||||
@@ -63,3 +64,139 @@ zfs_allocatable_devs(nvlist_t *nv)
|
||||
}
|
||||
return (B_FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
zpool_get_rewind_policy(nvlist_t *nvl, zpool_rewind_policy_t *zrpp)
|
||||
{
|
||||
nvlist_t *policy;
|
||||
nvpair_t *elem;
|
||||
char *nm;
|
||||
|
||||
/* Defaults */
|
||||
zrpp->zrp_request = ZPOOL_NO_REWIND;
|
||||
zrpp->zrp_maxmeta = 0;
|
||||
zrpp->zrp_maxdata = UINT64_MAX;
|
||||
zrpp->zrp_txg = UINT64_MAX;
|
||||
|
||||
if (nvl == NULL)
|
||||
return;
|
||||
|
||||
elem = NULL;
|
||||
while ((elem = nvlist_next_nvpair(nvl, elem)) != NULL) {
|
||||
nm = nvpair_name(elem);
|
||||
if (strcmp(nm, ZPOOL_REWIND_POLICY) == 0) {
|
||||
if (nvpair_value_nvlist(elem, &policy) == 0)
|
||||
zpool_get_rewind_policy(policy, zrpp);
|
||||
return;
|
||||
} else if (strcmp(nm, ZPOOL_REWIND_REQUEST) == 0) {
|
||||
if (nvpair_value_uint32(elem, &zrpp->zrp_request) == 0)
|
||||
if (zrpp->zrp_request & ~ZPOOL_REWIND_POLICIES)
|
||||
zrpp->zrp_request = ZPOOL_NO_REWIND;
|
||||
} else if (strcmp(nm, ZPOOL_REWIND_REQUEST_TXG) == 0) {
|
||||
(void) nvpair_value_uint64(elem, &zrpp->zrp_txg);
|
||||
} else if (strcmp(nm, ZPOOL_REWIND_META_THRESH) == 0) {
|
||||
(void) nvpair_value_uint64(elem, &zrpp->zrp_maxmeta);
|
||||
} else if (strcmp(nm, ZPOOL_REWIND_DATA_THRESH) == 0) {
|
||||
(void) nvpair_value_uint64(elem, &zrpp->zrp_maxdata);
|
||||
}
|
||||
}
|
||||
if (zrpp->zrp_request == 0)
|
||||
zrpp->zrp_request = ZPOOL_NO_REWIND;
|
||||
}
|
||||
|
||||
typedef struct zfs_version_spa_map {
|
||||
int version_zpl;
|
||||
int version_spa;
|
||||
} zfs_version_spa_map_t;
|
||||
|
||||
/*
|
||||
* Keep this table in monotonically increasing version number order.
|
||||
*/
|
||||
static zfs_version_spa_map_t zfs_version_table[] = {
|
||||
{ZPL_VERSION_INITIAL, SPA_VERSION_INITIAL},
|
||||
{ZPL_VERSION_DIRENT_TYPE, SPA_VERSION_INITIAL},
|
||||
{ZPL_VERSION_FUID, SPA_VERSION_FUID},
|
||||
{ZPL_VERSION_USERSPACE, SPA_VERSION_USERSPACE},
|
||||
{ZPL_VERSION_SA, SPA_VERSION_SA},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
/*
|
||||
* Return the max zpl version for a corresponding spa version
|
||||
* -1 is returned if no mapping exists.
|
||||
*/
|
||||
int
|
||||
zfs_zpl_version_map(int spa_version)
|
||||
{
|
||||
int i;
|
||||
int version = -1;
|
||||
|
||||
for (i = 0; zfs_version_table[i].version_spa; i++) {
|
||||
if (spa_version >= zfs_version_table[i].version_spa)
|
||||
version = zfs_version_table[i].version_zpl;
|
||||
}
|
||||
|
||||
return (version);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the min spa version for a corresponding spa version
|
||||
* -1 is returned if no mapping exists.
|
||||
*/
|
||||
int
|
||||
zfs_spa_version_map(int zpl_version)
|
||||
{
|
||||
int i;
|
||||
int version = -1;
|
||||
|
||||
for (i = 0; zfs_version_table[i].version_zpl; i++) {
|
||||
if (zfs_version_table[i].version_zpl >= zpl_version)
|
||||
return (zfs_version_table[i].version_spa);
|
||||
}
|
||||
|
||||
return (version);
|
||||
}
|
||||
|
||||
const char *zfs_history_event_names[LOG_END] = {
|
||||
"invalid event",
|
||||
"pool create",
|
||||
"vdev add",
|
||||
"pool remove",
|
||||
"pool destroy",
|
||||
"pool export",
|
||||
"pool import",
|
||||
"vdev attach",
|
||||
"vdev replace",
|
||||
"vdev detach",
|
||||
"vdev online",
|
||||
"vdev offline",
|
||||
"vdev upgrade",
|
||||
"pool clear",
|
||||
"pool scrub",
|
||||
"pool property set",
|
||||
"create",
|
||||
"clone",
|
||||
"destroy",
|
||||
"destroy_begin_sync",
|
||||
"inherit",
|
||||
"property set",
|
||||
"quota set",
|
||||
"permission update",
|
||||
"permission remove",
|
||||
"permission who remove",
|
||||
"promote",
|
||||
"receive",
|
||||
"rename",
|
||||
"reservation set",
|
||||
"replay_inc_sync",
|
||||
"replay_full_sync",
|
||||
"rollback",
|
||||
"snapshot",
|
||||
"filesystem version upgrade",
|
||||
"refquota set",
|
||||
"refreservation set",
|
||||
"pool scrub done",
|
||||
"user hold",
|
||||
"user release",
|
||||
"pool split",
|
||||
};
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* 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
|
||||
* or http://www.opensolaris.org/os/licensing.
|
||||
* 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 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Fletcher Checksums
|
||||
* ------------------
|
||||
*
|
||||
* ZFS's 2nd and 4th order Fletcher checksums are defined by the following
|
||||
* recurrence relations:
|
||||
*
|
||||
* a = a + f
|
||||
* i i-1 i-1
|
||||
*
|
||||
* b = b + a
|
||||
* i i-1 i
|
||||
*
|
||||
* c = c + b (fletcher-4 only)
|
||||
* i i-1 i
|
||||
*
|
||||
* d = d + c (fletcher-4 only)
|
||||
* i i-1 i
|
||||
*
|
||||
* Where
|
||||
* a_0 = b_0 = c_0 = d_0 = 0
|
||||
* and
|
||||
* f_0 .. f_(n-1) are the input data.
|
||||
*
|
||||
* Using standard techniques, these translate into the following series:
|
||||
*
|
||||
* __n_ __n_
|
||||
* \ | \ |
|
||||
* a = > f b = > i * f
|
||||
* n /___| n - i n /___| n - i
|
||||
* i = 1 i = 1
|
||||
*
|
||||
*
|
||||
* __n_ __n_
|
||||
* \ | i*(i+1) \ | i*(i+1)*(i+2)
|
||||
* c = > ------- f d = > ------------- f
|
||||
* n /___| 2 n - i n /___| 6 n - i
|
||||
* i = 1 i = 1
|
||||
*
|
||||
* For fletcher-2, the f_is are 64-bit, and [ab]_i are 64-bit accumulators.
|
||||
* Since the additions are done mod (2^64), errors in the high bits may not
|
||||
* be noticed. For this reason, fletcher-2 is deprecated.
|
||||
*
|
||||
* For fletcher-4, the f_is are 32-bit, and [abcd]_i are 64-bit accumulators.
|
||||
* A conservative estimate of how big the buffer can get before we overflow
|
||||
* can be estimated using f_i = 0xffffffff for all i:
|
||||
*
|
||||
* % bc
|
||||
* f=2^32-1;d=0; for (i = 1; d<2^64; i++) { d += f*i*(i+1)*(i+2)/6 }; (i-1)*4
|
||||
* 2264
|
||||
* quit
|
||||
* %
|
||||
*
|
||||
* So blocks of up to 2k will not overflow. Our largest block size is
|
||||
* 128k, which has 32k 4-byte words, so we can compute the largest possible
|
||||
* accumulators, then divide by 2^64 to figure the max amount of overflow:
|
||||
*
|
||||
* % bc
|
||||
* a=b=c=d=0; f=2^32-1; for (i=1; i<=32*1024; i++) { a+=f; b+=a; c+=b; d+=c }
|
||||
* a/2^64;b/2^64;c/2^64;d/2^64
|
||||
* 0
|
||||
* 0
|
||||
* 1365
|
||||
* 11186858
|
||||
* quit
|
||||
* %
|
||||
*
|
||||
* So a and b cannot overflow. To make sure each bit of input has some
|
||||
* effect on the contents of c and d, we can look at what the factors of
|
||||
* the coefficients in the equations for c_n and d_n are. The number of 2s
|
||||
* in the factors determines the lowest set bit in the multiplier. Running
|
||||
* through the cases for n*(n+1)/2 reveals that the highest power of 2 is
|
||||
* 2^14, and for n*(n+1)*(n+2)/6 it is 2^15. So while some data may overflow
|
||||
* the 64-bit accumulators, every bit of every f_i effects every accumulator,
|
||||
* even for 128k blocks.
|
||||
*
|
||||
* If we wanted to make a stronger version of fletcher4 (fletcher4c?),
|
||||
* we could do our calculations mod (2^32 - 1) by adding in the carries
|
||||
* periodically, and store the number of carries in the top 32-bits.
|
||||
*
|
||||
* --------------------
|
||||
* Checksum Performance
|
||||
* --------------------
|
||||
*
|
||||
* There are two interesting components to checksum performance: cached and
|
||||
* uncached performance. With cached data, fletcher-2 is about four times
|
||||
* faster than fletcher-4. With uncached data, the performance difference is
|
||||
* negligible, since the cost of a cache fill dominates the processing time.
|
||||
* Even though fletcher-4 is slower than fletcher-2, it is still a pretty
|
||||
* efficient pass over the data.
|
||||
*
|
||||
* In normal operation, the data which is being checksummed is in a buffer
|
||||
* which has been filled either by:
|
||||
*
|
||||
* 1. a compression step, which will be mostly cached, or
|
||||
* 2. a bcopy() or copyin(), which will be uncached (because the
|
||||
* copy is cache-bypassing).
|
||||
*
|
||||
* For both cached and uncached data, both fletcher checksums are much faster
|
||||
* than sha-256, and slower than 'off', which doesn't touch the data at all.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/byteorder.h>
|
||||
#include <sys/zio.h>
|
||||
#include <sys/spa.h>
|
||||
|
||||
void
|
||||
fletcher_2_native(const void *buf, uint64_t size, zio_cksum_t *zcp)
|
||||
{
|
||||
const uint64_t *ip = buf;
|
||||
const uint64_t *ipend = ip + (size / sizeof (uint64_t));
|
||||
uint64_t a0, b0, a1, b1;
|
||||
|
||||
for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) {
|
||||
a0 += ip[0];
|
||||
a1 += ip[1];
|
||||
b0 += a0;
|
||||
b1 += a1;
|
||||
}
|
||||
|
||||
ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1);
|
||||
}
|
||||
|
||||
void
|
||||
fletcher_2_byteswap(const void *buf, uint64_t size, zio_cksum_t *zcp)
|
||||
{
|
||||
const uint64_t *ip = buf;
|
||||
const uint64_t *ipend = ip + (size / sizeof (uint64_t));
|
||||
uint64_t a0, b0, a1, b1;
|
||||
|
||||
for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) {
|
||||
a0 += BSWAP_64(ip[0]);
|
||||
a1 += BSWAP_64(ip[1]);
|
||||
b0 += a0;
|
||||
b1 += a1;
|
||||
}
|
||||
|
||||
ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1);
|
||||
}
|
||||
|
||||
void
|
||||
fletcher_4_native(const void *buf, uint64_t size, zio_cksum_t *zcp)
|
||||
{
|
||||
const uint32_t *ip = buf;
|
||||
const uint32_t *ipend = ip + (size / sizeof (uint32_t));
|
||||
uint64_t a, b, c, d;
|
||||
|
||||
for (a = b = c = d = 0; ip < ipend; ip++) {
|
||||
a += ip[0];
|
||||
b += a;
|
||||
c += b;
|
||||
d += c;
|
||||
}
|
||||
|
||||
ZIO_SET_CHECKSUM(zcp, a, b, c, d);
|
||||
}
|
||||
|
||||
void
|
||||
fletcher_4_byteswap(const void *buf, uint64_t size, zio_cksum_t *zcp)
|
||||
{
|
||||
const uint32_t *ip = buf;
|
||||
const uint32_t *ipend = ip + (size / sizeof (uint32_t));
|
||||
uint64_t a, b, c, d;
|
||||
|
||||
for (a = b = c = d = 0; ip < ipend; ip++) {
|
||||
a += BSWAP_32(ip[0]);
|
||||
b += a;
|
||||
c += b;
|
||||
d += c;
|
||||
}
|
||||
|
||||
ZIO_SET_CHECKSUM(zcp, a, b, c, d);
|
||||
}
|
||||
|
||||
void
|
||||
fletcher_4_incremental_native(const void *buf, uint64_t size,
|
||||
zio_cksum_t *zcp)
|
||||
{
|
||||
const uint32_t *ip = buf;
|
||||
const uint32_t *ipend = ip + (size / sizeof (uint32_t));
|
||||
uint64_t a, b, c, d;
|
||||
|
||||
a = zcp->zc_word[0];
|
||||
b = zcp->zc_word[1];
|
||||
c = zcp->zc_word[2];
|
||||
d = zcp->zc_word[3];
|
||||
|
||||
for (; ip < ipend; ip++) {
|
||||
a += ip[0];
|
||||
b += a;
|
||||
c += b;
|
||||
d += c;
|
||||
}
|
||||
|
||||
ZIO_SET_CHECKSUM(zcp, a, b, c, d);
|
||||
}
|
||||
|
||||
void
|
||||
fletcher_4_incremental_byteswap(const void *buf, uint64_t size,
|
||||
zio_cksum_t *zcp)
|
||||
{
|
||||
const uint32_t *ip = buf;
|
||||
const uint32_t *ipend = ip + (size / sizeof (uint32_t));
|
||||
uint64_t a, b, c, d;
|
||||
|
||||
a = zcp->zc_word[0];
|
||||
b = zcp->zc_word[1];
|
||||
c = zcp->zc_word[2];
|
||||
d = zcp->zc_word[3];
|
||||
|
||||
for (; ip < ipend; ip++) {
|
||||
a += BSWAP_32(ip[0]);
|
||||
b += a;
|
||||
c += b;
|
||||
d += c;
|
||||
}
|
||||
|
||||
ZIO_SET_CHECKSUM(zcp, a, b, c, d);
|
||||
}
|
||||
+147
-86
@@ -19,10 +19,11 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/* Portions Copyright 2010 Robert Milkowski */
|
||||
|
||||
#include <sys/zio.h>
|
||||
#include <sys/spa.h>
|
||||
#include <sys/u8_textprep.h>
|
||||
@@ -69,6 +70,16 @@ zfs_prop_init(void)
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static zprop_index_t dedup_table[] = {
|
||||
{ "on", ZIO_CHECKSUM_ON },
|
||||
{ "off", ZIO_CHECKSUM_OFF },
|
||||
{ "verify", ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY },
|
||||
{ "sha256", ZIO_CHECKSUM_SHA256 },
|
||||
{ "sha256,verify",
|
||||
ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static zprop_index_t compress_table[] = {
|
||||
{ "on", ZIO_COMPRESS_ON },
|
||||
{ "off", ZIO_COMPRESS_OFF },
|
||||
@@ -83,6 +94,7 @@ zfs_prop_init(void)
|
||||
{ "gzip-7", ZIO_COMPRESS_GZIP_7 },
|
||||
{ "gzip-8", ZIO_COMPRESS_GZIP_8 },
|
||||
{ "gzip-9", ZIO_COMPRESS_GZIP_9 },
|
||||
{ "zle", ZIO_COMPRESS_ZLE },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@@ -92,13 +104,6 @@ zfs_prop_init(void)
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static zprop_index_t acl_mode_table[] = {
|
||||
{ "discard", ZFS_ACL_DISCARD },
|
||||
{ "groupmask", ZFS_ACL_GROUPMASK },
|
||||
{ "passthrough", ZFS_ACL_PASSTHROUGH },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static zprop_index_t acl_inherit_table[] = {
|
||||
{ "discard", ZFS_ACL_DISCARD },
|
||||
{ "noallow", ZFS_ACL_NOALLOW },
|
||||
@@ -142,6 +147,7 @@ zfs_prop_init(void)
|
||||
{ "2", 2 },
|
||||
{ "3", 3 },
|
||||
{ "4", 4 },
|
||||
{ "5", 5 },
|
||||
{ "current", ZPL_VERSION },
|
||||
{ NULL }
|
||||
};
|
||||
@@ -152,6 +158,12 @@ zfs_prop_init(void)
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static zprop_index_t logbias_table[] = {
|
||||
{ "latency", ZFS_LOGBIAS_LATENCY },
|
||||
{ "throughput", ZFS_LOGBIAS_THROUGHPUT },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static zprop_index_t canmount_table[] = {
|
||||
{ "off", ZFS_CANMOUNT_OFF },
|
||||
{ "on", ZFS_CANMOUNT_ON },
|
||||
@@ -166,170 +178,208 @@ zfs_prop_init(void)
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static zprop_index_t sync_table[] = {
|
||||
{ "standard", ZFS_SYNC_STANDARD },
|
||||
{ "always", ZFS_SYNC_ALWAYS },
|
||||
{ "disabled", ZFS_SYNC_DISABLED },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/* inherit index properties */
|
||||
register_index(ZFS_PROP_CHECKSUM, "checksum", ZIO_CHECKSUM_DEFAULT,
|
||||
zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
|
||||
"standard | always | disabled", "SYNC",
|
||||
sync_table);
|
||||
zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",
|
||||
ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |
|
||||
ZFS_TYPE_VOLUME,
|
||||
"on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM",
|
||||
checksum_table);
|
||||
register_index(ZFS_PROP_COMPRESSION, "compression",
|
||||
zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
|
||||
"on | off | verify | sha256[,verify]", "DEDUP",
|
||||
dedup_table);
|
||||
zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
|
||||
ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
|
||||
"on | off | lzjb | gzip | gzip-[1-9]", "COMPRESS", compress_table);
|
||||
register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
|
||||
"on | off | lzjb | gzip | gzip-[1-9] | zle", "COMPRESS",
|
||||
compress_table);
|
||||
zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
|
||||
"hidden | visible", "SNAPDIR", snapdir_table);
|
||||
register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_GROUPMASK,
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
|
||||
"discard | groupmask | passthrough", "ACLMODE", acl_mode_table);
|
||||
register_index(ZFS_PROP_ACLINHERIT, "aclinherit", ZFS_ACL_RESTRICTED,
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
|
||||
zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
|
||||
ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
|
||||
"discard | noallow | restricted | passthrough | passthrough-x",
|
||||
"ACLINHERIT", acl_inherit_table);
|
||||
register_index(ZFS_PROP_COPIES, "copies", 1,
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
|
||||
zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
|
||||
"1 | 2 | 3", "COPIES", copies_table);
|
||||
register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
|
||||
zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
|
||||
ZFS_CACHE_ALL, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
|
||||
"all | none | metadata", "PRIMARYCACHE", cache_table);
|
||||
register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
|
||||
zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
|
||||
ZFS_CACHE_ALL, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
|
||||
"all | none | metadata", "SECONDARYCACHE", cache_table);
|
||||
zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
|
||||
"latency | throughput", "LOGBIAS", logbias_table);
|
||||
|
||||
/* inherit index (boolean) properties */
|
||||
register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
|
||||
zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table);
|
||||
register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
|
||||
zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
|
||||
boolean_table);
|
||||
register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
|
||||
zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
|
||||
boolean_table);
|
||||
register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
|
||||
zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
|
||||
boolean_table);
|
||||
register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
|
||||
zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
|
||||
boolean_table);
|
||||
register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
|
||||
zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table);
|
||||
register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT,
|
||||
zprop_register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR",
|
||||
boolean_table);
|
||||
register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
|
||||
zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN",
|
||||
boolean_table);
|
||||
register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
|
||||
zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
|
||||
boolean_table);
|
||||
|
||||
/* default index properties */
|
||||
register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
|
||||
zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
|
||||
"1 | 2 | 3 | 4 | current", "VERSION", version_table);
|
||||
register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
|
||||
zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
|
||||
PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
|
||||
"CANMOUNT", canmount_table);
|
||||
|
||||
/* readonly index (boolean) properties */
|
||||
register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
|
||||
zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
|
||||
ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
|
||||
register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
|
||||
zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
|
||||
PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
|
||||
boolean_table);
|
||||
|
||||
/* set once index properties */
|
||||
register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
|
||||
zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
|
||||
PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
|
||||
"none | formC | formD | formKC | formKD", "NORMALIZATION",
|
||||
normalize_table);
|
||||
register_index(ZFS_PROP_CASE, "casesensitivity", ZFS_CASE_SENSITIVE,
|
||||
PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
|
||||
zprop_register_index(ZFS_PROP_CASE, "casesensitivity",
|
||||
ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |
|
||||
ZFS_TYPE_SNAPSHOT,
|
||||
"sensitive | insensitive | mixed", "CASE", case_table);
|
||||
|
||||
/* set once index (boolean) properties */
|
||||
register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
|
||||
zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
|
||||
"on | off", "UTF8ONLY", boolean_table);
|
||||
|
||||
/* string properties */
|
||||
register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
|
||||
zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN");
|
||||
register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/", PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM, "<path> | legacy | none", "MOUNTPOINT");
|
||||
register_string(ZFS_PROP_SHARENFS, "sharenfs", "off", PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options", "SHARENFS");
|
||||
register_string(ZFS_PROP_SHAREISCSI, "shareiscsi", "off", PROP_INHERIT,
|
||||
ZFS_TYPE_DATASET, "on | off | type=<type>", "SHAREISCSI");
|
||||
register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
|
||||
zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/",
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none",
|
||||
"MOUNTPOINT");
|
||||
zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off",
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options",
|
||||
"SHARENFS");
|
||||
zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
|
||||
ZFS_TYPE_DATASET, "filesystem | volume | snapshot", "TYPE");
|
||||
register_string(ZFS_PROP_SHARESMB, "sharesmb", "off", PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM, "on | off | sharemgr(1M) options", "SHARESMB");
|
||||
zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off",
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
|
||||
"on | off | sharemgr(1M) options", "SHARESMB");
|
||||
zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel",
|
||||
ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET,
|
||||
"<sensitivity label>", "MLSLABEL");
|
||||
|
||||
/* readonly number properties */
|
||||
register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
|
||||
zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
|
||||
ZFS_TYPE_DATASET, "<size>", "USED");
|
||||
register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
|
||||
zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL");
|
||||
register_number(ZFS_PROP_REFERENCED, "referenced", 0, PROP_READONLY,
|
||||
ZFS_TYPE_DATASET, "<size>", "REFER");
|
||||
register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
|
||||
zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0,
|
||||
PROP_READONLY, ZFS_TYPE_DATASET, "<size>", "REFER");
|
||||
zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
|
||||
PROP_READONLY, ZFS_TYPE_DATASET,
|
||||
"<1.00x or higher if compressed>", "RATIO");
|
||||
register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize", 8192,
|
||||
PROP_ONETIME,
|
||||
zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
|
||||
ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
|
||||
ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK");
|
||||
register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0, PROP_READONLY,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDSNAP");
|
||||
register_number(ZFS_PROP_USEDDS, "usedbydataset", 0, PROP_READONLY,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDDS");
|
||||
register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0, PROP_READONLY,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDCHILD");
|
||||
register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
|
||||
zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0,
|
||||
PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
|
||||
"USEDSNAP");
|
||||
zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0,
|
||||
PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
|
||||
"USEDDS");
|
||||
zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0,
|
||||
PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
|
||||
"USEDCHILD");
|
||||
zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
|
||||
PROP_READONLY,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV");
|
||||
register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
|
||||
zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
|
||||
ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS");
|
||||
|
||||
/* default number properties */
|
||||
register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
|
||||
zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
|
||||
ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA");
|
||||
register_number(ZFS_PROP_RESERVATION, "reservation", 0, PROP_DEFAULT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size> | none", "RESERV");
|
||||
register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
|
||||
zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0,
|
||||
PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
|
||||
"<size> | none", "RESERV");
|
||||
zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
|
||||
ZFS_TYPE_VOLUME, "<size>", "VOLSIZE");
|
||||
register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
|
||||
zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
|
||||
ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA");
|
||||
register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
|
||||
zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
|
||||
PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
|
||||
"<size> | none", "REFRESERV");
|
||||
|
||||
/* inherit number properties */
|
||||
register_number(ZFS_PROP_RECORDSIZE, "recordsize", SPA_MAXBLOCKSIZE,
|
||||
PROP_INHERIT,
|
||||
zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize",
|
||||
SPA_MAXBLOCKSIZE, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM, "512 to 128k, power of 2", "RECSIZE");
|
||||
|
||||
/* hidden properties */
|
||||
register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER,
|
||||
PROP_READONLY, ZFS_TYPE_DATASET, NULL);
|
||||
register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
|
||||
PROP_READONLY, ZFS_TYPE_SNAPSHOT, NULL);
|
||||
register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
|
||||
zprop_register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER,
|
||||
PROP_READONLY, ZFS_TYPE_DATASET, "CREATETXG");
|
||||
zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
|
||||
PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES");
|
||||
zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
|
||||
PROP_READONLY, ZFS_TYPE_DATASET, "NAME");
|
||||
register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", PROP_TYPE_STRING,
|
||||
PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
|
||||
register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
|
||||
zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions",
|
||||
PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
|
||||
zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
|
||||
PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
|
||||
"STMF_SBD_LU");
|
||||
register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER, PROP_READONLY,
|
||||
ZFS_TYPE_DATASET, "GUID");
|
||||
register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
|
||||
PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, NULL);
|
||||
zprop_register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER,
|
||||
PROP_READONLY, ZFS_TYPE_DATASET, "GUID");
|
||||
zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
|
||||
PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
|
||||
"USERACCOUNTING");
|
||||
zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
|
||||
PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE");
|
||||
zprop_register_hidden(ZFS_PROP_OBJSETID, "objsetid", PROP_TYPE_NUMBER,
|
||||
PROP_READONLY, ZFS_TYPE_DATASET, "OBJSETID");
|
||||
|
||||
/*
|
||||
* Property to be removed once libbe is integrated
|
||||
*/
|
||||
zprop_register_hidden(ZFS_PROP_PRIVATE, "priv_prop",
|
||||
PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_FILESYSTEM,
|
||||
"PRIV_PROP");
|
||||
|
||||
/* oddball properties */
|
||||
register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, NULL,
|
||||
PROP_READONLY, ZFS_TYPE_DATASET,
|
||||
zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0,
|
||||
NULL, PROP_READONLY, ZFS_TYPE_DATASET,
|
||||
"<date>", "CREATION", B_FALSE, B_TRUE, NULL);
|
||||
}
|
||||
|
||||
@@ -337,6 +387,11 @@ boolean_t
|
||||
zfs_prop_delegatable(zfs_prop_t prop)
|
||||
{
|
||||
zprop_desc_t *pd = &zfs_prop_table[prop];
|
||||
|
||||
/* The mlslabel property is never delegatable. */
|
||||
if (prop == ZFS_PROP_MLSLABEL)
|
||||
return (B_FALSE);
|
||||
|
||||
return (pd->pd_attr != PROP_READONLY);
|
||||
}
|
||||
|
||||
@@ -421,6 +476,12 @@ zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)
|
||||
return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));
|
||||
}
|
||||
|
||||
uint64_t
|
||||
zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
|
||||
{
|
||||
return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns TRUE if the property applies to any of the given dataset types.
|
||||
*/
|
||||
|
||||
+37
-24
@@ -19,7 +19,7 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
@@ -64,48 +64,55 @@ zpool_prop_init(void)
|
||||
};
|
||||
|
||||
/* string properties */
|
||||
register_string(ZPOOL_PROP_ALTROOT, "altroot", NULL, PROP_DEFAULT,
|
||||
zprop_register_string(ZPOOL_PROP_ALTROOT, "altroot", NULL, PROP_DEFAULT,
|
||||
ZFS_TYPE_POOL, "<path>", "ALTROOT");
|
||||
register_string(ZPOOL_PROP_BOOTFS, "bootfs", NULL, PROP_DEFAULT,
|
||||
zprop_register_string(ZPOOL_PROP_BOOTFS, "bootfs", NULL, PROP_DEFAULT,
|
||||
ZFS_TYPE_POOL, "<filesystem>", "BOOTFS");
|
||||
register_string(ZPOOL_PROP_CACHEFILE, "cachefile", NULL, PROP_DEFAULT,
|
||||
ZFS_TYPE_POOL, "<file> | none", "CACHEFILE");
|
||||
zprop_register_string(ZPOOL_PROP_CACHEFILE, "cachefile", NULL,
|
||||
PROP_DEFAULT, ZFS_TYPE_POOL, "<file> | none", "CACHEFILE");
|
||||
|
||||
/* readonly number properties */
|
||||
register_number(ZPOOL_PROP_SIZE, "size", 0, PROP_READONLY,
|
||||
zprop_register_number(ZPOOL_PROP_SIZE, "size", 0, PROP_READONLY,
|
||||
ZFS_TYPE_POOL, "<size>", "SIZE");
|
||||
register_number(ZPOOL_PROP_USED, "used", 0, PROP_READONLY,
|
||||
ZFS_TYPE_POOL, "<size>", "USED");
|
||||
register_number(ZPOOL_PROP_AVAILABLE, "available", 0, PROP_READONLY,
|
||||
ZFS_TYPE_POOL, "<size>", "AVAIL");
|
||||
register_number(ZPOOL_PROP_CAPACITY, "capacity", 0, PROP_READONLY,
|
||||
zprop_register_number(ZPOOL_PROP_FREE, "free", 0, PROP_READONLY,
|
||||
ZFS_TYPE_POOL, "<size>", "FREE");
|
||||
zprop_register_number(ZPOOL_PROP_ALLOCATED, "allocated", 0,
|
||||
PROP_READONLY, ZFS_TYPE_POOL, "<size>", "ALLOC");
|
||||
zprop_register_number(ZPOOL_PROP_CAPACITY, "capacity", 0, PROP_READONLY,
|
||||
ZFS_TYPE_POOL, "<size>", "CAP");
|
||||
register_number(ZPOOL_PROP_GUID, "guid", 0, PROP_READONLY,
|
||||
zprop_register_number(ZPOOL_PROP_GUID, "guid", 0, PROP_READONLY,
|
||||
ZFS_TYPE_POOL, "<guid>", "GUID");
|
||||
register_number(ZPOOL_PROP_HEALTH, "health", 0, PROP_READONLY,
|
||||
zprop_register_number(ZPOOL_PROP_HEALTH, "health", 0, PROP_READONLY,
|
||||
ZFS_TYPE_POOL, "<state>", "HEALTH");
|
||||
zprop_register_number(ZPOOL_PROP_DEDUPRATIO, "dedupratio", 0,
|
||||
PROP_READONLY, ZFS_TYPE_POOL, "<1.00x or higher if deduped>",
|
||||
"DEDUP");
|
||||
|
||||
/* default number properties */
|
||||
register_number(ZPOOL_PROP_VERSION, "version", SPA_VERSION,
|
||||
zprop_register_number(ZPOOL_PROP_VERSION, "version", SPA_VERSION,
|
||||
PROP_DEFAULT, ZFS_TYPE_POOL, "<version>", "VERSION");
|
||||
zprop_register_number(ZPOOL_PROP_DEDUPDITTO, "dedupditto", 0,
|
||||
PROP_DEFAULT, ZFS_TYPE_POOL, "<threshold (min 100)>", "DEDUPDITTO");
|
||||
|
||||
/* default index (boolean) properties */
|
||||
register_index(ZPOOL_PROP_DELEGATION, "delegation", 1, PROP_DEFAULT,
|
||||
ZFS_TYPE_POOL, "on | off", "DELEGATION", boolean_table);
|
||||
register_index(ZPOOL_PROP_AUTOREPLACE, "autoreplace", 0, PROP_DEFAULT,
|
||||
ZFS_TYPE_POOL, "on | off", "REPLACE", boolean_table);
|
||||
register_index(ZPOOL_PROP_LISTSNAPS, "listsnapshots", 0, PROP_DEFAULT,
|
||||
ZFS_TYPE_POOL, "on | off", "LISTSNAPS", boolean_table);
|
||||
register_index(ZPOOL_PROP_AUTOEXPAND, "autoexpand", 0, PROP_DEFAULT,
|
||||
ZFS_TYPE_POOL, "on | off", "EXPAND", boolean_table);
|
||||
zprop_register_index(ZPOOL_PROP_DELEGATION, "delegation", 1,
|
||||
PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "DELEGATION",
|
||||
boolean_table);
|
||||
zprop_register_index(ZPOOL_PROP_AUTOREPLACE, "autoreplace", 0,
|
||||
PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "REPLACE", boolean_table);
|
||||
zprop_register_index(ZPOOL_PROP_LISTSNAPS, "listsnapshots", 0,
|
||||
PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "LISTSNAPS",
|
||||
boolean_table);
|
||||
zprop_register_index(ZPOOL_PROP_AUTOEXPAND, "autoexpand", 0,
|
||||
PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "EXPAND", boolean_table);
|
||||
|
||||
/* default index properties */
|
||||
register_index(ZPOOL_PROP_FAILUREMODE, "failmode",
|
||||
zprop_register_index(ZPOOL_PROP_FAILUREMODE, "failmode",
|
||||
ZIO_FAILURE_MODE_WAIT, PROP_DEFAULT, ZFS_TYPE_POOL,
|
||||
"wait | continue | panic", "FAILMODE", failuremode_table);
|
||||
|
||||
/* hidden properties */
|
||||
register_hidden(ZPOOL_PROP_NAME, "name", PROP_TYPE_STRING,
|
||||
zprop_register_hidden(ZPOOL_PROP_NAME, "name", PROP_TYPE_STRING,
|
||||
PROP_READONLY, ZFS_TYPE_POOL, "NAME");
|
||||
}
|
||||
|
||||
@@ -166,6 +173,12 @@ zpool_prop_index_to_string(zpool_prop_t prop, uint64_t index,
|
||||
return (zprop_index_to_string(prop, index, string, ZFS_TYPE_POOL));
|
||||
}
|
||||
|
||||
uint64_t
|
||||
zpool_prop_random_value(zpool_prop_t prop, uint64_t seed)
|
||||
{
|
||||
return (zprop_random_value(prop, seed, ZFS_TYPE_POOL));
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
|
||||
const char *
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
@@ -65,7 +65,7 @@ zprop_get_numprops(zfs_type_t type)
|
||||
}
|
||||
|
||||
void
|
||||
register_impl(int prop, const char *name, zprop_type_t type,
|
||||
zprop_register_impl(int prop, const char *name, zprop_type_t type,
|
||||
uint64_t numdefault, const char *strdefault, zprop_attr_t attr,
|
||||
int objset_types, const char *values, const char *colname,
|
||||
boolean_t rightalign, boolean_t visible, const zprop_index_t *idx_tbl)
|
||||
@@ -76,6 +76,8 @@ register_impl(int prop, const char *name, zprop_type_t type,
|
||||
pd = &prop_tbl[prop];
|
||||
|
||||
ASSERT(pd->pd_name == NULL || pd->pd_name == name);
|
||||
ASSERT(name != NULL);
|
||||
ASSERT(colname != NULL);
|
||||
|
||||
pd->pd_name = name;
|
||||
pd->pd_propnum = prop;
|
||||
@@ -89,40 +91,44 @@ register_impl(int prop, const char *name, zprop_type_t type,
|
||||
pd->pd_rightalign = rightalign;
|
||||
pd->pd_visible = visible;
|
||||
pd->pd_table = idx_tbl;
|
||||
pd->pd_table_size = 0;
|
||||
while (idx_tbl && (idx_tbl++)->pi_name != NULL)
|
||||
pd->pd_table_size++;
|
||||
}
|
||||
|
||||
void
|
||||
register_string(int prop, const char *name, const char *def,
|
||||
zprop_register_string(int prop, const char *name, const char *def,
|
||||
zprop_attr_t attr, int objset_types, const char *values,
|
||||
const char *colname)
|
||||
{
|
||||
register_impl(prop, name, PROP_TYPE_STRING, 0, def, attr,
|
||||
zprop_register_impl(prop, name, PROP_TYPE_STRING, 0, def, attr,
|
||||
objset_types, values, colname, B_FALSE, B_TRUE, NULL);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
register_number(int prop, const char *name, uint64_t def, zprop_attr_t attr,
|
||||
int objset_types, const char *values, const char *colname)
|
||||
zprop_register_number(int prop, const char *name, uint64_t def,
|
||||
zprop_attr_t attr, int objset_types, const char *values,
|
||||
const char *colname)
|
||||
{
|
||||
register_impl(prop, name, PROP_TYPE_NUMBER, def, NULL, attr,
|
||||
zprop_register_impl(prop, name, PROP_TYPE_NUMBER, def, NULL, attr,
|
||||
objset_types, values, colname, B_TRUE, B_TRUE, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
register_index(int prop, const char *name, uint64_t def, zprop_attr_t attr,
|
||||
int objset_types, const char *values, const char *colname,
|
||||
const zprop_index_t *idx_tbl)
|
||||
zprop_register_index(int prop, const char *name, uint64_t def,
|
||||
zprop_attr_t attr, int objset_types, const char *values,
|
||||
const char *colname, const zprop_index_t *idx_tbl)
|
||||
{
|
||||
register_impl(prop, name, PROP_TYPE_INDEX, def, NULL, attr,
|
||||
zprop_register_impl(prop, name, PROP_TYPE_INDEX, def, NULL, attr,
|
||||
objset_types, values, colname, B_TRUE, B_TRUE, idx_tbl);
|
||||
}
|
||||
|
||||
void
|
||||
register_hidden(int prop, const char *name, zprop_type_t type,
|
||||
zprop_register_hidden(int prop, const char *name, zprop_type_t type,
|
||||
zprop_attr_t attr, int objset_types, const char *colname)
|
||||
{
|
||||
register_impl(prop, name, type, 0, NULL, attr,
|
||||
zprop_register_impl(prop, name, type, 0, NULL, attr,
|
||||
objset_types, NULL, colname, B_FALSE, B_FALSE, NULL);
|
||||
}
|
||||
|
||||
@@ -307,6 +313,25 @@ zprop_index_to_string(int prop, uint64_t index, const char **string,
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a random valid property value. Used by ztest.
|
||||
*/
|
||||
uint64_t
|
||||
zprop_random_value(int prop, uint64_t seed, zfs_type_t type)
|
||||
{
|
||||
zprop_desc_t *prop_tbl;
|
||||
const zprop_index_t *idx_tbl;
|
||||
|
||||
ASSERT((uint_t)prop < zprop_get_numprops(type));
|
||||
prop_tbl = zprop_get_proptable(type);
|
||||
idx_tbl = prop_tbl[prop].pd_table;
|
||||
|
||||
if (idx_tbl == NULL)
|
||||
return (seed);
|
||||
|
||||
return (idx_tbl[seed % prop_tbl[prop].pd_table_size].pi_value);
|
||||
}
|
||||
|
||||
const char *
|
||||
zprop_values(int prop, zfs_type_t type)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user