1 789 ahrens /* 2 789 ahrens * CDDL HEADER START 3 789 ahrens * 4 789 ahrens * The contents of this file are subject to the terms of the 5 3461 ahrens * Common Development and Distribution License (the "License"). 6 3461 ahrens * You may not use this file except in compliance with the License. 7 789 ahrens * 8 789 ahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 789 ahrens * or http://www.opensolaris.org/os/licensing. 10 789 ahrens * See the License for the specific language governing permissions 11 789 ahrens * and limitations under the License. 12 789 ahrens * 13 789 ahrens * When distributing Covered Code, include this CDDL HEADER in each 14 789 ahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 789 ahrens * If applicable, add the following below this CDDL HEADER, with the 16 789 ahrens * fields enclosed by brackets "[]" replaced with your own identifying 17 789 ahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18 789 ahrens * 19 789 ahrens * CDDL HEADER END 20 789 ahrens */ 21 789 ahrens /* 22 8845 amw * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 789 ahrens * Use is subject to license terms. 24 789 ahrens */ 25 789 ahrens 26 789 ahrens #ifndef _SYS_FS_ZFS_VFSOPS_H 27 789 ahrens #define _SYS_FS_ZFS_VFSOPS_H 28 789 ahrens 29 789 ahrens #include <sys/isa_defs.h> 30 789 ahrens #include <sys/types32.h> 31 789 ahrens #include <sys/list.h> 32 789 ahrens #include <sys/vfs.h> 33 789 ahrens #include <sys/zil.h> 34 5326 ek110237 #include <sys/rrwlock.h> 35 5498 timh #include <sys/zfs_ioctl.h> 36 789 ahrens 37 789 ahrens #ifdef __cplusplus 38 789 ahrens extern "C" { 39 789 ahrens #endif 40 789 ahrens 41 789 ahrens typedef struct zfsvfs zfsvfs_t; 42 789 ahrens 43 789 ahrens struct zfsvfs { 44 789 ahrens vfs_t *z_vfs; /* generic fs struct */ 45 789 ahrens zfsvfs_t *z_parent; /* parent fs */ 46 789 ahrens objset_t *z_os; /* objset reference */ 47 789 ahrens uint64_t z_root; /* id of root znode */ 48 3461 ahrens uint64_t z_unlinkedobj; /* id of unlinked zapobj */ 49 789 ahrens uint64_t z_max_blksz; /* maximum block size for files */ 50 5331 amw uint64_t z_fuid_obj; /* fuid table object number */ 51 5824 marks uint64_t z_fuid_size; /* fuid table size */ 52 5331 amw avl_tree_t z_fuid_idx; /* fuid tree keyed by index */ 53 5331 amw avl_tree_t z_fuid_domain; /* fuid tree keyed by domain */ 54 5331 amw krwlock_t z_fuid_lock; /* fuid lock */ 55 5331 amw boolean_t z_fuid_loaded; /* fuid tables are loaded */ 56 9179 Mark boolean_t z_fuid_dirty; /* need to sync fuid table ? */ 57 5331 amw struct zfs_fuid_info *z_fuid_replay; /* fuid info for replay */ 58 789 ahrens zilog_t *z_log; /* intent log pointer */ 59 789 ahrens uint_t z_acl_mode; /* acl chmod/mode behavior */ 60 789 ahrens uint_t z_acl_inherit; /* acl inheritance behavior */ 61 5498 timh zfs_case_t z_case; /* case-sense */ 62 5498 timh boolean_t z_utf8; /* utf8-only */ 63 5331 amw int z_norm; /* normalization flags */ 64 789 ahrens boolean_t z_atime; /* enable atimes mount option */ 65 4787 ahrens boolean_t z_unmounted; /* unmounted */ 66 5326 ek110237 rrwlock_t z_teardown_lock; 67 5326 ek110237 krwlock_t z_teardown_inactive_lock; 68 789 ahrens list_t z_all_znodes; /* all vnodes in the fs */ 69 789 ahrens kmutex_t z_znodes_lock; /* lock for z_all_znodes */ 70 789 ahrens vnode_t *z_ctldir; /* .zfs directory pointer */ 71 789 ahrens boolean_t z_show_ctldir; /* expose .zfs in the root dir */ 72 789 ahrens boolean_t z_issnap; /* true if this is a snapshot */ 73 5331 amw boolean_t z_vscan; /* virus scan on/off */ 74 5331 amw boolean_t z_use_fuids; /* version allows fuids */ 75 8227 Neil boolean_t z_replay; /* set during ZIL replay */ 76 6083 ek110237 uint64_t z_version; /* ZPL version */ 77 8845 amw uint64_t z_shares_dir; /* hidden shares dir */ 78 9030 Mark kmutex_t z_lock; 79 9396 Matthew uint64_t z_userquota_obj; 80 9396 Matthew uint64_t z_groupquota_obj; 81 789 ahrens #define ZFS_OBJ_MTX_SZ 64 82 789 ahrens kmutex_t z_hold_mtx[ZFS_OBJ_MTX_SZ]; /* znode hold locks */ 83 789 ahrens }; 84 789 ahrens 85 789 ahrens /* 86 4820 ek110237 * Normal filesystems (those not under .zfs/snapshot) have a total 87 4820 ek110237 * file ID size limited to 12 bytes (including the length field) due to 88 4820 ek110237 * NFSv2 protocol's limitation of 32 bytes for a filehandle. For historical 89 4820 ek110237 * reasons, this same limit is being imposed by the Solaris NFSv3 implementation 90 4820 ek110237 * (although the NFSv3 protocol actually permits a maximum of 64 bytes). It 91 4820 ek110237 * is not possible to expand beyond 12 bytes without abandoning support 92 4820 ek110237 * of NFSv2. 93 789 ahrens * 94 4820 ek110237 * For normal filesystems, we partition up the available space as follows: 95 789 ahrens * 2 bytes fid length (required) 96 789 ahrens * 6 bytes object number (48 bits) 97 789 ahrens * 4 bytes generation number (32 bits) 98 4820 ek110237 * 99 789 ahrens * We reserve only 48 bits for the object number, as this is the limit 100 789 ahrens * currently defined and imposed by the DMU. 101 789 ahrens */ 102 789 ahrens typedef struct zfid_short { 103 789 ahrens uint16_t zf_len; 104 789 ahrens uint8_t zf_object[6]; /* obj[i] = obj >> (8 * i) */ 105 789 ahrens uint8_t zf_gen[4]; /* gen[i] = gen >> (8 * i) */ 106 789 ahrens } zfid_short_t; 107 789 ahrens 108 4820 ek110237 /* 109 4820 ek110237 * Filesystems under .zfs/snapshot have a total file ID size of 22 bytes 110 4820 ek110237 * (including the length field). This makes files under .zfs/snapshot 111 4820 ek110237 * accessible by NFSv3 and NFSv4, but not NFSv2. 112 4820 ek110237 * 113 4820 ek110237 * For files under .zfs/snapshot, we partition up the available space 114 4820 ek110237 * as follows: 115 4820 ek110237 * 2 bytes fid length (required) 116 4820 ek110237 * 6 bytes object number (48 bits) 117 4820 ek110237 * 4 bytes generation number (32 bits) 118 4820 ek110237 * 6 bytes objset id (48 bits) 119 4820 ek110237 * 4 bytes currently just zero (32 bits) 120 4820 ek110237 * 121 4820 ek110237 * We reserve only 48 bits for the object number and objset id, as these are 122 4820 ek110237 * the limits currently defined and imposed by the DMU. 123 4820 ek110237 */ 124 789 ahrens typedef struct zfid_long { 125 789 ahrens zfid_short_t z_fid; 126 789 ahrens uint8_t zf_setid[6]; /* obj[i] = obj >> (8 * i) */ 127 789 ahrens uint8_t zf_setgen[4]; /* gen[i] = gen >> (8 * i) */ 128 789 ahrens } zfid_long_t; 129 789 ahrens 130 789 ahrens #define SHORT_FID_LEN (sizeof (zfid_short_t) - sizeof (uint16_t)) 131 789 ahrens #define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t)) 132 789 ahrens 133 4720 fr157268 extern uint_t zfs_fsyncer_key; 134 4720 fr157268 135 10298 Matthew extern int zfs_suspend_fs(zfsvfs_t *zfsvfs); 136 10298 Matthew extern int zfs_resume_fs(zfsvfs_t *zfsvfs, const char *osname); 137 9396 Matthew extern int zfs_userspace_one(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type, 138 9396 Matthew const char *domain, uint64_t rid, uint64_t *valuep); 139 9396 Matthew extern int zfs_userspace_many(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type, 140 9396 Matthew uint64_t *cookiep, void *vbuf, uint64_t *bufsizep); 141 9396 Matthew extern int zfs_set_userquota(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type, 142 9396 Matthew const char *domain, uint64_t rid, uint64_t quota); 143 9396 Matthew extern boolean_t zfs_usergroup_overquota(zfsvfs_t *zfsvfs, 144 9396 Matthew boolean_t isgroup, uint64_t fuid); 145 9396 Matthew extern int zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers); 146 11185 Sean extern int zfsvfs_create(const char *name, zfsvfs_t **zfvp); 147 9396 Matthew extern void zfsvfs_free(zfsvfs_t *zfsvfs); 148 10972 Ric extern int zfs_check_global_label(const char *dsname, const char *hexsl); 149 5326 ek110237 150 789 ahrens #ifdef __cplusplus 151 789 ahrens } 152 789 ahrens #endif 153 789 ahrens 154 789 ahrens #endif /* _SYS_FS_ZFS_VFSOPS_H */ 155