4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>.
24 * All rights reserved.
27 #ifndef _SYS_FS_ZFS_VFSOPS_H
28 #define _SYS_FS_ZFS_VFSOPS_H
30 #include <sys/dataset_kstats.h>
35 #include <sys/rrwlock.h>
36 #include <sys/rmlock.h>
37 #include <sys/zfs_ioctl.h>
43 typedef struct rmslock zfs_teardown_lock_t
;
44 typedef struct rmslock zfs_teardown_inactive_lock_t
;
46 typedef struct zfsvfs zfsvfs_t
;
50 vfs_t
*z_vfs
; /* generic fs struct */
51 zfsvfs_t
*z_parent
; /* parent fs */
52 objset_t
*z_os
; /* objset reference */
53 uint64_t z_flags
; /* super_block flags */
54 uint64_t z_root
; /* id of root znode */
55 uint64_t z_unlinkedobj
; /* id of unlinked zapobj */
56 uint64_t z_max_blksz
; /* maximum block size for files */
57 uint64_t z_fuid_obj
; /* fuid table object number */
58 uint64_t z_fuid_size
; /* fuid table size */
59 avl_tree_t z_fuid_idx
; /* fuid tree keyed by index */
60 avl_tree_t z_fuid_domain
; /* fuid tree keyed by domain */
61 krwlock_t z_fuid_lock
; /* fuid lock */
62 boolean_t z_fuid_loaded
; /* fuid tables are loaded */
63 boolean_t z_fuid_dirty
; /* need to sync fuid table ? */
64 struct zfs_fuid_info
*z_fuid_replay
; /* fuid info for replay */
65 zilog_t
*z_log
; /* intent log pointer */
66 uint_t z_acl_type
; /* type of acl usable on this fs */
67 uint_t z_acl_mode
; /* acl chmod/mode behavior */
68 uint_t z_acl_inherit
; /* acl inheritance behavior */
69 zfs_case_t z_case
; /* case-sense */
70 boolean_t z_utf8
; /* utf8-only */
71 int z_norm
; /* normalization flags */
72 boolean_t z_atime
; /* enable atimes mount option */
73 boolean_t z_unmounted
; /* unmounted */
74 zfs_teardown_lock_t z_teardown_lock
;
75 zfs_teardown_inactive_lock_t z_teardown_inactive_lock
;
76 list_t z_all_znodes
; /* all vnodes in the fs */
77 kmutex_t z_znodes_lock
; /* lock for z_all_znodes */
78 struct zfsctl_root
*z_ctldir
; /* .zfs directory pointer */
79 uint_t z_show_ctldir
; /* how to expose .zfs in the root dir */
80 boolean_t z_issnap
; /* true if this is a snapshot */
81 boolean_t z_use_fuids
; /* version allows fuids */
82 boolean_t z_replay
; /* set during ZIL replay */
83 boolean_t z_use_sa
; /* version allow system attributes */
84 boolean_t z_xattr_sa
; /* allow xattrs to be stores as SA */
85 boolean_t z_use_namecache
; /* make use of FreeBSD name cache */
86 boolean_t z_longname
; /* Dataset supports long names */
87 uint8_t z_xattr
; /* xattr type in use */
88 uint64_t z_version
; /* ZPL version */
89 uint64_t z_shares_dir
; /* hidden shares dir */
90 dataset_kstats_t z_kstat
; /* fs kstats */
92 uint64_t z_userquota_obj
;
93 uint64_t z_groupquota_obj
;
94 uint64_t z_userobjquota_obj
;
95 uint64_t z_groupobjquota_obj
;
96 uint64_t z_projectquota_obj
;
97 uint64_t z_projectobjquota_obj
;
98 uint64_t z_replay_eof
; /* New end of file - replay only */
99 sa_attr_type_t
*z_attr_table
; /* SA attr mapping->id */
100 #define ZFS_OBJ_MTX_SZ 64
101 kmutex_t z_hold_mtx
[ZFS_OBJ_MTX_SZ
]; /* znode hold locks */
102 struct task z_unlinked_drain_task
;
105 #define ZFS_TEARDOWN_INIT(zfsvfs) \
106 rms_init(&(zfsvfs)->z_teardown_lock, "zfs teardown")
108 #define ZFS_TEARDOWN_DESTROY(zfsvfs) \
109 rms_destroy(&(zfsvfs)->z_teardown_lock)
111 #define ZFS_TEARDOWN_ENTER_READ(zfsvfs, tag) \
112 rms_rlock(&(zfsvfs)->z_teardown_lock);
114 #define ZFS_TEARDOWN_EXIT_READ(zfsvfs, tag) \
115 rms_runlock(&(zfsvfs)->z_teardown_lock)
117 #define ZFS_TEARDOWN_ENTER_WRITE(zfsvfs, tag) \
118 rms_wlock(&(zfsvfs)->z_teardown_lock)
120 #define ZFS_TEARDOWN_EXIT_WRITE(zfsvfs) \
121 rms_wunlock(&(zfsvfs)->z_teardown_lock)
123 #define ZFS_TEARDOWN_EXIT(zfsvfs, tag) \
124 rms_unlock(&(zfsvfs)->z_teardown_lock)
126 #define ZFS_TEARDOWN_READ_HELD(zfsvfs) \
127 rms_rowned(&(zfsvfs)->z_teardown_lock)
129 #define ZFS_TEARDOWN_WRITE_HELD(zfsvfs) \
130 rms_wowned(&(zfsvfs)->z_teardown_lock)
132 #define ZFS_TEARDOWN_HELD(zfsvfs) \
133 rms_owned_any(&(zfsvfs)->z_teardown_lock)
135 #define ZFS_TEARDOWN_INACTIVE_INIT(zfsvfs) \
136 rms_init(&(zfsvfs)->z_teardown_inactive_lock, "zfs teardown inactive")
138 #define ZFS_TEARDOWN_INACTIVE_DESTROY(zfsvfs) \
139 rms_destroy(&(zfsvfs)->z_teardown_inactive_lock)
141 #define ZFS_TEARDOWN_INACTIVE_TRY_ENTER_READ(zfsvfs) \
142 rms_try_rlock(&(zfsvfs)->z_teardown_inactive_lock)
144 #define ZFS_TEARDOWN_INACTIVE_ENTER_READ(zfsvfs) \
145 rms_rlock(&(zfsvfs)->z_teardown_inactive_lock)
147 #define ZFS_TEARDOWN_INACTIVE_EXIT_READ(zfsvfs) \
148 rms_runlock(&(zfsvfs)->z_teardown_inactive_lock)
150 #define ZFS_TEARDOWN_INACTIVE_ENTER_WRITE(zfsvfs) \
151 rms_wlock(&(zfsvfs)->z_teardown_inactive_lock)
153 #define ZFS_TEARDOWN_INACTIVE_EXIT_WRITE(zfsvfs) \
154 rms_wunlock(&(zfsvfs)->z_teardown_inactive_lock)
156 #define ZFS_TEARDOWN_INACTIVE_WRITE_HELD(zfsvfs) \
157 rms_wowned(&(zfsvfs)->z_teardown_inactive_lock)
159 #define ZSB_XATTR 0x0001 /* Enable user xattrs */
161 * Normal filesystems (those not under .zfs/snapshot) have a total
162 * file ID size limited to 12 bytes (including the length field) due to
163 * NFSv2 protocol's limitation of 32 bytes for a filehandle. For historical
164 * reasons, this same limit is being imposed by the Solaris NFSv3 implementation
165 * (although the NFSv3 protocol actually permits a maximum of 64 bytes). It
166 * is not possible to expand beyond 12 bytes without abandoning support
169 * For normal filesystems, we partition up the available space as follows:
170 * 2 bytes fid length (required)
171 * 6 bytes object number (48 bits)
172 * 4 bytes generation number (32 bits)
174 * We reserve only 48 bits for the object number, as this is the limit
175 * currently defined and imposed by the DMU.
177 typedef struct zfid_short
{
179 uint8_t zf_object
[6]; /* obj[i] = obj >> (8 * i) */
180 uint8_t zf_gen
[4]; /* gen[i] = gen >> (8 * i) */
184 * Filesystems under .zfs/snapshot have a total file ID size of 22[*] bytes
185 * (including the length field). This makes files under .zfs/snapshot
186 * accessible by NFSv3 and NFSv4, but not NFSv2.
188 * For files under .zfs/snapshot, we partition up the available space
190 * 2 bytes fid length (required)
191 * 6 bytes object number (48 bits)
192 * 4 bytes generation number (32 bits)
193 * 6 bytes objset id (48 bits)
194 * 4 bytes[**] currently just zero (32 bits)
196 * We reserve only 48 bits for the object number and objset id, as these are
197 * the limits currently defined and imposed by the DMU.
199 * [*] 20 bytes on FreeBSD to fit into the size of struct fid.
200 * [**] 2 bytes on FreeBSD for the above reason.
202 typedef struct zfid_long
{
204 uint8_t zf_setid
[6]; /* obj[i] = obj >> (8 * i) */
205 uint8_t zf_setgen
[2]; /* gen[i] = gen >> (8 * i) */
208 #define SHORT_FID_LEN (sizeof (zfid_short_t) - sizeof (uint16_t))
209 #define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t))
211 extern int zfs_super_owner
;
213 extern void zfs_init(void);
214 extern void zfs_fini(void);
216 extern int zfs_suspend_fs(zfsvfs_t
*zfsvfs
);
217 extern int zfs_resume_fs(zfsvfs_t
*zfsvfs
, struct dsl_dataset
*ds
);
218 extern int zfs_end_fs(zfsvfs_t
*zfsvfs
, struct dsl_dataset
*ds
);
219 extern int zfs_set_version(zfsvfs_t
*zfsvfs
, uint64_t newvers
);
220 extern int zfsvfs_create(const char *name
, boolean_t readonly
, zfsvfs_t
**zfvp
);
221 extern int zfsvfs_create_impl(zfsvfs_t
**zfvp
, zfsvfs_t
*zfsvfs
, objset_t
*os
);
222 extern void zfsvfs_free(zfsvfs_t
*zfsvfs
);
223 extern int zfs_check_global_label(const char *dsname
, const char *hexsl
);
224 extern boolean_t
zfs_is_readonly(zfsvfs_t
*zfsvfs
);
225 extern int zfs_get_temporary_prop(struct dsl_dataset
*ds
, zfs_prop_t zfs_prop
,
226 uint64_t *val
, char *setpoint
);
227 extern int zfs_busy(void);
233 #endif /* _SYS_FS_ZFS_VFSOPS_H */