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