]> git.proxmox.com Git - mirror_zfs.git/blob - include/sys/zfs_vfsops.h
ZIL claiming should not start user accounting
[mirror_zfs.git] / include / sys / zfs_vfsops.h
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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #ifndef _SYS_FS_ZFS_VFSOPS_H
26 #define _SYS_FS_ZFS_VFSOPS_H
27
28 #include <sys/isa_defs.h>
29 #include <sys/types32.h>
30 #include <sys/list.h>
31 #include <sys/vfs.h>
32 #include <sys/zil.h>
33 #include <sys/sa.h>
34 #include <sys/rrwlock.h>
35 #include <sys/zfs_ioctl.h>
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 typedef struct zfsvfs zfsvfs_t;
42 struct znode;
43
44 /*
45 * This structure emulates the vfs_t from other platforms. It's purpose
46 * is to faciliate the handling of mount options and minimize structural
47 * differences between the platforms.
48 */
49 typedef struct vfs {
50 struct zfsvfs *vfs_data;
51 char *vfs_mntpoint; /* Primary mount point */
52 uint64_t vfs_xattr;
53 boolean_t vfs_readonly;
54 boolean_t vfs_do_readonly;
55 boolean_t vfs_setuid;
56 boolean_t vfs_do_setuid;
57 boolean_t vfs_exec;
58 boolean_t vfs_do_exec;
59 boolean_t vfs_devices;
60 boolean_t vfs_do_devices;
61 boolean_t vfs_do_xattr;
62 boolean_t vfs_atime;
63 boolean_t vfs_do_atime;
64 boolean_t vfs_relatime;
65 boolean_t vfs_do_relatime;
66 boolean_t vfs_nbmand;
67 boolean_t vfs_do_nbmand;
68 } vfs_t;
69
70 typedef struct zfs_mnt {
71 const char *mnt_osname; /* Objset name */
72 char *mnt_data; /* Raw mount options */
73 } zfs_mnt_t;
74
75 struct zfsvfs {
76 vfs_t *z_vfs; /* generic fs struct */
77 struct super_block *z_sb; /* generic super_block */
78 struct zfsvfs *z_parent; /* parent fs */
79 objset_t *z_os; /* objset reference */
80 uint64_t z_flags; /* super_block flags */
81 uint64_t z_root; /* id of root znode */
82 uint64_t z_unlinkedobj; /* id of unlinked zapobj */
83 uint64_t z_max_blksz; /* maximum block size for files */
84 uint64_t z_fuid_obj; /* fuid table object number */
85 uint64_t z_fuid_size; /* fuid table size */
86 avl_tree_t z_fuid_idx; /* fuid tree keyed by index */
87 avl_tree_t z_fuid_domain; /* fuid tree keyed by domain */
88 krwlock_t z_fuid_lock; /* fuid lock */
89 boolean_t z_fuid_loaded; /* fuid tables are loaded */
90 boolean_t z_fuid_dirty; /* need to sync fuid table ? */
91 struct zfs_fuid_info *z_fuid_replay; /* fuid info for replay */
92 zilog_t *z_log; /* intent log pointer */
93 uint_t z_acl_inherit; /* acl inheritance behavior */
94 uint_t z_acl_type; /* type of ACL usable on this FS */
95 zfs_case_t z_case; /* case-sense */
96 boolean_t z_utf8; /* utf8-only */
97 int z_norm; /* normalization flags */
98 boolean_t z_atime; /* enable atimes mount option */
99 boolean_t z_relatime; /* enable relatime mount option */
100 boolean_t z_unmounted; /* unmounted */
101 rrmlock_t z_teardown_lock;
102 krwlock_t z_teardown_inactive_lock;
103 list_t z_all_znodes; /* all znodes in the fs */
104 uint64_t z_nr_znodes; /* number of znodes in the fs */
105 unsigned long z_rollback_time; /* last online rollback time */
106 unsigned long z_snap_defer_time; /* last snapshot unmount deferal */
107 kmutex_t z_znodes_lock; /* lock for z_all_znodes */
108 arc_prune_t *z_arc_prune; /* called by ARC to prune caches */
109 struct inode *z_ctldir; /* .zfs directory inode */
110 boolean_t z_show_ctldir; /* expose .zfs in the root dir */
111 boolean_t z_issnap; /* true if this is a snapshot */
112 boolean_t z_vscan; /* virus scan on/off */
113 boolean_t z_use_fuids; /* version allows fuids */
114 boolean_t z_replay; /* set during ZIL replay */
115 boolean_t z_use_sa; /* version allow system attributes */
116 boolean_t z_xattr_sa; /* allow xattrs to be stores as SA */
117 uint64_t z_version; /* ZPL version */
118 uint64_t z_shares_dir; /* hidden shares dir */
119 kmutex_t z_lock;
120 uint64_t z_userquota_obj;
121 uint64_t z_groupquota_obj;
122 uint64_t z_userobjquota_obj;
123 uint64_t z_groupobjquota_obj;
124 uint64_t z_projectquota_obj;
125 uint64_t z_projectobjquota_obj;
126 uint64_t z_replay_eof; /* New end of file - replay only */
127 sa_attr_type_t *z_attr_table; /* SA attr mapping->id */
128 uint64_t z_hold_size; /* znode hold array size */
129 avl_tree_t *z_hold_trees; /* znode hold trees */
130 kmutex_t *z_hold_locks; /* znode hold locks */
131 };
132
133 #define ZSB_XATTR 0x0001 /* Enable user xattrs */
134
135 /*
136 * Allow a maximum number of links. While ZFS does not internally limit
137 * this the inode->i_nlink member is defined as an unsigned int. To be
138 * safe we use 2^31-1 as the limit.
139 */
140 #define ZFS_LINK_MAX ((1U << 31) - 1U)
141
142 /*
143 * Normal filesystems (those not under .zfs/snapshot) have a total
144 * file ID size limited to 12 bytes (including the length field) due to
145 * NFSv2 protocol's limitation of 32 bytes for a filehandle. For historical
146 * reasons, this same limit is being imposed by the Solaris NFSv3 implementation
147 * (although the NFSv3 protocol actually permits a maximum of 64 bytes). It
148 * is not possible to expand beyond 12 bytes without abandoning support
149 * of NFSv2.
150 *
151 * For normal filesystems, we partition up the available space as follows:
152 * 2 bytes fid length (required)
153 * 6 bytes object number (48 bits)
154 * 4 bytes generation number (32 bits)
155 *
156 * We reserve only 48 bits for the object number, as this is the limit
157 * currently defined and imposed by the DMU.
158 */
159 typedef struct zfid_short {
160 uint16_t zf_len;
161 uint8_t zf_object[6]; /* obj[i] = obj >> (8 * i) */
162 uint8_t zf_gen[4]; /* gen[i] = gen >> (8 * i) */
163 } zfid_short_t;
164
165 /*
166 * Filesystems under .zfs/snapshot have a total file ID size of 22 bytes
167 * (including the length field). This makes files under .zfs/snapshot
168 * accessible by NFSv3 and NFSv4, but not NFSv2.
169 *
170 * For files under .zfs/snapshot, we partition up the available space
171 * as follows:
172 * 2 bytes fid length (required)
173 * 6 bytes object number (48 bits)
174 * 4 bytes generation number (32 bits)
175 * 6 bytes objset id (48 bits)
176 * 4 bytes currently just zero (32 bits)
177 *
178 * We reserve only 48 bits for the object number and objset id, as these are
179 * the limits currently defined and imposed by the DMU.
180 */
181 typedef struct zfid_long {
182 zfid_short_t z_fid;
183 uint8_t zf_setid[6]; /* obj[i] = obj >> (8 * i) */
184 uint8_t zf_setgen[4]; /* gen[i] = gen >> (8 * i) */
185 } zfid_long_t;
186
187 #define SHORT_FID_LEN (sizeof (zfid_short_t) - sizeof (uint16_t))
188 #define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t))
189
190 extern uint_t zfs_fsyncer_key;
191
192 extern int zfs_suspend_fs(zfsvfs_t *zfsvfs);
193 extern int zfs_resume_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds);
194 extern int zfs_userspace_one(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
195 const char *domain, uint64_t rid, uint64_t *valuep);
196 extern int zfs_userspace_many(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
197 uint64_t *cookiep, void *vbuf, uint64_t *bufsizep);
198 extern int zfs_set_userquota(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
199 const char *domain, uint64_t rid, uint64_t quota);
200 extern boolean_t zfs_id_overblockquota(zfsvfs_t *zfsvfs, uint64_t usedobj,
201 uint64_t id);
202 extern boolean_t zfs_id_overobjquota(zfsvfs_t *zfsvfs, uint64_t usedobj,
203 uint64_t id);
204 extern boolean_t zfs_id_overquota(zfsvfs_t *zfsvfs, uint64_t usedobj,
205 uint64_t id);
206 extern int zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers);
207 extern int zfsvfs_create(const char *name, boolean_t readony, zfsvfs_t **zfvp);
208 extern int zfsvfs_create_impl(zfsvfs_t **zfvp, zfsvfs_t *zfsvfs, objset_t *os);
209 extern void zfsvfs_free(zfsvfs_t *zfsvfs);
210 extern int zfs_check_global_label(const char *dsname, const char *hexsl);
211
212 extern boolean_t zfs_is_readonly(zfsvfs_t *zfsvfs);
213 extern int zfs_domount(struct super_block *sb, zfs_mnt_t *zm, int silent);
214 extern void zfs_preumount(struct super_block *sb);
215 extern int zfs_umount(struct super_block *sb);
216 extern int zfs_remount(struct super_block *sb, int *flags, zfs_mnt_t *zm);
217 extern int zfs_statvfs(struct dentry *dentry, struct kstatfs *statp);
218 extern int zfs_vget(struct super_block *sb, struct inode **ipp, fid_t *fidp);
219 extern int zfs_prune(struct super_block *sb, unsigned long nr_to_scan,
220 int *objects);
221
222 #ifdef __cplusplus
223 }
224 #endif
225
226 #endif /* _SYS_FS_ZFS_VFSOPS_H */