1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #ifndef _NFS_RNODE_H 31*7c478bd9Sstevel@tonic-gate #define _NFS_RNODE_H 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #include <sys/avl.h> 36*7c478bd9Sstevel@tonic-gate #include <sys/list.h> 37*7c478bd9Sstevel@tonic-gate #include <nfs/nfs.h> 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 40*7c478bd9Sstevel@tonic-gate extern "C" { 41*7c478bd9Sstevel@tonic-gate #endif 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate typedef enum nfs_access_type { 44*7c478bd9Sstevel@tonic-gate NFS_ACCESS_UNKNOWN, 45*7c478bd9Sstevel@tonic-gate NFS_ACCESS_ALLOWED, 46*7c478bd9Sstevel@tonic-gate NFS_ACCESS_DENIED 47*7c478bd9Sstevel@tonic-gate } nfs_access_type_t; 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate typedef struct acache_hash { 50*7c478bd9Sstevel@tonic-gate struct acache *next; /* next and prev must be first */ 51*7c478bd9Sstevel@tonic-gate struct acache *prev; 52*7c478bd9Sstevel@tonic-gate krwlock_t lock; 53*7c478bd9Sstevel@tonic-gate } acache_hash_t; 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate typedef struct acache { 56*7c478bd9Sstevel@tonic-gate struct acache *next; /* next and prev must be first */ 57*7c478bd9Sstevel@tonic-gate struct acache *prev; 58*7c478bd9Sstevel@tonic-gate uint32_t known; 59*7c478bd9Sstevel@tonic-gate uint32_t allowed; 60*7c478bd9Sstevel@tonic-gate struct rnode *rnode; 61*7c478bd9Sstevel@tonic-gate cred_t *cred; 62*7c478bd9Sstevel@tonic-gate struct acache *list; 63*7c478bd9Sstevel@tonic-gate struct acache_hash *hashq; 64*7c478bd9Sstevel@tonic-gate } acache_t; 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate #define NFS_FHANDLE_LEN 64 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate typedef struct nfs_fhandle { 69*7c478bd9Sstevel@tonic-gate int fh_len; 70*7c478bd9Sstevel@tonic-gate char fh_buf[NFS_FHANDLE_LEN]; 71*7c478bd9Sstevel@tonic-gate } nfs_fhandle; 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate typedef struct rddir_cache { 74*7c478bd9Sstevel@tonic-gate lloff_t _cookie; /* cookie used to find this cache entry */ 75*7c478bd9Sstevel@tonic-gate lloff_t _ncookie; /* cookie used to find the next cache entry */ 76*7c478bd9Sstevel@tonic-gate char *entries; /* buffer containing dirent entries */ 77*7c478bd9Sstevel@tonic-gate int eof; /* EOF reached after this request */ 78*7c478bd9Sstevel@tonic-gate int entlen; /* size of dirent entries in buf */ 79*7c478bd9Sstevel@tonic-gate int buflen; /* size of the buffer used to store entries */ 80*7c478bd9Sstevel@tonic-gate int flags; /* control flags, see below */ 81*7c478bd9Sstevel@tonic-gate kcondvar_t cv; /* cv for blocking */ 82*7c478bd9Sstevel@tonic-gate int error; /* error from RPC operation */ 83*7c478bd9Sstevel@tonic-gate kmutex_t lock; 84*7c478bd9Sstevel@tonic-gate uint_t count; /* reference count */ 85*7c478bd9Sstevel@tonic-gate avl_node_t tree; /* AVL tree links */ 86*7c478bd9Sstevel@tonic-gate } rddir_cache; 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate #define nfs_cookie _cookie._p._l 89*7c478bd9Sstevel@tonic-gate #define nfs_ncookie _ncookie._p._l 90*7c478bd9Sstevel@tonic-gate #define nfs3_cookie _cookie._f 91*7c478bd9Sstevel@tonic-gate #define nfs3_ncookie _ncookie._f 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate #define RDDIR 0x1 /* readdir operation in progress */ 94*7c478bd9Sstevel@tonic-gate #define RDDIRWAIT 0x2 /* waiting on readdir in progress */ 95*7c478bd9Sstevel@tonic-gate #define RDDIRREQ 0x4 /* a new readdir is required */ 96*7c478bd9Sstevel@tonic-gate #define RDDIRCACHED 0x8 /* entry is in the cache */ 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate #define HAVE_RDDIR_CACHE(rp) (avl_numnodes(&(rp)->r_dir) > 0) 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate typedef struct symlink_cache { 101*7c478bd9Sstevel@tonic-gate char *contents; /* contents of the symbolic link */ 102*7c478bd9Sstevel@tonic-gate int len; /* length of the contents */ 103*7c478bd9Sstevel@tonic-gate int size; /* size of the allocated buffer */ 104*7c478bd9Sstevel@tonic-gate } symlink_cache; 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate typedef struct commit { 107*7c478bd9Sstevel@tonic-gate page_t *c_pages; /* list of pages to commit */ 108*7c478bd9Sstevel@tonic-gate offset3 c_commbase; /* base offset to do commit from */ 109*7c478bd9Sstevel@tonic-gate count3 c_commlen; /* len to commit */ 110*7c478bd9Sstevel@tonic-gate kcondvar_t c_cv; /* condvar for waiting for commit */ 111*7c478bd9Sstevel@tonic-gate } commit_t; 112*7c478bd9Sstevel@tonic-gate 113*7c478bd9Sstevel@tonic-gate /* 114*7c478bd9Sstevel@tonic-gate * The various values for the commit states. These are stored in 115*7c478bd9Sstevel@tonic-gate * the p_fsdata byte in the page struct. 116*7c478bd9Sstevel@tonic-gate */ 117*7c478bd9Sstevel@tonic-gate #define C_NOCOMMIT 0 /* no commit is required */ 118*7c478bd9Sstevel@tonic-gate #define C_COMMIT 1 /* a commit is required so do it now */ 119*7c478bd9Sstevel@tonic-gate #define C_DELAYCOMMIT 2 /* a commit is required, but can be delayed */ 120*7c478bd9Sstevel@tonic-gate 121*7c478bd9Sstevel@tonic-gate /* 122*7c478bd9Sstevel@tonic-gate * The lock manager holds state making it possible for the client 123*7c478bd9Sstevel@tonic-gate * and server to be out of sync. For example, if the response from 124*7c478bd9Sstevel@tonic-gate * the server granting a lock request is lost, the server will think 125*7c478bd9Sstevel@tonic-gate * the lock is granted and the client will think the lock is lost. 126*7c478bd9Sstevel@tonic-gate * To deal with this, a list of processes for which the client is 127*7c478bd9Sstevel@tonic-gate * not sure if the server holds a lock is attached to the rnode. 128*7c478bd9Sstevel@tonic-gate * When such a process closes the rnode, an unlock request is sent 129*7c478bd9Sstevel@tonic-gate * to the server to unlock the entire file. 130*7c478bd9Sstevel@tonic-gate * 131*7c478bd9Sstevel@tonic-gate * The list is kept as a singularly linked NULL terminated list. 132*7c478bd9Sstevel@tonic-gate * Because it is only added to under extreme error conditions, the 133*7c478bd9Sstevel@tonic-gate * list shouldn't get very big. DEBUG kernels print a console warning 134*7c478bd9Sstevel@tonic-gate * when the number of entries on a list go beyond nfs_lmpl_high_water 135*7c478bd9Sstevel@tonic-gate * an arbitrary number defined in nfs_add_locking_id() 136*7c478bd9Sstevel@tonic-gate */ 137*7c478bd9Sstevel@tonic-gate #define RLMPL_PID 1 138*7c478bd9Sstevel@tonic-gate #define RLMPL_OWNER 2 139*7c478bd9Sstevel@tonic-gate typedef struct lock_manager_pid_list { 140*7c478bd9Sstevel@tonic-gate int lmpl_type; 141*7c478bd9Sstevel@tonic-gate pid_t lmpl_pid; 142*7c478bd9Sstevel@tonic-gate union { 143*7c478bd9Sstevel@tonic-gate pid_t _pid; 144*7c478bd9Sstevel@tonic-gate struct { 145*7c478bd9Sstevel@tonic-gate int len; 146*7c478bd9Sstevel@tonic-gate char *owner; 147*7c478bd9Sstevel@tonic-gate } _own; 148*7c478bd9Sstevel@tonic-gate } un; 149*7c478bd9Sstevel@tonic-gate struct lock_manager_pid_list *lmpl_next; 150*7c478bd9Sstevel@tonic-gate } lmpl_t; 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate #define lmpl_opid un._pid 153*7c478bd9Sstevel@tonic-gate #define lmpl_own_len un._own.len 154*7c478bd9Sstevel@tonic-gate #define lmpl_owner un._own.owner 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate /* 157*7c478bd9Sstevel@tonic-gate * A homegrown reader/writer lock implementation. It addresses 158*7c478bd9Sstevel@tonic-gate * two requirements not addressed by the system primitives. They 159*7c478bd9Sstevel@tonic-gate * are that the `enter" operation is optionally interruptible and 160*7c478bd9Sstevel@tonic-gate * that that they can be re`enter'ed by writers without deadlock. 161*7c478bd9Sstevel@tonic-gate */ 162*7c478bd9Sstevel@tonic-gate typedef struct nfs_rwlock { 163*7c478bd9Sstevel@tonic-gate int count; 164*7c478bd9Sstevel@tonic-gate int waiters; 165*7c478bd9Sstevel@tonic-gate kthread_t *owner; 166*7c478bd9Sstevel@tonic-gate kmutex_t lock; 167*7c478bd9Sstevel@tonic-gate kcondvar_t cv; 168*7c478bd9Sstevel@tonic-gate } nfs_rwlock_t; 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate /* 171*7c478bd9Sstevel@tonic-gate * The format of the hash bucket used to lookup rnodes from a file handle. 172*7c478bd9Sstevel@tonic-gate */ 173*7c478bd9Sstevel@tonic-gate typedef struct rhashq { 174*7c478bd9Sstevel@tonic-gate struct rnode *r_hashf; 175*7c478bd9Sstevel@tonic-gate struct rnode *r_hashb; 176*7c478bd9Sstevel@tonic-gate krwlock_t r_lock; 177*7c478bd9Sstevel@tonic-gate } rhashq_t; 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate /* 180*7c478bd9Sstevel@tonic-gate * Remote file information structure. 181*7c478bd9Sstevel@tonic-gate * 182*7c478bd9Sstevel@tonic-gate * The rnode is the "inode" for remote files. It contains all the 183*7c478bd9Sstevel@tonic-gate * information necessary to handle remote file on the client side. 184*7c478bd9Sstevel@tonic-gate * 185*7c478bd9Sstevel@tonic-gate * Note on file sizes: we keep two file sizes in the rnode: the size 186*7c478bd9Sstevel@tonic-gate * according to the client (r_size) and the size according to the server 187*7c478bd9Sstevel@tonic-gate * (r_attr.va_size). They can differ because we modify r_size during a 188*7c478bd9Sstevel@tonic-gate * write system call (nfs_rdwr), before the write request goes over the 189*7c478bd9Sstevel@tonic-gate * wire (before the file is actually modified on the server). If an OTW 190*7c478bd9Sstevel@tonic-gate * request occurs before the cached data is written to the server the file 191*7c478bd9Sstevel@tonic-gate * size returned from the server (r_attr.va_size) may not match r_size. 192*7c478bd9Sstevel@tonic-gate * r_size is the one we use, in general. r_attr.va_size is only used to 193*7c478bd9Sstevel@tonic-gate * determine whether or not our cached data is valid. 194*7c478bd9Sstevel@tonic-gate * 195*7c478bd9Sstevel@tonic-gate * Each rnode has 3 locks associated with it (not including the rnode 196*7c478bd9Sstevel@tonic-gate * hash table and free list locks): 197*7c478bd9Sstevel@tonic-gate * 198*7c478bd9Sstevel@tonic-gate * r_rwlock: Serializes nfs_write and nfs_setattr requests 199*7c478bd9Sstevel@tonic-gate * and allows nfs_read requests to proceed in parallel. 200*7c478bd9Sstevel@tonic-gate * Serializes reads/updates to directories. 201*7c478bd9Sstevel@tonic-gate * 202*7c478bd9Sstevel@tonic-gate * r_lkserlock: Serializes lock requests with map, write, and 203*7c478bd9Sstevel@tonic-gate * readahead operations. 204*7c478bd9Sstevel@tonic-gate * 205*7c478bd9Sstevel@tonic-gate * r_statelock: Protects all fields in the rnode except for 206*7c478bd9Sstevel@tonic-gate * those listed below. This lock is intented 207*7c478bd9Sstevel@tonic-gate * to be held for relatively short periods of 208*7c478bd9Sstevel@tonic-gate * time (not accross entire putpage operations, 209*7c478bd9Sstevel@tonic-gate * for example). 210*7c478bd9Sstevel@tonic-gate * 211*7c478bd9Sstevel@tonic-gate * The following members are protected by the mutex rpfreelist_lock: 212*7c478bd9Sstevel@tonic-gate * r_freef 213*7c478bd9Sstevel@tonic-gate * r_freeb 214*7c478bd9Sstevel@tonic-gate * 215*7c478bd9Sstevel@tonic-gate * The following members are protected by the hash bucket rwlock: 216*7c478bd9Sstevel@tonic-gate * r_hashf 217*7c478bd9Sstevel@tonic-gate * r_hashb 218*7c478bd9Sstevel@tonic-gate * 219*7c478bd9Sstevel@tonic-gate * Note: r_modaddr is only accessed when the r_statelock mutex is held. 220*7c478bd9Sstevel@tonic-gate * Its value is also controlled via r_rwlock. It is assumed that 221*7c478bd9Sstevel@tonic-gate * there will be only 1 writer active at a time, so it safe to 222*7c478bd9Sstevel@tonic-gate * set r_modaddr and release r_statelock as long as the r_rwlock 223*7c478bd9Sstevel@tonic-gate * writer lock is held. 224*7c478bd9Sstevel@tonic-gate * 225*7c478bd9Sstevel@tonic-gate * 64-bit offsets: the code formerly assumed that atomic reads of 226*7c478bd9Sstevel@tonic-gate * r_size were safe and reliable; on 32-bit architectures, this is 227*7c478bd9Sstevel@tonic-gate * not true since an intervening bus cycle from another processor 228*7c478bd9Sstevel@tonic-gate * could update half of the size field. The r_statelock must now 229*7c478bd9Sstevel@tonic-gate * be held whenever any kind of access of r_size is made. 230*7c478bd9Sstevel@tonic-gate * 231*7c478bd9Sstevel@tonic-gate * Lock ordering: 232*7c478bd9Sstevel@tonic-gate * r_rwlock > r_lkserlock > r_statelock 233*7c478bd9Sstevel@tonic-gate */ 234*7c478bd9Sstevel@tonic-gate struct exportinfo; /* defined in nfs/export.h */ 235*7c478bd9Sstevel@tonic-gate struct servinfo; /* defined in nfs/nfs_clnt.h */ 236*7c478bd9Sstevel@tonic-gate struct failinfo; /* defined in nfs/nfs_clnt.h */ 237*7c478bd9Sstevel@tonic-gate struct mntinfo; /* defined in nfs/nfs_clnt.h */ 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 240*7c478bd9Sstevel@tonic-gate 241*7c478bd9Sstevel@tonic-gate typedef struct rnode { 242*7c478bd9Sstevel@tonic-gate /* the hash fields must be first to match the rhashq_t */ 243*7c478bd9Sstevel@tonic-gate struct rnode *r_hashf; /* hash queue forward pointer */ 244*7c478bd9Sstevel@tonic-gate struct rnode *r_hashb; /* hash queue back pointer */ 245*7c478bd9Sstevel@tonic-gate struct rnode *r_freef; /* free list forward pointer */ 246*7c478bd9Sstevel@tonic-gate struct rnode *r_freeb; /* free list back pointer */ 247*7c478bd9Sstevel@tonic-gate rhashq_t *r_hashq; /* pointer to the hash bucket */ 248*7c478bd9Sstevel@tonic-gate vnode_t *r_vnode; /* vnode for remote file */ 249*7c478bd9Sstevel@tonic-gate nfs_rwlock_t r_rwlock; /* serializes write/setattr requests */ 250*7c478bd9Sstevel@tonic-gate nfs_rwlock_t r_lkserlock; /* serialize lock with other ops */ 251*7c478bd9Sstevel@tonic-gate kmutex_t r_statelock; /* protects (most of) rnode contents */ 252*7c478bd9Sstevel@tonic-gate nfs_fhandle r_fh; /* file handle */ 253*7c478bd9Sstevel@tonic-gate struct servinfo *r_server; /* current server */ 254*7c478bd9Sstevel@tonic-gate char *r_path; /* path to this rnode */ 255*7c478bd9Sstevel@tonic-gate u_offset_t r_nextr; /* next byte read offset (read-ahead) */ 256*7c478bd9Sstevel@tonic-gate cred_t *r_cred; /* current credentials */ 257*7c478bd9Sstevel@tonic-gate cred_t *r_unlcred; /* unlinked credentials */ 258*7c478bd9Sstevel@tonic-gate char *r_unlname; /* unlinked file name */ 259*7c478bd9Sstevel@tonic-gate vnode_t *r_unldvp; /* parent dir of unlinked file */ 260*7c478bd9Sstevel@tonic-gate len_t r_size; /* client's view of file size */ 261*7c478bd9Sstevel@tonic-gate struct vattr r_attr; /* cached vnode attributes */ 262*7c478bd9Sstevel@tonic-gate hrtime_t r_attrtime; /* time attributes become invalid */ 263*7c478bd9Sstevel@tonic-gate hrtime_t r_mtime; /* client time file last modified */ 264*7c478bd9Sstevel@tonic-gate long r_mapcnt; /* count of mmapped pages */ 265*7c478bd9Sstevel@tonic-gate uint_t r_count; /* # of refs not reflect in v_count */ 266*7c478bd9Sstevel@tonic-gate uint_t r_awcount; /* # of outstanding async write */ 267*7c478bd9Sstevel@tonic-gate uint_t r_gcount; /* getattrs waiting to flush pages */ 268*7c478bd9Sstevel@tonic-gate ushort_t r_flags; /* flags, see below */ 269*7c478bd9Sstevel@tonic-gate short r_error; /* async write error */ 270*7c478bd9Sstevel@tonic-gate kcondvar_t r_cv; /* condvar for blocked threads */ 271*7c478bd9Sstevel@tonic-gate int (*r_putapage) /* address of putapage routine */ 272*7c478bd9Sstevel@tonic-gate (vnode_t *, page_t *, u_offset_t *, size_t *, int, cred_t *); 273*7c478bd9Sstevel@tonic-gate avl_tree_t r_dir; /* cache of readdir responses */ 274*7c478bd9Sstevel@tonic-gate rddir_cache *r_direof; /* pointer to the EOF entry */ 275*7c478bd9Sstevel@tonic-gate symlink_cache r_symlink; /* cached readlink response */ 276*7c478bd9Sstevel@tonic-gate writeverf3 r_verf; /* version 3 write verifier */ 277*7c478bd9Sstevel@tonic-gate u_offset_t r_modaddr; /* address for page in writerp */ 278*7c478bd9Sstevel@tonic-gate commit_t r_commit; /* commit information */ 279*7c478bd9Sstevel@tonic-gate u_offset_t r_truncaddr; /* base for truncate operation */ 280*7c478bd9Sstevel@tonic-gate vsecattr_t *r_secattr; /* cached security attributes (acls) */ 281*7c478bd9Sstevel@tonic-gate cookieverf3 r_cookieverf; /* version 3 readdir cookie verifier */ 282*7c478bd9Sstevel@tonic-gate lmpl_t *r_lmpl; /* pids that may be holding locks */ 283*7c478bd9Sstevel@tonic-gate nfs3_pathconf_info *r_pathconf; /* cached pathconf information */ 284*7c478bd9Sstevel@tonic-gate acache_t *r_acache; /* list of access cache entries */ 285*7c478bd9Sstevel@tonic-gate kthread_t *r_serial; /* id of purging thread */ 286*7c478bd9Sstevel@tonic-gate list_t r_indelmap; /* list of delmap callers */ 287*7c478bd9Sstevel@tonic-gate } rnode_t; 288*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 289*7c478bd9Sstevel@tonic-gate 290*7c478bd9Sstevel@tonic-gate /* 291*7c478bd9Sstevel@tonic-gate * Flags 292*7c478bd9Sstevel@tonic-gate */ 293*7c478bd9Sstevel@tonic-gate #define RREADDIRPLUS 0x1 /* issue a READDIRPLUS instead of READDIR */ 294*7c478bd9Sstevel@tonic-gate #define RDIRTY 0x2 /* dirty pages from write operation */ 295*7c478bd9Sstevel@tonic-gate #define RSTALE 0x4 /* file handle is stale */ 296*7c478bd9Sstevel@tonic-gate #define RMODINPROGRESS 0x8 /* page modification happening */ 297*7c478bd9Sstevel@tonic-gate #define RTRUNCATE 0x10 /* truncating, don't commit */ 298*7c478bd9Sstevel@tonic-gate #define RHAVEVERF 0x20 /* have a write verifier to compare against */ 299*7c478bd9Sstevel@tonic-gate #define RCOMMIT 0x40 /* commit in progress */ 300*7c478bd9Sstevel@tonic-gate #define RCOMMITWAIT 0x80 /* someone is waiting to do a commit */ 301*7c478bd9Sstevel@tonic-gate #define RHASHED 0x100 /* rnode is in hash queues */ 302*7c478bd9Sstevel@tonic-gate #define ROUTOFSPACE 0x200 /* an out of space error has happened */ 303*7c478bd9Sstevel@tonic-gate #define RDIRECTIO 0x400 /* bypass the buffer cache */ 304*7c478bd9Sstevel@tonic-gate #define RLOOKUP 0x800 /* a lookup has been performed */ 305*7c478bd9Sstevel@tonic-gate #define RWRITEATTR 0x1000 /* attributes came from WRITE */ 306*7c478bd9Sstevel@tonic-gate #define RINDNLCPURGE 0x2000 /* in the process of purging DNLC references */ 307*7c478bd9Sstevel@tonic-gate #define RDELMAPLIST 0x4000 /* delmap callers tracking for as callback */ 308*7c478bd9Sstevel@tonic-gate 309*7c478bd9Sstevel@tonic-gate /* 310*7c478bd9Sstevel@tonic-gate * Convert between vnode and rnode 311*7c478bd9Sstevel@tonic-gate */ 312*7c478bd9Sstevel@tonic-gate #define RTOV(rp) ((rp)->r_vnode) 313*7c478bd9Sstevel@tonic-gate #define VTOR(vp) ((rnode_t *)((vp)->v_data)) 314*7c478bd9Sstevel@tonic-gate 315*7c478bd9Sstevel@tonic-gate #define VTOFH(vp) (RTOFH(VTOR(vp))) 316*7c478bd9Sstevel@tonic-gate #define RTOFH(rp) ((fhandle_t *)(&(rp)->r_fh.fh_buf)) 317*7c478bd9Sstevel@tonic-gate #define VTOFH3(vp) (RTOFH3(VTOR(vp))) 318*7c478bd9Sstevel@tonic-gate #define RTOFH3(rp) ((nfs_fh3 *)(&(rp)->r_fh)) 319*7c478bd9Sstevel@tonic-gate 320*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 321*7c478bd9Sstevel@tonic-gate extern int nfs_async_readahead(vnode_t *, u_offset_t, caddr_t, 322*7c478bd9Sstevel@tonic-gate struct seg *, cred_t *, 323*7c478bd9Sstevel@tonic-gate void (*)(vnode_t *, u_offset_t, 324*7c478bd9Sstevel@tonic-gate caddr_t, struct seg *, cred_t *)); 325*7c478bd9Sstevel@tonic-gate extern int nfs_async_putapage(vnode_t *, page_t *, u_offset_t, size_t, 326*7c478bd9Sstevel@tonic-gate int, cred_t *, int (*)(vnode_t *, page_t *, 327*7c478bd9Sstevel@tonic-gate u_offset_t, size_t, int, cred_t *)); 328*7c478bd9Sstevel@tonic-gate extern int nfs_async_pageio(vnode_t *, page_t *, u_offset_t, size_t, 329*7c478bd9Sstevel@tonic-gate int, cred_t *, int (*)(vnode_t *, page_t *, 330*7c478bd9Sstevel@tonic-gate u_offset_t, size_t, int, cred_t *)); 331*7c478bd9Sstevel@tonic-gate extern void nfs_async_readdir(vnode_t *, rddir_cache *, 332*7c478bd9Sstevel@tonic-gate cred_t *, int (*)(vnode_t *, 333*7c478bd9Sstevel@tonic-gate rddir_cache *, cred_t *)); 334*7c478bd9Sstevel@tonic-gate extern void nfs_async_commit(vnode_t *, page_t *, offset3, count3, 335*7c478bd9Sstevel@tonic-gate cred_t *, void (*)(vnode_t *, page_t *, 336*7c478bd9Sstevel@tonic-gate offset3, count3, cred_t *)); 337*7c478bd9Sstevel@tonic-gate extern void nfs_async_inactive(vnode_t *, cred_t *, void (*)(vnode_t *, 338*7c478bd9Sstevel@tonic-gate cred_t *)); 339*7c478bd9Sstevel@tonic-gate extern int writerp(rnode_t *, caddr_t, int, struct uio *, int); 340*7c478bd9Sstevel@tonic-gate extern int nfs_putpages(vnode_t *, u_offset_t, size_t, int, cred_t *); 341*7c478bd9Sstevel@tonic-gate extern void nfs_invalidate_pages(vnode_t *, u_offset_t, cred_t *); 342*7c478bd9Sstevel@tonic-gate extern int rfs2call(struct mntinfo *, rpcproc_t, xdrproc_t, caddr_t, 343*7c478bd9Sstevel@tonic-gate xdrproc_t, caddr_t, cred_t *, int *, enum nfsstat *, 344*7c478bd9Sstevel@tonic-gate int, struct failinfo *); 345*7c478bd9Sstevel@tonic-gate extern int rfs3call(struct mntinfo *, rpcproc_t, xdrproc_t, caddr_t, 346*7c478bd9Sstevel@tonic-gate xdrproc_t, caddr_t, cred_t *, int *, nfsstat3 *, 347*7c478bd9Sstevel@tonic-gate int, struct failinfo *); 348*7c478bd9Sstevel@tonic-gate extern void nfs_setswaplike(vnode_t *, vattr_t *); 349*7c478bd9Sstevel@tonic-gate extern vnode_t *makenfsnode(fhandle_t *, struct nfsfattr *, struct vfs *, 350*7c478bd9Sstevel@tonic-gate hrtime_t, cred_t *, char *, char *); 351*7c478bd9Sstevel@tonic-gate extern vnode_t *makenfs3node_va(nfs_fh3 *, vattr_t *, struct vfs *, hrtime_t, 352*7c478bd9Sstevel@tonic-gate cred_t *, char *, char *); 353*7c478bd9Sstevel@tonic-gate extern vnode_t *makenfs3node(nfs_fh3 *, fattr3 *, struct vfs *, hrtime_t, 354*7c478bd9Sstevel@tonic-gate cred_t *, char *, char *); 355*7c478bd9Sstevel@tonic-gate extern void rp_addfree(rnode_t *, cred_t *); 356*7c478bd9Sstevel@tonic-gate extern void rp_rmhash(rnode_t *); 357*7c478bd9Sstevel@tonic-gate extern int check_rtable(struct vfs *); 358*7c478bd9Sstevel@tonic-gate extern void destroy_rtable(struct vfs *, cred_t *); 359*7c478bd9Sstevel@tonic-gate extern void rflush(struct vfs *, cred_t *); 360*7c478bd9Sstevel@tonic-gate extern nfs_access_type_t nfs_access_check(rnode_t *, uint32_t, cred_t *); 361*7c478bd9Sstevel@tonic-gate extern void nfs_access_cache(rnode_t *rp, uint32_t, uint32_t, cred_t *); 362*7c478bd9Sstevel@tonic-gate extern int nfs_access_purge_rp(rnode_t *); 363*7c478bd9Sstevel@tonic-gate extern int nfs_putapage(vnode_t *, page_t *, u_offset_t *, size_t *, 364*7c478bd9Sstevel@tonic-gate int, cred_t *); 365*7c478bd9Sstevel@tonic-gate extern int nfs3_putapage(vnode_t *, page_t *, u_offset_t *, size_t *, 366*7c478bd9Sstevel@tonic-gate int, cred_t *); 367*7c478bd9Sstevel@tonic-gate extern void nfs_printfhandle(nfs_fhandle *); 368*7c478bd9Sstevel@tonic-gate extern void nfs_write_error(vnode_t *, int, cred_t *); 369*7c478bd9Sstevel@tonic-gate extern rddir_cache *rddir_cache_alloc(int); 370*7c478bd9Sstevel@tonic-gate extern void rddir_cache_hold(rddir_cache *); 371*7c478bd9Sstevel@tonic-gate extern void rddir_cache_rele(rddir_cache *); 372*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 373*7c478bd9Sstevel@tonic-gate extern char *rddir_cache_buf_alloc(size_t, int); 374*7c478bd9Sstevel@tonic-gate extern void rddir_cache_buf_free(void *, size_t); 375*7c478bd9Sstevel@tonic-gate #endif 376*7c478bd9Sstevel@tonic-gate extern int nfs_rw_enter_sig(nfs_rwlock_t *, krw_t, int); 377*7c478bd9Sstevel@tonic-gate extern int nfs_rw_tryenter(nfs_rwlock_t *, krw_t); 378*7c478bd9Sstevel@tonic-gate extern void nfs_rw_exit(nfs_rwlock_t *); 379*7c478bd9Sstevel@tonic-gate extern int nfs_rw_lock_held(nfs_rwlock_t *, krw_t); 380*7c478bd9Sstevel@tonic-gate extern void nfs_rw_init(nfs_rwlock_t *, char *, krw_type_t, void *); 381*7c478bd9Sstevel@tonic-gate extern void nfs_rw_destroy(nfs_rwlock_t *); 382*7c478bd9Sstevel@tonic-gate extern int nfs_directio(vnode_t *, int, cred_t *); 383*7c478bd9Sstevel@tonic-gate extern int nfs3_rddir_compar(const void *, const void *); 384*7c478bd9Sstevel@tonic-gate extern int nfs_rddir_compar(const void *, const void *); 385*7c478bd9Sstevel@tonic-gate 386*7c478bd9Sstevel@tonic-gate #endif 387*7c478bd9Sstevel@tonic-gate 388*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 389*7c478bd9Sstevel@tonic-gate } 390*7c478bd9Sstevel@tonic-gate #endif 391*7c478bd9Sstevel@tonic-gate 392*7c478bd9Sstevel@tonic-gate #endif /* _NFS_RNODE_H */ 393