rnode.h revision f8bbc5716bd2f470114db82bab03cedb9ce9d72e
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2010 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_RNODE_H
#define _NFS_RNODE_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum nfs_access_type {
typedef struct acache_hash {
typedef struct acache {
struct acache_hash *hashq;
} acache_t;
#define NFS_FHANDLE_LEN 72
typedef struct nfs_fhandle {
int fh_len;
char fh_buf[NFS_FHANDLE_LEN];
} nfs_fhandle;
typedef struct rddir_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 flags; /* control flags, see below */
int error; /* error from RPC operation */
} rddir_cache;
typedef struct symlink_cache {
char *contents; /* contents of the symbolic link */
int len; /* length of the contents */
int size; /* size of the allocated buffer */
typedef struct commit {
} commit_t;
/*
* The various values for the commit states. These are stored in
* the p_fsdata byte in the page struct.
* NFSv3,4 can use asynchronous writes - the NFS server can send a response
* before storing the data to the stable store (disk). The response contains
* information if the data are on a disk or not. NFS client marks pages
* which are already on the stable store as C_NOCOMMIT. The pages which were
* sent but are not yet on the stable store are only partially 'safe' and are
* marked as C_DELAYCOMMIT, which can be later changed to C_COMMIT if the
* commit operation is in progress. If the NFS server is e.g. rebooted, the
* client needs to resend all the uncommitted data. The client walks all the
* vp->v_pages and if C_DELAYCOMMIT or C_COMMIT is set, the page is marked as
* dirty and thus will be written to the server again.
*/
#define C_NOCOMMIT 0 /* no commit is required */
/*
* The lock manager holds state making it possible for the client
* and server to be out of sync. For example, if the response from
* the server granting a lock request is lost, the server will think
* the lock is granted and the client will think the lock is lost.
* To deal with this, a list of processes for which the client is
* not sure if the server holds a lock is attached to the rnode.
* When such a process closes the rnode, an unlock request is sent
* to the server to unlock the entire file.
*
* The list is kept as a singularly linked NULL terminated list.
* Because it is only added to under extreme error conditions, the
* list shouldn't get very big. DEBUG kernels print a console warning
* when the number of entries on a list go beyond nfs_lmpl_high_water
* an arbitrary number defined in nfs_add_locking_id()
*/
#define RLMPL_PID 1
#define RLMPL_OWNER 2
typedef struct lock_manager_pid_list {
int lmpl_type;
union {
struct {
int len;
char *owner;
} _own;
} un;
struct lock_manager_pid_list *lmpl_next;
} lmpl_t;
/*
* two requirements not addressed by the system primitives. They
* are that the `enter" operation is optionally interruptible and
* that that they can be re`enter'ed by writers without deadlock.
*/
typedef struct nfs_rwlock {
int count;
int waiters;
} nfs_rwlock_t;
/*
* The format of the hash bucket used to lookup rnodes from a file handle.
*/
typedef struct rhashq {
} rhashq_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 3 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).
*
* The following members are protected by the mutex rpfreelist_lock:
* r_freef
* r_freeb
*
* The following members are protected by the hash bucket rwlock:
* r_hashf
* r_hashb
*
* 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.
*
* r_inmap informs nfsX_read()/write() that there is a call to nfsX_map()
* in progress. nfsX_read()/write() check r_inmap to decide whether
* to perform directio on the file or not. r_inmap is atomically
* incremented in nfsX_map() before the address space routines are
* called and atomically decremented just before nfsX_map() exits.
* r_inmap is not protected by any lock.
*
* r_mapcnt tells that the rnode has mapped pages. r_inmap can be 0
* while the rnode has mapped pages.
*
* 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_statelock
*/
struct exportinfo; /* defined in nfs/export.h */
struct servinfo; /* defined in nfs/nfs_clnt.h */
struct failinfo; /* defined in nfs/nfs_clnt.h */
struct mntinfo; /* defined in nfs/nfs_clnt.h */
#ifdef _KERNEL
typedef struct rnode {
/* the hash fields must be first to match the rhashq_t */
char *r_path; /* path to this rnode */
char *r_unlname; /* unlinked file name */
long r_mapcnt; /* count of mmapped pages */
short r_error; /* async write error */
int (*r_putapage) /* address of putapage routine */
} rnode_t;
#endif /* _KERNEL */
/*
* Flags
*/
/*
* Convert between vnode and rnode
*/
#ifdef _KERNEL
void (*)(vnode_t *, u_offset_t,
rddir_cache *, cred_t *));
cred_t *, caller_context_t *));
int, struct failinfo *);
int, struct failinfo *);
cred_t *, char *, char *);
cred_t *, char *, char *);
extern int check_rtable(struct vfs *);
extern int nfs_access_purge_rp(rnode_t *);
int, cred_t *);
int, cred_t *);
extern void nfs_printfhandle(nfs_fhandle *);
extern rddir_cache *rddir_cache_alloc(int);
extern void rddir_cache_hold(rddir_cache *);
extern void rddir_cache_rele(rddir_cache *);
#ifdef DEBUG
extern char *rddir_cache_buf_alloc(size_t, int);
extern void rddir_cache_buf_free(void *, size_t);
#endif
extern void nfs_rw_exit(nfs_rwlock_t *);
extern void nfs_rw_destroy(nfs_rwlock_t *);
extern int nfs3_rddir_compar(const void *, const void *);
extern int nfs_rddir_compar(const void *, const void *);
extern zoneid_t nfs_zoneid(void);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _NFS_RNODE_H */