smbfs_node.h revision 5ecede3380b4d48e616af1e5dc4671daf3aef703
/*
* Copyright (c) 2000-2001, Boris Popov
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Boris Popov.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: smbfs_node.h,v 1.31.52.1 2005/05/27 02:35:28 lindak Exp $
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _FS_SMBFS_NODE_H_
#define _FS_SMBFS_NODE_H_
/*
* Much code copied into here from Sun NFS.
*/
#ifdef __cplusplus
extern "C" {
#endif
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;
/*
* 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 smbfs_rwlock {
int count;
int waiters;
/*
* The format of the hash bucket used to lookup smbnodes from a file handle.
*/
typedef struct rhashq {
} rhashq_t;
/*
* Remote file information structure.
*
* The smbnode 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 smbnode: 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 (smbfs_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 smbnode has 3 locks associated with it (not including the smbnode
* hash table and free list locks):
*
* r_rwlock: Serializes smbfs_write and smbfs_setattr requests
* and allows smbfs_read requests to proceed in parallel.
*
* r_lkserlock: Serializes lock requests with map, write, and
* readahead operations.
*
* r_statelock: Protects all fields in the smbnode 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.
*
* 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 smbfs/export.h */
struct failinfo; /* defined in smbfs/smbfs_clnt.h */
struct mntinfo; /* defined in smbfs/smbfs_clnt.h */
#ifdef _KERNEL
/* Bits for smbnode.n_flag */
#define NFLUSHINPROG 0x00001
#define NGOTIDS 0x00020
#define NISMAPPED 0x00800
#define NFLUSHWIRE 0x01000
typedef struct smbnode {
/* from Sun NFS struct rnode (XXX: cleanup needed) */
/* the hash fields must be first to match the rhashq_t */
/* Lock for the hash queue is: np->r_hashq->r_lock */
/* Lock for the free list is: smbfreelist_lock */
long r_mapcnt; /* count of mmapped pages */
short r_error; /* async write error */
/*
* Members derived from Darwin struct smbnode.
* Note: n_parent node pointer removed because it
* caused unwanted "holds" on nodes in our cache.
* Now keeping just the full remote path instead,
* in server form, relative to the share root.
*/
char *n_rpath;
int n_rplen;
/* Lock for the next 7 is r_lkserlock */
int n_dirrefs;
int n_dirofs; /* last ff offset */
int n_vcgenid; /* gereration no. (reconnect) */
int n_fidrefs;
/* Lock for the rest is r_statelock */
int n_dosattr;
/*
* XXX: Maybe use this instead:
* #define n_atime r_attr.va_atime
* etc.
*/
#define n_attrage r_attrtime
} smbnode_t;
#endif /* _KERNEL */
/*
* Flags
*/
/*
* Convert between vnode and smbnode
*/
/* Attribute cache timeouts in seconds */
#define SMB_MINATTRTIMO 2
#define SMB_MAXATTRTIMO 30
/*
* Function definitions.
*/
struct smb_cred;
#ifdef __cplusplus
}
#endif
#endif /* _FS_SMBFS_NODE_H_ */