Print this page
6265 speed up mount/umount
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/vfs.h
+++ new/usr/src/uts/common/sys/vfs.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25
26 26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27 27 /* All Rights Reserved */
28 28
29 29 /*
30 30 * Portions of this source code were derived from Berkeley 4.3 BSD
31 31 * under license from the Regents of the University of California.
32 32 */
33 33
34 34 #ifndef _SYS_VFS_H
35 35 #define _SYS_VFS_H
36 36
37 37 #include <sys/zone.h>
38 38 #include <sys/types.h>
39 39 #include <sys/t_lock.h>
40 40 #include <sys/cred.h>
41 41 #include <sys/vnode.h>
42 42 #include <sys/statvfs.h>
43 43 #include <sys/refstr.h>
44 44 #include <sys/avl.h>
45 45 #include <sys/time.h>
46 46
47 47 #ifdef __cplusplus
48 48 extern "C" {
49 49 #endif
50 50
51 51 /*
52 52 * Data associated with mounted file systems.
53 53 */
54 54
55 55 /*
56 56 * Operations vector. This is used internal to the kernel; file systems
57 57 * supply their list of operations via vfs_setfsops().
58 58 */
59 59
60 60 typedef struct vfsops vfsops_t;
61 61
62 62 /*
63 63 * File system identifier. Should be unique (at least per machine).
64 64 */
65 65 typedef struct {
66 66 int val[2]; /* file system id type */
67 67 } fsid_t;
68 68
69 69 /*
70 70 * File identifier. Should be unique per filesystem on a single
71 71 * machine. This is typically called by a stateless file server
72 72 * in order to generate "file handles".
73 73 *
74 74 * Do not change the definition of struct fid ... fid_t without
75 75 * letting the CacheFS group know about it! They will have to do at
76 76 * least two things, in the same change that changes this structure:
77 77 * 1. change CFSVERSION in usr/src/uts/common/sys/fs/cachefs_fs.h
78 78 * 2. put the old version # in the canupgrade array
79 79 * in cachfs_upgrade() in usr/src/cmd/fs.d/cachefs/fsck/fsck.c
80 80 * This is necessary because CacheFS stores FIDs on disk.
81 81 *
82 82 * Many underlying file systems cast a struct fid into other
83 83 * file system dependent structures which may require 4 byte alignment.
84 84 * Because a fid starts with a short it may not be 4 byte aligned, the
85 85 * fid_pad will force the alignment.
86 86 */
87 87 #define MAXFIDSZ 64
88 88 #define OLD_MAXFIDSZ 16
89 89
90 90 typedef struct fid {
91 91 union {
92 92 long fid_pad;
93 93 struct {
94 94 ushort_t len; /* length of data in bytes */
95 95 char data[MAXFIDSZ]; /* data (variable len) */
96 96 } _fid;
97 97 } un;
98 98 } fid_t;
99 99
100 100 #ifdef _SYSCALL32
101 101 /*
102 102 * Solaris 64 - use old-style cache format with 32-bit aligned fid for on-disk
103 103 * struct compatibility.
104 104 */
105 105 typedef struct fid32 {
106 106 union {
107 107 int32_t fid_pad;
108 108 struct {
109 109 uint16_t len; /* length of data in bytes */
110 110 char data[MAXFIDSZ]; /* data (variable len) */
111 111 } _fid;
112 112 } un;
113 113 } fid32_t;
114 114 #else /* not _SYSCALL32 */
115 115 #define fid32 fid
116 116 typedef fid_t fid32_t;
117 117 #endif /* _SYSCALL32 */
118 118
119 119 #define fid_len un._fid.len
120 120 #define fid_data un._fid.data
121 121
122 122 /*
123 123 * Structure defining a mount option for a filesystem.
124 124 * option names are found in mntent.h
125 125 */
126 126 typedef struct mntopt {
127 127 char *mo_name; /* option name */
128 128 char **mo_cancel; /* list of options cancelled by this one */
129 129 char *mo_arg; /* argument string for this option */
130 130 int mo_flags; /* flags for this mount option */
131 131 void *mo_data; /* filesystem specific data */
132 132 } mntopt_t;
133 133
134 134 /*
135 135 * Flags that apply to mount options
136 136 */
137 137
138 138 #define MO_SET 0x01 /* option is set */
139 139 #define MO_NODISPLAY 0x02 /* option not listed in mnttab */
140 140 #define MO_HASVALUE 0x04 /* option takes a value */
141 141 #define MO_IGNORE 0x08 /* option ignored by parser */
142 142 #define MO_DEFAULT MO_SET /* option is on by default */
143 143 #define MO_TAG 0x10 /* flags a tag set by user program */
144 144 #define MO_EMPTY 0x20 /* empty space in option table */
145 145
146 146 #define VFS_NOFORCEOPT 0x01 /* honor MO_IGNORE (don't set option) */
147 147 #define VFS_DISPLAY 0x02 /* Turn off MO_NODISPLAY bit for opt */
148 148 #define VFS_NODISPLAY 0x04 /* Turn on MO_NODISPLAY bit for opt */
149 149 #define VFS_CREATEOPT 0x08 /* Create the opt if it's not there */
150 150
151 151 /*
152 152 * Structure holding mount option strings for the mounted file system.
153 153 */
154 154 typedef struct mntopts {
155 155 uint_t mo_count; /* number of entries in table */
156 156 mntopt_t *mo_list; /* list of mount options */
157 157 } mntopts_t;
158 158
159 159 /*
160 160 * The kstat structures associated with the vopstats are kept in an
161 161 * AVL tree. This is to avoid the case where a file system does not
162 162 * use a unique fsid_t for each vfs (e.g., namefs). In order to do
163 163 * this, we need a structure that the AVL tree can use that also
164 164 * references the kstat.
165 165 * Note that the vks_fsid is generated from the value reported by
166 166 * VFS_STATVFS().
167 167 */
168 168 typedef struct vskstat_anchor {
169 169 avl_node_t vsk_node; /* Required for use by AVL routines */
170 170 kstat_t *vsk_ksp; /* kstat structure for vopstats */
171 171 ulong_t vsk_fsid; /* fsid associated w/this FS */
172 172 } vsk_anchor_t;
173 173
174 174 extern avl_tree_t vskstat_tree;
175 175 extern kmutex_t vskstat_tree_lock;
176 176
177 177 /*
178 178 * Structure per mounted file system. Each mounted file system has
179 179 * an array of operations and an instance record.
180 180 *
181 181 * The file systems are kept on a doubly linked circular list headed by
182 182 * "rootvfs".
183 183 * File system implementations should not access this list;
184 184 * it's intended for use only in the kernel's vfs layer.
185 185 *
186 186 * Each zone also has its own list of mounts, containing filesystems mounted
187 187 * somewhere within the filesystem tree rooted at the zone's rootpath. The
188 188 * list is doubly linked to match the global list.
189 189 *
190 190 * mnttab locking: the in-kernel mnttab uses the vfs_mntpt, vfs_resource and
191 191 * vfs_mntopts fields in the vfs_t. mntpt and resource are refstr_ts that
192 192 * are set at mount time and can only be modified during a remount.
193 193 * It is safe to read these fields if you can prevent a remount on the vfs,
194 194 * or through the convenience funcs vfs_getmntpoint() and vfs_getresource().
195 195 * The mntopts field may only be accessed through the provided convenience
↓ open down ↓ |
195 lines elided |
↑ open up ↑ |
196 196 * functions, as it is protected by the vfs list lock. Modifying a mount
197 197 * option requires grabbing the vfs list write lock, which can be a very
198 198 * high latency lock.
199 199 */
200 200 struct zone; /* from zone.h */
201 201 struct fem_head; /* from fem.h */
202 202
203 203 typedef struct vfs {
204 204 struct vfs *vfs_next; /* next VFS in VFS list */
205 205 struct vfs *vfs_prev; /* prev VFS in VFS list */
206 + avl_node_t vfs_avldev; /* by dev index */
207 + avl_node_t vfs_avlmntpnt; /* by mntpnt index */
208 + /*
209 + * global mount count to define an order on entries in
210 + * the avl trees with same dev/mountpoint
211 + */
212 + uint64_t vfs_mntix;
206 213
207 214 /* vfs_op should not be used directly. Accessor functions are provided */
208 215 vfsops_t *vfs_op; /* operations on VFS */
209 216
210 217 struct vnode *vfs_vnodecovered; /* vnode mounted on */
211 218 uint_t vfs_flag; /* flags */
212 219 uint_t vfs_bsize; /* native block size */
213 220 int vfs_fstype; /* file system type index */
214 221 fsid_t vfs_fsid; /* file system id */
215 222 void *vfs_data; /* private data */
216 223 dev_t vfs_dev; /* device of mounted VFS */
217 224 ulong_t vfs_bcount; /* I/O count (accounting) */
218 225 struct vfs *vfs_list; /* sync list pointer */
219 226 struct vfs *vfs_hash; /* hash list pointer */
220 227 ksema_t vfs_reflock; /* mount/unmount/sync lock */
221 228 uint_t vfs_count; /* vfs reference count */
222 229 mntopts_t vfs_mntopts; /* options mounted with */
223 230 refstr_t *vfs_resource; /* mounted resource name */
224 231 refstr_t *vfs_mntpt; /* mount point name */
225 232 time_t vfs_mtime; /* time we were mounted */
226 233 struct vfs_impl *vfs_implp; /* impl specific data */
227 234 /*
228 235 * Zones support. Note that the zone that "owns" the mount isn't
229 236 * necessarily the same as the zone in which the zone is visible.
230 237 * That is, vfs_zone and (vfs_zone_next|vfs_zone_prev) may refer to
231 238 * different zones.
232 239 */
233 240 struct zone *vfs_zone; /* zone that owns the mount */
234 241 struct vfs *vfs_zone_next; /* next VFS visible in zone */
235 242 struct vfs *vfs_zone_prev; /* prev VFS visible in zone */
236 243
237 244 struct fem_head *vfs_femhead; /* fs monitoring */
238 245 minor_t vfs_lofi_minor; /* minor if lofi mount */
239 246 } vfs_t;
240 247
241 248 #define vfs_featureset vfs_implp->vi_featureset
242 249 #define vfs_vskap vfs_implp->vi_vskap
243 250 #define vfs_fstypevsp vfs_implp->vi_fstypevsp
244 251 #define vfs_vopstats vfs_implp->vi_vopstats
245 252 #define vfs_hrctime vfs_implp->vi_hrctime
246 253
247 254 /*
248 255 * VFS flags.
249 256 */
250 257 #define VFS_RDONLY 0x01 /* read-only vfs */
251 258 #define VFS_NOMNTTAB 0x02 /* vfs not seen in mnttab */
252 259 #define VFS_NOSETUID 0x08 /* setuid disallowed */
253 260 #define VFS_REMOUNT 0x10 /* modify mount options only */
254 261 #define VFS_NOTRUNC 0x20 /* does not truncate long file names */
255 262 #define VFS_UNLINKABLE 0x40 /* unlink(2) can be applied to root */
256 263 #define VFS_PXFS 0x80 /* clustering: global fs proxy vfs */
257 264 #define VFS_UNMOUNTED 0x100 /* file system has been unmounted */
258 265 #define VFS_NBMAND 0x200 /* allow non-blocking mandatory locks */
259 266 #define VFS_XATTR 0x400 /* fs supports extended attributes */
260 267 #define VFS_NODEVICES 0x800 /* device-special files disallowed */
261 268 #define VFS_NOEXEC 0x1000 /* executables disallowed */
262 269 #define VFS_STATS 0x2000 /* file system can collect stats */
263 270 #define VFS_XID 0x4000 /* file system supports extended ids */
264 271
265 272 #define VFS_NORESOURCE "unspecified_resource"
266 273 #define VFS_NOMNTPT "unspecified_mountpoint"
267 274
268 275 /*
269 276 * VFS features are implemented as bits set in the vfs_t.
270 277 * The vfs_feature_t typedef is a 64-bit number that will translate
271 278 * into an element in an array of bitmaps and a bit in that element.
272 279 * Developers must not depend on the implementation of this and
273 280 * need to use vfs_has_feature()/vfs_set_feature() routines.
274 281 */
275 282 typedef uint64_t vfs_feature_t;
276 283
277 284 #define VFSFT_XVATTR 0x100000001 /* Supports xvattr for attrs */
278 285 #define VFSFT_CASEINSENSITIVE 0x100000002 /* Supports case-insensitive */
279 286 #define VFSFT_NOCASESENSITIVE 0x100000004 /* NOT case-sensitive */
280 287 #define VFSFT_DIRENTFLAGS 0x100000008 /* Supports dirent flags */
281 288 #define VFSFT_ACLONCREATE 0x100000010 /* Supports ACL on create */
282 289 #define VFSFT_ACEMASKONACCESS 0x100000020 /* Can use ACEMASK for access */
283 290 #define VFSFT_SYSATTR_VIEWS 0x100000040 /* Supports sysattr view i/f */
284 291 #define VFSFT_ACCESS_FILTER 0x100000080 /* dirents filtered by access */
285 292 #define VFSFT_REPARSE 0x100000100 /* Supports reparse point */
286 293 #define VFSFT_ZEROCOPY_SUPPORTED 0x100000200
287 294 /* Support loaning /returning cache buffer */
288 295 /*
289 296 * Argument structure for mount(2).
290 297 *
291 298 * Flags are defined in <sys/mount.h>.
292 299 *
293 300 * Note that if the MS_SYSSPACE bit is set in flags, the pointer fields in
294 301 * this structure are to be interpreted as kernel addresses. File systems
295 302 * should be prepared for this possibility.
296 303 */
297 304 struct mounta {
298 305 char *spec;
299 306 char *dir;
300 307 int flags;
301 308 char *fstype;
302 309 char *dataptr;
303 310 int datalen;
304 311 char *optptr;
305 312 int optlen;
306 313 };
307 314
308 315 /*
309 316 * Reasons for calling the vfs_mountroot() operation.
310 317 */
311 318 enum whymountroot { ROOT_INIT, ROOT_REMOUNT, ROOT_UNMOUNT};
312 319 typedef enum whymountroot whymountroot_t;
313 320
314 321 /*
315 322 * Reasons for calling the VFS_VNSTATE():
316 323 */
317 324 enum vntrans {
318 325 VNTRANS_EXISTS,
319 326 VNTRANS_IDLED,
320 327 VNTRANS_RECLAIMED,
321 328 VNTRANS_DESTROYED
322 329 };
323 330 typedef enum vntrans vntrans_t;
324 331
325 332 /*
326 333 * VFS_OPS defines all the vfs operations. It is used to define
327 334 * the vfsops structure (below) and the fs_func_p union (vfs_opreg.h).
328 335 */
329 336 #define VFS_OPS \
330 337 int (*vfs_mount)(vfs_t *, vnode_t *, struct mounta *, cred_t *); \
331 338 int (*vfs_unmount)(vfs_t *, int, cred_t *); \
332 339 int (*vfs_root)(vfs_t *, vnode_t **); \
333 340 int (*vfs_statvfs)(vfs_t *, statvfs64_t *); \
334 341 int (*vfs_sync)(vfs_t *, short, cred_t *); \
335 342 int (*vfs_vget)(vfs_t *, vnode_t **, fid_t *); \
336 343 int (*vfs_mountroot)(vfs_t *, enum whymountroot); \
337 344 void (*vfs_freevfs)(vfs_t *); \
338 345 int (*vfs_vnstate)(vfs_t *, vnode_t *, vntrans_t) /* NB: No ";" */
339 346
340 347 /*
341 348 * Operations supported on virtual file system.
342 349 */
343 350 struct vfsops {
344 351 VFS_OPS; /* Signature of all vfs operations (vfsops) */
345 352 };
346 353
347 354 extern int fsop_mount(vfs_t *, vnode_t *, struct mounta *, cred_t *);
348 355 extern int fsop_unmount(vfs_t *, int, cred_t *);
349 356 extern int fsop_root(vfs_t *, vnode_t **);
350 357 extern int fsop_statfs(vfs_t *, statvfs64_t *);
351 358 extern int fsop_sync(vfs_t *, short, cred_t *);
352 359 extern int fsop_vget(vfs_t *, vnode_t **, fid_t *);
353 360 extern int fsop_mountroot(vfs_t *, enum whymountroot);
354 361 extern void fsop_freefs(vfs_t *);
355 362 extern int fsop_sync_by_kind(int, short, cred_t *);
356 363 extern int fsop_vnstate(vfs_t *, vnode_t *, vntrans_t);
357 364
358 365 #define VFS_MOUNT(vfsp, mvp, uap, cr) fsop_mount(vfsp, mvp, uap, cr)
359 366 #define VFS_UNMOUNT(vfsp, flag, cr) fsop_unmount(vfsp, flag, cr)
360 367 #define VFS_ROOT(vfsp, vpp) fsop_root(vfsp, vpp)
361 368 #define VFS_STATVFS(vfsp, sp) fsop_statfs(vfsp, sp)
362 369 #define VFS_SYNC(vfsp, flag, cr) fsop_sync(vfsp, flag, cr)
363 370 #define VFS_VGET(vfsp, vpp, fidp) fsop_vget(vfsp, vpp, fidp)
364 371 #define VFS_MOUNTROOT(vfsp, init) fsop_mountroot(vfsp, init)
365 372 #define VFS_FREEVFS(vfsp) fsop_freefs(vfsp)
366 373 #define VFS_VNSTATE(vfsp, vn, ns) fsop_vnstate(vfsp, vn, ns)
367 374
368 375 #define VFSNAME_MOUNT "mount"
369 376 #define VFSNAME_UNMOUNT "unmount"
370 377 #define VFSNAME_ROOT "root"
371 378 #define VFSNAME_STATVFS "statvfs"
372 379 #define VFSNAME_SYNC "sync"
373 380 #define VFSNAME_VGET "vget"
374 381 #define VFSNAME_MOUNTROOT "mountroot"
375 382 #define VFSNAME_FREEVFS "freevfs"
376 383 #define VFSNAME_VNSTATE "vnstate"
377 384 /*
378 385 * Filesystem type switch table.
379 386 */
380 387
381 388 typedef struct vfssw {
382 389 char *vsw_name; /* type name -- max len _ST_FSTYPSZ */
383 390 int (*vsw_init) (int, char *);
384 391 /* init routine (for non-loadable fs only) */
385 392 int vsw_flag; /* flags */
386 393 mntopts_t vsw_optproto; /* mount options table prototype */
387 394 uint_t vsw_count; /* count of references */
388 395 kmutex_t vsw_lock; /* lock to protect vsw_count */
389 396 vfsops_t vsw_vfsops; /* filesystem operations vector */
390 397 } vfssw_t;
391 398
392 399 /*
393 400 * Filesystem type definition record. All file systems must export a record
394 401 * of this type through their modlfs structure. N.B., changing the version
395 402 * number requires a change in sys/modctl.h.
396 403 */
397 404
398 405 typedef struct vfsdef_v5 {
399 406 int def_version; /* structure version, must be first */
400 407 char *name; /* filesystem type name */
401 408 int (*init) (int, char *); /* init routine */
402 409 int flags; /* filesystem flags */
403 410 mntopts_t *optproto; /* mount options table prototype */
404 411 } vfsdef_v5;
405 412
406 413 typedef struct vfsdef_v5 vfsdef_t;
407 414
408 415 enum {
409 416 VFSDEF_VERSION = 5
410 417 };
411 418
412 419 /*
413 420 * flags for vfssw and vfsdef
414 421 */
415 422 #define VSW_HASPROTO 0x01 /* struct has a mount options prototype */
416 423 #define VSW_CANRWRO 0x02 /* file system can transition from rw to ro */
417 424 #define VSW_CANREMOUNT 0x04 /* file system supports remounts */
418 425 #define VSW_NOTZONESAFE 0x08 /* zone_enter(2) should fail for these files */
419 426 #define VSW_VOLATILEDEV 0x10 /* vfs_dev can change each time fs is mounted */
420 427 #define VSW_STATS 0x20 /* file system can collect stats */
421 428 #define VSW_XID 0x40 /* file system supports extended ids */
422 429 #define VSW_CANLOFI 0x80 /* file system supports lofi mounts */
423 430 #define VSW_ZMOUNT 0x100 /* file system always allowed in a zone */
424 431
425 432 #define VSW_INSTALLED 0x8000 /* this vsw is associated with a file system */
426 433
427 434 /*
428 435 * A flag for vfs_setpath().
429 436 */
430 437 #define VFSSP_VERBATIM 0x1 /* do not prefix the supplied path */
431 438
432 439 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
433 440
434 441 /*
435 442 * Private vfs data, NOT to be used by a file system implementation.
436 443 */
437 444
438 445 #define VFS_FEATURE_MAXSZ 4
439 446
440 447 typedef struct vfs_impl {
441 448 /* Counted array - Bitmap of vfs features */
442 449 uint32_t vi_featureset[VFS_FEATURE_MAXSZ];
443 450 /*
444 451 * Support for statistics on the vnode operations
445 452 */
446 453 vsk_anchor_t *vi_vskap; /* anchor for vopstats' kstat */
447 454 vopstats_t *vi_fstypevsp; /* ptr to per-fstype vopstats */
448 455 vopstats_t vi_vopstats; /* per-mount vnode op stats */
449 456
450 457 timespec_t vi_hrctime; /* High-res creation time */
451 458
452 459 zone_ref_t vi_zone_ref; /* reference to zone */
453 460 } vfs_impl_t;
454 461
455 462 /*
456 463 * Public operations.
457 464 */
458 465 struct umounta;
459 466 struct statvfsa;
460 467 struct fstatvfsa;
461 468
462 469 void vfs_freevfsops(vfsops_t *);
463 470 int vfs_freevfsops_by_type(int);
464 471 void vfs_setops(vfs_t *, vfsops_t *);
465 472 vfsops_t *vfs_getops(vfs_t *vfsp);
466 473 int vfs_matchops(vfs_t *, vfsops_t *);
467 474 int vfs_can_sync(vfs_t *vfsp);
468 475 vfs_t *vfs_alloc(int);
469 476 void vfs_free(vfs_t *);
470 477 void vfs_init(vfs_t *vfsp, vfsops_t *, void *);
471 478 void vfsimpl_setup(vfs_t *vfsp);
472 479 void vfsimpl_teardown(vfs_t *vfsp);
473 480 void vn_exists(vnode_t *);
474 481 void vn_idle(vnode_t *);
475 482 void vn_reclaim(vnode_t *);
476 483 void vn_invalid(vnode_t *);
477 484
478 485 int rootconf(void);
479 486 int svm_rootconf(void);
480 487 int domount(char *, struct mounta *, vnode_t *, struct cred *,
481 488 struct vfs **);
482 489 int dounmount(struct vfs *, int, cred_t *);
483 490 int vfs_lock(struct vfs *);
484 491 int vfs_rlock(struct vfs *);
485 492 void vfs_lock_wait(struct vfs *);
486 493 void vfs_rlock_wait(struct vfs *);
487 494 void vfs_unlock(struct vfs *);
488 495 int vfs_lock_held(struct vfs *);
489 496 struct _kthread *vfs_lock_owner(struct vfs *);
490 497 void sync(void);
491 498 void vfs_sync(int);
492 499 void vfs_mountroot(void);
493 500 void vfs_add(vnode_t *, struct vfs *, int);
494 501 void vfs_remove(struct vfs *);
495 502
496 503 /* VFS feature routines */
497 504 void vfs_set_feature(vfs_t *, vfs_feature_t);
498 505 void vfs_clear_feature(vfs_t *, vfs_feature_t);
499 506 int vfs_has_feature(vfs_t *, vfs_feature_t);
500 507 void vfs_propagate_features(vfs_t *, vfs_t *);
501 508
502 509 /* The following functions are not for general use by filesystems */
503 510
504 511 void vfs_createopttbl(mntopts_t *, const char *);
505 512 void vfs_copyopttbl(const mntopts_t *, mntopts_t *);
506 513 void vfs_mergeopttbl(const mntopts_t *, const mntopts_t *, mntopts_t *);
507 514 void vfs_freeopttbl(mntopts_t *);
508 515 void vfs_parsemntopts(mntopts_t *, char *, int);
509 516 int vfs_buildoptionstr(const mntopts_t *, char *, int);
510 517 struct mntopt *vfs_hasopt(const mntopts_t *, const char *);
511 518 void vfs_mnttab_modtimeupd(void);
512 519
513 520 void vfs_clearmntopt(struct vfs *, const char *);
514 521 void vfs_setmntopt(struct vfs *, const char *, const char *, int);
515 522 void vfs_setresource(struct vfs *, const char *, uint32_t);
516 523 void vfs_setmntpoint(struct vfs *, const char *, uint32_t);
517 524 refstr_t *vfs_getresource(const struct vfs *);
518 525 refstr_t *vfs_getmntpoint(const struct vfs *);
519 526 int vfs_optionisset(const struct vfs *, const char *, char **);
520 527 int vfs_settag(uint_t, uint_t, const char *, const char *, cred_t *);
521 528 int vfs_clrtag(uint_t, uint_t, const char *, const char *, cred_t *);
522 529 void vfs_syncall(void);
523 530 void vfs_syncprogress(void);
524 531 void vfsinit(void);
525 532 void vfs_unmountall(void);
526 533 void vfs_make_fsid(fsid_t *, dev_t, int);
527 534 void vfs_addmip(dev_t, struct vfs *);
528 535 void vfs_delmip(struct vfs *);
529 536 int vfs_devismounted(dev_t);
530 537 int vfs_devmounting(dev_t, struct vfs *);
531 538 int vfs_opsinuse(vfsops_t *);
532 539 struct vfs *getvfs(fsid_t *);
533 540 struct vfs *vfs_dev2vfsp(dev_t);
534 541 struct vfs *vfs_mntpoint2vfsp(const char *);
535 542 struct vfssw *allocate_vfssw(const char *);
536 543 struct vfssw *vfs_getvfssw(const char *);
537 544 struct vfssw *vfs_getvfsswbyname(const char *);
538 545 struct vfssw *vfs_getvfsswbyvfsops(vfsops_t *);
539 546 void vfs_refvfssw(struct vfssw *);
540 547 void vfs_unrefvfssw(struct vfssw *);
541 548 uint_t vf_to_stf(uint_t);
542 549 void vfs_mnttab_modtime(timespec_t *);
543 550 void vfs_mnttab_poll(timespec_t *, struct pollhead **);
544 551
545 552 void vfs_list_lock(void);
546 553 void vfs_list_read_lock(void);
547 554 void vfs_list_unlock(void);
548 555 void vfs_list_add(struct vfs *);
549 556 void vfs_list_remove(struct vfs *);
550 557 void vfs_hold(vfs_t *vfsp);
551 558 void vfs_rele(vfs_t *vfsp);
552 559 void fs_freevfs(vfs_t *);
553 560 void vfs_root_redev(vfs_t *vfsp, dev_t ndev, int fstype);
554 561
555 562 int vfs_zone_change_safe(vfs_t *);
556 563
557 564 int vfs_get_lofi(vfs_t *, vnode_t **);
558 565
559 566 #define VFSHASH(maj, min) (((int)((maj)+(min))) & (vfshsz - 1))
560 567 #define VFS_ON_LIST(vfsp) \
561 568 ((vfsp)->vfs_next != (vfsp) && (vfsp)->vfs_next != NULL)
562 569
563 570 /*
564 571 * Globals.
565 572 */
566 573
567 574 extern struct vfssw vfssw[]; /* table of filesystem types */
568 575 extern krwlock_t vfssw_lock;
569 576 extern char rootfstype[]; /* name of root fstype */
570 577 extern const int nfstype; /* # of elements in vfssw array */
571 578 extern vfsops_t *EIO_vfsops; /* operations for vfs being torn-down */
572 579
573 580 /*
574 581 * The following variables are private to the the kernel's vfs layer. File
575 582 * system implementations should not access them.
576 583 */
577 584 extern struct vfs *rootvfs; /* ptr to root vfs structure */
578 585 typedef struct {
579 586 struct vfs *rvfs_head; /* head vfs in chain */
580 587 kmutex_t rvfs_lock; /* mutex protecting this chain */
581 588 uint32_t rvfs_len; /* length of this chain */
582 589 } rvfs_t;
583 590 extern rvfs_t *rvfs_list;
584 591 extern int vfshsz; /* # of elements in rvfs_head array */
585 592 extern const mntopts_t vfs_mntopts; /* globally recognized options */
586 593
587 594 #endif /* defined(_KERNEL) */
588 595
589 596 #define VFS_HOLD(vfsp) { \
590 597 vfs_hold(vfsp); \
591 598 }
592 599
593 600 #define VFS_RELE(vfsp) { \
594 601 vfs_rele(vfsp); \
595 602 }
596 603
597 604 #define VFS_INIT(vfsp, op, data) { \
598 605 vfs_init((vfsp), (op), (data)); \
599 606 }
600 607
601 608
602 609 #define VFS_INSTALLED(vfsswp) (((vfsswp)->vsw_flag & VSW_INSTALLED) != 0)
603 610 #define ALLOCATED_VFSSW(vswp) ((vswp)->vsw_name[0] != '\0')
604 611 #define RLOCK_VFSSW() (rw_enter(&vfssw_lock, RW_READER))
605 612 #define RUNLOCK_VFSSW() (rw_exit(&vfssw_lock))
606 613 #define WLOCK_VFSSW() (rw_enter(&vfssw_lock, RW_WRITER))
607 614 #define WUNLOCK_VFSSW() (rw_exit(&vfssw_lock))
608 615 #define VFSSW_LOCKED() (RW_LOCK_HELD(&vfssw_lock))
609 616 #define VFSSW_WRITE_LOCKED() (RW_WRITE_HELD(&vfssw_lock))
610 617 /*
611 618 * VFS_SYNC flags.
612 619 */
613 620 #define SYNC_ATTR 0x01 /* sync attributes only */
614 621 #define SYNC_CLOSE 0x02 /* close open file */
615 622 #define SYNC_ALL 0x04 /* force to sync all fs */
616 623
617 624 #ifdef __cplusplus
618 625 }
619 626 #endif
620 627
621 628 #endif /* _SYS_VFS_H */
↓ open down ↓ |
406 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX