diff options
Diffstat (limited to 'usr/src/uts/common/sys')
-rw-r--r-- | usr/src/uts/common/sys/Makefile | 3 | ||||
-rw-r--r-- | usr/src/uts/common/sys/acl.h | 112 | ||||
-rw-r--r-- | usr/src/uts/common/sys/autoconf.h | 2 | ||||
-rw-r--r-- | usr/src/uts/common/sys/avl.h | 18 | ||||
-rw-r--r-- | usr/src/uts/common/sys/debug.h | 55 | ||||
-rw-r--r-- | usr/src/uts/common/sys/dkio.h | 27 | ||||
-rw-r--r-- | usr/src/uts/common/sys/dktp/dadk.h | 6 | ||||
-rw-r--r-- | usr/src/uts/common/sys/dktp/dadkio.h | 6 | ||||
-rw-r--r-- | usr/src/uts/common/sys/esunddi.h | 4 | ||||
-rw-r--r-- | usr/src/uts/common/sys/fs/zfs.h | 308 | ||||
-rw-r--r-- | usr/src/uts/common/sys/kmem.h | 4 | ||||
-rw-r--r-- | usr/src/uts/common/sys/list.h | 8 | ||||
-rw-r--r-- | usr/src/uts/common/sys/mntent.h | 6 | ||||
-rw-r--r-- | usr/src/uts/common/sys/policy.h | 1 | ||||
-rw-r--r-- | usr/src/uts/common/sys/scsi/targets/sddef.h | 13 | ||||
-rw-r--r-- | usr/src/uts/common/sys/sunndi.h | 6 | ||||
-rw-r--r-- | usr/src/uts/common/sys/vnode.h | 4 | ||||
-rw-r--r-- | usr/src/uts/common/sys/zone.h | 23 |
18 files changed, 546 insertions, 60 deletions
diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile index 3bebf87a41..4af9e19f12 100644 --- a/usr/src/uts/common/sys/Makefile +++ b/usr/src/uts/common/sys/Makefile @@ -720,7 +720,8 @@ FSHDRS= \ ufs_prot.h \ ufs_quota.h \ ufs_snap.h \ - ufs_trans.h + ufs_trans.h \ + zfs.h PCMCIAHDRS= \ pcata.h \ diff --git a/usr/src/uts/common/sys/acl.h b/usr/src/uts/common/sys/acl.h index e6a7e43c77..7c34d88753 100644 --- a/usr/src/uts/common/sys/acl.h +++ b/usr/src/uts/common/sys/acl.h @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -44,11 +44,13 @@ typedef struct acl { typedef struct ace { uid_t a_who; /* uid or gid */ - uint32_t a_access_mask; /* "rwx" */ + uint32_t a_access_mask; /* read,write,... */ uint16_t a_flags; /* see below */ uint16_t a_type; /* allow or deny */ } ace_t; +typedef struct acl_info acl_t; + /* * The following are Defined types for an aclent_t. */ @@ -75,37 +77,61 @@ typedef struct ace { /* * The following are defined for ace_t. */ +#define ACE_READ_DATA 0x00000001 +#define ACE_LIST_DIRECTORY 0x00000001 +#define ACE_WRITE_DATA 0x00000002 +#define ACE_ADD_FILE 0x00000002 +#define ACE_APPEND_DATA 0x00000004 +#define ACE_ADD_SUBDIRECTORY 0x00000004 +#define ACE_READ_NAMED_ATTRS 0x00000008 +#define ACE_WRITE_NAMED_ATTRS 0x00000010 +#define ACE_EXECUTE 0x00000020 +#define ACE_DELETE_CHILD 0x00000040 +#define ACE_READ_ATTRIBUTES 0x00000080 +#define ACE_WRITE_ATTRIBUTES 0x00000100 +#define ACE_DELETE 0x00010000 +#define ACE_READ_ACL 0x00020000 +#define ACE_WRITE_ACL 0x00040000 +#define ACE_WRITE_OWNER 0x00080000 +#define ACE_SYNCHRONIZE 0x00100000 + #define ACE_FILE_INHERIT_ACE 0x0001 #define ACE_DIRECTORY_INHERIT_ACE 0x0002 -#define ACE_NO_PROPOGATE_INHERIT_ACE 0x0004 +#define ACE_NO_PROPAGATE_INHERIT_ACE 0x0004 #define ACE_INHERIT_ONLY_ACE 0x0008 -#define ACE_LOCALLY_DEFINED 0x0010 -#define ACE_OWNER 0x0100 /* file owner */ -#define ACE_GROUP 0x0200 /* file group */ -#define ACE_OTHER 0x0400 /* other field */ -#define ACE_USER 0x0800 /* additional users */ -#define ACE_GROUPS 0x1000 /* additional groups */ +#define ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x0010 +#define ACE_FAILED_ACCESS_ACE_FLAG 0x0020 +#define ACE_IDENTIFIER_GROUP 0x0040 +#define ACE_OWNER 0x1000 +#define ACE_GROUP 0x2000 +#define ACE_EVERYONE 0x4000 + +#define ACE_ACCESS_ALLOWED_ACE_TYPE 0x0000 +#define ACE_ACCESS_DENIED_ACE_TYPE 0x0001 +#define ACE_SYSTEM_AUDIT_ACE_TYPE 0x0002 +#define ACE_SYSTEM_ALARM_ACE_TYPE 0x0003 + +#define ACE_ALL_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \ + ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \ + ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \ + ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_WRITE_ACL| \ + ACE_WRITE_OWNER|ACE_SYNCHRONIZE) + /* * The following flags are supported by both NFSv4 ACLs and ace_t. */ #define ACE_NFSV4_SUP_FLAGS (ACE_FILE_INHERIT_ACE | \ ACE_DIRECTORY_INHERIT_ACE | \ - ACE_NO_PROPOGATE_INHERIT_ACE | \ - ACE_INHERIT_ONLY_ACE) - -#define ALLOW 0 -#define DENY 1 - -#define ACE_READ_DATA 04 /* 'r' */ -#define ACE_WRITE_DATA 02 /* 'w' */ -#define ACE_EXECUTE 01 /* 'x' */ + ACE_NO_PROPAGATE_INHERIT_ACE | \ + ACE_INHERIT_ONLY_ACE | \ + ACE_IDENTIFIER_GROUP) /* cmd args to acl(2) for aclent_t */ #define GETACL 1 #define SETACL 2 #define GETACLCNT 3 -/* cmd's to manipulate ace acl's. */ +/* cmd's to manipulate ace acls. */ #define ACE_GETACL 4 #define ACE_SETACL 5 #define ACE_GETACLCNT 6 @@ -125,6 +151,7 @@ typedef struct ace { #define MEM_ERROR 7 #define ENTRY_ERROR 8 + /* * similar to ufs_acl.h: changed to char type for user commands (tar, cpio) * Attribute types @@ -132,6 +159,43 @@ typedef struct ace { #define UFSD_FREE ('0') /* Free entry */ #define UFSD_ACL ('1') /* Access Control Lists */ #define UFSD_DFACL ('2') /* reserved for future use */ +#define ACE_ACL ('3') /* ace_t style acls */ + +/* + * flag to [f]acl_get() + * controls whether a trivial acl should be returned. + */ +#define ACL_NO_TRIVIAL 0x2 + +/* + * Legacy aclcheck errors for aclent_t ACLs + */ +#define EACL_GRP_ERROR GRP_ERROR +#define EACL_USER_ERROR USER_ERROR +#define EACL_OTHER_ERROR OTHER_ERROR +#define EACL_CLASS_ERROR CLASS_ERROR +#define EACL_DUPLICATE_ERROR DUPLICATE_ERROR +#define EACL_MISS_ERROR MISS_ERROR +#define EACL_MEM_ERROR MEM_ERROR +#define EACL_ENTRY_ERROR ENTRY_ERROR + +#define EACL_INHERIT_ERROR 9 /* invalid inherit flags */ +#define EACL_FLAGS_ERROR 10 /* unknown flag value */ +#define EACL_PERM_MASK_ERROR 11 /* unknown permission */ +#define EACL_COUNT_ERROR 12 /* invalid acl count */ + +#define EACL_INVALID_SLOT 13 /* invalid acl slot */ +#define EACL_NO_ACL_ENTRY 14 /* Entry doesn't exist */ +#define EACL_DIFF_TYPE 15 /* acls aren't same type */ + +#define EACL_INVALID_USER_GROUP 16 /* need user/group name */ +#define EACL_INVALID_STR 17 /* invalid acl string */ +#define EACL_FIELD_NOT_BLANK 18 /* can't have blank field */ +#define EACL_INVALID_ACCESS_TYPE 19 /* invalid access type */ +#define EACL_UNKNOWN_DATA 20 /* Unrecognized data in ACL */ +#define EACL_MISSING_FIELDS 21 /* missing fields in acl */ + +#define EACL_INHERIT_NOTDIR 22 /* Need dir for inheritance */ extern int aclcheck(aclent_t *, int, int *); extern int acltomode(aclent_t *, int, mode_t *); @@ -139,6 +203,16 @@ extern int aclfrommode(aclent_t *, int, mode_t *); extern int aclsort(int, int, aclent_t *); extern char *acltotext(aclent_t *, int); extern aclent_t *aclfromtext(char *, int *); +extern void acl_free(acl_t *); +extern int acl_get(const char *, int, acl_t **); +extern int facl_get(int, int, acl_t **); +extern int acl_set(const char *, acl_t *acl); +extern int facl_set(int, acl_t *acl); +extern int acl_strip(const char *, uid_t, gid_t, mode_t); +extern int acl_trivial(const char *); +extern char *acl_totext(acl_t *); +extern int acl_fromtext(const char *, acl_t **); +extern int acl_check(acl_t *, int); #else /* !defined(_KERNEL) */ diff --git a/usr/src/uts/common/sys/autoconf.h b/usr/src/uts/common/sys/autoconf.h index a3ff515d1d..73082ab412 100644 --- a/usr/src/uts/common/sys/autoconf.h +++ b/usr/src/uts/common/sys/autoconf.h @@ -236,7 +236,7 @@ extern int exclude_level(int); extern major_t path_to_major(char *); extern void i_ddi_node_cache_init(void); -extern dev_info_t *i_ddi_alloc_node(dev_info_t *, char *, dnode_t, int, +extern dev_info_t *i_ddi_alloc_node(dev_info_t *, char *, pnode_t, int, ddi_prop_t *, int); extern void i_ddi_forceattach_drivers(void); extern int i_ddi_io_initialized(void); diff --git a/usr/src/uts/common/sys/avl.h b/usr/src/uts/common/sys/avl.h index f3dbce7d9d..bf9af8948a 100644 --- a/usr/src/uts/common/sys/avl.h +++ b/usr/src/uts/common/sys/avl.h @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -78,7 +78,7 @@ extern "C" { * * followed by any mixture of: * - * 2a. Insert nodes with: avl_find() and avl_insert() + * 2a. Insert nodes with: avl_add(), or avl_find() and avl_insert() * * 2b. Visited elements with: * avl_first() - returns the lowest valued node @@ -89,7 +89,7 @@ extern "C" { * 2c. Find the node with the closest value either less than or greater * than a given value with avl_nearest(). * - * 2d. Remove individual nodes from the list/tree with avl_remove. + * 2d. Remove individual nodes from the list/tree with avl_remove(). * * and finally when the list is being destroyed * @@ -235,7 +235,17 @@ extern void *avl_nearest(avl_tree_t *tree, avl_index_t where, int direction); /* - * Remove a single node from the tree. + * Add a single node to the tree. + * The node must not be in the tree, and it must not + * compare equal to any other node already in the tree. + * + * node - the node to add + */ +extern void avl_add(avl_tree_t *tree, void *node); + + +/* + * Remove a single node from the tree. The node must be in the tree. * * node - the node to remove */ diff --git a/usr/src/uts/common/sys/debug.h b/usr/src/uts/common/sys/debug.h index a114dc0e99..cc419e5132 100644 --- a/usr/src/uts/common/sys/debug.h +++ b/usr/src/uts/common/sys/debug.h @@ -20,12 +20,12 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ #ifndef _SYS_DEBUG_H @@ -34,6 +34,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include <sys/isa_defs.h> +#include <sys/types.h> #ifdef __cplusplus extern "C" { @@ -43,29 +44,22 @@ extern "C" { * ASSERT(ex) causes a panic or debugger entry if expression ex is not * true. ASSERT() is included only for debugging, and is a no-op in * production kernels. VERIFY(ex), on the other hand, behaves like - * ASSERT on debug kernels but evaluates the expression on non-debug - * kernels. + * ASSERT and is evaluated on both debug and non-debug kernels. */ -#ifdef _KERNEL -#if DEBUG -#define VERIFY(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__))) -#else -#define VERIFY(EX) ((void)(EX)) -#endif -#endif - #if defined(__STDC__) extern int assfail(const char *, const char *, int); +#define VERIFY(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__))) #if DEBUG -#define ASSERT(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__))) +#define ASSERT(EX) VERIFY(EX) #else #define ASSERT(x) ((void)0) #endif #else /* defined(__STDC__) */ extern int assfail(); +#define VERIFY(EX) ((void)((EX) || assfail("EX", __FILE__, __LINE__))) #if DEBUG -#define ASSERT(EX) ((void)((EX) || assfail("EX", __FILE__, __LINE__))) +#define ASSERT(EX) VERIFY(EX) #else #define ASSERT(x) ((void)0) #endif @@ -82,6 +76,39 @@ extern int assfail(); #define ASSERT32(x) ASSERT(x) #endif +/* + * ASSERT3() behaves like ASSERT() except that it is an explicit conditional, + * and prints out the values of the left and right hand expressions as part of + * the panic message to ease debugging. The three variants imply the type + * of their arguments. ASSERT3S() is for signed data types, ASSERT3U() is + * for unsigned, and ASSERT3P() is for pointers. The VERIFY3*() macros + * have the same relationship as above. + */ +extern void assfail3(const char *, uintmax_t, const char *, uintmax_t, + const char *, int); +#define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \ + const TYPE __left = (TYPE)(LEFT); \ + const TYPE __right = (TYPE)(RIGHT); \ + if (!(__left OP __right)) \ + assfail3(#LEFT " " #OP " " #RIGHT, \ + (uintmax_t)__left, #OP, (uintmax_t)__right, \ + __FILE__, __LINE__); \ +_NOTE(CONSTCOND) } while (0) + + +#define VERIFY3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t) +#define VERIFY3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t) +#define VERIFY3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t) +#if DEBUG +#define ASSERT3S(x, y, z) VERIFY3S(x, y, z) +#define ASSERT3U(x, y, z) VERIFY3U(x, y, z) +#define ASSERT3P(x, y, z) VERIFY3P(x, y, z) +#else +#define ASSERT3S(x, y, z) ((void)0) +#define ASSERT3U(x, y, z) ((void)0) +#define ASSERT3P(x, y, z) ((void)0) +#endif + #ifdef _KERNEL extern void abort_sequence_enter(char *); diff --git a/usr/src/uts/common/sys/dkio.h b/usr/src/uts/common/sys/dkio.h index 546976eea4..b3de6726c8 100644 --- a/usr/src/uts/common/sys/dkio.h +++ b/usr/src/uts/common/sys/dkio.h @@ -167,6 +167,33 @@ struct dk_geom { #define DKIOCSVTOC (DKIOC|12) /* Set VTOC & Write to Disk */ /* + * Disk Cache Controls. These ioctls should be supported by + * all disk drivers. + * + * DKIOCFLUSHWRITECACHE when used from user-mode ignores the ioctl + * argument, but it should be passed as NULL to allow for future + * reinterpretation. From user-mode, this ioctl request is synchronous. + * + * When invoked from within the kernel, the arg can be NULL to indicate + * a synchronous request or can be the address of a struct dk_callback + * to request an asynchronous callback when the flush request is complete. + * In this case, the flag to the ioctl must include FKIOCTL and the + * dkc_callback field of the pointed to struct must be non-null or the + * request is made synchronously. + * + * In the callback case: if the ioctl returns 0, a callback WILL be performed. + * If the ioctl returns non-zero, a callback will NOT be performed. + * NOTE: In some cases, the callback may be done BEFORE the ioctl call + * returns. The caller's locking strategy should be prepared for this case. + */ +#define DKIOCFLUSHWRITECACHE (DKIOC|34) /* flush cache to phys medium */ + +struct dk_callback { + void (*dkc_callback)(void *dkc_cookie, int error); + void *dkc_cookie; +}; + +/* * The following ioctls are used by Sun drivers to communicate * with their associated format routines. Support of these ioctls * is not required of foreign drivers diff --git a/usr/src/uts/common/sys/dktp/dadk.h b/usr/src/uts/common/sys/dktp/dadk.h index 1b1853e17b..0db566bd50 100644 --- a/usr/src/uts/common/sys/dktp/dadk.h +++ b/usr/src/uts/common/sys/dktp/dadk.h @@ -45,7 +45,9 @@ struct dadk { unsigned dad_rmb : 1; /* removable device */ unsigned dad_rdonly : 1; /* read only device */ unsigned dad_cdrom : 1; /* cdrom device */ - unsigned dad_resv : 5; + unsigned dad_noflush : 1; /* flush cmd unsupported */ + unsigned dad_wce : 1; /* disk write cache enabled */ + unsigned dad_resv : 3; unsigned char dad_type; /* device type */ unsigned char dad_ctype; /* controller type */ @@ -74,6 +76,7 @@ struct dadk { */ #define DADK_BSY_TIMEOUT (drv_usectohz(5 * 1000000)) #define DADK_IO_TIME 35 +#define DADK_FLUSH_CACHE_TIME 60 #define DADK_RETRY_COUNT 5 #define DADK_SILENT 1 @@ -97,6 +100,7 @@ int dadk_open(opaque_t objp, int flag); int dadk_close(opaque_t objp); int dadk_ioctl(opaque_t objp, dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cred_p, int *rval_p); +int dadk_flushdone(struct buf *bp); int dadk_strategy(opaque_t objp, struct buf *bp); int dadk_setgeom(opaque_t objp, struct tgdk_geom *dkgeom_p); int dadk_getgeom(opaque_t objp, struct tgdk_geom *dkgeom_p); diff --git a/usr/src/uts/common/sys/dktp/dadkio.h b/usr/src/uts/common/sys/dktp/dadkio.h index d5ff7c8cc5..a6c2e792d1 100644 --- a/usr/src/uts/common/sys/dktp/dadkio.h +++ b/usr/src/uts/common/sys/dktp/dadkio.h @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -39,7 +39,7 @@ extern "C" { #define DIOCTL_GETMODEL 3 /* get model number */ #define DIOCTL_GETSERIAL 4 /* get serial number */ #define DIOCTL_RWCMD 5 /* read/write a disk */ - +#define DIOCTL_GETWCE 6 /* get write cache enabled state */ /* * arg structure for DIOCTL_GETMODEL and DIOCTL_GETSERIAL * On input to the ioctl, is_size contains the size of the buffer @@ -92,6 +92,8 @@ typedef struct dadk_ioc_string #define DCMD_READOFFSET 24 /* cdrom read offset */ #define DCMD_READMODE2 25 /* cdrom mode 2 */ #define DCMD_VOLCTRL 26 /* cdrom volume control */ +/* additional disk commands */ +#define DCMD_FLUSH_CACHE 27 /* flush write cache to physical medium */ /* driver error code */ #define DERR_SUCCESS 0 /* success */ diff --git a/usr/src/uts/common/sys/esunddi.h b/usr/src/uts/common/sys/esunddi.h index e057d7e36e..3cde0b2b14 100644 --- a/usr/src/uts/common/sys/esunddi.h +++ b/usr/src/uts/common/sys/esunddi.h @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -211,7 +211,7 @@ e_ddi_walk_driver(char *, int (*f)(dev_info_t *, void *), void *); * NOTE: .conf nodeids are not valid arguments to this function. */ dev_info_t * -e_ddi_nodeid_to_dip(dnode_t nodeid); +e_ddi_nodeid_to_dip(pnode_t nodeid); /* * Obsolete interfaces, no longer used, to be removed. diff --git a/usr/src/uts/common/sys/fs/zfs.h b/usr/src/uts/common/sys/fs/zfs.h new file mode 100644 index 0000000000..b40f4789b6 --- /dev/null +++ b/usr/src/uts/common/sys/fs/zfs.h @@ -0,0 +1,308 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_ZFS_H +#define _SYS_FS_ZFS_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Types and constants shared between userland and the kernel. + */ + +/* + * Each dataset can be one of the following types. These constants can be + * combined into masks that can be passed to various functions. + */ +typedef enum { + ZFS_TYPE_FILESYSTEM = 0x1, + ZFS_TYPE_SNAPSHOT = 0x2, + ZFS_TYPE_VOLUME = 0x4 +} zfs_type_t; + +#define ZFS_TYPE_ANY \ + (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) + +/* + * Properties are identified by these constants. They are arranged in order of + * how they should be displayed by 'zfs get'. If you make any changes to this + * list, be sure to update the property table in usr/src/common/zfs/zfs_prop.c. + */ +typedef enum { + ZFS_PROP_INVAL = -1, + ZFS_PROP_TYPE, + ZFS_PROP_CREATION, + ZFS_PROP_USED, + ZFS_PROP_AVAILABLE, + ZFS_PROP_REFERENCED, + ZFS_PROP_COMPRESSRATIO, + ZFS_PROP_MOUNTED, + ZFS_PROP_ORIGIN, + ZFS_PROP_QUOTA, + ZFS_PROP_RESERVATION, + ZFS_PROP_VOLSIZE, + ZFS_PROP_VOLBLOCKSIZE, + ZFS_PROP_RECORDSIZE, + ZFS_PROP_MOUNTPOINT, + ZFS_PROP_SHARENFS, + ZFS_PROP_CHECKSUM, + ZFS_PROP_COMPRESSION, + ZFS_PROP_ATIME, + ZFS_PROP_DEVICES, + ZFS_PROP_EXEC, + ZFS_PROP_SETUID, + ZFS_PROP_READONLY, + ZFS_PROP_ZONED, + ZFS_PROP_SNAPDIR, + ZFS_PROP_ACLMODE, + ZFS_PROP_ACLINHERIT, + /* + * The following properties are not exposed to the user, but are + * accessible by libzfs clients. + */ + ZFS_PROP_CREATETXG, + ZFS_PROP_NAME, + ZFS_NPROP_ALL +} zfs_prop_t; + +#define ZFS_NPROP_VISIBLE ZFS_PROP_CREATETXG + +/* + * The following functions are shared between libzfs and the kernel. + */ +zfs_prop_t zfs_name_to_prop(const char *); +int zfs_prop_readonly(zfs_prop_t); +void zfs_prop_default_string(zfs_prop_t, char *, size_t); +uint64_t zfs_prop_default_numeric(zfs_prop_t); + +/* + * The following are configuration names used in the nvlist describing a pool's + * configuration. + */ +#define ZPOOL_CONFIG_VERSION "version" +#define ZPOOL_CONFIG_POOL_NAME "name" +#define ZPOOL_CONFIG_POOL_STATE "state" +#define ZPOOL_CONFIG_POOL_TXG "txg" +#define ZPOOL_CONFIG_POOL_GUID "pool_guid" +#define ZPOOL_CONFIG_CREATE_TXG "create_txg" +#define ZPOOL_CONFIG_TOP_GUID "top_guid" +#define ZPOOL_CONFIG_POOL_HEALTH "pool_health" +#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" +#define ZPOOL_CONFIG_TYPE "type" +#define ZPOOL_CONFIG_CHILDREN "children" +#define ZPOOL_CONFIG_ID "id" +#define ZPOOL_CONFIG_GUID "guid" +#define ZPOOL_CONFIG_PATH "path" +#define ZPOOL_CONFIG_DEVID "devid" +#define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" +#define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" +#define ZPOOL_CONFIG_ASHIFT "ashift" +#define ZPOOL_CONFIG_ASIZE "asize" +#define ZPOOL_CONFIG_DTL "DTL" +#define ZPOOL_CONFIG_STATS "stats" + +#define VDEV_TYPE_ROOT "root" +#define VDEV_TYPE_MIRROR "mirror" +#define VDEV_TYPE_REPLACING "replacing" +#define VDEV_TYPE_RAIDZ "raidz" +#define VDEV_TYPE_DISK "disk" +#define VDEV_TYPE_FILE "file" +#define VDEV_TYPE_MISSING "missing" + +/* + * This is needed in userland to report the minimum necessary device size. + */ +#define SPA_MINDEVSIZE (64ULL << 20) + +/* + * The location of the pool configuration repository, shared between kernel and + * userland. + */ +#define ZPOOL_CACHE_DIR "/etc/zfs" +#define ZPOOL_CACHE_FILE "zpool.cache" +#define ZPOOL_CACHE_TMP ".zpool.cache" + +#define ZPOOL_CACHE ZPOOL_CACHE_DIR "/" ZPOOL_CACHE_FILE + +/* + * vdev states are ordered from least to most healthy. + * A vdev that's CANT_OPEN or below is considered unusable. + */ +typedef enum vdev_state { + VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ + VDEV_STATE_CLOSED, /* Not currently open */ + VDEV_STATE_OFFLINE, /* Not allowed to open */ + VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ + VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ + VDEV_STATE_HEALTHY /* Presumed good */ +} vdev_state_t; + +/* + * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field + * of the vdev stats structure uses these constants to distinguish why. + */ +typedef enum vdev_aux { + VDEV_AUX_NONE, /* no error */ + VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ + VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ + VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ + VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ + VDEV_AUX_TOO_SMALL, /* vdev size is too small */ + VDEV_AUX_BAD_LABEL /* the label is OK but invalid */ +} vdev_aux_t; + +/* + * pool state. The following states are actually written to disk as part of the + * normal SPA lifecycle: ACTIVE, EXPORTED, DESTROYED. The remaining states + * (UNITIALIZED, UNAVAIL) are software abstractions used at various levels to + * communicate pool state. + */ +typedef enum pool_state { + POOL_STATE_ACTIVE = 0, /* In active use */ + POOL_STATE_EXPORTED, /* Explicitly exported */ + POOL_STATE_DESTROYED, /* Explicitly destroyed */ + POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ + POOL_STATE_UNAVAIL /* Internal libzfs state */ +} pool_state_t; + +/* + * Scrub types. + */ +typedef enum pool_scrub_type { + POOL_SCRUB_NONE, + POOL_SCRUB_RESILVER, + POOL_SCRUB_EVERYTHING, + POOL_SCRUB_TYPES +} pool_scrub_type_t; + +/* + * ZIO types. Needed to interpret vdev statistics below. + */ +typedef enum zio_type { + ZIO_TYPE_NULL = 0, + ZIO_TYPE_READ, + ZIO_TYPE_WRITE, + ZIO_TYPE_FREE, + ZIO_TYPE_CLAIM, + ZIO_TYPE_IOCTL, + ZIO_TYPES +} zio_type_t; + +/* + * Vdev statistics. Note: all fields should be 64-bit because this + * is passed between kernel and userland as an nvlist uint64 array. + */ +typedef struct vdev_stat { + hrtime_t vs_timestamp; /* time since vdev load */ + uint64_t vs_state; /* vdev state */ + uint64_t vs_aux; /* see vdev_aux_t */ + uint64_t vs_alloc; /* space allocated */ + uint64_t vs_space; /* total capacity */ + uint64_t vs_ops[ZIO_TYPES]; /* operation count */ + uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */ + uint64_t vs_read_errors; /* read errors */ + 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 */ +} vdev_stat_t; + +#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. + */ +#define ZVOL_PSEUDO_DEV "/devices/pseudo/zvol@0:" +#define ZVOL_FULL_DEV_DIR "/dev/" ZVOL_DEV_DIR + +#define ZVOL_PROP_NAME "name" + +/* + * /dev/zfs ioctl numbers. + */ +#define ZFS_IOC ('Z' << 8) + +typedef enum zfs_ioc { + ZFS_IOC_POOL_CREATE = ZFS_IOC, + ZFS_IOC_POOL_DESTROY, + ZFS_IOC_POOL_IMPORT, + ZFS_IOC_POOL_EXPORT, + ZFS_IOC_POOL_CONFIGS, + ZFS_IOC_POOL_GUID, + ZFS_IOC_POOL_STATS, + ZFS_IOC_POOL_TRYIMPORT, + ZFS_IOC_POOL_SCRUB, + ZFS_IOC_POOL_FREEZE, + ZFS_IOC_VDEV_ADD, + ZFS_IOC_VDEV_REMOVE, + ZFS_IOC_VDEV_ONLINE, + ZFS_IOC_VDEV_OFFLINE, + ZFS_IOC_VDEV_ATTACH, + ZFS_IOC_VDEV_DETACH, + ZFS_IOC_OBJSET_STATS, + ZFS_IOC_DATASET_LIST_NEXT, + ZFS_IOC_SNAPSHOT_LIST_NEXT, + ZFS_IOC_SET_PROP, + ZFS_IOC_SET_QUOTA, + ZFS_IOC_SET_RESERVATION, + ZFS_IOC_SET_VOLSIZE, + ZFS_IOC_SET_VOLBLOCKSIZE, + ZFS_IOC_CREATE_MINOR, + ZFS_IOC_REMOVE_MINOR, + ZFS_IOC_CREATE, + ZFS_IOC_DESTROY, + ZFS_IOC_ROLLBACK, + ZFS_IOC_RENAME, + ZFS_IOC_RECVBACKUP, + ZFS_IOC_SENDBACKUP +} zfs_ioc_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_ZFS_H */ diff --git a/usr/src/uts/common/sys/kmem.h b/usr/src/uts/common/sys/kmem.h index b0e0e030e7..097e92f2e5 100644 --- a/usr/src/uts/common/sys/kmem.h +++ b/usr/src/uts/common/sys/kmem.h @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -92,6 +92,7 @@ extern void kmem_thread_init(void); extern void kmem_mp_init(void); extern void kmem_reap(void); extern void kmem_reap_idspace(void); +extern int kmem_debugging(void); extern size_t kmem_avail(void); extern size_t kmem_maxavail(void); @@ -102,6 +103,7 @@ extern void kmem_cache_destroy(kmem_cache_t *); extern void *kmem_cache_alloc(kmem_cache_t *, int); extern void kmem_cache_free(kmem_cache_t *, void *); extern uint64_t kmem_cache_stat(kmem_cache_t *, char *); +extern void kmem_cache_reap_now(kmem_cache_t *); #endif /* _KERNEL */ diff --git a/usr/src/uts/common/sys/list.h b/usr/src/uts/common/sys/list.h index dc22eb1abd..7e9d9aaaf7 100644 --- a/usr/src/uts/common/sys/list.h +++ b/usr/src/uts/common/sys/list.h @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -36,9 +36,6 @@ extern "C" { #endif typedef struct list_node list_node_t; -struct list; - -#ifdef _KERNEL typedef struct list list_t; void list_create(list_t *, size_t, size_t); @@ -56,7 +53,8 @@ void *list_tail(list_t *); void *list_next(list_t *, void *); void *list_prev(list_t *, void *); -#endif /* _KERNEL */ +int list_link_active(list_node_t *); +int list_is_empty(list_t *); #ifdef __cplusplus } diff --git a/usr/src/uts/common/sys/mntent.h b/usr/src/uts/common/sys/mntent.h index 75217cabda..ef1e297430 100644 --- a/usr/src/uts/common/sys/mntent.h +++ b/usr/src/uts/common/sys/mntent.h @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T @@ -40,6 +40,7 @@ extern "C" { #define VFSTAB "/etc/vfstab" #define MNTMAXSTR 128 +#define MNTTYPE_ZFS "zfs" /* ZFS file system */ #define MNTTYPE_UFS "ufs" /* Unix file system */ #define MNTTYPE_NFS "nfs" /* NFS file system */ #define MNTTYPE_NFS3 "nfs3" /* NFS Version 3 file system */ @@ -116,7 +117,8 @@ extern "C" { #define MNTOPT_PUBLIC "public" /* Use NFS public file handlee */ #define MNTOPT_LOGGING "logging" /* enable logging */ #define MNTOPT_NOLOGGING "nologging" /* disable logging */ -#define MNTOPT_NOATIME "noatime" /* Do not update i_atime for inodes */ +#define MNTOPT_ATIME "atime" /* update atime for files */ +#define MNTOPT_NOATIME "noatime" /* do not update atime for files */ #define MNTOPT_GLOBAL "global" /* Cluster-wide global mount */ #define MNTOPT_NOGLOBAL "noglobal" /* Mount local to single node */ #define MNTOPT_DFRATIME "dfratime" /* Deferred access time updates */ diff --git a/usr/src/uts/common/sys/policy.h b/usr/src/uts/common/sys/policy.h index 3ac69f9bda..c26ef92d31 100644 --- a/usr/src/uts/common/sys/policy.h +++ b/usr/src/uts/common/sys/policy.h @@ -140,6 +140,7 @@ int secpolicy_vnode_setdac(const cred_t *, uid_t); int secpolicy_vnode_setid_retain(const cred_t *, boolean_t); int secpolicy_vnode_setids_setgids(const cred_t *, gid_t); int secpolicy_vnode_stky_modify(const cred_t *); +int secpolicy_zfs(const cred_t *); int secpolicy_basic_exec(const cred_t *); int secpolicy_basic_fork(const cred_t *); diff --git a/usr/src/uts/common/sys/scsi/targets/sddef.h b/usr/src/uts/common/sys/scsi/targets/sddef.h index ee2dfeefea..3b2a45b099 100644 --- a/usr/src/uts/common/sys/scsi/targets/sddef.h +++ b/usr/src/uts/common/sys/scsi/targets/sddef.h @@ -422,8 +422,8 @@ struct sd_lun { /* a part of error recovery. */ un_f_is_fibre :1, /* The device supports fibre */ /* channel */ - un_f_available :1, /* Not use */ - /* available */ + un_f_sync_cache_unsupported :1, /* sync cache cmd not */ + /* supported */ un_f_format_in_progress :1, /* The device is currently */ /* executing a FORMAT cmd. */ un_f_opt_queueing :1, /* Enable Command Queuing to */ @@ -433,7 +433,9 @@ struct sd_lun { un_f_opt_disable_cache :1, /* Read/Write disk cache is */ /* disabled. */ un_f_cfg_is_atapi :1, /* This is an ATAPI device. */ - un_f_cfg_obsolete :1, /* available for reuse */ + un_f_write_cache_enabled :1, /* device return success on */ + /* writes before transfer to */ + /* physical media complete */ un_f_cfg_playmsf_bcd :1, /* Play Audio, BCD params. */ un_f_cfg_readsub_bcd :1, /* READ SUBCHANNEL BCD resp. */ un_f_cfg_read_toc_trk_bcd :1, /* track # is BCD */ @@ -1414,6 +1416,11 @@ _NOTE(SCHEME_PROTECTS_DATA("unique per pkt", sd_xbuf)) struct sd_uscsi_info { int ui_flags; struct uscsi_cmd *ui_cmdp; + /* + * ui_dkc is used by sd_send_scsi_SYNCHRONIZE_CACHE() to allow + * for async completion notification. + */ + struct dk_callback ui_dkc; }; _NOTE(SCHEME_PROTECTS_DATA("Unshared data", sd_uscsi_info)) diff --git a/usr/src/uts/common/sys/sunndi.h b/usr/src/uts/common/sys/sunndi.h index 60f2970ce5..09b8c83bb6 100644 --- a/usr/src/uts/common/sys/sunndi.h +++ b/usr/src/uts/common/sys/sunndi.h @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -119,11 +119,11 @@ ndi_prop_remove_all(dev_info_t *dip); * not allowed to sleep. */ int -ndi_devi_alloc(dev_info_t *parent, char *node_name, dnode_t nodeid, +ndi_devi_alloc(dev_info_t *parent, char *node_name, pnode_t nodeid, dev_info_t **ret_dip); void -ndi_devi_alloc_sleep(dev_info_t *parent, char *node_name, dnode_t nodeid, +ndi_devi_alloc_sleep(dev_info_t *parent, char *node_name, pnode_t nodeid, dev_info_t **ret_dip); /* diff --git a/usr/src/uts/common/sys/vnode.h b/usr/src/uts/common/sys/vnode.h index 4fd3444bc0..904d7a80ec 100644 --- a/usr/src/uts/common/sys/vnode.h +++ b/usr/src/uts/common/sys/vnode.h @@ -912,7 +912,9 @@ extern uint_t pvn_vmodsort_supported; * Generally useful macros. */ #define VBSIZE(vp) ((vp)->v_vfsp->vfs_bsize) -#define VTOZ(vp) ((vp)->v_vfsp->vfs_zone) + +#define VTOZONE(vp) ((vp)->v_vfsp->vfs_zone) + #define NULLVP ((struct vnode *)0) #define NULLVPP ((struct vnode **)0) diff --git a/usr/src/uts/common/sys/zone.h b/usr/src/uts/common/sys/zone.h index 0bc997a57b..fbcbea12fa 100644 --- a/usr/src/uts/common/sys/zone.h +++ b/usr/src/uts/common/sys/zone.h @@ -84,6 +84,8 @@ typedef struct { caddr32_t rctlbuf; size32_t rctlbufsz; caddr32_t extended_error; + caddr32_t zfsbuf; + size32_t zfsbufsz; } zone_def32; #endif typedef struct { @@ -93,6 +95,8 @@ typedef struct { const char *rctlbuf; size_t rctlbufsz; int *extended_error; + const char *zfsbuf; + size_t zfsbufsz; } zone_def; /* extended error information */ @@ -185,6 +189,14 @@ typedef struct zone_cmd_rval { struct pool; +/* + * Structure to record list of ZFS datasets exported to a zone. + */ +typedef struct zone_dataset { + char *zd_dataset; + list_node_t zd_linkage; +} zone_dataset_t; + typedef struct zone { /* * zone_name is never modified once set. @@ -259,6 +271,10 @@ typedef struct zone { */ int zone_ncpus; /* zone's idea of ncpus */ int zone_ncpus_online; /* zone's idea of ncpus_online */ + /* + * List of ZFS datasets exported to this zone. + */ + list_t zone_datasets; /* list of datasets */ } zone_t; /* @@ -273,7 +289,7 @@ extern rctl_hndl_t rc_zone_nlwps; extern const char * const zone_initname; -extern long zone(int, void *, void *, void *, void *, void *); +extern long zone(int, void *, void *, void *, void *); extern void zone_zsd_init(void); extern void zone_init(void); extern void zone_hold(zone_t *); @@ -425,6 +441,11 @@ extern int zone_ncpus_get(zone_t *); extern int zone_ncpus_online_get(zone_t *); /* + * Returns true if the named pool/dataset is visible in the current zone. + */ +extern int zone_dataset_visible(const char *, int *); + +/* * zone version of uadmin() */ extern int zone_uadmin(int, int, struct cred *); |