10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*5302Sth199096 * Common Development and Distribution License (the "License"). 6*5302Sth199096 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*5302Sth199096 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 270Sstevel@tonic-gate /* All Rights Reserved */ 280Sstevel@tonic-gate 290Sstevel@tonic-gate #ifndef _NFS_RNODE4_H 300Sstevel@tonic-gate #define _NFS_RNODE4_H 310Sstevel@tonic-gate 320Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifdef __cplusplus 350Sstevel@tonic-gate extern "C" { 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 380Sstevel@tonic-gate #include <nfs/rnode.h> /* for symlink_cache, nfs_rwlock_t, etc. */ 390Sstevel@tonic-gate #include <nfs/nfs4.h> 400Sstevel@tonic-gate #include <nfs/nfs4_clnt.h> 410Sstevel@tonic-gate #include <sys/thread.h> 420Sstevel@tonic-gate #include <sys/sysmacros.h> /* for offsetof */ 430Sstevel@tonic-gate 44*5302Sth199096 typedef enum nfs4_stub_type { 45*5302Sth199096 NFS4_STUB_NONE, 46*5302Sth199096 NFS4_STUB_MIRRORMOUNT 47*5302Sth199096 } nfs4_stub_type_t; 48*5302Sth199096 490Sstevel@tonic-gate typedef enum nfs4_access_type { 500Sstevel@tonic-gate NFS4_ACCESS_UNKNOWN, 510Sstevel@tonic-gate NFS4_ACCESS_ALLOWED, 520Sstevel@tonic-gate NFS4_ACCESS_DENIED 530Sstevel@tonic-gate } nfs4_access_type_t; 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* 560Sstevel@tonic-gate * Access cache 570Sstevel@tonic-gate */ 580Sstevel@tonic-gate typedef struct acache4_hash { 590Sstevel@tonic-gate struct acache4 *next; 600Sstevel@tonic-gate struct acache4 *prev; 610Sstevel@tonic-gate krwlock_t lock; 620Sstevel@tonic-gate } acache4_hash_t; 630Sstevel@tonic-gate 640Sstevel@tonic-gate typedef struct acache4 { 650Sstevel@tonic-gate struct acache4 *next; /* next and prev must be first */ 660Sstevel@tonic-gate struct acache4 *prev; 670Sstevel@tonic-gate uint32_t known; 680Sstevel@tonic-gate uint32_t allowed; 690Sstevel@tonic-gate struct rnode4 *rnode; 700Sstevel@tonic-gate cred_t *cred; 710Sstevel@tonic-gate struct acache4 *list; 720Sstevel@tonic-gate struct acache4_hash *hashq; 730Sstevel@tonic-gate } acache4_t; 740Sstevel@tonic-gate 750Sstevel@tonic-gate /* 760Sstevel@tonic-gate * Note on the different buffer sizes in rddir4_cache: 770Sstevel@tonic-gate * There seems to be some discrepancy between the intended and actual 780Sstevel@tonic-gate * use of entlen and buflen, which does not correspond to the comment below. 790Sstevel@tonic-gate * entlen - nfsv2/3 used as both alloc'd size of entries buffer and 800Sstevel@tonic-gate * as the actual size of the entries (XXX is this correct?). 810Sstevel@tonic-gate * nfsv4 will use it only as the alloc'd size. 820Sstevel@tonic-gate * buflen - used for calculations of readahead. 830Sstevel@tonic-gate * actlen - added for nfsv4 to serve as the size of the useful 840Sstevel@tonic-gate * portion of the entries buffer. That is because in 850Sstevel@tonic-gate * nfsv4, the otw entries are converted to system entries, 860Sstevel@tonic-gate * and may not be the same size - thus buffer may not be full. 870Sstevel@tonic-gate */ 880Sstevel@tonic-gate typedef struct rddir4_cache { 890Sstevel@tonic-gate lloff_t _cookie; /* cookie used to find this cache entry */ 900Sstevel@tonic-gate lloff_t _ncookie; /* cookie used to find the next cache entry */ 910Sstevel@tonic-gate char *entries; /* buffer containing dirent entries */ 920Sstevel@tonic-gate int eof; /* EOF reached after this request */ 930Sstevel@tonic-gate int entlen; /* size of dirent entries in buf */ 940Sstevel@tonic-gate int buflen; /* size of the buffer used to store entries */ 950Sstevel@tonic-gate int actlen; /* size of the actual entries (nfsv4 only) */ 960Sstevel@tonic-gate int flags; /* control flags, see below */ 970Sstevel@tonic-gate kcondvar_t cv; /* cv for blocking */ 980Sstevel@tonic-gate int error; /* error from RPC operation */ 990Sstevel@tonic-gate void *data; /* private data */ 1000Sstevel@tonic-gate } rddir4_cache; 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate #define nfs4_cookie _cookie._f 1030Sstevel@tonic-gate #define nfs4_ncookie _ncookie._f 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate /* 1060Sstevel@tonic-gate * Shadow vnode, v4 only. 1070Sstevel@tonic-gate * 1080Sstevel@tonic-gate * A file's shadow vnode list is protected by its hash bucket lock, 1090Sstevel@tonic-gate * r_hashq->r_lock. 1100Sstevel@tonic-gate * 1110Sstevel@tonic-gate * sv_r_vnode is protected by the appropriate vnode locks. 1120Sstevel@tonic-gate * 1130Sstevel@tonic-gate * sv_dfh, sv_name, sv_dfileid, and sv_dfileid_valid are protected 1140Sstevel@tonic-gate * by rp->r_svlock. 1150Sstevel@tonic-gate */ 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate typedef struct insq_link { 1180Sstevel@tonic-gate void *forw; 1190Sstevel@tonic-gate void *back; 1200Sstevel@tonic-gate } insq_link_t; 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate typedef struct svnode { 1230Sstevel@tonic-gate insq_link_t sv_link; /* must be first for insque */ 1240Sstevel@tonic-gate vnode_t *sv_r_vnode; /* vnode for this shadow */ 1250Sstevel@tonic-gate nfs4_fname_t *sv_name; /* component name */ 1260Sstevel@tonic-gate nfs4_sharedfh_t *sv_dfh; /* directory file handle */ 1270Sstevel@tonic-gate } svnode_t; 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate #define sv_forw sv_link.forw 1300Sstevel@tonic-gate #define sv_back sv_link.back 1310Sstevel@tonic-gate extern svnode_t *vtosv(vnode_t *); 1320Sstevel@tonic-gate #define VTOSV(vp) vtosv(vp) 1330Sstevel@tonic-gate #define SVTOV(svp) (((svp)->sv_r_vnode)) 1340Sstevel@tonic-gate #define IS_SHADOW(vp, rp) ((vp) != (rp)->r_vnode) 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate /* 1370Sstevel@tonic-gate * The format of the hash bucket used to lookup rnodes from a file handle. 1380Sstevel@tonic-gate */ 1390Sstevel@tonic-gate typedef struct r4hashq { 1400Sstevel@tonic-gate struct rnode4 *r_hashf; 1410Sstevel@tonic-gate struct rnode4 *r_hashb; 1420Sstevel@tonic-gate krwlock_t r_lock; 1430Sstevel@tonic-gate } r4hashq_t; 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate /* 1460Sstevel@tonic-gate * Remote file information structure. 1470Sstevel@tonic-gate * 1480Sstevel@tonic-gate * The rnode is the "inode" for remote files. It contains all the 1490Sstevel@tonic-gate * information necessary to handle remote file on the client side. 1500Sstevel@tonic-gate * 1510Sstevel@tonic-gate * Note on file sizes: we keep two file sizes in the rnode: the size 1520Sstevel@tonic-gate * according to the client (r_size) and the size according to the server 1530Sstevel@tonic-gate * (r_attr.va_size). They can differ because we modify r_size during a 1540Sstevel@tonic-gate * write system call (nfs_rdwr), before the write request goes over the 1550Sstevel@tonic-gate * wire (before the file is actually modified on the server). If an OTW 1560Sstevel@tonic-gate * request occurs before the cached data is written to the server the file 1570Sstevel@tonic-gate * size returned from the server (r_attr.va_size) may not match r_size. 1580Sstevel@tonic-gate * r_size is the one we use, in general. r_attr.va_size is only used to 1590Sstevel@tonic-gate * determine whether or not our cached data is valid. 1600Sstevel@tonic-gate * 1610Sstevel@tonic-gate * Each rnode has 5 locks associated with it (not including the rnode 1620Sstevel@tonic-gate * hash table and free list locks): 1630Sstevel@tonic-gate * 1640Sstevel@tonic-gate * r_rwlock: Serializes nfs_write and nfs_setattr requests 1650Sstevel@tonic-gate * and allows nfs_read requests to proceed in parallel. 1660Sstevel@tonic-gate * Serializes reads/updates to directories. 1670Sstevel@tonic-gate * 1680Sstevel@tonic-gate * r_lkserlock: Serializes lock requests with map, write, and 1690Sstevel@tonic-gate * readahead operations. 1700Sstevel@tonic-gate * 1710Sstevel@tonic-gate * r_statelock: Protects all fields in the rnode except for 1720Sstevel@tonic-gate * those listed below. This lock is intented 1730Sstevel@tonic-gate * to be held for relatively short periods of 1740Sstevel@tonic-gate * time (not accross entire putpage operations, 1750Sstevel@tonic-gate * for example). 1760Sstevel@tonic-gate * 1770Sstevel@tonic-gate * r_statev4_lock: Protects the created_v4 flag, the lock_owners list, 1780Sstevel@tonic-gate * and all the delegation fields except r_deleg_list. 1790Sstevel@tonic-gate * 1800Sstevel@tonic-gate * r_os_lock: Protects r_open_streams. 1810Sstevel@tonic-gate * 1820Sstevel@tonic-gate * 1830Sstevel@tonic-gate * The following members are protected by the mutex rp4freelist_lock: 1840Sstevel@tonic-gate * r_freef 1850Sstevel@tonic-gate * r_freeb 1860Sstevel@tonic-gate * 1870Sstevel@tonic-gate * The following members are protected by the hash bucket rwlock: 1880Sstevel@tonic-gate * r_hashf 1890Sstevel@tonic-gate * r_hashb 1900Sstevel@tonic-gate * 1910Sstevel@tonic-gate * r_fh is read-only except when an rnode is created (or recycled from the 1920Sstevel@tonic-gate * free list). 1930Sstevel@tonic-gate * 1940Sstevel@tonic-gate * The following members are protected by nfs4_server_t::s_lock: 1950Sstevel@tonic-gate * r_deleg_list 1960Sstevel@tonic-gate * 1970Sstevel@tonic-gate * Note: r_modaddr is only accessed when the r_statelock mutex is held. 1980Sstevel@tonic-gate * Its value is also controlled via r_rwlock. It is assumed that 1990Sstevel@tonic-gate * there will be only 1 writer active at a time, so it safe to 2000Sstevel@tonic-gate * set r_modaddr and release r_statelock as long as the r_rwlock 2010Sstevel@tonic-gate * writer lock is held. 2020Sstevel@tonic-gate * 2030Sstevel@tonic-gate * 64-bit offsets: the code formerly assumed that atomic reads of 2040Sstevel@tonic-gate * r_size were safe and reliable; on 32-bit architectures, this is 2050Sstevel@tonic-gate * not true since an intervening bus cycle from another processor 2060Sstevel@tonic-gate * could update half of the size field. The r_statelock must now 2070Sstevel@tonic-gate * be held whenever any kind of access of r_size is made. 2080Sstevel@tonic-gate * 2090Sstevel@tonic-gate * Lock ordering: 2100Sstevel@tonic-gate * r_rwlock > r_lkserlock > r_os_lock > r_statelock > r_statev4_lock 2110Sstevel@tonic-gate * vnode_t::v_lock > r_os_lock 2120Sstevel@tonic-gate */ 2130Sstevel@tonic-gate struct exportinfo; /* defined in nfs/export.h */ 2140Sstevel@tonic-gate struct servinfo4; /* defined in nfs/nfs4_clnt.h */ 2150Sstevel@tonic-gate struct failinfo; /* defined in nfs/nfs_clnt.h */ 2160Sstevel@tonic-gate struct mntinfo4; /* defined in nfs/nfs4_clnt.h */ 2170Sstevel@tonic-gate 2180Sstevel@tonic-gate typedef struct rnode4 { 2190Sstevel@tonic-gate /* the hash fields must be first to match the rhashq_t */ 2200Sstevel@tonic-gate struct rnode4 *r_hashf; /* hash queue forward pointer */ 2210Sstevel@tonic-gate struct rnode4 *r_hashb; /* hash queue back pointer */ 2220Sstevel@tonic-gate struct rnode4 *r_freef; /* free list forward pointer */ 2230Sstevel@tonic-gate struct rnode4 *r_freeb; /* free list back pointer */ 2240Sstevel@tonic-gate r4hashq_t *r_hashq; /* pointer to the hash bucket */ 2250Sstevel@tonic-gate 2260Sstevel@tonic-gate svnode_t r_svnode; /* "master" shadow vnode for file */ 2270Sstevel@tonic-gate kmutex_t r_svlock; /* serializes access to svnode list */ 2280Sstevel@tonic-gate nfs_rwlock_t r_rwlock; /* serializes write/setattr requests */ 2290Sstevel@tonic-gate nfs_rwlock_t r_lkserlock; /* serialize lock with other ops */ 2300Sstevel@tonic-gate kmutex_t r_statelock; /* protects (most of) rnode contents */ 2310Sstevel@tonic-gate nfs4_sharedfh_t *r_fh; /* file handle */ 2320Sstevel@tonic-gate struct servinfo4 2330Sstevel@tonic-gate *r_server; /* current server */ 2340Sstevel@tonic-gate u_offset_t r_nextr; /* next byte read offset (read-ahead) */ 2350Sstevel@tonic-gate uint_t r_flags; /* flags, see below */ 2360Sstevel@tonic-gate short r_error; /* async write error */ 2370Sstevel@tonic-gate cred_t *r_unlcred; /* unlinked credentials */ 2380Sstevel@tonic-gate char *r_unlname; /* unlinked file name */ 2390Sstevel@tonic-gate vnode_t *r_unldvp; /* parent dir of unlinked file */ 2400Sstevel@tonic-gate vnode_t *r_xattr_dir; /* cached xattr dir vnode */ 2410Sstevel@tonic-gate len_t r_size; /* client's view of file size */ 2420Sstevel@tonic-gate vattr_t r_attr; /* cached vnode attributes */ 2430Sstevel@tonic-gate hrtime_t r_time_attr_saved; /* time attributes were cached */ 2440Sstevel@tonic-gate hrtime_t r_time_attr_inval; /* time attributes become invalid */ 2450Sstevel@tonic-gate hrtime_t r_time_cache_inval; /* time caches become invalid */ 2460Sstevel@tonic-gate time_t r_delay_wait; /* future time for DELAY handling */ 2470Sstevel@tonic-gate int r_delay_interval; /* Number of Secs of last DELAY */ 2480Sstevel@tonic-gate time_t r_last_recov; /* time of last recovery operation */ 2490Sstevel@tonic-gate nfs4_recov_t r_recov_act; /* action from last recovery op */ 2500Sstevel@tonic-gate long r_mapcnt; /* count of mmapped pages */ 2510Sstevel@tonic-gate uint_t r_count; /* # of refs not reflect in v_count */ 2520Sstevel@tonic-gate uint_t r_awcount; /* # of outstanding async write */ 2530Sstevel@tonic-gate uint_t r_gcount; /* getattrs waiting to flush pages */ 2540Sstevel@tonic-gate kcondvar_t r_cv; /* condvar for blocked threads */ 2550Sstevel@tonic-gate int (*r_putapage) /* address of putapage routine */ 2560Sstevel@tonic-gate (vnode_t *, page_t *, u_offset_t *, size_t *, int, cred_t *); 2570Sstevel@tonic-gate void *r_dir; /* cache of readdir responses */ 2580Sstevel@tonic-gate rddir4_cache *r_direof; /* pointer to the EOF entry */ 2590Sstevel@tonic-gate symlink_cache r_symlink; /* cached readlink response */ 2600Sstevel@tonic-gate verifier4 r_writeverf; /* file data write verifier */ 2610Sstevel@tonic-gate u_offset_t r_modaddr; /* address for page in writerp */ 2620Sstevel@tonic-gate commit_t r_commit; /* commit information */ 2630Sstevel@tonic-gate u_offset_t r_truncaddr; /* base for truncate operation */ 2640Sstevel@tonic-gate vsecattr_t *r_secattr; /* cached security attributes (acls) */ 2650Sstevel@tonic-gate verifier4 r_cookieverf4; /* version 4 readdir cookie verifier */ 2660Sstevel@tonic-gate nfs4_pathconf_info_t r_pathconf; /* cached pathconf info */ 2670Sstevel@tonic-gate acache4_t *r_acache; /* list of access cache entries */ 2680Sstevel@tonic-gate list_t r_open_streams; /* open streams list */ 2690Sstevel@tonic-gate kmutex_t r_os_lock; /* protects r_open_streams */ 2700Sstevel@tonic-gate nfs4_lock_owner_t 2710Sstevel@tonic-gate r_lo_head; /* lock owners list head */ 2720Sstevel@tonic-gate int created_v4; /* 1 if file has been created in v4 */ 2730Sstevel@tonic-gate kmutex_t r_statev4_lock; /* protects created_v4, state4ptr */ 2740Sstevel@tonic-gate 2750Sstevel@tonic-gate list_node_t r_deleg_link; /* linkage into list of */ 2760Sstevel@tonic-gate /* delegated rnodes for this server */ 2770Sstevel@tonic-gate open_delegation_type4 2780Sstevel@tonic-gate r_deleg_type; /* type of delegation granted */ 2790Sstevel@tonic-gate stateid4 r_deleg_stateid; 2800Sstevel@tonic-gate /* delegation state id */ 2810Sstevel@tonic-gate nfs_space_limit4 2820Sstevel@tonic-gate r_deleg_limit; /* file limits returned from */ 2830Sstevel@tonic-gate /* server on delegated open */ 2840Sstevel@tonic-gate nfsace4 r_deleg_perms; /* file permissions returned from */ 2850Sstevel@tonic-gate /* server on delegated open */ 2860Sstevel@tonic-gate fattr4_change r_deleg_change; /* current deleg change attr */ 2870Sstevel@tonic-gate fattr4_change r_deleg_change_grant; 2880Sstevel@tonic-gate /* change @ write deleg grant */ 2890Sstevel@tonic-gate cred_t *r_deleg_cred; /* credential in force when the */ 2900Sstevel@tonic-gate /* delegation was granted */ 2910Sstevel@tonic-gate open_delegation_type4 2920Sstevel@tonic-gate r_deleg_needs_recovery; 2930Sstevel@tonic-gate /* delegation needs recovery */ 2940Sstevel@tonic-gate /* This contains the delegation type */ 2950Sstevel@tonic-gate /* for use with CLAIM_PREVIOUS. */ 2960Sstevel@tonic-gate /* OPEN_DELEGATE_NONE means recovery */ 2970Sstevel@tonic-gate /* is not needed. */ 2980Sstevel@tonic-gate unsigned r_deleg_needs_recall:1; 2990Sstevel@tonic-gate /* delegation has been recalled by */ 3000Sstevel@tonic-gate /* the server during open with */ 3010Sstevel@tonic-gate /* CLAIM_PREVIOUS */ 3020Sstevel@tonic-gate unsigned r_deleg_return_pending:1; 3030Sstevel@tonic-gate /* delegreturn is pending, don't use */ 3040Sstevel@tonic-gate /* the delegation stateid, set in */ 3050Sstevel@tonic-gate /* nfs4_dlistadd */ 3060Sstevel@tonic-gate unsigned r_deleg_return_inprog:1; 3070Sstevel@tonic-gate /* delegreturn is in progress, may */ 3080Sstevel@tonic-gate /* only be set by nfs4delegreturn. */ 3090Sstevel@tonic-gate nfs_rwlock_t r_deleg_recall_lock; 3100Sstevel@tonic-gate /* lock for synchronizing delegreturn */ 3110Sstevel@tonic-gate /* with in other operations, acquired */ 3120Sstevel@tonic-gate /* in read mode by nfs4_start_fop, */ 3130Sstevel@tonic-gate /* acquired in write mode in */ 3140Sstevel@tonic-gate /* nfs4delegreturn */ 3150Sstevel@tonic-gate fattr4_change r_change; /* GETATTR4 change attr; client */ 3160Sstevel@tonic-gate /* should always request change */ 3170Sstevel@tonic-gate /* when c/mtime requested to keep */ 3180Sstevel@tonic-gate /* change and c/mtime in sync */ 3190Sstevel@tonic-gate fattr4_fileid r_mntd_fid; /* mounted on fileid attr */ 3200Sstevel@tonic-gate kthread_t *r_serial; /* attrcache validation thread */ 3210Sstevel@tonic-gate kthread_t *r_pgflush; /* thread flushing page cache */ 3220Sstevel@tonic-gate list_t r_indelmap; /* list of delmap callers */ 3230Sstevel@tonic-gate fattr4_fsid r_srv_fsid; /* fsid of srv fs containing object */ 3240Sstevel@tonic-gate /* when rnode created; compare with */ 3250Sstevel@tonic-gate /* sv_fsid (servinfo4_t) to see why */ 326*5302Sth199096 /* stub type was set */ 327*5302Sth199096 nfs4_stub_type_t r_stub_type; 328*5302Sth199096 /* e.g. mirror-mount */ 3290Sstevel@tonic-gate } rnode4_t; 3300Sstevel@tonic-gate 3310Sstevel@tonic-gate #define r_vnode r_svnode.sv_r_vnode 3320Sstevel@tonic-gate 3330Sstevel@tonic-gate /* 3340Sstevel@tonic-gate * Flags 3350Sstevel@tonic-gate */ 3360Sstevel@tonic-gate #define R4READDIRWATTR 0x1 /* Use READDIR with attributes */ 3370Sstevel@tonic-gate #define R4DIRTY 0x2 /* dirty pages from write operation */ 3380Sstevel@tonic-gate #define R4STALE 0x4 /* stale, don't even attempt to write */ 3390Sstevel@tonic-gate #define R4MODINPROGRESS 0x8 /* page modification happening */ 3400Sstevel@tonic-gate #define R4TRUNCATE 0x10 /* truncating, don't commit */ 3410Sstevel@tonic-gate #define R4HAVEVERF 0x20 /* have a write verifier to compare against */ 3420Sstevel@tonic-gate #define R4COMMIT 0x40 /* commit in progress */ 3430Sstevel@tonic-gate #define R4COMMITWAIT 0x80 /* someone is waiting to do a commit */ 3440Sstevel@tonic-gate #define R4HASHED 0x100 /* rnode is in hash queues */ 3450Sstevel@tonic-gate #define R4OUTOFSPACE 0x200 /* an out of space error has happened */ 3460Sstevel@tonic-gate #define R4LODANGLERS 0x400 /* rnode has dangling lock_owners to cleanup */ 3470Sstevel@tonic-gate #define R4WRITEMODIFIED 0x800 /* file data has been modified by write */ 3480Sstevel@tonic-gate #define R4DIRECTIO 0x1000 /* bypass the buffer cache */ 3490Sstevel@tonic-gate #define R4RECOVERR 0x2000 /* couldn't recover */ 3500Sstevel@tonic-gate #define R4RECEXPFH 0x4000 /* recovering expired filehandle */ 3510Sstevel@tonic-gate #define R4RECOVERRP 0x8000 /* R4RECOVERR pending, but not set (yet) */ 3520Sstevel@tonic-gate #define R4ISXATTR 0x20000 /* rnode is a named attribute */ 3530Sstevel@tonic-gate #define R4DELMAPLIST 0x40000 /* delmap callers tracked for as callback */ 3540Sstevel@tonic-gate #define R4PGFLUSH 0x80000 /* page flush thread active */ 3550Sstevel@tonic-gate #define R4LOOKUP 0x200000 /* a lookup has been done in the directory */ 3560Sstevel@tonic-gate /* 3570Sstevel@tonic-gate * Convert between vnode and rnode 3580Sstevel@tonic-gate */ 3590Sstevel@tonic-gate #define RTOV4(rp) ((rp)->r_vnode) 3600Sstevel@tonic-gate #define VTOR4(vp) ((rnode4_t *)((vp)->v_data)) 3610Sstevel@tonic-gate 362*5302Sth199096 #define RP_ISSTUB(rp) (((rp)->r_stub_type != NFS4_STUB_NONE)) 363*5302Sth199096 #define RP_ISSTUB_MIRRORMOUNT(rp) ((rp)->r_stub_type == NFS4_STUB_MIRRORMOUNT) 364*5302Sth199096 3650Sstevel@tonic-gate /* 3660Sstevel@tonic-gate * Open file instances. 3670Sstevel@tonic-gate */ 3680Sstevel@tonic-gate 3690Sstevel@tonic-gate typedef struct nfs4_opinst { 3700Sstevel@tonic-gate struct nfs4_opinst *re_next; /* next in list */ 3710Sstevel@tonic-gate vnode_t *re_vp; /* held reference */ 3720Sstevel@tonic-gate uint32_t re_numosp; /* number of valid open streams */ 3730Sstevel@tonic-gate nfs4_open_stream_t **re_osp; /* held reference */ 3740Sstevel@tonic-gate } nfs4_opinst_t; 3750Sstevel@tonic-gate 3760Sstevel@tonic-gate #ifdef _KERNEL 3770Sstevel@tonic-gate 3780Sstevel@tonic-gate extern long nrnode; 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate /* Used for r_delay_interval */ 3810Sstevel@tonic-gate #define NFS4_INITIAL_DELAY_INTERVAL 1 3820Sstevel@tonic-gate #define NFS4_MAX_DELAY_INTERVAL 20 3830Sstevel@tonic-gate 3840Sstevel@tonic-gate extern rnode4_t *r4find(r4hashq_t *, nfs4_sharedfh_t *, struct vfs *); 3850Sstevel@tonic-gate extern rnode4_t *r4find_unlocked(nfs4_sharedfh_t *, struct vfs *); 3860Sstevel@tonic-gate extern void r4flush(struct vfs *, cred_t *); 3870Sstevel@tonic-gate extern void destroy_rtable4(struct vfs *, cred_t *); 3880Sstevel@tonic-gate extern int check_rtable4(struct vfs *); 3890Sstevel@tonic-gate extern void rp4_addfree(rnode4_t *, cred_t *); 3900Sstevel@tonic-gate extern void rp4_addhash(rnode4_t *); 3910Sstevel@tonic-gate extern void rp4_rmhash(rnode4_t *); 3920Sstevel@tonic-gate extern void rp4_rmhash_locked(rnode4_t *); 3930Sstevel@tonic-gate extern int rtable4hash(nfs4_sharedfh_t *); 3940Sstevel@tonic-gate 3950Sstevel@tonic-gate extern vnode_t *makenfs4node(nfs4_sharedfh_t *, nfs4_ga_res_t *, struct vfs *, 3960Sstevel@tonic-gate hrtime_t, cred_t *, vnode_t *, nfs4_fname_t *); 3970Sstevel@tonic-gate extern vnode_t *makenfs4node_by_fh(nfs4_sharedfh_t *, nfs4_sharedfh_t *, 3980Sstevel@tonic-gate nfs4_fname_t **, nfs4_ga_res_t *, mntinfo4_t *, cred_t *, hrtime_t); 3990Sstevel@tonic-gate 4000Sstevel@tonic-gate extern nfs4_opinst_t *r4mkopenlist(struct mntinfo4 *); 4010Sstevel@tonic-gate extern void r4releopenlist(nfs4_opinst_t *); 4020Sstevel@tonic-gate 4030Sstevel@tonic-gate /* Access cache calls */ 4040Sstevel@tonic-gate extern nfs4_access_type_t nfs4_access_check(rnode4_t *, uint32_t, cred_t *); 4050Sstevel@tonic-gate extern void nfs4_access_cache(rnode4_t *rp, uint32_t, uint32_t, cred_t *); 4060Sstevel@tonic-gate extern int nfs4_access_purge_rp(rnode4_t *); 4070Sstevel@tonic-gate 4080Sstevel@tonic-gate extern int nfs4_free_data_reclaim(rnode4_t *); 4090Sstevel@tonic-gate extern void nfs4_rnode_invalidate(struct vfs *); 4100Sstevel@tonic-gate 4110Sstevel@tonic-gate extern time_t r2lease_time(rnode4_t *); 4120Sstevel@tonic-gate extern int nfs4_directio(vnode_t *, int, cred_t *); 4130Sstevel@tonic-gate 4140Sstevel@tonic-gate /* shadow vnode functions */ 4150Sstevel@tonic-gate extern void sv_activate(vnode_t **, vnode_t *, nfs4_fname_t **, int); 4160Sstevel@tonic-gate extern vnode_t *sv_find(vnode_t *, vnode_t *, nfs4_fname_t **); 4170Sstevel@tonic-gate extern void sv_update_path(vnode_t *, char *, char *); 4180Sstevel@tonic-gate extern void sv_inactive(vnode_t *); 4190Sstevel@tonic-gate extern void sv_exchange(vnode_t **); 4200Sstevel@tonic-gate extern void sv_uninit(svnode_t *); 4210Sstevel@tonic-gate extern void nfs4_clear_open_streams(rnode4_t *); 4220Sstevel@tonic-gate 4230Sstevel@tonic-gate /* 4240Sstevel@tonic-gate * Mark cached attributes as timed out 4250Sstevel@tonic-gate * 4260Sstevel@tonic-gate * The caller must not be holding the rnode r_statelock mutex. 4270Sstevel@tonic-gate */ 4280Sstevel@tonic-gate #define PURGE_ATTRCACHE4_LOCKED(rp) \ 4290Sstevel@tonic-gate rp->r_time_attr_inval = gethrtime(); \ 4300Sstevel@tonic-gate rp->r_time_attr_saved = rp->r_time_attr_inval; \ 4310Sstevel@tonic-gate rp->r_pathconf.pc4_xattr_valid = 0; \ 4320Sstevel@tonic-gate rp->r_pathconf.pc4_cache_valid = 0; 4330Sstevel@tonic-gate 4340Sstevel@tonic-gate #define PURGE_ATTRCACHE4(vp) { \ 4350Sstevel@tonic-gate rnode4_t *rp = VTOR4(vp); \ 4360Sstevel@tonic-gate mutex_enter(&rp->r_statelock); \ 4370Sstevel@tonic-gate PURGE_ATTRCACHE4_LOCKED(rp); \ 4380Sstevel@tonic-gate mutex_exit(&rp->r_statelock); \ 4390Sstevel@tonic-gate } 4400Sstevel@tonic-gate 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate extern void nfs4_async_readdir(vnode_t *, rddir4_cache *, 4430Sstevel@tonic-gate cred_t *, int (*)(vnode_t *, rddir4_cache *, cred_t *)); 4440Sstevel@tonic-gate extern char *rnode4info(rnode4_t *rp); 4450Sstevel@tonic-gate 4460Sstevel@tonic-gate extern int writerp4(rnode4_t *, caddr_t, int, struct uio *, int); 4470Sstevel@tonic-gate extern void nfs4_set_nonvattrs(rnode4_t *, struct nfs4attr_to_vattr *); 4480Sstevel@tonic-gate extern void nfs4delegabandon(rnode4_t *); 4490Sstevel@tonic-gate extern stateid4 nfs4_get_w_stateid(cred_t *, rnode4_t *, pid_t, mntinfo4_t *, 4500Sstevel@tonic-gate nfs_opnum4, nfs4_stateid_types_t *); 4510Sstevel@tonic-gate extern stateid4 nfs4_get_stateid(cred_t *, rnode4_t *, pid_t, mntinfo4_t *, 4520Sstevel@tonic-gate nfs_opnum4, nfs4_stateid_types_t *, bool_t); 4530Sstevel@tonic-gate extern nfsstat4 nfs4_find_or_create_lock_owner(pid_t, rnode4_t *, cred_t *, 4540Sstevel@tonic-gate nfs4_open_owner_t **, nfs4_open_stream_t **, 4550Sstevel@tonic-gate nfs4_lock_owner_t **); 4560Sstevel@tonic-gate extern cred_t *nfs4_get_otw_cred_by_osp(rnode4_t *, cred_t *, 4570Sstevel@tonic-gate nfs4_open_stream_t **, bool_t *, bool_t *); 4580Sstevel@tonic-gate 4590Sstevel@tonic-gate 4600Sstevel@tonic-gate /* 4610Sstevel@tonic-gate * Defines for the flag argument of nfs4delegreturn 4620Sstevel@tonic-gate */ 4630Sstevel@tonic-gate #define NFS4_DR_FORCE 0x1 /* discard even if start_op fails */ 4640Sstevel@tonic-gate #define NFS4_DR_PUSH 0x2 /* push modified data back to the server */ 4650Sstevel@tonic-gate #define NFS4_DR_DISCARD 0x4 /* discard the delegation w/o delegreturn */ 4660Sstevel@tonic-gate #define NFS4_DR_DID_OP 0x8 /* calling function did nfs4_start_op */ 4670Sstevel@tonic-gate #define NFS4_DR_RECALL 0x10 /* delegreturn done in response to CB_RECALL */ 4680Sstevel@tonic-gate #define NFS4_DR_REOPEN 0x20 /* perform file reopens, if applicable */ 4690Sstevel@tonic-gate 4700Sstevel@tonic-gate extern int nfs4delegreturn(rnode4_t *, int); 4710Sstevel@tonic-gate extern void nfs4_delegreturn_all(nfs4_server_t *); 4720Sstevel@tonic-gate extern void nfs4delegreturn_cleanup(rnode4_t *, nfs4_server_t *); 4730Sstevel@tonic-gate extern void nfs4_delegation_accept(rnode4_t *, open_claim_type4, OPEN4res *, 4740Sstevel@tonic-gate nfs4_ga_res_t *, cred_t *); 4750Sstevel@tonic-gate 4760Sstevel@tonic-gate extern void nfs4_dlistclean(void); 4770Sstevel@tonic-gate extern void nfs4_deleg_discard(mntinfo4_t *, nfs4_server_t *); 4780Sstevel@tonic-gate 4790Sstevel@tonic-gate extern void rddir4_cache_create(rnode4_t *); 4800Sstevel@tonic-gate extern void rddir4_cache_purge(rnode4_t *); 4810Sstevel@tonic-gate extern void rddir4_cache_destroy(rnode4_t *); 4820Sstevel@tonic-gate extern rddir4_cache *rddir4_cache_lookup(rnode4_t *, offset_t, int); 4830Sstevel@tonic-gate extern void rddir4_cache_rele(rnode4_t *, rddir4_cache *); 4840Sstevel@tonic-gate 485*5302Sth199096 extern void r4_stub_mirrormount(rnode4_t *); 486*5302Sth199096 extern void r4_stub_none(rnode4_t *); 487*5302Sth199096 4880Sstevel@tonic-gate #ifdef DEBUG 4890Sstevel@tonic-gate extern char *rddir4_cache_buf_alloc(size_t, int); 4900Sstevel@tonic-gate extern void rddir4_cache_buf_free(void *, size_t); 4910Sstevel@tonic-gate #endif 4920Sstevel@tonic-gate 4930Sstevel@tonic-gate 4940Sstevel@tonic-gate 4950Sstevel@tonic-gate #endif /* _KERNEL */ 4960Sstevel@tonic-gate 4970Sstevel@tonic-gate #ifdef __cplusplus 4980Sstevel@tonic-gate } 4990Sstevel@tonic-gate #endif 5000Sstevel@tonic-gate 5010Sstevel@tonic-gate #endif /* _NFS_RNODE4_H */ 502