17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5b9238976Sth199096 * Common Development and Distribution License (the "License"). 6b9238976Sth199096 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22b9238976Sth199096 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _NFS_RNODE4_H 307c478bd9Sstevel@tonic-gate #define _NFS_RNODE4_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #include <nfs/rnode.h> /* for symlink_cache, nfs_rwlock_t, etc. */ 397c478bd9Sstevel@tonic-gate #include <nfs/nfs4.h> 407c478bd9Sstevel@tonic-gate #include <nfs/nfs4_clnt.h> 417c478bd9Sstevel@tonic-gate #include <sys/thread.h> 427c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> /* for offsetof */ 437c478bd9Sstevel@tonic-gate 44b9238976Sth199096 typedef enum nfs4_stub_type { 45b9238976Sth199096 NFS4_STUB_NONE, 46b9238976Sth199096 NFS4_STUB_MIRRORMOUNT 47b9238976Sth199096 } nfs4_stub_type_t; 48b9238976Sth199096 497c478bd9Sstevel@tonic-gate typedef enum nfs4_access_type { 507c478bd9Sstevel@tonic-gate NFS4_ACCESS_UNKNOWN, 517c478bd9Sstevel@tonic-gate NFS4_ACCESS_ALLOWED, 527c478bd9Sstevel@tonic-gate NFS4_ACCESS_DENIED 537c478bd9Sstevel@tonic-gate } nfs4_access_type_t; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* 567c478bd9Sstevel@tonic-gate * Access cache 577c478bd9Sstevel@tonic-gate */ 587c478bd9Sstevel@tonic-gate typedef struct acache4_hash { 597c478bd9Sstevel@tonic-gate struct acache4 *next; 607c478bd9Sstevel@tonic-gate struct acache4 *prev; 617c478bd9Sstevel@tonic-gate krwlock_t lock; 627c478bd9Sstevel@tonic-gate } acache4_hash_t; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate typedef struct acache4 { 657c478bd9Sstevel@tonic-gate struct acache4 *next; /* next and prev must be first */ 667c478bd9Sstevel@tonic-gate struct acache4 *prev; 677c478bd9Sstevel@tonic-gate uint32_t known; 687c478bd9Sstevel@tonic-gate uint32_t allowed; 697c478bd9Sstevel@tonic-gate struct rnode4 *rnode; 707c478bd9Sstevel@tonic-gate cred_t *cred; 717c478bd9Sstevel@tonic-gate struct acache4 *list; 727c478bd9Sstevel@tonic-gate struct acache4_hash *hashq; 737c478bd9Sstevel@tonic-gate } acache4_t; 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate /* 767c478bd9Sstevel@tonic-gate * Note on the different buffer sizes in rddir4_cache: 777c478bd9Sstevel@tonic-gate * There seems to be some discrepancy between the intended and actual 787c478bd9Sstevel@tonic-gate * use of entlen and buflen, which does not correspond to the comment below. 797c478bd9Sstevel@tonic-gate * entlen - nfsv2/3 used as both alloc'd size of entries buffer and 807c478bd9Sstevel@tonic-gate * as the actual size of the entries (XXX is this correct?). 817c478bd9Sstevel@tonic-gate * nfsv4 will use it only as the alloc'd size. 827c478bd9Sstevel@tonic-gate * buflen - used for calculations of readahead. 837c478bd9Sstevel@tonic-gate * actlen - added for nfsv4 to serve as the size of the useful 847c478bd9Sstevel@tonic-gate * portion of the entries buffer. That is because in 857c478bd9Sstevel@tonic-gate * nfsv4, the otw entries are converted to system entries, 867c478bd9Sstevel@tonic-gate * and may not be the same size - thus buffer may not be full. 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate typedef struct rddir4_cache { 897c478bd9Sstevel@tonic-gate lloff_t _cookie; /* cookie used to find this cache entry */ 907c478bd9Sstevel@tonic-gate lloff_t _ncookie; /* cookie used to find the next cache entry */ 917c478bd9Sstevel@tonic-gate char *entries; /* buffer containing dirent entries */ 927c478bd9Sstevel@tonic-gate int eof; /* EOF reached after this request */ 937c478bd9Sstevel@tonic-gate int entlen; /* size of dirent entries in buf */ 947c478bd9Sstevel@tonic-gate int buflen; /* size of the buffer used to store entries */ 957c478bd9Sstevel@tonic-gate int actlen; /* size of the actual entries (nfsv4 only) */ 967c478bd9Sstevel@tonic-gate int flags; /* control flags, see below */ 977c478bd9Sstevel@tonic-gate kcondvar_t cv; /* cv for blocking */ 987c478bd9Sstevel@tonic-gate int error; /* error from RPC operation */ 997c478bd9Sstevel@tonic-gate void *data; /* private data */ 1007c478bd9Sstevel@tonic-gate } rddir4_cache; 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate #define nfs4_cookie _cookie._f 1037c478bd9Sstevel@tonic-gate #define nfs4_ncookie _ncookie._f 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate /* 1067c478bd9Sstevel@tonic-gate * Shadow vnode, v4 only. 1077c478bd9Sstevel@tonic-gate * 1087c478bd9Sstevel@tonic-gate * A file's shadow vnode list is protected by its hash bucket lock, 1097c478bd9Sstevel@tonic-gate * r_hashq->r_lock. 1107c478bd9Sstevel@tonic-gate * 1117c478bd9Sstevel@tonic-gate * sv_r_vnode is protected by the appropriate vnode locks. 1127c478bd9Sstevel@tonic-gate * 1137c478bd9Sstevel@tonic-gate * sv_dfh, sv_name, sv_dfileid, and sv_dfileid_valid are protected 1147c478bd9Sstevel@tonic-gate * by rp->r_svlock. 1157c478bd9Sstevel@tonic-gate */ 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate typedef struct insq_link { 1187c478bd9Sstevel@tonic-gate void *forw; 1197c478bd9Sstevel@tonic-gate void *back; 1207c478bd9Sstevel@tonic-gate } insq_link_t; 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate typedef struct svnode { 1237c478bd9Sstevel@tonic-gate insq_link_t sv_link; /* must be first for insque */ 1247c478bd9Sstevel@tonic-gate vnode_t *sv_r_vnode; /* vnode for this shadow */ 1257c478bd9Sstevel@tonic-gate nfs4_fname_t *sv_name; /* component name */ 1267c478bd9Sstevel@tonic-gate nfs4_sharedfh_t *sv_dfh; /* directory file handle */ 1277c478bd9Sstevel@tonic-gate } svnode_t; 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate #define sv_forw sv_link.forw 1307c478bd9Sstevel@tonic-gate #define sv_back sv_link.back 1317c478bd9Sstevel@tonic-gate extern svnode_t *vtosv(vnode_t *); 1327c478bd9Sstevel@tonic-gate #define VTOSV(vp) vtosv(vp) 1337c478bd9Sstevel@tonic-gate #define SVTOV(svp) (((svp)->sv_r_vnode)) 1347c478bd9Sstevel@tonic-gate #define IS_SHADOW(vp, rp) ((vp) != (rp)->r_vnode) 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate /* 1377c478bd9Sstevel@tonic-gate * The format of the hash bucket used to lookup rnodes from a file handle. 1387c478bd9Sstevel@tonic-gate */ 1397c478bd9Sstevel@tonic-gate typedef struct r4hashq { 1407c478bd9Sstevel@tonic-gate struct rnode4 *r_hashf; 1417c478bd9Sstevel@tonic-gate struct rnode4 *r_hashb; 1427c478bd9Sstevel@tonic-gate krwlock_t r_lock; 1437c478bd9Sstevel@tonic-gate } r4hashq_t; 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * Remote file information structure. 1477c478bd9Sstevel@tonic-gate * 1487c478bd9Sstevel@tonic-gate * The rnode is the "inode" for remote files. It contains all the 1497c478bd9Sstevel@tonic-gate * information necessary to handle remote file on the client side. 1507c478bd9Sstevel@tonic-gate * 1517c478bd9Sstevel@tonic-gate * Note on file sizes: we keep two file sizes in the rnode: the size 1527c478bd9Sstevel@tonic-gate * according to the client (r_size) and the size according to the server 1537c478bd9Sstevel@tonic-gate * (r_attr.va_size). They can differ because we modify r_size during a 1547c478bd9Sstevel@tonic-gate * write system call (nfs_rdwr), before the write request goes over the 1557c478bd9Sstevel@tonic-gate * wire (before the file is actually modified on the server). If an OTW 1567c478bd9Sstevel@tonic-gate * request occurs before the cached data is written to the server the file 1577c478bd9Sstevel@tonic-gate * size returned from the server (r_attr.va_size) may not match r_size. 1587c478bd9Sstevel@tonic-gate * r_size is the one we use, in general. r_attr.va_size is only used to 1597c478bd9Sstevel@tonic-gate * determine whether or not our cached data is valid. 1607c478bd9Sstevel@tonic-gate * 1617c478bd9Sstevel@tonic-gate * Each rnode has 5 locks associated with it (not including the rnode 1627c478bd9Sstevel@tonic-gate * hash table and free list locks): 1637c478bd9Sstevel@tonic-gate * 1647c478bd9Sstevel@tonic-gate * r_rwlock: Serializes nfs_write and nfs_setattr requests 1657c478bd9Sstevel@tonic-gate * and allows nfs_read requests to proceed in parallel. 1667c478bd9Sstevel@tonic-gate * Serializes reads/updates to directories. 1677c478bd9Sstevel@tonic-gate * 1687c478bd9Sstevel@tonic-gate * r_lkserlock: Serializes lock requests with map, write, and 1697c478bd9Sstevel@tonic-gate * readahead operations. 1707c478bd9Sstevel@tonic-gate * 1717c478bd9Sstevel@tonic-gate * r_statelock: Protects all fields in the rnode except for 1727c478bd9Sstevel@tonic-gate * those listed below. This lock is intented 1737c478bd9Sstevel@tonic-gate * to be held for relatively short periods of 1747c478bd9Sstevel@tonic-gate * time (not accross entire putpage operations, 1757c478bd9Sstevel@tonic-gate * for example). 1767c478bd9Sstevel@tonic-gate * 1777c478bd9Sstevel@tonic-gate * r_statev4_lock: Protects the created_v4 flag, the lock_owners list, 1787c478bd9Sstevel@tonic-gate * and all the delegation fields except r_deleg_list. 1797c478bd9Sstevel@tonic-gate * 1807c478bd9Sstevel@tonic-gate * r_os_lock: Protects r_open_streams. 1817c478bd9Sstevel@tonic-gate * 1827c478bd9Sstevel@tonic-gate * 1837c478bd9Sstevel@tonic-gate * The following members are protected by the mutex rp4freelist_lock: 1847c478bd9Sstevel@tonic-gate * r_freef 1857c478bd9Sstevel@tonic-gate * r_freeb 1867c478bd9Sstevel@tonic-gate * 1877c478bd9Sstevel@tonic-gate * The following members are protected by the hash bucket rwlock: 1887c478bd9Sstevel@tonic-gate * r_hashf 1897c478bd9Sstevel@tonic-gate * r_hashb 1907c478bd9Sstevel@tonic-gate * 1917c478bd9Sstevel@tonic-gate * r_fh is read-only except when an rnode is created (or recycled from the 1927c478bd9Sstevel@tonic-gate * free list). 1937c478bd9Sstevel@tonic-gate * 1947c478bd9Sstevel@tonic-gate * The following members are protected by nfs4_server_t::s_lock: 1957c478bd9Sstevel@tonic-gate * r_deleg_list 1967c478bd9Sstevel@tonic-gate * 1977c478bd9Sstevel@tonic-gate * Note: r_modaddr is only accessed when the r_statelock mutex is held. 1987c478bd9Sstevel@tonic-gate * Its value is also controlled via r_rwlock. It is assumed that 1997c478bd9Sstevel@tonic-gate * there will be only 1 writer active at a time, so it safe to 2007c478bd9Sstevel@tonic-gate * set r_modaddr and release r_statelock as long as the r_rwlock 2017c478bd9Sstevel@tonic-gate * writer lock is held. 2027c478bd9Sstevel@tonic-gate * 2037c478bd9Sstevel@tonic-gate * 64-bit offsets: the code formerly assumed that atomic reads of 2047c478bd9Sstevel@tonic-gate * r_size were safe and reliable; on 32-bit architectures, this is 2057c478bd9Sstevel@tonic-gate * not true since an intervening bus cycle from another processor 2067c478bd9Sstevel@tonic-gate * could update half of the size field. The r_statelock must now 2077c478bd9Sstevel@tonic-gate * be held whenever any kind of access of r_size is made. 2087c478bd9Sstevel@tonic-gate * 2097c478bd9Sstevel@tonic-gate * Lock ordering: 2107c478bd9Sstevel@tonic-gate * r_rwlock > r_lkserlock > r_os_lock > r_statelock > r_statev4_lock 2117c478bd9Sstevel@tonic-gate * vnode_t::v_lock > r_os_lock 2127c478bd9Sstevel@tonic-gate */ 2137c478bd9Sstevel@tonic-gate struct exportinfo; /* defined in nfs/export.h */ 2147c478bd9Sstevel@tonic-gate struct servinfo4; /* defined in nfs/nfs4_clnt.h */ 2157c478bd9Sstevel@tonic-gate struct failinfo; /* defined in nfs/nfs_clnt.h */ 2167c478bd9Sstevel@tonic-gate struct mntinfo4; /* defined in nfs/nfs4_clnt.h */ 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate typedef struct rnode4 { 2197c478bd9Sstevel@tonic-gate /* the hash fields must be first to match the rhashq_t */ 2207c478bd9Sstevel@tonic-gate struct rnode4 *r_hashf; /* hash queue forward pointer */ 2217c478bd9Sstevel@tonic-gate struct rnode4 *r_hashb; /* hash queue back pointer */ 2227c478bd9Sstevel@tonic-gate struct rnode4 *r_freef; /* free list forward pointer */ 2237c478bd9Sstevel@tonic-gate struct rnode4 *r_freeb; /* free list back pointer */ 2247c478bd9Sstevel@tonic-gate r4hashq_t *r_hashq; /* pointer to the hash bucket */ 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate svnode_t r_svnode; /* "master" shadow vnode for file */ 2277c478bd9Sstevel@tonic-gate kmutex_t r_svlock; /* serializes access to svnode list */ 2287c478bd9Sstevel@tonic-gate nfs_rwlock_t r_rwlock; /* serializes write/setattr requests */ 2297c478bd9Sstevel@tonic-gate nfs_rwlock_t r_lkserlock; /* serialize lock with other ops */ 2307c478bd9Sstevel@tonic-gate kmutex_t r_statelock; /* protects (most of) rnode contents */ 2317c478bd9Sstevel@tonic-gate nfs4_sharedfh_t *r_fh; /* file handle */ 2327c478bd9Sstevel@tonic-gate struct servinfo4 2337c478bd9Sstevel@tonic-gate *r_server; /* current server */ 2347c478bd9Sstevel@tonic-gate u_offset_t r_nextr; /* next byte read offset (read-ahead) */ 2357c478bd9Sstevel@tonic-gate uint_t r_flags; /* flags, see below */ 2367c478bd9Sstevel@tonic-gate short r_error; /* async write error */ 2377c478bd9Sstevel@tonic-gate cred_t *r_unlcred; /* unlinked credentials */ 2387c478bd9Sstevel@tonic-gate char *r_unlname; /* unlinked file name */ 2397c478bd9Sstevel@tonic-gate vnode_t *r_unldvp; /* parent dir of unlinked file */ 2407c478bd9Sstevel@tonic-gate vnode_t *r_xattr_dir; /* cached xattr dir vnode */ 2417c478bd9Sstevel@tonic-gate len_t r_size; /* client's view of file size */ 2427c478bd9Sstevel@tonic-gate vattr_t r_attr; /* cached vnode attributes */ 2437c478bd9Sstevel@tonic-gate hrtime_t r_time_attr_saved; /* time attributes were cached */ 2447c478bd9Sstevel@tonic-gate hrtime_t r_time_attr_inval; /* time attributes become invalid */ 2457c478bd9Sstevel@tonic-gate hrtime_t r_time_cache_inval; /* time caches become invalid */ 2467c478bd9Sstevel@tonic-gate time_t r_delay_wait; /* future time for DELAY handling */ 2477c478bd9Sstevel@tonic-gate int r_delay_interval; /* Number of Secs of last DELAY */ 2487c478bd9Sstevel@tonic-gate time_t r_last_recov; /* time of last recovery operation */ 2497c478bd9Sstevel@tonic-gate nfs4_recov_t r_recov_act; /* action from last recovery op */ 2507c478bd9Sstevel@tonic-gate long r_mapcnt; /* count of mmapped pages */ 2517c478bd9Sstevel@tonic-gate uint_t r_count; /* # of refs not reflect in v_count */ 2527c478bd9Sstevel@tonic-gate uint_t r_awcount; /* # of outstanding async write */ 2537c478bd9Sstevel@tonic-gate uint_t r_gcount; /* getattrs waiting to flush pages */ 2547c478bd9Sstevel@tonic-gate kcondvar_t r_cv; /* condvar for blocked threads */ 2557c478bd9Sstevel@tonic-gate int (*r_putapage) /* address of putapage routine */ 2567c478bd9Sstevel@tonic-gate (vnode_t *, page_t *, u_offset_t *, size_t *, int, cred_t *); 2577c478bd9Sstevel@tonic-gate void *r_dir; /* cache of readdir responses */ 2587c478bd9Sstevel@tonic-gate rddir4_cache *r_direof; /* pointer to the EOF entry */ 2597c478bd9Sstevel@tonic-gate symlink_cache r_symlink; /* cached readlink response */ 2607c478bd9Sstevel@tonic-gate verifier4 r_writeverf; /* file data write verifier */ 2617c478bd9Sstevel@tonic-gate u_offset_t r_modaddr; /* address for page in writerp */ 2627c478bd9Sstevel@tonic-gate commit_t r_commit; /* commit information */ 2637c478bd9Sstevel@tonic-gate u_offset_t r_truncaddr; /* base for truncate operation */ 2647c478bd9Sstevel@tonic-gate vsecattr_t *r_secattr; /* cached security attributes (acls) */ 2657c478bd9Sstevel@tonic-gate verifier4 r_cookieverf4; /* version 4 readdir cookie verifier */ 2667c478bd9Sstevel@tonic-gate nfs4_pathconf_info_t r_pathconf; /* cached pathconf info */ 2677c478bd9Sstevel@tonic-gate acache4_t *r_acache; /* list of access cache entries */ 2687c478bd9Sstevel@tonic-gate list_t r_open_streams; /* open streams list */ 2697c478bd9Sstevel@tonic-gate kmutex_t r_os_lock; /* protects r_open_streams */ 2707c478bd9Sstevel@tonic-gate nfs4_lock_owner_t 2717c478bd9Sstevel@tonic-gate r_lo_head; /* lock owners list head */ 2727c478bd9Sstevel@tonic-gate int created_v4; /* 1 if file has been created in v4 */ 2737c478bd9Sstevel@tonic-gate kmutex_t r_statev4_lock; /* protects created_v4, state4ptr */ 2747c478bd9Sstevel@tonic-gate 2757c478bd9Sstevel@tonic-gate list_node_t r_deleg_link; /* linkage into list of */ 2767c478bd9Sstevel@tonic-gate /* delegated rnodes for this server */ 2777c478bd9Sstevel@tonic-gate open_delegation_type4 2787c478bd9Sstevel@tonic-gate r_deleg_type; /* type of delegation granted */ 2797c478bd9Sstevel@tonic-gate stateid4 r_deleg_stateid; 2807c478bd9Sstevel@tonic-gate /* delegation state id */ 2817c478bd9Sstevel@tonic-gate nfs_space_limit4 2827c478bd9Sstevel@tonic-gate r_deleg_limit; /* file limits returned from */ 2837c478bd9Sstevel@tonic-gate /* server on delegated open */ 2847c478bd9Sstevel@tonic-gate nfsace4 r_deleg_perms; /* file permissions returned from */ 2857c478bd9Sstevel@tonic-gate /* server on delegated open */ 2867c478bd9Sstevel@tonic-gate fattr4_change r_deleg_change; /* current deleg change attr */ 2877c478bd9Sstevel@tonic-gate fattr4_change r_deleg_change_grant; 2887c478bd9Sstevel@tonic-gate /* change @ write deleg grant */ 2897c478bd9Sstevel@tonic-gate cred_t *r_deleg_cred; /* credential in force when the */ 2907c478bd9Sstevel@tonic-gate /* delegation was granted */ 2917c478bd9Sstevel@tonic-gate open_delegation_type4 2927c478bd9Sstevel@tonic-gate r_deleg_needs_recovery; 2937c478bd9Sstevel@tonic-gate /* delegation needs recovery */ 2947c478bd9Sstevel@tonic-gate /* This contains the delegation type */ 2957c478bd9Sstevel@tonic-gate /* for use with CLAIM_PREVIOUS. */ 2967c478bd9Sstevel@tonic-gate /* OPEN_DELEGATE_NONE means recovery */ 2977c478bd9Sstevel@tonic-gate /* is not needed. */ 2987c478bd9Sstevel@tonic-gate unsigned r_deleg_needs_recall:1; 2997c478bd9Sstevel@tonic-gate /* delegation has been recalled by */ 3007c478bd9Sstevel@tonic-gate /* the server during open with */ 3017c478bd9Sstevel@tonic-gate /* CLAIM_PREVIOUS */ 3027c478bd9Sstevel@tonic-gate unsigned r_deleg_return_pending:1; 3037c478bd9Sstevel@tonic-gate /* delegreturn is pending, don't use */ 3047c478bd9Sstevel@tonic-gate /* the delegation stateid, set in */ 3057c478bd9Sstevel@tonic-gate /* nfs4_dlistadd */ 3067c478bd9Sstevel@tonic-gate unsigned r_deleg_return_inprog:1; 3077c478bd9Sstevel@tonic-gate /* delegreturn is in progress, may */ 3087c478bd9Sstevel@tonic-gate /* only be set by nfs4delegreturn. */ 3097c478bd9Sstevel@tonic-gate nfs_rwlock_t r_deleg_recall_lock; 3107c478bd9Sstevel@tonic-gate /* lock for synchronizing delegreturn */ 3117c478bd9Sstevel@tonic-gate /* with in other operations, acquired */ 3127c478bd9Sstevel@tonic-gate /* in read mode by nfs4_start_fop, */ 3137c478bd9Sstevel@tonic-gate /* acquired in write mode in */ 3147c478bd9Sstevel@tonic-gate /* nfs4delegreturn */ 3157c478bd9Sstevel@tonic-gate fattr4_change r_change; /* GETATTR4 change attr; client */ 3167c478bd9Sstevel@tonic-gate /* should always request change */ 3177c478bd9Sstevel@tonic-gate /* when c/mtime requested to keep */ 3187c478bd9Sstevel@tonic-gate /* change and c/mtime in sync */ 3197c478bd9Sstevel@tonic-gate fattr4_fileid r_mntd_fid; /* mounted on fileid attr */ 3207c478bd9Sstevel@tonic-gate kthread_t *r_serial; /* attrcache validation thread */ 3217c478bd9Sstevel@tonic-gate kthread_t *r_pgflush; /* thread flushing page cache */ 3227c478bd9Sstevel@tonic-gate list_t r_indelmap; /* list of delmap callers */ 3237c478bd9Sstevel@tonic-gate fattr4_fsid r_srv_fsid; /* fsid of srv fs containing object */ 3247c478bd9Sstevel@tonic-gate /* when rnode created; compare with */ 3257c478bd9Sstevel@tonic-gate /* sv_fsid (servinfo4_t) to see why */ 326b9238976Sth199096 /* stub type was set */ 327b9238976Sth199096 nfs4_stub_type_t r_stub_type; 328b9238976Sth199096 /* e.g. mirror-mount */ 3297c478bd9Sstevel@tonic-gate } rnode4_t; 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate #define r_vnode r_svnode.sv_r_vnode 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate /* 3347c478bd9Sstevel@tonic-gate * Flags 3357c478bd9Sstevel@tonic-gate */ 3367c478bd9Sstevel@tonic-gate #define R4READDIRWATTR 0x1 /* Use READDIR with attributes */ 3377c478bd9Sstevel@tonic-gate #define R4DIRTY 0x2 /* dirty pages from write operation */ 3387c478bd9Sstevel@tonic-gate #define R4STALE 0x4 /* stale, don't even attempt to write */ 3397c478bd9Sstevel@tonic-gate #define R4MODINPROGRESS 0x8 /* page modification happening */ 3407c478bd9Sstevel@tonic-gate #define R4TRUNCATE 0x10 /* truncating, don't commit */ 3417c478bd9Sstevel@tonic-gate #define R4HAVEVERF 0x20 /* have a write verifier to compare against */ 3427c478bd9Sstevel@tonic-gate #define R4COMMIT 0x40 /* commit in progress */ 3437c478bd9Sstevel@tonic-gate #define R4COMMITWAIT 0x80 /* someone is waiting to do a commit */ 3447c478bd9Sstevel@tonic-gate #define R4HASHED 0x100 /* rnode is in hash queues */ 3457c478bd9Sstevel@tonic-gate #define R4OUTOFSPACE 0x200 /* an out of space error has happened */ 3467c478bd9Sstevel@tonic-gate #define R4LODANGLERS 0x400 /* rnode has dangling lock_owners to cleanup */ 3477c478bd9Sstevel@tonic-gate #define R4WRITEMODIFIED 0x800 /* file data has been modified by write */ 3487c478bd9Sstevel@tonic-gate #define R4DIRECTIO 0x1000 /* bypass the buffer cache */ 3497c478bd9Sstevel@tonic-gate #define R4RECOVERR 0x2000 /* couldn't recover */ 3507c478bd9Sstevel@tonic-gate #define R4RECEXPFH 0x4000 /* recovering expired filehandle */ 3517c478bd9Sstevel@tonic-gate #define R4RECOVERRP 0x8000 /* R4RECOVERR pending, but not set (yet) */ 3527c478bd9Sstevel@tonic-gate #define R4ISXATTR 0x20000 /* rnode is a named attribute */ 3537c478bd9Sstevel@tonic-gate #define R4DELMAPLIST 0x40000 /* delmap callers tracked for as callback */ 3547c478bd9Sstevel@tonic-gate #define R4PGFLUSH 0x80000 /* page flush thread active */ 355*5e4df02aSvv149972 #define R4INCACHEPURGE 0x100000 /* purging caches due to file size change */ 3567c478bd9Sstevel@tonic-gate #define R4LOOKUP 0x200000 /* a lookup has been done in the directory */ 3577c478bd9Sstevel@tonic-gate /* 3587c478bd9Sstevel@tonic-gate * Convert between vnode and rnode 3597c478bd9Sstevel@tonic-gate */ 3607c478bd9Sstevel@tonic-gate #define RTOV4(rp) ((rp)->r_vnode) 3617c478bd9Sstevel@tonic-gate #define VTOR4(vp) ((rnode4_t *)((vp)->v_data)) 3627c478bd9Sstevel@tonic-gate 363b9238976Sth199096 #define RP_ISSTUB(rp) (((rp)->r_stub_type != NFS4_STUB_NONE)) 364b9238976Sth199096 #define RP_ISSTUB_MIRRORMOUNT(rp) ((rp)->r_stub_type == NFS4_STUB_MIRRORMOUNT) 365b9238976Sth199096 3667c478bd9Sstevel@tonic-gate /* 3677c478bd9Sstevel@tonic-gate * Open file instances. 3687c478bd9Sstevel@tonic-gate */ 3697c478bd9Sstevel@tonic-gate 3707c478bd9Sstevel@tonic-gate typedef struct nfs4_opinst { 3717c478bd9Sstevel@tonic-gate struct nfs4_opinst *re_next; /* next in list */ 3727c478bd9Sstevel@tonic-gate vnode_t *re_vp; /* held reference */ 3737c478bd9Sstevel@tonic-gate uint32_t re_numosp; /* number of valid open streams */ 3747c478bd9Sstevel@tonic-gate nfs4_open_stream_t **re_osp; /* held reference */ 3757c478bd9Sstevel@tonic-gate } nfs4_opinst_t; 3767c478bd9Sstevel@tonic-gate 3777c478bd9Sstevel@tonic-gate #ifdef _KERNEL 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate extern long nrnode; 3807c478bd9Sstevel@tonic-gate 3817c478bd9Sstevel@tonic-gate /* Used for r_delay_interval */ 3827c478bd9Sstevel@tonic-gate #define NFS4_INITIAL_DELAY_INTERVAL 1 3837c478bd9Sstevel@tonic-gate #define NFS4_MAX_DELAY_INTERVAL 20 3847c478bd9Sstevel@tonic-gate 3857c478bd9Sstevel@tonic-gate extern rnode4_t *r4find(r4hashq_t *, nfs4_sharedfh_t *, struct vfs *); 3867c478bd9Sstevel@tonic-gate extern rnode4_t *r4find_unlocked(nfs4_sharedfh_t *, struct vfs *); 3877c478bd9Sstevel@tonic-gate extern void r4flush(struct vfs *, cred_t *); 3887c478bd9Sstevel@tonic-gate extern void destroy_rtable4(struct vfs *, cred_t *); 3897c478bd9Sstevel@tonic-gate extern int check_rtable4(struct vfs *); 3907c478bd9Sstevel@tonic-gate extern void rp4_addfree(rnode4_t *, cred_t *); 3917c478bd9Sstevel@tonic-gate extern void rp4_addhash(rnode4_t *); 3927c478bd9Sstevel@tonic-gate extern void rp4_rmhash(rnode4_t *); 3937c478bd9Sstevel@tonic-gate extern void rp4_rmhash_locked(rnode4_t *); 3947c478bd9Sstevel@tonic-gate extern int rtable4hash(nfs4_sharedfh_t *); 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate extern vnode_t *makenfs4node(nfs4_sharedfh_t *, nfs4_ga_res_t *, struct vfs *, 3977c478bd9Sstevel@tonic-gate hrtime_t, cred_t *, vnode_t *, nfs4_fname_t *); 3987c478bd9Sstevel@tonic-gate extern vnode_t *makenfs4node_by_fh(nfs4_sharedfh_t *, nfs4_sharedfh_t *, 3997c478bd9Sstevel@tonic-gate nfs4_fname_t **, nfs4_ga_res_t *, mntinfo4_t *, cred_t *, hrtime_t); 4007c478bd9Sstevel@tonic-gate 4017c478bd9Sstevel@tonic-gate extern nfs4_opinst_t *r4mkopenlist(struct mntinfo4 *); 4027c478bd9Sstevel@tonic-gate extern void r4releopenlist(nfs4_opinst_t *); 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate /* Access cache calls */ 4057c478bd9Sstevel@tonic-gate extern nfs4_access_type_t nfs4_access_check(rnode4_t *, uint32_t, cred_t *); 4067c478bd9Sstevel@tonic-gate extern void nfs4_access_cache(rnode4_t *rp, uint32_t, uint32_t, cred_t *); 4077c478bd9Sstevel@tonic-gate extern int nfs4_access_purge_rp(rnode4_t *); 4087c478bd9Sstevel@tonic-gate 4097c478bd9Sstevel@tonic-gate extern int nfs4_free_data_reclaim(rnode4_t *); 4107c478bd9Sstevel@tonic-gate extern void nfs4_rnode_invalidate(struct vfs *); 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate extern time_t r2lease_time(rnode4_t *); 4137c478bd9Sstevel@tonic-gate extern int nfs4_directio(vnode_t *, int, cred_t *); 4147c478bd9Sstevel@tonic-gate 4157c478bd9Sstevel@tonic-gate /* shadow vnode functions */ 4167c478bd9Sstevel@tonic-gate extern void sv_activate(vnode_t **, vnode_t *, nfs4_fname_t **, int); 4177c478bd9Sstevel@tonic-gate extern vnode_t *sv_find(vnode_t *, vnode_t *, nfs4_fname_t **); 4187c478bd9Sstevel@tonic-gate extern void sv_update_path(vnode_t *, char *, char *); 4197c478bd9Sstevel@tonic-gate extern void sv_inactive(vnode_t *); 4207c478bd9Sstevel@tonic-gate extern void sv_exchange(vnode_t **); 4217c478bd9Sstevel@tonic-gate extern void sv_uninit(svnode_t *); 4227c478bd9Sstevel@tonic-gate extern void nfs4_clear_open_streams(rnode4_t *); 4237c478bd9Sstevel@tonic-gate 4247c478bd9Sstevel@tonic-gate /* 4257c478bd9Sstevel@tonic-gate * Mark cached attributes as timed out 4267c478bd9Sstevel@tonic-gate * 4277c478bd9Sstevel@tonic-gate * The caller must not be holding the rnode r_statelock mutex. 4287c478bd9Sstevel@tonic-gate */ 4297c478bd9Sstevel@tonic-gate #define PURGE_ATTRCACHE4_LOCKED(rp) \ 4307c478bd9Sstevel@tonic-gate rp->r_time_attr_inval = gethrtime(); \ 4317c478bd9Sstevel@tonic-gate rp->r_time_attr_saved = rp->r_time_attr_inval; \ 4327c478bd9Sstevel@tonic-gate rp->r_pathconf.pc4_xattr_valid = 0; \ 4337c478bd9Sstevel@tonic-gate rp->r_pathconf.pc4_cache_valid = 0; 4347c478bd9Sstevel@tonic-gate 4357c478bd9Sstevel@tonic-gate #define PURGE_ATTRCACHE4(vp) { \ 4367c478bd9Sstevel@tonic-gate rnode4_t *rp = VTOR4(vp); \ 4377c478bd9Sstevel@tonic-gate mutex_enter(&rp->r_statelock); \ 4387c478bd9Sstevel@tonic-gate PURGE_ATTRCACHE4_LOCKED(rp); \ 4397c478bd9Sstevel@tonic-gate mutex_exit(&rp->r_statelock); \ 4407c478bd9Sstevel@tonic-gate } 4417c478bd9Sstevel@tonic-gate 4427c478bd9Sstevel@tonic-gate 4437c478bd9Sstevel@tonic-gate extern void nfs4_async_readdir(vnode_t *, rddir4_cache *, 4447c478bd9Sstevel@tonic-gate cred_t *, int (*)(vnode_t *, rddir4_cache *, cred_t *)); 4457c478bd9Sstevel@tonic-gate extern char *rnode4info(rnode4_t *rp); 4467c478bd9Sstevel@tonic-gate 4477c478bd9Sstevel@tonic-gate extern int writerp4(rnode4_t *, caddr_t, int, struct uio *, int); 4487c478bd9Sstevel@tonic-gate extern void nfs4_set_nonvattrs(rnode4_t *, struct nfs4attr_to_vattr *); 4497c478bd9Sstevel@tonic-gate extern void nfs4delegabandon(rnode4_t *); 4507c478bd9Sstevel@tonic-gate extern stateid4 nfs4_get_w_stateid(cred_t *, rnode4_t *, pid_t, mntinfo4_t *, 4517c478bd9Sstevel@tonic-gate nfs_opnum4, nfs4_stateid_types_t *); 4527c478bd9Sstevel@tonic-gate extern stateid4 nfs4_get_stateid(cred_t *, rnode4_t *, pid_t, mntinfo4_t *, 4537c478bd9Sstevel@tonic-gate nfs_opnum4, nfs4_stateid_types_t *, bool_t); 4547c478bd9Sstevel@tonic-gate extern nfsstat4 nfs4_find_or_create_lock_owner(pid_t, rnode4_t *, cred_t *, 4557c478bd9Sstevel@tonic-gate nfs4_open_owner_t **, nfs4_open_stream_t **, 4567c478bd9Sstevel@tonic-gate nfs4_lock_owner_t **); 4577c478bd9Sstevel@tonic-gate extern cred_t *nfs4_get_otw_cred_by_osp(rnode4_t *, cred_t *, 4587c478bd9Sstevel@tonic-gate nfs4_open_stream_t **, bool_t *, bool_t *); 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate 4617c478bd9Sstevel@tonic-gate /* 4627c478bd9Sstevel@tonic-gate * Defines for the flag argument of nfs4delegreturn 4637c478bd9Sstevel@tonic-gate */ 4647c478bd9Sstevel@tonic-gate #define NFS4_DR_FORCE 0x1 /* discard even if start_op fails */ 4657c478bd9Sstevel@tonic-gate #define NFS4_DR_PUSH 0x2 /* push modified data back to the server */ 4667c478bd9Sstevel@tonic-gate #define NFS4_DR_DISCARD 0x4 /* discard the delegation w/o delegreturn */ 4677c478bd9Sstevel@tonic-gate #define NFS4_DR_DID_OP 0x8 /* calling function did nfs4_start_op */ 4687c478bd9Sstevel@tonic-gate #define NFS4_DR_RECALL 0x10 /* delegreturn done in response to CB_RECALL */ 4697c478bd9Sstevel@tonic-gate #define NFS4_DR_REOPEN 0x20 /* perform file reopens, if applicable */ 4707c478bd9Sstevel@tonic-gate 4717c478bd9Sstevel@tonic-gate extern int nfs4delegreturn(rnode4_t *, int); 4727c478bd9Sstevel@tonic-gate extern void nfs4_delegreturn_all(nfs4_server_t *); 4737c478bd9Sstevel@tonic-gate extern void nfs4delegreturn_cleanup(rnode4_t *, nfs4_server_t *); 4747c478bd9Sstevel@tonic-gate extern void nfs4_delegation_accept(rnode4_t *, open_claim_type4, OPEN4res *, 4757c478bd9Sstevel@tonic-gate nfs4_ga_res_t *, cred_t *); 4767c478bd9Sstevel@tonic-gate 4777c478bd9Sstevel@tonic-gate extern void nfs4_dlistclean(void); 4787c478bd9Sstevel@tonic-gate extern void nfs4_deleg_discard(mntinfo4_t *, nfs4_server_t *); 4797c478bd9Sstevel@tonic-gate 4807c478bd9Sstevel@tonic-gate extern void rddir4_cache_create(rnode4_t *); 4817c478bd9Sstevel@tonic-gate extern void rddir4_cache_purge(rnode4_t *); 4827c478bd9Sstevel@tonic-gate extern void rddir4_cache_destroy(rnode4_t *); 4837c478bd9Sstevel@tonic-gate extern rddir4_cache *rddir4_cache_lookup(rnode4_t *, offset_t, int); 4847c478bd9Sstevel@tonic-gate extern void rddir4_cache_rele(rnode4_t *, rddir4_cache *); 4857c478bd9Sstevel@tonic-gate 486b9238976Sth199096 extern void r4_stub_mirrormount(rnode4_t *); 487b9238976Sth199096 extern void r4_stub_none(rnode4_t *); 488b9238976Sth199096 4897c478bd9Sstevel@tonic-gate #ifdef DEBUG 4907c478bd9Sstevel@tonic-gate extern char *rddir4_cache_buf_alloc(size_t, int); 4917c478bd9Sstevel@tonic-gate extern void rddir4_cache_buf_free(void *, size_t); 4927c478bd9Sstevel@tonic-gate #endif 4937c478bd9Sstevel@tonic-gate 4947c478bd9Sstevel@tonic-gate 4957c478bd9Sstevel@tonic-gate 4967c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 4977c478bd9Sstevel@tonic-gate 4987c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4997c478bd9Sstevel@tonic-gate } 5007c478bd9Sstevel@tonic-gate #endif 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate #endif /* _NFS_RNODE4_H */ 503