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