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