rnode4.h revision 2d1fef9794dcbfc8f70207f189fcb4500bb98970
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#ifndef _NFS_RNODE4_H
#define _NFS_RNODE4_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <nfs/nfs4_clnt.h>
typedef enum nfs4_access_type {
/*
* Access cache
*/
typedef struct acache4_hash {
typedef struct acache4 {
struct acache4_hash *hashq;
} acache4_t;
/*
* Note on the different buffer sizes in rddir4_cache:
* There seems to be some discrepancy between the intended and actual
* use of entlen and buflen, which does not correspond to the comment below.
* entlen - nfsv2/3 used as both alloc'd size of entries buffer and
* as the actual size of the entries (XXX is this correct?).
* nfsv4 will use it only as the alloc'd size.
* buflen - used for calculations of readahead.
* actlen - added for nfsv4 to serve as the size of the useful
* portion of the entries buffer. That is because in
* nfsv4, the otw entries are converted to system entries,
* and may not be the same size - thus buffer may not be full.
*/
typedef struct rddir4_cache {
char *entries; /* buffer containing dirent entries */
int eof; /* EOF reached after this request */
int entlen; /* size of dirent entries in buf */
int buflen; /* size of the buffer used to store entries */
int actlen; /* size of the actual entries (nfsv4 only) */
int flags; /* control flags, see below */
int error; /* error from RPC operation */
void *data; /* private data */
} rddir4_cache;
/*
* Shadow vnode, v4 only.
*
* A file's shadow vnode list is protected by its hash bucket lock,
* r_hashq->r_lock.
*
* sv_r_vnode is protected by the appropriate vnode locks.
*
* sv_dfh, sv_name, sv_dfileid, and sv_dfileid_valid are protected
* by rp->r_svlock.
*/
typedef struct insq_link {
void *forw;
void *back;
} insq_link_t;
typedef struct svnode {
} svnode_t;
/*
* The format of the hash bucket used to lookup rnodes from a file handle.
*/
typedef struct r4hashq {
} r4hashq_t;
/*
* Remote file information structure.
*
* The rnode is the "inode" for remote files. It contains all the
* information necessary to handle remote file on the client side.
*
* Note on file sizes: we keep two file sizes in the rnode: the size
* according to the client (r_size) and the size according to the server
* (r_attr.va_size). They can differ because we modify r_size during a
* write system call (nfs_rdwr), before the write request goes over the
* wire (before the file is actually modified on the server). If an OTW
* request occurs before the cached data is written to the server the file
* size returned from the server (r_attr.va_size) may not match r_size.
* r_size is the one we use, in general. r_attr.va_size is only used to
* determine whether or not our cached data is valid.
*
* Each rnode has 5 locks associated with it (not including the rnode
* hash table and free list locks):
*
* r_rwlock: Serializes nfs_write and nfs_setattr requests
* and allows nfs_read requests to proceed in parallel.
*
* r_lkserlock: Serializes lock requests with map, write, and
* readahead operations.
*
* r_statelock: Protects all fields in the rnode except for
* those listed below. This lock is intented
* to be held for relatively short periods of
* time (not accross entire putpage operations,
* for example).
*
* r_statev4_lock: Protects the created_v4 flag, the lock_owners list,
* and all the delegation fields except r_deleg_list.
*
* r_os_lock: Protects r_open_streams.
*
*
* The following members are protected by the mutex rp4freelist_lock:
* r_freef
* r_freeb
*
* The following members are protected by the hash bucket rwlock:
* r_hashf
* r_hashb
*
* r_fh is read-only except when an rnode is created (or recycled from the
* free list).
*
* The following members are protected by nfs4_server_t::s_lock:
* r_deleg_list
*
* Note: r_modaddr is only accessed when the r_statelock mutex is held.
* Its value is also controlled via r_rwlock. It is assumed that
* there will be only 1 writer active at a time, so it safe to
* set r_modaddr and release r_statelock as long as the r_rwlock
* writer lock is held.
*
* 64-bit offsets: the code formerly assumed that atomic reads of
* r_size were safe and reliable; on 32-bit architectures, this is
* not true since an intervening bus cycle from another processor
* could update half of the size field. The r_statelock must now
* be held whenever any kind of access of r_size is made.
*
* Lock ordering:
* r_rwlock > r_lkserlock > r_os_lock > r_statelock > r_statev4_lock
* vnode_t::v_lock > r_os_lock
*/
struct exportinfo; /* defined in nfs/export.h */
struct servinfo4; /* defined in nfs/nfs4_clnt.h */
struct failinfo; /* defined in nfs/nfs_clnt.h */
struct mntinfo4; /* defined in nfs/nfs4_clnt.h */
typedef struct rnode4 {
/* the hash fields must be first to match the rhashq_t */
struct servinfo4
*r_server; /* current server */
short r_error; /* async write error */
char *r_unlname; /* unlinked file name */
int r_delay_interval; /* Number of Secs of last DELAY */
long r_mapcnt; /* count of mmapped pages */
int (*r_putapage) /* address of putapage routine */
void *r_dir; /* cache of readdir responses */
r_lo_head; /* lock owners list head */
int created_v4; /* 1 if file has been created in v4 */
/* delegated rnodes for this server */
r_deleg_type; /* type of delegation granted */
/* delegation state id */
r_deleg_limit; /* file limits returned from */
/* server on delegated open */
/* server on delegated open */
/* change @ write deleg grant */
/* delegation was granted */
/* delegation needs recovery */
/* This contains the delegation type */
/* for use with CLAIM_PREVIOUS. */
/* OPEN_DELEGATE_NONE means recovery */
/* is not needed. */
unsigned r_deleg_needs_recall:1;
/* delegation has been recalled by */
/* the server during open with */
/* CLAIM_PREVIOUS */
unsigned r_deleg_return_pending:1;
/* delegreturn is pending, don't use */
/* the delegation stateid, set in */
/* nfs4_dlistadd */
unsigned r_deleg_return_inprog:1;
/* delegreturn is in progress, may */
/* only be set by nfs4delegreturn. */
/* lock for synchronizing delegreturn */
/* with in other operations, acquired */
/* in read mode by nfs4_start_fop, */
/* acquired in write mode in */
/* nfs4delegreturn */
/* should always request change */
/* when rnode created; compare with */
/* sv_fsid (servinfo4_t) to see why */
/* R4SRVSTUB was set */
} rnode4_t;
/*
* Flags
*/
/*
* Convert between vnode and rnode
*/
/*
* Open file instances.
*/
typedef struct nfs4_opinst {
#ifdef _KERNEL
extern long nrnode;
/* Used for r_delay_interval */
#define NFS4_INITIAL_DELAY_INTERVAL 1
#define NFS4_MAX_DELAY_INTERVAL 20
extern int check_rtable4(struct vfs *);
extern void rp4_addhash(rnode4_t *);
extern void rp4_rmhash(rnode4_t *);
extern void rp4_rmhash_locked(rnode4_t *);
extern int rtable4hash(nfs4_sharedfh_t *);
extern void r4releopenlist(nfs4_opinst_t *);
/* Access cache calls */
extern int nfs4_access_purge_rp(rnode4_t *);
extern int nfs4_free_data_reclaim(rnode4_t *);
extern void nfs4_rnode_invalidate(struct vfs *);
/* shadow vnode functions */
extern void sv_update_path(vnode_t *, char *, char *);
extern void sv_inactive(vnode_t *);
extern void sv_exchange(vnode_t **);
extern void nfs4_clear_open_streams(rnode4_t *);
/*
* Mark cached attributes as timed out
*
* The caller must not be holding the rnode r_statelock mutex.
*/
#define PURGE_ATTRCACHE4_LOCKED(rp) \
#define PURGE_ATTRCACHE4(vp) { \
}
extern void nfs4delegabandon(rnode4_t *);
nfs4_open_owner_t **, nfs4_open_stream_t **,
nfs4_lock_owner_t **);
/*
* Defines for the flag argument of nfs4delegreturn
*/
extern int nfs4delegreturn(rnode4_t *, int);
extern void nfs4_delegreturn_all(nfs4_server_t *);
nfs4_ga_res_t *, cred_t *);
extern void nfs4_dlistclean(void);
extern void rddir4_cache_create(rnode4_t *);
extern void rddir4_cache_purge(rnode4_t *);
extern void rddir4_cache_destroy(rnode4_t *);
#ifdef DEBUG
extern char *rddir4_cache_buf_alloc(size_t, int);
extern void rddir4_cache_buf_free(void *, size_t);
#endif
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _NFS_RNODE4_H */