Home | History | Annotate | Download | only in sys
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  */
     22 /*
     23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  */
     26 
     27 #ifndef	_SYS_FS_ZFS_VFSOPS_H
     28 #define	_SYS_FS_ZFS_VFSOPS_H
     29 
     30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     31 
     32 #include <sys/isa_defs.h>
     33 #include <sys/types32.h>
     34 #include <sys/list.h>
     35 #include <sys/vfs.h>
     36 #include <sys/zil.h>
     37 
     38 #ifdef	__cplusplus
     39 extern "C" {
     40 #endif
     41 
     42 typedef struct zfs_delete_list {
     43 	kmutex_t		z_mutex;
     44 	kcondvar_t		z_cv;
     45 	kcondvar_t		z_quiesce_cv;
     46 	uint8_t			z_drained;
     47 	uint8_t			z_draining;
     48 	uint32_t		z_thread_target;
     49 	uint32_t		z_thread_count;
     50 	uint64_t		z_znode_count;
     51 	list_t			z_znodes;
     52 } zfs_delete_t;
     53 
     54 typedef struct zfsvfs zfsvfs_t;
     55 
     56 struct zfsvfs {
     57 	vfs_t		*z_vfs;		/* generic fs struct */
     58 	zfsvfs_t	*z_parent;	/* parent fs */
     59 	objset_t	*z_os;		/* objset reference */
     60 	uint64_t	z_root;		/* id of root znode */
     61 	uint64_t	z_dqueue;	/* delete queue */
     62 	uint64_t	z_max_blksz;	/* maximum block size for files */
     63 	uint64_t	z_assign;	/* TXG_NOWAIT or set by zil_replay() */
     64 	zilog_t		*z_log;		/* intent log pointer */
     65 	uint_t		z_acl_mode;	/* acl chmod/mode behavior */
     66 	uint_t		z_acl_inherit;	/* acl inheritance behavior */
     67 	boolean_t	z_atime;	/* enable atimes mount option */
     68 	boolean_t	z_unmounted1;	/* unmounted phase 1 */
     69 	boolean_t	z_unmounted2;	/* unmounted phase 2 */
     70 	uint32_t	z_op_cnt;	/* vnode/vfs operations ref count */
     71 	krwlock_t	z_um_lock;	/* rw lock for umount phase 2 */
     72 	zfs_delete_t 	z_delete_head;	/* zfs delete list */
     73 	list_t		z_all_znodes;	/* all vnodes in the fs */
     74 	kmutex_t	z_znodes_lock;	/* lock for z_all_znodes */
     75 	vnode_t		*z_ctldir;	/* .zfs directory pointer */
     76 	boolean_t	z_show_ctldir;	/* expose .zfs in the root dir */
     77 	boolean_t	z_issnap;	/* true if this is a snapshot */
     78 #define	ZFS_OBJ_MTX_SZ	64
     79 	kmutex_t	z_hold_mtx[ZFS_OBJ_MTX_SZ];	/* znode hold locks */
     80 };
     81 
     82 /*
     83  * The total file ID size is limited to 12 bytes (including the length
     84  * field) in the NFSv2 protocol.  For historical reasons, this same limit
     85  * is currently being imposed by the Solaris NFSv3 implementation...
     86  * although the protocol actually permits a maximum of 64 bytes.  It will
     87  * not be possible to expand beyond 12 bytes without abandoning support
     88  * of NFSv2 and making some changes to the Solaris NFSv3 implementation.
     89  *
     90  * For the time being, we will partition up the available space as follows:
     91  *	2 bytes		fid length (required)
     92  *	6 bytes		object number (48 bits)
     93  *	4 bytes		generation number (32 bits)
     94  * We reserve only 48 bits for the object number, as this is the limit
     95  * currently defined and imposed by the DMU.
     96  */
     97 typedef struct zfid_short {
     98 	uint16_t	zf_len;
     99 	uint8_t		zf_object[6];		/* obj[i] = obj >> (8 * i) */
    100 	uint8_t		zf_gen[4];		/* gen[i] = gen >> (8 * i) */
    101 } zfid_short_t;
    102 
    103 typedef struct zfid_long {
    104 	zfid_short_t	z_fid;
    105 	uint8_t		zf_setid[6];		/* obj[i] = obj >> (8 * i) */
    106 	uint8_t		zf_setgen[4];		/* gen[i] = gen >> (8 * i) */
    107 } zfid_long_t;
    108 
    109 #define	SHORT_FID_LEN	(sizeof (zfid_short_t) - sizeof (uint16_t))
    110 #define	LONG_FID_LEN	(sizeof (zfid_long_t) - sizeof (uint16_t))
    111 
    112 #ifdef	__cplusplus
    113 }
    114 #endif
    115 
    116 #endif	/* _SYS_FS_ZFS_VFSOPS_H */
    117