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 /* 23 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright (c) 2017, Joyent, Inc. 25 * Copyright (c) 2011, 2017 by Delphix. All rights reserved. 26 */ 27 28 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 29 /* All Rights Reserved */ 30 31 /* 32 * University Copyright- Copyright (c) 1982, 1986, 1988 33 * The Regents of the University of California 34 * All Rights Reserved 35 * 36 * University Acknowledgment- Portions of this document are derived from 37 * software developed by the University of California, Berkeley, and its 38 * contributors. 39 */ 40 41 #ifndef _SYS_VNODE_H 42 #define _SYS_VNODE_H 43 44 #include <sys/types.h> 45 #include <sys/t_lock.h> 46 #include <sys/rwstlock.h> 47 #include <sys/time_impl.h> 48 #include <sys/cred.h> 49 #include <sys/uio.h> 50 #include <sys/resource.h> 51 #include <vm/seg_enum.h> 52 #include <sys/kstat.h> 53 #include <sys/kmem.h> 54 #include <sys/list.h> 55 #ifdef _KERNEL 56 #include <sys/buf.h> 57 #include <sys/sdt.h> 58 #endif /* _KERNEL */ 59 60 #ifdef __cplusplus 61 extern "C" { 62 #endif 63 64 /* 65 * Statistics for all vnode operations. 66 * All operations record number of ops (since boot/mount/zero'ed). 67 * Certain I/O operations (read, write, readdir) also record number 68 * of bytes transferred. 69 * This appears in two places in the system: one is embedded in each 70 * vfs_t. There is also an array of vopstats_t structures allocated 71 * on a per-fstype basis. 72 */ 73 74 #define VOPSTATS_STR "vopstats_" /* Initial string for vopstat kstats */ 75 76 typedef struct vopstats { 77 kstat_named_t nopen; /* VOP_OPEN */ 78 kstat_named_t nclose; /* VOP_CLOSE */ 79 kstat_named_t nread; /* VOP_READ */ 80 kstat_named_t read_bytes; 81 kstat_named_t nwrite; /* VOP_WRITE */ 82 kstat_named_t write_bytes; 83 kstat_named_t nioctl; /* VOP_IOCTL */ 84 kstat_named_t nsetfl; /* VOP_SETFL */ 85 kstat_named_t ngetattr; /* VOP_GETATTR */ 86 kstat_named_t nsetattr; /* VOP_SETATTR */ 87 kstat_named_t naccess; /* VOP_ACCESS */ 88 kstat_named_t nlookup; /* VOP_LOOKUP */ 89 kstat_named_t ncreate; /* VOP_CREATE */ 90 kstat_named_t nremove; /* VOP_REMOVE */ 91 kstat_named_t nlink; /* VOP_LINK */ 92 kstat_named_t nrename; /* VOP_RENAME */ 93 kstat_named_t nmkdir; /* VOP_MKDIR */ 94 kstat_named_t nrmdir; /* VOP_RMDIR */ 95 kstat_named_t nreaddir; /* VOP_READDIR */ 96 kstat_named_t readdir_bytes; 97 kstat_named_t nsymlink; /* VOP_SYMLINK */ 98 kstat_named_t nreadlink; /* VOP_READLINK */ 99 kstat_named_t nfsync; /* VOP_FSYNC */ 100 kstat_named_t ninactive; /* VOP_INACTIVE */ 101 kstat_named_t nfid; /* VOP_FID */ 102 kstat_named_t nrwlock; /* VOP_RWLOCK */ 103 kstat_named_t nrwunlock; /* VOP_RWUNLOCK */ 104 kstat_named_t nseek; /* VOP_SEEK */ 105 kstat_named_t ncmp; /* VOP_CMP */ 106 kstat_named_t nfrlock; /* VOP_FRLOCK */ 107 kstat_named_t nspace; /* VOP_SPACE */ 108 kstat_named_t nrealvp; /* VOP_REALVP */ 109 kstat_named_t ngetpage; /* VOP_GETPAGE */ 110 kstat_named_t nputpage; /* VOP_PUTPAGE */ 111 kstat_named_t nmap; /* VOP_MAP */ 112 kstat_named_t naddmap; /* VOP_ADDMAP */ 113 kstat_named_t ndelmap; /* VOP_DELMAP */ 114 kstat_named_t npoll; /* VOP_POLL */ 115 kstat_named_t ndump; /* VOP_DUMP */ 116 kstat_named_t npathconf; /* VOP_PATHCONF */ 117 kstat_named_t npageio; /* VOP_PAGEIO */ 118 kstat_named_t ndumpctl; /* VOP_DUMPCTL */ 119 kstat_named_t ndispose; /* VOP_DISPOSE */ 120 kstat_named_t nsetsecattr; /* VOP_SETSECATTR */ 121 kstat_named_t ngetsecattr; /* VOP_GETSECATTR */ 122 kstat_named_t nshrlock; /* VOP_SHRLOCK */ 123 kstat_named_t nvnevent; /* VOP_VNEVENT */ 124 kstat_named_t nreqzcbuf; /* VOP_REQZCBUF */ 125 kstat_named_t nretzcbuf; /* VOP_RETZCBUF */ 126 } vopstats_t; 127 128 /* 129 * The vnode is the focus of all file activity in UNIX. 130 * A vnode is allocated for each active file, each current 131 * directory, each mounted-on file, and the root. 132 * 133 * Each vnode is usually associated with a file-system-specific node (for 134 * UFS, this is the in-memory inode). Generally, a vnode and an fs-node 135 * should be created and destroyed together as a pair. 136 * 137 * If a vnode is reused for a new file, it should be reinitialized by calling 138 * either vn_reinit() or vn_recycle(). 139 * 140 * vn_reinit() resets the entire vnode as if it was returned by vn_alloc(). 141 * The caller is responsible for setting up the entire vnode after calling 142 * vn_reinit(). This is important when using kmem caching where the vnode is 143 * allocated by a constructor, for instance. 144 * 145 * vn_recycle() is used when the file system keeps some state around in both 146 * the vnode and the associated FS-node. In UFS, for example, the inode of 147 * a deleted file can be reused immediately. The v_data, v_vfsp, v_op, etc. 148 * remains the same but certain fields related to the previous instance need 149 * to be reset. In particular: 150 * v_femhead 151 * v_path 152 * v_rdcnt, v_wrcnt 153 * v_mmap_read, v_mmap_write 154 */ 155 156 /* 157 * vnode types. VNON means no type. These values are unrelated to 158 * values in on-disk inodes. 159 */ 160 typedef enum vtype { 161 VNON = 0, 162 VREG = 1, 163 VDIR = 2, 164 VBLK = 3, 165 VCHR = 4, 166 VLNK = 5, 167 VFIFO = 6, 168 VDOOR = 7, 169 VPROC = 8, 170 VSOCK = 9, 171 VPORT = 10, 172 VBAD = 11 173 } vtype_t; 174 175 /* 176 * VSD - Vnode Specific Data 177 * Used to associate additional private data with a vnode. 178 */ 179 struct vsd_node { 180 list_node_t vs_nodes; /* list of all VSD nodes */ 181 uint_t vs_nkeys; /* entries in value array */ 182 void **vs_value; /* array of value/key */ 183 }; 184 185 /* 186 * Many of the fields in the vnode are read-only once they are initialized 187 * at vnode creation time. Other fields are protected by locks. 188 * 189 * IMPORTANT: vnodes should be created ONLY by calls to vn_alloc(). They 190 * may not be embedded into the file-system specific node (inode). The 191 * size of vnodes may change. 192 * 193 * The v_lock protects: 194 * v_flag 195 * v_stream 196 * v_count 197 * v_shrlocks 198 * v_path 199 * v_vsd 200 * v_xattrdir 201 * 202 * A special lock (implemented by vn_vfswlock in vnode.c) protects: 203 * v_vfsmountedhere 204 * 205 * The global flock_lock mutex (in flock.c) protects: 206 * v_filocks 207 * 208 * IMPORTANT NOTE: 209 * 210 * The following vnode fields are considered public and may safely be 211 * accessed by file systems or other consumers: 212 * 213 * v_lock 214 * v_flag 215 * v_count 216 * v_data 217 * v_vfsp 218 * v_stream 219 * v_type 220 * v_rdev 221 * 222 * ALL OTHER FIELDS SHOULD BE ACCESSED ONLY BY THE OWNER OF THAT FIELD. 223 * In particular, file systems should not access other fields; they may 224 * change or even be removed. The functionality which was once provided 225 * by these fields is available through vn_* functions. 226 * 227 * VNODE PATH THEORY: 228 * In each vnode, the v_path field holds a cached version of the canonical 229 * filesystem path which that node represents. Because vnodes lack contextual 230 * information about their own name or position in the VFS hierarchy, this path 231 * must be calculated when the vnode is instantiated by operations such as 232 * fop_create, fop_lookup, or fop_mkdir. During said operations, both the 233 * parent vnode (and its cached v_path) and future name are known, so the 234 * v_path of the resulting object can easily be set. 235 * 236 * The caching nature of v_path is complicated in the face of directory 237 * renames. Filesystem drivers are responsible for calling vn_renamepath when 238 * a fop_rename operation succeeds. While the v_path on the renamed vnode will 239 * be updated, existing children of the directory (direct, or at deeper levels) 240 * will now possess v_path caches which are stale. 241 * 242 * It is expensive (and for non-directories, impossible) to recalculate stale 243 * v_path entries during operations such as vnodetopath. The best time during 244 * which to correct such wrongs is the same as when v_path is first 245 * initialized: during fop_create/fop_lookup/fop_mkdir/etc, where adequate 246 * context is available to generate the current path. 247 * 248 * In order to quickly detect stale v_path entries (without full lookup 249 * verification) to trigger a v_path update, the v_path_stamp field has been 250 * added to vnode_t. As part of successful fop_create/fop_lookup/fop_mkdir 251 * operations, where the name and parent vnode are available, the following 252 * rules are used to determine updates to the child: 253 * 254 * 1. If the parent lacks a v_path, clear any existing v_path and v_path_stamp 255 * on the child. Until the parent v_path is refreshed to a valid state, the 256 * child v_path must be considered invalid too. 257 * 258 * 2. If the child lacks a v_path (implying v_path_stamp == 0), it inherits the 259 * v_path_stamp value from its parent and its v_path is updated. 260 * 261 * 3. If the child v_path_stamp is less than v_path_stamp in the parent, it is 262 * an indication that the child v_path is stale. The v_path is updated and 263 * v_path_stamp in the child is set to the current hrtime(). 264 * 265 * It does _not_ inherit the parent v_path_stamp in order to propagate the 266 * the time of v_path invalidation through the directory structure. This 267 * prevents concurrent invalidations (operating with a now-incorrect v_path) 268 * at deeper levels in the tree from persisting. 269 * 270 * 4. If the child v_path_stamp is greater or equal to the parent, no action 271 * needs to be taken. 272 * 273 * Note that fop_rename operations do not follow this ruleset. They perform an 274 * explicit update of v_path and v_path_stamp (setting it to the current time) 275 * 276 * With these constraints in place, v_path invalidations and updates should 277 * proceed in a timely manner as vnodes are accessed. While there still are 278 * limited cases where vnodetopath operations will fail, the risk is minimized. 279 */ 280 281 struct fem_head; /* from fem.h */ 282 283 typedef struct vnode { 284 kmutex_t v_lock; /* protects vnode fields */ 285 uint_t v_flag; /* vnode flags (see below) */ 286 uint_t v_count; /* reference count */ 287 void *v_data; /* private data for fs */ 288 struct vfs *v_vfsp; /* ptr to containing VFS */ 289 struct stdata *v_stream; /* associated stream */ 290 enum vtype v_type; /* vnode type */ 291 dev_t v_rdev; /* device (VCHR, VBLK) */ 292 293 /* PRIVATE FIELDS BELOW - DO NOT USE */ 294 295 struct vfs *v_vfsmountedhere; /* ptr to vfs mounted here */ 296 struct vnodeops *v_op; /* vnode operations */ 297 struct page *v_pages; /* vnode pages list */ 298 struct filock *v_filocks; /* ptr to filock list */ 299 struct shrlocklist *v_shrlocks; /* ptr to shrlock list */ 300 krwlock_t v_nbllock; /* sync for NBMAND locks */ 301 kcondvar_t v_cv; /* synchronize locking */ 302 void *v_locality; /* hook for locality info */ 303 struct fem_head *v_femhead; /* fs monitoring */ 304 char *v_path; /* cached path */ 305 hrtime_t v_path_stamp; /* timestamp for cached path */ 306 uint_t v_rdcnt; /* open for read count (VREG only) */ 307 uint_t v_wrcnt; /* open for write count (VREG only) */ 308 u_longlong_t v_mmap_read; /* mmap read count */ 309 u_longlong_t v_mmap_write; /* mmap write count */ 310 void *v_mpssdata; /* info for large page mappings */ 311 void *v_fopdata; /* list of file ops event watches */ 312 kmutex_t v_vsd_lock; /* protects v_vsd field */ 313 struct vsd_node *v_vsd; /* vnode specific data */ 314 struct vnode *v_xattrdir; /* unnamed extended attr dir (GFS) */ 315 uint_t v_count_dnlc; /* dnlc reference count */ 316 } vnode_t; 317 318 #define IS_DEVVP(vp) \ 319 ((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO) 320 321 #define VNODE_ALIGN 64 322 /* Count of low-order 0 bits in a vnode *, based on size and alignment. */ 323 #if defined(_LP64) 324 #define VNODE_ALIGN_LOG2 8 325 #else 326 #define VNODE_ALIGN_LOG2 7 327 #endif 328 329 /* 330 * vnode flags. 331 */ 332 #define VROOT 0x01 /* root of its file system */ 333 #define VNOCACHE 0x02 /* don't keep cache pages on vnode */ 334 #define VNOMAP 0x04 /* file cannot be mapped/faulted */ 335 #define VDUP 0x08 /* file should be dup'ed rather then opened */ 336 #define VNOSWAP 0x10 /* file cannot be used as virtual swap device */ 337 #define VNOMOUNT 0x20 /* file cannot be covered by mount */ 338 #define VISSWAP 0x40 /* vnode is being used for swap */ 339 #define VSWAPLIKE 0x80 /* vnode acts like swap (but may not be) */ 340 341 #define IS_SWAPVP(vp) (((vp)->v_flag & (VISSWAP | VSWAPLIKE)) != 0) 342 343 typedef struct vn_vfslocks_entry { 344 rwstlock_t ve_lock; 345 void *ve_vpvfs; 346 struct vn_vfslocks_entry *ve_next; 347 uint32_t ve_refcnt; 348 char pad[64 - sizeof (rwstlock_t) - 2 * sizeof (void *) - \ 349 sizeof (uint32_t)]; 350 } vn_vfslocks_entry_t; 351 352 /* 353 * The following two flags are used to lock the v_vfsmountedhere field 354 */ 355 #define VVFSLOCK 0x100 356 #define VVFSWAIT 0x200 357 358 /* 359 * Used to serialize VM operations on a vnode 360 */ 361 #define VVMLOCK 0x400 362 363 /* 364 * Tell vn_open() not to fail a directory open for writing but 365 * to go ahead and call VOP_OPEN() to let the filesystem check. 366 */ 367 #define VDIROPEN 0x800 368 369 /* 370 * Flag to let the VM system know that this file is most likely a binary 371 * or shared library since it has been mmap()ed EXEC at some time. 372 */ 373 #define VVMEXEC 0x1000 374 375 #define VPXFS 0x2000 /* clustering: global fs proxy vnode */ 376 377 #define IS_PXFSVP(vp) ((vp)->v_flag & VPXFS) 378 379 #define V_XATTRDIR 0x4000 /* attribute unnamed directory */ 380 381 #define IS_XATTRDIR(vp) ((vp)->v_flag & V_XATTRDIR) 382 383 #define V_LOCALITY 0x8000 /* whether locality aware */ 384 385 /* 386 * Flag that indicates the VM should maintain the v_pages list with all modified 387 * pages on one end and unmodified pages at the other. This makes finding dirty 388 * pages to write back to disk much faster at the expense of taking a minor 389 * fault on the first store instruction which touches a writable page. 390 */ 391 #define VMODSORT (0x10000) 392 #define IS_VMODSORT(vp) \ 393 (pvn_vmodsort_supported != 0 && ((vp)->v_flag & VMODSORT) != 0) 394 395 #define VISSWAPFS 0x20000 /* vnode is being used for swapfs */ 396 397 /* 398 * The mdb memstat command assumes that IS_SWAPFSVP only uses the 399 * vnode's v_flag field. If this changes, cache the additional 400 * fields in mdb; see vn_get in mdb/common/modules/genunix/memory.c 401 */ 402 #define IS_SWAPFSVP(vp) (((vp)->v_flag & VISSWAPFS) != 0) 403 404 #define V_SYSATTR 0x40000 /* vnode is a GFS system attribute */ 405 406 /* 407 * Indication that VOP_LOOKUP operations on this vnode may yield results from a 408 * different VFS instance. The main use of this is to suppress v_path 409 * calculation logic when filesystems such as procfs emit results which defy 410 * expectations about normal VFS behavior. 411 */ 412 #define VTRAVERSE 0x80000 413 414 /* 415 * Vnode attributes. A bit-mask is supplied as part of the 416 * structure to indicate the attributes the caller wants to 417 * set (setattr) or extract (getattr). 418 */ 419 420 /* 421 * Note that va_nodeid and va_nblocks are 64bit data type. 422 * We support large files over NFSV3. With Solaris client and 423 * Server that generates 64bit ino's and sizes these fields 424 * will overflow if they are 32 bit sizes. 425 */ 426 427 typedef struct vattr { 428 uint_t va_mask; /* bit-mask of attributes */ 429 vtype_t va_type; /* vnode type (for create) */ 430 mode_t va_mode; /* file access mode */ 431 uid_t va_uid; /* owner user id */ 432 gid_t va_gid; /* owner group id */ 433 dev_t va_fsid; /* file system id (dev for now) */ 434 u_longlong_t va_nodeid; /* node id */ 435 nlink_t va_nlink; /* number of references to file */ 436 u_offset_t va_size; /* file size in bytes */ 437 timestruc_t va_atime; /* time of last access */ 438 timestruc_t va_mtime; /* time of last modification */ 439 timestruc_t va_ctime; /* time of last status change */ 440 dev_t va_rdev; /* device the file represents */ 441 uint_t va_blksize; /* fundamental block size */ 442 u_longlong_t va_nblocks; /* # of blocks allocated */ 443 uint_t va_seq; /* sequence number */ 444 } vattr_t; 445 446 #define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */ 447 448 /* 449 * Structure of all optional attributes. 450 */ 451 typedef struct xoptattr { 452 timestruc_t xoa_createtime; /* Create time of file */ 453 uint8_t xoa_archive; 454 uint8_t xoa_system; 455 uint8_t xoa_readonly; 456 uint8_t xoa_hidden; 457 uint8_t xoa_nounlink; 458 uint8_t xoa_immutable; 459 uint8_t xoa_appendonly; 460 uint8_t xoa_nodump; 461 uint8_t xoa_opaque; 462 uint8_t xoa_av_quarantined; 463 uint8_t xoa_av_modified; 464 uint8_t xoa_av_scanstamp[AV_SCANSTAMP_SZ]; 465 uint8_t xoa_reparse; 466 uint64_t xoa_generation; 467 uint8_t xoa_offline; 468 uint8_t xoa_sparse; 469 } xoptattr_t; 470 471 /* 472 * The xvattr structure is really a variable length structure that 473 * is made up of: 474 * - The classic vattr_t (xva_vattr) 475 * - a 32 bit quantity (xva_mapsize) that specifies the size of the 476 * attribute bitmaps in 32 bit words. 477 * - A pointer to the returned attribute bitmap (needed because the 478 * previous element, the requested attribute bitmap) is variable lenth. 479 * - The requested attribute bitmap, which is an array of 32 bit words. 480 * Callers use the XVA_SET_REQ() macro to set the bits corresponding to 481 * the attributes that are being requested. 482 * - The returned attribute bitmap, which is an array of 32 bit words. 483 * File systems that support optional attributes use the XVA_SET_RTN() 484 * macro to set the bits corresponding to the attributes that are being 485 * returned. 486 * - The xoptattr_t structure which contains the attribute values 487 * 488 * xva_mapsize determines how many words in the attribute bitmaps. 489 * Immediately following the attribute bitmaps is the xoptattr_t. 490 * xva_getxoptattr() is used to get the pointer to the xoptattr_t 491 * section. 492 */ 493 494 #define XVA_MAPSIZE 3 /* Size of attr bitmaps */ 495 #define XVA_MAGIC 0x78766174 /* Magic # for verification */ 496 497 /* 498 * The xvattr structure is an extensible structure which permits optional 499 * attributes to be requested/returned. File systems may or may not support 500 * optional attributes. They do so at their own discretion but if they do 501 * support optional attributes, they must register the VFSFT_XVATTR feature 502 * so that the optional attributes can be set/retrived. 503 * 504 * The fields of the xvattr structure are: 505 * 506 * xva_vattr - The first element of an xvattr is a legacy vattr structure 507 * which includes the common attributes. If AT_XVATTR is set in the va_mask 508 * then the entire structure is treated as an xvattr. If AT_XVATTR is not 509 * set, then only the xva_vattr structure can be used. 510 * 511 * xva_magic - 0x78766174 (hex for "xvat"). Magic number for verification. 512 * 513 * xva_mapsize - Size of requested and returned attribute bitmaps. 514 * 515 * xva_rtnattrmapp - Pointer to xva_rtnattrmap[]. We need this since the 516 * size of the array before it, xva_reqattrmap[], could change which means 517 * the location of xva_rtnattrmap[] could change. This will allow unbundled 518 * file systems to find the location of xva_rtnattrmap[] when the sizes change. 519 * 520 * xva_reqattrmap[] - Array of requested attributes. Attributes are 521 * represented by a specific bit in a specific element of the attribute 522 * map array. Callers set the bits corresponding to the attributes 523 * that the caller wants to get/set. 524 * 525 * xva_rtnattrmap[] - Array of attributes that the file system was able to 526 * process. Not all file systems support all optional attributes. This map 527 * informs the caller which attributes the underlying file system was able 528 * to set/get. (Same structure as the requested attributes array in terms 529 * of each attribute corresponding to specific bits and array elements.) 530 * 531 * xva_xoptattrs - Structure containing values of optional attributes. 532 * These values are only valid if the corresponding bits in xva_reqattrmap 533 * are set and the underlying file system supports those attributes. 534 */ 535 typedef struct xvattr { 536 vattr_t xva_vattr; /* Embedded vattr structure */ 537 uint32_t xva_magic; /* Magic Number */ 538 uint32_t xva_mapsize; /* Size of attr bitmap (32-bit words) */ 539 uint32_t *xva_rtnattrmapp; /* Ptr to xva_rtnattrmap[] */ 540 uint32_t xva_reqattrmap[XVA_MAPSIZE]; /* Requested attrs */ 541 uint32_t xva_rtnattrmap[XVA_MAPSIZE]; /* Returned attrs */ 542 xoptattr_t xva_xoptattrs; /* Optional attributes */ 543 } xvattr_t; 544 545 #ifdef _SYSCALL32 546 /* 547 * For bigtypes time_t changed to 64 bit on the 64-bit kernel. 548 * Define an old version for user/kernel interface 549 */ 550 551 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 552 #pragma pack(4) 553 #endif 554 555 typedef struct vattr32 { 556 uint32_t va_mask; /* bit-mask of attributes */ 557 vtype_t va_type; /* vnode type (for create) */ 558 mode32_t va_mode; /* file access mode */ 559 uid32_t va_uid; /* owner user id */ 560 gid32_t va_gid; /* owner group id */ 561 dev32_t va_fsid; /* file system id (dev for now) */ 562 u_longlong_t va_nodeid; /* node id */ 563 nlink_t va_nlink; /* number of references to file */ 564 u_offset_t va_size; /* file size in bytes */ 565 timestruc32_t va_atime; /* time of last access */ 566 timestruc32_t va_mtime; /* time of last modification */ 567 timestruc32_t va_ctime; /* time of last status change */ 568 dev32_t va_rdev; /* device the file represents */ 569 uint32_t va_blksize; /* fundamental block size */ 570 u_longlong_t va_nblocks; /* # of blocks allocated */ 571 uint32_t va_seq; /* sequence number */ 572 } vattr32_t; 573 574 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 575 #pragma pack() 576 #endif 577 578 #else /* not _SYSCALL32 */ 579 #define vattr32 vattr 580 typedef vattr_t vattr32_t; 581 #endif /* _SYSCALL32 */ 582 583 /* 584 * Attributes of interest to the caller of setattr or getattr. 585 */ 586 #define AT_TYPE 0x00001 587 #define AT_MODE 0x00002 588 #define AT_UID 0x00004 589 #define AT_GID 0x00008 590 #define AT_FSID 0x00010 591 #define AT_NODEID 0x00020 592 #define AT_NLINK 0x00040 593 #define AT_SIZE 0x00080 594 #define AT_ATIME 0x00100 595 #define AT_MTIME 0x00200 596 #define AT_CTIME 0x00400 597 #define AT_RDEV 0x00800 598 #define AT_BLKSIZE 0x01000 599 #define AT_NBLOCKS 0x02000 600 /* 0x04000 */ /* unused */ 601 #define AT_SEQ 0x08000 602 /* 603 * If AT_XVATTR is set then there are additional bits to process in 604 * the xvattr_t's attribute bitmap. If this is not set then the bitmap 605 * MUST be ignored. Note that this bit must be set/cleared explicitly. 606 * That is, setting AT_ALL will NOT set AT_XVATTR. 607 */ 608 #define AT_XVATTR 0x10000 609 610 #define AT_ALL (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\ 611 AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\ 612 AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) 613 614 #define AT_STAT (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\ 615 AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE) 616 617 #define AT_TIMES (AT_ATIME|AT_MTIME|AT_CTIME) 618 619 #define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ 620 AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) 621 622 /* 623 * Attribute bits used in the extensible attribute's (xva's) attribute 624 * bitmaps. Note that the bitmaps are made up of a variable length number 625 * of 32-bit words. The convention is to use XAT{n}_{attrname} where "n" 626 * is the element in the bitmap (starting at 1). This convention is for 627 * the convenience of the maintainer to keep track of which element each 628 * attribute belongs to. 629 * 630 * NOTE THAT CONSUMERS MUST *NOT* USE THE XATn_* DEFINES DIRECTLY. CONSUMERS 631 * MUST USE THE XAT_* DEFINES. 632 */ 633 #define XAT0_INDEX 0LL /* Index into bitmap for XAT0 attrs */ 634 #define XAT0_CREATETIME 0x00000001 /* Create time of file */ 635 #define XAT0_ARCHIVE 0x00000002 /* Archive */ 636 #define XAT0_SYSTEM 0x00000004 /* System */ 637 #define XAT0_READONLY 0x00000008 /* Readonly */ 638 #define XAT0_HIDDEN 0x00000010 /* Hidden */ 639 #define XAT0_NOUNLINK 0x00000020 /* Nounlink */ 640 #define XAT0_IMMUTABLE 0x00000040 /* immutable */ 641 #define XAT0_APPENDONLY 0x00000080 /* appendonly */ 642 #define XAT0_NODUMP 0x00000100 /* nodump */ 643 #define XAT0_OPAQUE 0x00000200 /* opaque */ 644 #define XAT0_AV_QUARANTINED 0x00000400 /* anti-virus quarantine */ 645 #define XAT0_AV_MODIFIED 0x00000800 /* anti-virus modified */ 646 #define XAT0_AV_SCANSTAMP 0x00001000 /* anti-virus scanstamp */ 647 #define XAT0_REPARSE 0x00002000 /* FS reparse point */ 648 #define XAT0_GEN 0x00004000 /* object generation number */ 649 #define XAT0_OFFLINE 0x00008000 /* offline */ 650 #define XAT0_SPARSE 0x00010000 /* sparse */ 651 652 #define XAT0_ALL_ATTRS (XAT0_CREATETIME|XAT0_ARCHIVE|XAT0_SYSTEM| \ 653 XAT0_READONLY|XAT0_HIDDEN|XAT0_NOUNLINK|XAT0_IMMUTABLE|XAT0_APPENDONLY| \ 654 XAT0_NODUMP|XAT0_OPAQUE|XAT0_AV_QUARANTINED| XAT0_AV_MODIFIED| \ 655 XAT0_AV_SCANSTAMP|XAT0_REPARSE|XATO_GEN|XAT0_OFFLINE|XAT0_SPARSE) 656 657 /* Support for XAT_* optional attributes */ 658 #define XVA_MASK 0xffffffff /* Used to mask off 32 bits */ 659 #define XVA_SHFT 32 /* Used to shift index */ 660 661 /* 662 * Used to pry out the index and attribute bits from the XAT_* attributes 663 * defined below. Note that we're masking things down to 32 bits then 664 * casting to uint32_t. 665 */ 666 #define XVA_INDEX(attr) ((uint32_t)(((attr) >> XVA_SHFT) & XVA_MASK)) 667 #define XVA_ATTRBIT(attr) ((uint32_t)((attr) & XVA_MASK)) 668 669 /* 670 * The following defines present a "flat namespace" so that consumers don't 671 * need to keep track of which element belongs to which bitmap entry. 672 * 673 * NOTE THAT THESE MUST NEVER BE OR-ed TOGETHER 674 */ 675 #define XAT_CREATETIME ((XAT0_INDEX << XVA_SHFT) | XAT0_CREATETIME) 676 #define XAT_ARCHIVE ((XAT0_INDEX << XVA_SHFT) | XAT0_ARCHIVE) 677 #define XAT_SYSTEM ((XAT0_INDEX << XVA_SHFT) | XAT0_SYSTEM) 678 #define XAT_READONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_READONLY) 679 #define XAT_HIDDEN ((XAT0_INDEX << XVA_SHFT) | XAT0_HIDDEN) 680 #define XAT_NOUNLINK ((XAT0_INDEX << XVA_SHFT) | XAT0_NOUNLINK) 681 #define XAT_IMMUTABLE ((XAT0_INDEX << XVA_SHFT) | XAT0_IMMUTABLE) 682 #define XAT_APPENDONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_APPENDONLY) 683 #define XAT_NODUMP ((XAT0_INDEX << XVA_SHFT) | XAT0_NODUMP) 684 #define XAT_OPAQUE ((XAT0_INDEX << XVA_SHFT) | XAT0_OPAQUE) 685 #define XAT_AV_QUARANTINED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_QUARANTINED) 686 #define XAT_AV_MODIFIED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_MODIFIED) 687 #define XAT_AV_SCANSTAMP ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_SCANSTAMP) 688 #define XAT_REPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_REPARSE) 689 #define XAT_GEN ((XAT0_INDEX << XVA_SHFT) | XAT0_GEN) 690 #define XAT_OFFLINE ((XAT0_INDEX << XVA_SHFT) | XAT0_OFFLINE) 691 #define XAT_SPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_SPARSE) 692 693 /* 694 * The returned attribute map array (xva_rtnattrmap[]) is located past the 695 * requested attribute map array (xva_reqattrmap[]). Its location changes 696 * when the array sizes change. We use a separate pointer in a known location 697 * (xva_rtnattrmapp) to hold the location of xva_rtnattrmap[]. This is 698 * set in xva_init() 699 */ 700 #define XVA_RTNATTRMAP(xvap) ((xvap)->xva_rtnattrmapp) 701 702 /* 703 * XVA_SET_REQ() sets an attribute bit in the proper element in the bitmap 704 * of requested attributes (xva_reqattrmap[]). 705 */ 706 #define XVA_SET_REQ(xvap, attr) \ 707 ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ 708 ASSERT((xvap)->xva_magic == XVA_MAGIC); \ 709 (xvap)->xva_reqattrmap[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr) 710 /* 711 * XVA_CLR_REQ() clears an attribute bit in the proper element in the bitmap 712 * of requested attributes (xva_reqattrmap[]). 713 */ 714 #define XVA_CLR_REQ(xvap, attr) \ 715 ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ 716 ASSERT((xvap)->xva_magic == XVA_MAGIC); \ 717 (xvap)->xva_reqattrmap[XVA_INDEX(attr)] &= ~XVA_ATTRBIT(attr) 718 719 /* 720 * XVA_SET_RTN() sets an attribute bit in the proper element in the bitmap 721 * of returned attributes (xva_rtnattrmap[]). 722 */ 723 #define XVA_SET_RTN(xvap, attr) \ 724 ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ 725 ASSERT((xvap)->xva_magic == XVA_MAGIC); \ 726 (XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr) 727 728 /* 729 * XVA_ISSET_REQ() checks the requested attribute bitmap (xva_reqattrmap[]) 730 * to see of the corresponding attribute bit is set. If so, returns non-zero. 731 */ 732 #define XVA_ISSET_REQ(xvap, attr) \ 733 ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \ 734 ((xvap)->xva_magic == XVA_MAGIC) && \ 735 ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \ 736 ((xvap)->xva_reqattrmap[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0) 737 738 /* 739 * XVA_ISSET_RTN() checks the returned attribute bitmap (xva_rtnattrmap[]) 740 * to see of the corresponding attribute bit is set. If so, returns non-zero. 741 */ 742 #define XVA_ISSET_RTN(xvap, attr) \ 743 ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \ 744 ((xvap)->xva_magic == XVA_MAGIC) && \ 745 ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \ 746 ((XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0) 747 748 /* 749 * Modes. Some values same as S_xxx entries from stat.h for convenience. 750 */ 751 #define VSUID 04000 /* set user id on execution */ 752 #define VSGID 02000 /* set group id on execution */ 753 #define VSVTX 01000 /* save swapped text even after use */ 754 755 /* 756 * Permissions. 757 */ 758 #define VREAD 00400 759 #define VWRITE 00200 760 #define VEXEC 00100 761 762 #define MODEMASK 07777 /* mode bits plus permission bits */ 763 #define PERMMASK 00777 /* permission bits */ 764 765 /* 766 * VOP_ACCESS flags 767 */ 768 #define V_ACE_MASK 0x1 /* mask represents NFSv4 ACE permissions */ 769 #define V_APPEND 0x2 /* want to do append only check */ 770 771 /* 772 * Check whether mandatory file locking is enabled. 773 */ 774 775 #define MANDMODE(mode) (((mode) & (VSGID|(VEXEC>>3))) == VSGID) 776 #define MANDLOCK(vp, mode) ((vp)->v_type == VREG && MANDMODE(mode)) 777 778 /* 779 * Flags for vnode operations. 780 */ 781 enum rm { RMFILE, RMDIRECTORY }; /* rm or rmdir (remove) */ 782 enum symfollow { NO_FOLLOW, FOLLOW }; /* follow symlinks (or not) */ 783 enum vcexcl { NONEXCL, EXCL }; /* (non)excl create */ 784 enum create { CRCREAT, CRMKNOD, CRMKDIR }; /* reason for create */ 785 786 typedef enum rm rm_t; 787 typedef enum symfollow symfollow_t; 788 typedef enum vcexcl vcexcl_t; 789 typedef enum create create_t; 790 791 /* 792 * Vnode Events - Used by VOP_VNEVENT 793 * The VE_PRE_RENAME_* events fire before the rename operation and are 794 * primarily used for specialized applications, such as NFSv4 delegation, which 795 * need to know about rename before it occurs. 796 */ 797 typedef enum vnevent { 798 VE_SUPPORT = 0, /* Query */ 799 VE_RENAME_SRC = 1, /* Rename, with vnode as source */ 800 VE_RENAME_DEST = 2, /* Rename, with vnode as target/destination */ 801 VE_REMOVE = 3, /* Remove of vnode's name */ 802 VE_RMDIR = 4, /* Remove of directory vnode's name */ 803 VE_CREATE = 5, /* Create with vnode's name which exists */ 804 VE_LINK = 6, /* Link with vnode's name as source */ 805 VE_RENAME_DEST_DIR = 7, /* Rename with vnode as target dir */ 806 VE_MOUNTEDOVER = 8, /* File or Filesystem got mounted over vnode */ 807 VE_TRUNCATE = 9, /* Truncate */ 808 VE_PRE_RENAME_SRC = 10, /* Pre-rename, with vnode as source */ 809 VE_PRE_RENAME_DEST = 11, /* Pre-rename, with vnode as target/dest. */ 810 VE_PRE_RENAME_DEST_DIR = 12 /* Pre-rename with vnode as target dir */ 811 } vnevent_t; 812 813 /* 814 * Values for checking vnode open and map counts 815 */ 816 enum v_mode { V_READ, V_WRITE, V_RDORWR, V_RDANDWR }; 817 818 typedef enum v_mode v_mode_t; 819 820 #define V_TRUE 1 821 #define V_FALSE 0 822 823 /* 824 * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations 825 */ 826 827 typedef struct vsecattr { 828 uint_t vsa_mask; /* See below */ 829 int vsa_aclcnt; /* ACL entry count */ 830 void *vsa_aclentp; /* pointer to ACL entries */ 831 int vsa_dfaclcnt; /* default ACL entry count */ 832 void *vsa_dfaclentp; /* pointer to default ACL entries */ 833 size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */ 834 uint_t vsa_aclflags; /* ACE ACL flags */ 835 } vsecattr_t; 836 837 /* vsa_mask values */ 838 #define VSA_ACL 0x0001 839 #define VSA_ACLCNT 0x0002 840 #define VSA_DFACL 0x0004 841 #define VSA_DFACLCNT 0x0008 842 #define VSA_ACE 0x0010 843 #define VSA_ACECNT 0x0020 844 #define VSA_ACE_ALLTYPES 0x0040 845 #define VSA_ACE_ACLFLAGS 0x0080 /* get/set ACE ACL flags */ 846 847 /* 848 * Structure used by various vnode operations to determine 849 * the context (pid, host, identity) of a caller. 850 * 851 * The cc_caller_id is used to identify one or more callers who invoke 852 * operations, possibly on behalf of others. For example, the NFS 853 * server could have it's own cc_caller_id which can be detected by 854 * vnode/vfs operations or (FEM) monitors on those operations. New 855 * caller IDs are generated by fs_new_caller_id(). 856 */ 857 typedef struct caller_context { 858 pid_t cc_pid; /* Process ID of the caller */ 859 int cc_sysid; /* System ID, used for remote calls */ 860 u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */ 861 ulong_t cc_flags; 862 } caller_context_t; 863 864 /* 865 * Flags for caller context. The caller sets CC_DONTBLOCK if it does not 866 * want to block inside of a FEM monitor. The monitor will set CC_WOULDBLOCK 867 * and return EAGAIN if the operation would have blocked. 868 */ 869 #define CC_WOULDBLOCK 0x01 870 #define CC_DONTBLOCK 0x02 871 872 /* 873 * Structure tags for function prototypes, defined elsewhere. 874 */ 875 struct pathname; 876 struct fid; 877 struct flock64; 878 struct flk_callback; 879 struct shrlock; 880 struct page; 881 struct seg; 882 struct as; 883 struct pollhead; 884 struct taskq; 885 886 #ifdef _KERNEL 887 888 /* 889 * VNODE_OPS defines all the vnode operations. It is used to define 890 * the vnodeops structure (below) and the fs_func_p union (vfs_opreg.h). 891 */ 892 #define VNODE_OPS \ 893 int (*vop_open)(vnode_t **, int, cred_t *, \ 894 caller_context_t *); \ 895 int (*vop_close)(vnode_t *, int, int, offset_t, cred_t *, \ 896 caller_context_t *); \ 897 int (*vop_read)(vnode_t *, uio_t *, int, cred_t *, \ 898 caller_context_t *); \ 899 int (*vop_write)(vnode_t *, uio_t *, int, cred_t *, \ 900 caller_context_t *); \ 901 int (*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *, \ 902 int *, caller_context_t *); \ 903 int (*vop_setfl)(vnode_t *, int, int, cred_t *, \ 904 caller_context_t *); \ 905 int (*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *, \ 906 caller_context_t *); \ 907 int (*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *, \ 908 caller_context_t *); \ 909 int (*vop_access)(vnode_t *, int, int, cred_t *, \ 910 caller_context_t *); \ 911 int (*vop_lookup)(vnode_t *, char *, vnode_t **, \ 912 struct pathname *, \ 913 int, vnode_t *, cred_t *, \ 914 caller_context_t *, int *, \ 915 struct pathname *); \ 916 int (*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t, \ 917 int, vnode_t **, cred_t *, int, \ 918 caller_context_t *, vsecattr_t *); \ 919 int (*vop_remove)(vnode_t *, char *, cred_t *, \ 920 caller_context_t *, int); \ 921 int (*vop_link)(vnode_t *, vnode_t *, char *, cred_t *, \ 922 caller_context_t *, int); \ 923 int (*vop_rename)(vnode_t *, char *, vnode_t *, char *, \ 924 cred_t *, caller_context_t *, int); \ 925 int (*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **, \ 926 cred_t *, caller_context_t *, int, \ 927 vsecattr_t *); \ 928 int (*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *, \ 929 caller_context_t *, int); \ 930 int (*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *, \ 931 caller_context_t *, int); \ 932 int (*vop_symlink)(vnode_t *, char *, vattr_t *, char *, \ 933 cred_t *, caller_context_t *, int); \ 934 int (*vop_readlink)(vnode_t *, uio_t *, cred_t *, \ 935 caller_context_t *); \ 936 int (*vop_fsync)(vnode_t *, int, cred_t *, \ 937 caller_context_t *); \ 938 void (*vop_inactive)(vnode_t *, cred_t *, \ 939 caller_context_t *); \ 940 int (*vop_fid)(vnode_t *, struct fid *, \ 941 caller_context_t *); \ 942 int (*vop_rwlock)(vnode_t *, int, caller_context_t *); \ 943 void (*vop_rwunlock)(vnode_t *, int, caller_context_t *); \ 944 int (*vop_seek)(vnode_t *, offset_t, offset_t *, \ 945 caller_context_t *); \ 946 int (*vop_cmp)(vnode_t *, vnode_t *, caller_context_t *); \ 947 int (*vop_frlock)(vnode_t *, int, struct flock64 *, \ 948 int, offset_t, \ 949 struct flk_callback *, cred_t *, \ 950 caller_context_t *); \ 951 int (*vop_space)(vnode_t *, int, struct flock64 *, \ 952 int, offset_t, \ 953 cred_t *, caller_context_t *); \ 954 int (*vop_realvp)(vnode_t *, vnode_t **, \ 955 caller_context_t *); \ 956 int (*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *, \ 957 struct page **, size_t, struct seg *, \ 958 caddr_t, enum seg_rw, cred_t *, \ 959 caller_context_t *); \ 960 int (*vop_putpage)(vnode_t *, offset_t, size_t, \ 961 int, cred_t *, caller_context_t *); \ 962 int (*vop_map)(vnode_t *, offset_t, struct as *, \ 963 caddr_t *, size_t, \ 964 uchar_t, uchar_t, uint_t, cred_t *, \ 965 caller_context_t *); \ 966 int (*vop_addmap)(vnode_t *, offset_t, struct as *, \ 967 caddr_t, size_t, \ 968 uchar_t, uchar_t, uint_t, cred_t *, \ 969 caller_context_t *); \ 970 int (*vop_delmap)(vnode_t *, offset_t, struct as *, \ 971 caddr_t, size_t, \ 972 uint_t, uint_t, uint_t, cred_t *, \ 973 caller_context_t *); \ 974 int (*vop_poll)(vnode_t *, short, int, short *, \ 975 struct pollhead **, \ 976 caller_context_t *); \ 977 int (*vop_dump)(vnode_t *, caddr_t, offset_t, offset_t, \ 978 caller_context_t *); \ 979 int (*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *, \ 980 caller_context_t *); \ 981 int (*vop_pageio)(vnode_t *, struct page *, \ 982 u_offset_t, size_t, int, cred_t *, \ 983 caller_context_t *); \ 984 int (*vop_dumpctl)(vnode_t *, int, offset_t *, \ 985 caller_context_t *); \ 986 void (*vop_dispose)(vnode_t *, struct page *, \ 987 int, int, cred_t *, \ 988 caller_context_t *); \ 989 int (*vop_setsecattr)(vnode_t *, vsecattr_t *, \ 990 int, cred_t *, caller_context_t *); \ 991 int (*vop_getsecattr)(vnode_t *, vsecattr_t *, \ 992 int, cred_t *, caller_context_t *); \ 993 int (*vop_shrlock)(vnode_t *, int, struct shrlock *, \ 994 int, cred_t *, caller_context_t *); \ 995 int (*vop_vnevent)(vnode_t *, vnevent_t, vnode_t *, \ 996 char *, caller_context_t *); \ 997 int (*vop_reqzcbuf)(vnode_t *, enum uio_rw, xuio_t *, \ 998 cred_t *, caller_context_t *); \ 999 int (*vop_retzcbuf)(vnode_t *, xuio_t *, cred_t *, \ 1000 caller_context_t *) 1001 /* NB: No ";" */ 1002 1003 /* 1004 * Operations on vnodes. Note: File systems must never operate directly 1005 * on a 'vnodeops' structure -- it WILL change in future releases! They 1006 * must use vn_make_ops() to create the structure. 1007 */ 1008 typedef struct vnodeops { 1009 const char *vnop_name; 1010 VNODE_OPS; /* Signatures of all vnode operations (vops) */ 1011 } vnodeops_t; 1012 1013 typedef int (*fs_generic_func_p) (); /* Generic vop/vfsop/femop/fsemop ptr */ 1014 1015 extern int fop_open(vnode_t **, int, cred_t *, caller_context_t *); 1016 extern int fop_close(vnode_t *, int, int, offset_t, cred_t *, 1017 caller_context_t *); 1018 extern int fop_read(vnode_t *, uio_t *, int, cred_t *, caller_context_t *); 1019 extern int fop_write(vnode_t *, uio_t *, int, cred_t *, 1020 caller_context_t *); 1021 extern int fop_ioctl(vnode_t *, int, intptr_t, int, cred_t *, int *, 1022 caller_context_t *); 1023 extern int fop_setfl(vnode_t *, int, int, cred_t *, caller_context_t *); 1024 extern int fop_getattr(vnode_t *, vattr_t *, int, cred_t *, 1025 caller_context_t *); 1026 extern int fop_setattr(vnode_t *, vattr_t *, int, cred_t *, 1027 caller_context_t *); 1028 extern int fop_access(vnode_t *, int, int, cred_t *, caller_context_t *); 1029 extern int fop_lookup(vnode_t *, char *, vnode_t **, struct pathname *, 1030 int, vnode_t *, cred_t *, caller_context_t *, 1031 int *, struct pathname *); 1032 extern int fop_create(vnode_t *, char *, vattr_t *, vcexcl_t, int, 1033 vnode_t **, cred_t *, int, caller_context_t *, 1034 vsecattr_t *); 1035 extern int fop_remove(vnode_t *vp, char *, cred_t *, caller_context_t *, 1036 int); 1037 extern int fop_link(vnode_t *, vnode_t *, char *, cred_t *, 1038 caller_context_t *, int); 1039 extern int fop_rename(vnode_t *, char *, vnode_t *, char *, cred_t *, 1040 caller_context_t *, int); 1041 extern int fop_mkdir(vnode_t *, char *, vattr_t *, vnode_t **, cred_t *, 1042 caller_context_t *, int, vsecattr_t *); 1043 extern int fop_rmdir(vnode_t *, char *, vnode_t *, cred_t *, 1044 caller_context_t *, int); 1045 extern int fop_readdir(vnode_t *, uio_t *, cred_t *, int *, 1046 caller_context_t *, int); 1047 extern int fop_symlink(vnode_t *, char *, vattr_t *, char *, cred_t *, 1048 caller_context_t *, int); 1049 extern int fop_readlink(vnode_t *, uio_t *, cred_t *, caller_context_t *); 1050 extern int fop_fsync(vnode_t *, int, cred_t *, caller_context_t *); 1051 extern void fop_inactive(vnode_t *, cred_t *, caller_context_t *); 1052 extern int fop_fid(vnode_t *, struct fid *, caller_context_t *); 1053 extern int fop_rwlock(vnode_t *, int, caller_context_t *); 1054 extern void fop_rwunlock(vnode_t *, int, caller_context_t *); 1055 extern int fop_seek(vnode_t *, offset_t, offset_t *, caller_context_t *); 1056 extern int fop_cmp(vnode_t *, vnode_t *, caller_context_t *); 1057 extern int fop_frlock(vnode_t *, int, struct flock64 *, int, offset_t, 1058 struct flk_callback *, cred_t *, 1059 caller_context_t *); 1060 extern int fop_space(vnode_t *, int, struct flock64 *, int, offset_t, 1061 cred_t *, caller_context_t *); 1062 extern int fop_realvp(vnode_t *, vnode_t **, caller_context_t *); 1063 extern int fop_getpage(vnode_t *, offset_t, size_t, uint_t *, 1064 struct page **, size_t, struct seg *, 1065 caddr_t, enum seg_rw, cred_t *, 1066 caller_context_t *); 1067 extern int fop_putpage(vnode_t *, offset_t, size_t, int, cred_t *, 1068 caller_context_t *); 1069 extern int fop_map(vnode_t *, offset_t, struct as *, caddr_t *, size_t, 1070 uchar_t, uchar_t, uint_t, cred_t *cr, 1071 caller_context_t *); 1072 extern int fop_addmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, 1073 uchar_t, uchar_t, uint_t, cred_t *, 1074 caller_context_t *); 1075 extern int fop_delmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, 1076 uint_t, uint_t, uint_t, cred_t *, 1077 caller_context_t *); 1078 extern int fop_poll(vnode_t *, short, int, short *, struct pollhead **, 1079 caller_context_t *); 1080 extern int fop_dump(vnode_t *, caddr_t, offset_t, offset_t, 1081 caller_context_t *); 1082 extern int fop_pathconf(vnode_t *, int, ulong_t *, cred_t *, 1083 caller_context_t *); 1084 extern int fop_pageio(vnode_t *, struct page *, u_offset_t, size_t, int, 1085 cred_t *, caller_context_t *); 1086 extern int fop_dumpctl(vnode_t *, int, offset_t *, caller_context_t *); 1087 extern void fop_dispose(vnode_t *, struct page *, int, int, cred_t *, 1088 caller_context_t *); 1089 extern int fop_setsecattr(vnode_t *, vsecattr_t *, int, cred_t *, 1090 caller_context_t *); 1091 extern int fop_getsecattr(vnode_t *, vsecattr_t *, int, cred_t *, 1092 caller_context_t *); 1093 extern int fop_shrlock(vnode_t *, int, struct shrlock *, int, cred_t *, 1094 caller_context_t *); 1095 extern int fop_vnevent(vnode_t *, vnevent_t, vnode_t *, char *, 1096 caller_context_t *); 1097 extern int fop_reqzcbuf(vnode_t *, enum uio_rw, xuio_t *, cred_t *, 1098 caller_context_t *); 1099 extern int fop_retzcbuf(vnode_t *, xuio_t *, cred_t *, caller_context_t *); 1100 1101 #endif /* _KERNEL */ 1102 1103 #define VOP_OPEN(vpp, mode, cr, ct) \ 1104 fop_open(vpp, mode, cr, ct) 1105 #define VOP_CLOSE(vp, f, c, o, cr, ct) \ 1106 fop_close(vp, f, c, o, cr, ct) 1107 #define VOP_READ(vp, uiop, iof, cr, ct) \ 1108 fop_read(vp, uiop, iof, cr, ct) 1109 #define VOP_WRITE(vp, uiop, iof, cr, ct) \ 1110 fop_write(vp, uiop, iof, cr, ct) 1111 #define VOP_IOCTL(vp, cmd, a, f, cr, rvp, ct) \ 1112 fop_ioctl(vp, cmd, a, f, cr, rvp, ct) 1113 #define VOP_SETFL(vp, f, a, cr, ct) \ 1114 fop_setfl(vp, f, a, cr, ct) 1115 #define VOP_GETATTR(vp, vap, f, cr, ct) \ 1116 fop_getattr(vp, vap, f, cr, ct) 1117 #define VOP_SETATTR(vp, vap, f, cr, ct) \ 1118 fop_setattr(vp, vap, f, cr, ct) 1119 #define VOP_ACCESS(vp, mode, f, cr, ct) \ 1120 fop_access(vp, mode, f, cr, ct) 1121 #define VOP_LOOKUP(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp) \ 1122 fop_lookup(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp) 1123 #define VOP_CREATE(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap) \ 1124 fop_create(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap) 1125 #define VOP_REMOVE(dvp, p, cr, ct, f) \ 1126 fop_remove(dvp, p, cr, ct, f) 1127 #define VOP_LINK(tdvp, fvp, p, cr, ct, f) \ 1128 fop_link(tdvp, fvp, p, cr, ct, f) 1129 #define VOP_RENAME(fvp, fnm, tdvp, tnm, cr, ct, f) \ 1130 fop_rename(fvp, fnm, tdvp, tnm, cr, ct, f) 1131 #define VOP_MKDIR(dp, p, vap, vpp, cr, ct, f, vsap) \ 1132 fop_mkdir(dp, p, vap, vpp, cr, ct, f, vsap) 1133 #define VOP_RMDIR(dp, p, cdir, cr, ct, f) \ 1134 fop_rmdir(dp, p, cdir, cr, ct, f) 1135 #define VOP_READDIR(vp, uiop, cr, eofp, ct, f) \ 1136 fop_readdir(vp, uiop, cr, eofp, ct, f) 1137 #define VOP_SYMLINK(dvp, lnm, vap, tnm, cr, ct, f) \ 1138 fop_symlink(dvp, lnm, vap, tnm, cr, ct, f) 1139 #define VOP_READLINK(vp, uiop, cr, ct) \ 1140 fop_readlink(vp, uiop, cr, ct) 1141 #define VOP_FSYNC(vp, syncflag, cr, ct) \ 1142 fop_fsync(vp, syncflag, cr, ct) 1143 #define VOP_INACTIVE(vp, cr, ct) \ 1144 fop_inactive(vp, cr, ct) 1145 #define VOP_FID(vp, fidp, ct) \ 1146 fop_fid(vp, fidp, ct) 1147 #define VOP_RWLOCK(vp, w, ct) \ 1148 fop_rwlock(vp, w, ct) 1149 #define VOP_RWUNLOCK(vp, w, ct) \ 1150 fop_rwunlock(vp, w, ct) 1151 #define VOP_SEEK(vp, ooff, noffp, ct) \ 1152 fop_seek(vp, ooff, noffp, ct) 1153 #define VOP_CMP(vp1, vp2, ct) \ 1154 fop_cmp(vp1, vp2, ct) 1155 #define VOP_FRLOCK(vp, cmd, a, f, o, cb, cr, ct) \ 1156 fop_frlock(vp, cmd, a, f, o, cb, cr, ct) 1157 #define VOP_SPACE(vp, cmd, a, f, o, cr, ct) \ 1158 fop_space(vp, cmd, a, f, o, cr, ct) 1159 #define VOP_REALVP(vp1, vp2, ct) \ 1160 fop_realvp(vp1, vp2, ct) 1161 #define VOP_GETPAGE(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct) \ 1162 fop_getpage(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct) 1163 #define VOP_PUTPAGE(vp, of, sz, fl, cr, ct) \ 1164 fop_putpage(vp, of, sz, fl, cr, ct) 1165 #define VOP_MAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \ 1166 fop_map(vp, of, as, a, sz, p, mp, fl, cr, ct) 1167 #define VOP_ADDMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \ 1168 fop_addmap(vp, of, as, a, sz, p, mp, fl, cr, ct) 1169 #define VOP_DELMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \ 1170 fop_delmap(vp, of, as, a, sz, p, mp, fl, cr, ct) 1171 #define VOP_POLL(vp, events, anyyet, reventsp, phpp, ct) \ 1172 fop_poll(vp, events, anyyet, reventsp, phpp, ct) 1173 #define VOP_DUMP(vp, addr, bn, count, ct) \ 1174 fop_dump(vp, addr, bn, count, ct) 1175 #define VOP_PATHCONF(vp, cmd, valp, cr, ct) \ 1176 fop_pathconf(vp, cmd, valp, cr, ct) 1177 #define VOP_PAGEIO(vp, pp, io_off, io_len, flags, cr, ct) \ 1178 fop_pageio(vp, pp, io_off, io_len, flags, cr, ct) 1179 #define VOP_DUMPCTL(vp, action, blkp, ct) \ 1180 fop_dumpctl(vp, action, blkp, ct) 1181 #define VOP_DISPOSE(vp, pp, flag, dn, cr, ct) \ 1182 fop_dispose(vp, pp, flag, dn, cr, ct) 1183 #define VOP_GETSECATTR(vp, vsap, f, cr, ct) \ 1184 fop_getsecattr(vp, vsap, f, cr, ct) 1185 #define VOP_SETSECATTR(vp, vsap, f, cr, ct) \ 1186 fop_setsecattr(vp, vsap, f, cr, ct) 1187 #define VOP_SHRLOCK(vp, cmd, shr, f, cr, ct) \ 1188 fop_shrlock(vp, cmd, shr, f, cr, ct) 1189 #define VOP_VNEVENT(vp, vnevent, dvp, fnm, ct) \ 1190 fop_vnevent(vp, vnevent, dvp, fnm, ct) 1191 #define VOP_REQZCBUF(vp, rwflag, xuiop, cr, ct) \ 1192 fop_reqzcbuf(vp, rwflag, xuiop, cr, ct) 1193 #define VOP_RETZCBUF(vp, xuiop, cr, ct) \ 1194 fop_retzcbuf(vp, xuiop, cr, ct) 1195 1196 #define VOPNAME_OPEN "open" 1197 #define VOPNAME_CLOSE "close" 1198 #define VOPNAME_READ "read" 1199 #define VOPNAME_WRITE "write" 1200 #define VOPNAME_IOCTL "ioctl" 1201 #define VOPNAME_SETFL "setfl" 1202 #define VOPNAME_GETATTR "getattr" 1203 #define VOPNAME_SETATTR "setattr" 1204 #define VOPNAME_ACCESS "access" 1205 #define VOPNAME_LOOKUP "lookup" 1206 #define VOPNAME_CREATE "create" 1207 #define VOPNAME_REMOVE "remove" 1208 #define VOPNAME_LINK "link" 1209 #define VOPNAME_RENAME "rename" 1210 #define VOPNAME_MKDIR "mkdir" 1211 #define VOPNAME_RMDIR "rmdir" 1212 #define VOPNAME_READDIR "readdir" 1213 #define VOPNAME_SYMLINK "symlink" 1214 #define VOPNAME_READLINK "readlink" 1215 #define VOPNAME_FSYNC "fsync" 1216 #define VOPNAME_INACTIVE "inactive" 1217 #define VOPNAME_FID "fid" 1218 #define VOPNAME_RWLOCK "rwlock" 1219 #define VOPNAME_RWUNLOCK "rwunlock" 1220 #define VOPNAME_SEEK "seek" 1221 #define VOPNAME_CMP "cmp" 1222 #define VOPNAME_FRLOCK "frlock" 1223 #define VOPNAME_SPACE "space" 1224 #define VOPNAME_REALVP "realvp" 1225 #define VOPNAME_GETPAGE "getpage" 1226 #define VOPNAME_PUTPAGE "putpage" 1227 #define VOPNAME_MAP "map" 1228 #define VOPNAME_ADDMAP "addmap" 1229 #define VOPNAME_DELMAP "delmap" 1230 #define VOPNAME_POLL "poll" 1231 #define VOPNAME_DUMP "dump" 1232 #define VOPNAME_PATHCONF "pathconf" 1233 #define VOPNAME_PAGEIO "pageio" 1234 #define VOPNAME_DUMPCTL "dumpctl" 1235 #define VOPNAME_DISPOSE "dispose" 1236 #define VOPNAME_GETSECATTR "getsecattr" 1237 #define VOPNAME_SETSECATTR "setsecattr" 1238 #define VOPNAME_SHRLOCK "shrlock" 1239 #define VOPNAME_VNEVENT "vnevent" 1240 #define VOPNAME_REQZCBUF "reqzcbuf" 1241 #define VOPNAME_RETZCBUF "retzcbuf" 1242 1243 /* 1244 * Flags for VOP_LOOKUP 1245 * 1246 * Defined in file.h, but also possible, FIGNORECASE and FSEARCH 1247 * 1248 */ 1249 #define LOOKUP_DIR 0x01 /* want parent dir vp */ 1250 #define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */ 1251 #define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */ 1252 #define LOOKUP_HAVE_SYSATTR_DIR 0x08 /* Already created virtual GFS dir */ 1253 1254 /* 1255 * Flags for VOP_READDIR 1256 */ 1257 #define V_RDDIR_ENTFLAGS 0x01 /* request dirent flags */ 1258 #define V_RDDIR_ACCFILTER 0x02 /* filter out inaccessible dirents */ 1259 1260 /* 1261 * Flags for VOP_RWLOCK/VOP_RWUNLOCK 1262 * VOP_RWLOCK will return the flag that was actually set, or -1 if none. 1263 */ 1264 #define V_WRITELOCK_TRUE (1) /* Request write-lock on the vnode */ 1265 #define V_WRITELOCK_FALSE (0) /* Request read-lock on the vnode */ 1266 1267 /* 1268 * Flags for VOP_DUMPCTL 1269 */ 1270 #define DUMP_ALLOC 0 1271 #define DUMP_FREE 1 1272 #define DUMP_SCAN 2 1273 1274 /* 1275 * Public vnode manipulation functions. 1276 */ 1277 #ifdef _KERNEL 1278 1279 vnode_t *vn_alloc(int); 1280 void vn_reinit(vnode_t *); 1281 void vn_recycle(vnode_t *); 1282 void vn_free(vnode_t *); 1283 1284 int vn_is_readonly(vnode_t *); 1285 int vn_is_opened(vnode_t *, v_mode_t); 1286 int vn_is_mapped(vnode_t *, v_mode_t); 1287 int vn_has_other_opens(vnode_t *, v_mode_t); 1288 void vn_open_upgrade(vnode_t *, int); 1289 void vn_open_downgrade(vnode_t *, int); 1290 1291 int vn_can_change_zones(vnode_t *vp); 1292 1293 int vn_has_flocks(vnode_t *); 1294 int vn_has_mandatory_locks(vnode_t *, int); 1295 int vn_has_cached_data(vnode_t *); 1296 1297 void vn_setops(vnode_t *, vnodeops_t *); 1298 vnodeops_t *vn_getops(vnode_t *); 1299 int vn_matchops(vnode_t *, vnodeops_t *); 1300 int vn_matchopval(vnode_t *, char *, fs_generic_func_p); 1301 int vn_ismntpt(vnode_t *); 1302 1303 struct vfs *vn_mountedvfs(vnode_t *); 1304 1305 int vn_in_dnlc(vnode_t *); 1306 1307 void vn_create_cache(void); 1308 void vn_destroy_cache(void); 1309 1310 void vn_freevnodeops(vnodeops_t *); 1311 1312 int vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode, 1313 struct vnode **vpp, enum create crwhy, mode_t umask); 1314 int vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode, 1315 struct vnode **vpp, enum create crwhy, 1316 mode_t umask, struct vnode *startvp, int fd); 1317 int vn_create(char *pnamep, enum uio_seg seg, struct vattr *vap, 1318 enum vcexcl excl, int mode, struct vnode **vpp, 1319 enum create why, int flag, mode_t umask); 1320 int vn_createat(char *pnamep, enum uio_seg seg, struct vattr *vap, 1321 enum vcexcl excl, int mode, struct vnode **vpp, 1322 enum create why, int flag, mode_t umask, struct vnode *startvp); 1323 int vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, ssize_t len, 1324 offset_t offset, enum uio_seg seg, int ioflag, rlim64_t ulimit, 1325 cred_t *cr, ssize_t *residp); 1326 void vn_rele(struct vnode *vp); 1327 void vn_rele_async(struct vnode *vp, struct taskq *taskq); 1328 void vn_rele_dnlc(struct vnode *vp); 1329 void vn_rele_stream(struct vnode *vp); 1330 int vn_link(char *from, char *to, enum uio_seg seg); 1331 int vn_linkat(vnode_t *fstartvp, char *from, enum symfollow follow, 1332 vnode_t *tstartvp, char *to, enum uio_seg seg); 1333 int vn_rename(char *from, char *to, enum uio_seg seg); 1334 int vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp, char *tname, 1335 enum uio_seg seg); 1336 int vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag); 1337 int vn_removeat(vnode_t *startvp, char *fnamep, enum uio_seg seg, 1338 enum rm dirflag); 1339 int vn_compare(vnode_t *vp1, vnode_t *vp2); 1340 int vn_vfswlock(struct vnode *vp); 1341 int vn_vfswlock_wait(struct vnode *vp); 1342 int vn_vfsrlock(struct vnode *vp); 1343 int vn_vfsrlock_wait(struct vnode *vp); 1344 void vn_vfsunlock(struct vnode *vp); 1345 int vn_vfswlock_held(struct vnode *vp); 1346 vnode_t *specvp(struct vnode *vp, dev_t dev, vtype_t type, struct cred *cr); 1347 vnode_t *makespecvp(dev_t dev, vtype_t type); 1348 vn_vfslocks_entry_t *vn_vfslocks_getlock(void *); 1349 void vn_vfslocks_rele(vn_vfslocks_entry_t *); 1350 boolean_t vn_is_reparse(vnode_t *, cred_t *, caller_context_t *); 1351 1352 void vn_copypath(struct vnode *src, struct vnode *dst); 1353 void vn_setpath_str(struct vnode *vp, const char *str, size_t len); 1354 void vn_setpath(vnode_t *rootvp, struct vnode *startvp, struct vnode *vp, 1355 const char *path, size_t plen); 1356 void vn_renamepath(vnode_t *dvp, vnode_t *vp, const char *nm, size_t len); 1357 1358 /* Private vnode manipulation functions */ 1359 void vn_clearpath(vnode_t *, hrtime_t); 1360 void vn_updatepath(vnode_t *, vnode_t *, const char *); 1361 1362 1363 /* Vnode event notification */ 1364 void vnevent_rename_src(vnode_t *, vnode_t *, char *, caller_context_t *); 1365 void vnevent_rename_dest(vnode_t *, vnode_t *, char *, caller_context_t *); 1366 void vnevent_remove(vnode_t *, vnode_t *, char *, caller_context_t *); 1367 void vnevent_rmdir(vnode_t *, vnode_t *, char *, caller_context_t *); 1368 void vnevent_create(vnode_t *, caller_context_t *); 1369 void vnevent_link(vnode_t *, caller_context_t *); 1370 void vnevent_rename_dest_dir(vnode_t *, caller_context_t *ct); 1371 void vnevent_mountedover(vnode_t *, caller_context_t *); 1372 void vnevent_truncate(vnode_t *, caller_context_t *); 1373 int vnevent_support(vnode_t *, caller_context_t *); 1374 void vnevent_pre_rename_src(vnode_t *, vnode_t *, char *, 1375 caller_context_t *); 1376 void vnevent_pre_rename_dest(vnode_t *, vnode_t *, char *, 1377 caller_context_t *); 1378 void vnevent_pre_rename_dest_dir(vnode_t *, vnode_t *, char *, 1379 caller_context_t *); 1380 1381 /* Vnode specific data */ 1382 void vsd_create(uint_t *, void (*)(void *)); 1383 void vsd_destroy(uint_t *); 1384 void *vsd_get(vnode_t *, uint_t); 1385 int vsd_set(vnode_t *, uint_t, void *); 1386 void vsd_free(vnode_t *); 1387 1388 /* 1389 * Extensible vnode attribute (xva) routines: 1390 * xva_init() initializes an xvattr_t (zero struct, init mapsize, set AT_XATTR) 1391 * xva_getxoptattr() returns a ponter to the xoptattr_t section of xvattr_t 1392 */ 1393 void xva_init(xvattr_t *); 1394 xoptattr_t *xva_getxoptattr(xvattr_t *); /* Get ptr to xoptattr_t */ 1395 1396 void xattr_init(void); /* Initialize vnodeops for xattrs */ 1397 1398 /* GFS tunnel for xattrs */ 1399 int xattr_dir_lookup(vnode_t *, vnode_t **, int, cred_t *); 1400 1401 /* Reparse Point */ 1402 void reparse_point_init(void); 1403 1404 /* Context identification */ 1405 u_longlong_t fs_new_caller_id(); 1406 1407 int vn_vmpss_usepageio(vnode_t *); 1408 1409 /* Empty v_path placeholder */ 1410 extern char *vn_vpath_empty; 1411 1412 /* 1413 * Needed for use of IS_VMODSORT() in kernel. 1414 */ 1415 extern uint_t pvn_vmodsort_supported; 1416 1417 /* 1418 * All changes to v_count should be done through VN_HOLD() or VN_RELE(), or 1419 * one of their variants. This makes it possible to ensure proper locking, 1420 * and to guarantee that all modifications are accompanied by a firing of 1421 * the vn-hold or vn-rele SDT DTrace probe. 1422 * 1423 * Example DTrace command for tracing vnode references using these probes: 1424 * 1425 * dtrace -q -n 'sdt:::vn-hold,sdt:::vn-rele 1426 * { 1427 * this->vp = (vnode_t *)arg0; 1428 * printf("%s %s(%p[%s]) %d\n", execname, probename, this->vp, 1429 * this->vp->v_path == NULL ? "NULL" : stringof(this->vp->v_path), 1430 * this->vp->v_count) 1431 * }' 1432 */ 1433 #define VN_HOLD_LOCKED(vp) { \ 1434 ASSERT(mutex_owned(&(vp)->v_lock)); \ 1435 (vp)->v_count++; \ 1436 DTRACE_PROBE1(vn__hold, vnode_t *, vp); \ 1437 } 1438 1439 #define VN_HOLD(vp) { \ 1440 mutex_enter(&(vp)->v_lock); \ 1441 VN_HOLD_LOCKED(vp); \ 1442 mutex_exit(&(vp)->v_lock); \ 1443 } 1444 1445 #define VN_RELE(vp) { \ 1446 vn_rele(vp); \ 1447 } 1448 1449 #define VN_RELE_ASYNC(vp, taskq) { \ 1450 vn_rele_async(vp, taskq); \ 1451 } 1452 1453 #define VN_RELE_LOCKED(vp) { \ 1454 ASSERT(mutex_owned(&(vp)->v_lock)); \ 1455 ASSERT((vp)->v_count >= 1); \ 1456 (vp)->v_count--; \ 1457 DTRACE_PROBE1(vn__rele, vnode_t *, vp); \ 1458 } 1459 1460 #define VN_SET_VFS_TYPE_DEV(vp, vfsp, type, dev) { \ 1461 (vp)->v_vfsp = (vfsp); \ 1462 (vp)->v_type = (type); \ 1463 (vp)->v_rdev = (dev); \ 1464 } 1465 1466 /* 1467 * Compare two vnodes for equality. In general this macro should be used 1468 * in preference to calling VOP_CMP directly. 1469 */ 1470 #define VN_CMP(VP1, VP2) ((VP1) == (VP2) ? 1 : \ 1471 ((VP1) && (VP2) && (vn_getops(VP1) == vn_getops(VP2)) ? \ 1472 VOP_CMP(VP1, VP2, NULL) : 0)) 1473 1474 /* 1475 * Some well-known global vnodes used by the VM system to name pages. 1476 */ 1477 extern struct vnode kvps[]; 1478 1479 typedef enum { 1480 KV_KVP, /* vnode for all segkmem pages */ 1481 KV_ZVP, /* vnode for all ZFS pages */ 1482 #if defined(__sparc) 1483 KV_MPVP, /* vnode for all page_t meta-pages */ 1484 KV_PROMVP, /* vnode for all PROM pages */ 1485 #endif /* __sparc */ 1486 KV_MAX /* total number of vnodes in kvps[] */ 1487 } kvps_index_t; 1488 1489 #define VN_ISKAS(vp) ((vp) >= &kvps[0] && (vp) < &kvps[KV_MAX]) 1490 1491 #endif /* _KERNEL */ 1492 1493 /* 1494 * Flags to VOP_SETATTR/VOP_GETATTR. 1495 */ 1496 #define ATTR_UTIME 0x01 /* non-default utime(2) request */ 1497 #define ATTR_EXEC 0x02 /* invocation from exec(2) */ 1498 #define ATTR_COMM 0x04 /* yield common vp attributes */ 1499 #define ATTR_HINT 0x08 /* information returned will be `hint' */ 1500 #define ATTR_REAL 0x10 /* yield attributes of the real vp */ 1501 #define ATTR_NOACLCHECK 0x20 /* Don't check ACL when checking permissions */ 1502 #define ATTR_TRIGGER 0x40 /* Mount first if vnode is a trigger mount */ 1503 /* 1504 * Generally useful macros. 1505 */ 1506 #define VBSIZE(vp) ((vp)->v_vfsp->vfs_bsize) 1507 1508 #define VTOZONE(vp) ((vp)->v_vfsp->vfs_zone) 1509 1510 #define NULLVP ((struct vnode *)0) 1511 #define NULLVPP ((struct vnode **)0) 1512 1513 #ifdef _KERNEL 1514 1515 /* 1516 * Structure used while handling asynchronous VOP_PUTPAGE operations. 1517 */ 1518 struct async_reqs { 1519 struct async_reqs *a_next; /* pointer to next arg struct */ 1520 struct vnode *a_vp; /* vnode pointer */ 1521 u_offset_t a_off; /* offset in file */ 1522 uint_t a_len; /* size of i/o request */ 1523 int a_flags; /* flags to indicate operation type */ 1524 struct cred *a_cred; /* cred pointer */ 1525 ushort_t a_prealloced; /* set if struct is pre-allocated */ 1526 }; 1527 1528 /* 1529 * VN_DISPOSE() -- given a page pointer, safely invoke VOP_DISPOSE(). 1530 * Note that there is no guarantee that the page passed in will be 1531 * freed. If that is required, then a check after calling VN_DISPOSE would 1532 * be necessary to ensure the page was freed. 1533 */ 1534 #define VN_DISPOSE(pp, flag, dn, cr) { \ 1535 if ((pp)->p_vnode != NULL && !VN_ISKAS((pp)->p_vnode)) \ 1536 VOP_DISPOSE((pp)->p_vnode, (pp), (flag), (dn), (cr), NULL); \ 1537 else if ((flag) == B_FREE) \ 1538 page_free((pp), (dn)); \ 1539 else \ 1540 page_destroy((pp), (dn)); \ 1541 } 1542 1543 #endif /* _KERNEL */ 1544 1545 #ifdef __cplusplus 1546 } 1547 #endif 1548 1549 #endif /* _SYS_VNODE_H */ 1550