1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1989, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Rick Macklem at The University of Guelph.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
|
|
|
*
|
1997-02-10 02:22:35 +00:00
|
|
|
* @(#)nfsnode.h 8.9 (Berkeley) 5/14/95
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1994-08-21 06:50:16 +00:00
|
|
|
#ifndef _NFS_NFSNODE_H_
|
|
|
|
#define _NFS_NFSNODE_H_
|
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
#if !defined(_NFS_NFS_H_) && !defined(_KERNEL)
|
1995-06-27 11:07:30 +00:00
|
|
|
#include <nfs/nfs.h>
|
|
|
|
#endif
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Silly rename structure that hangs off the nfsnode until the name
|
|
|
|
* can be removed by nfs_inactive()
|
|
|
|
*/
|
|
|
|
struct sillyrename {
|
|
|
|
struct ucred *s_cred;
|
|
|
|
struct vnode *s_dvp;
|
|
|
|
long s_namlen;
|
|
|
|
char s_name[20];
|
|
|
|
};
|
|
|
|
|
1995-06-27 11:07:30 +00:00
|
|
|
/*
|
|
|
|
* This structure is used to save the logical directory offset to
|
|
|
|
* NFS cookie mappings.
|
|
|
|
* The mappings are stored in a list headed
|
|
|
|
* by n_cookies, as required.
|
|
|
|
* There is one mapping for each NFS_DIRBLKSIZ bytes of directory information
|
|
|
|
* stored in increasing logical offset byte order.
|
|
|
|
*/
|
|
|
|
#define NFSNUMCOOKIES 31
|
|
|
|
|
|
|
|
struct nfsdmap {
|
2000-05-26 02:09:24 +00:00
|
|
|
LIST_ENTRY(nfsdmap) ndm_list;
|
1995-06-27 11:07:30 +00:00
|
|
|
int ndm_eocookie;
|
|
|
|
nfsuint64 ndm_cookies[NFSNUMCOOKIES];
|
|
|
|
};
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* The nfsnode is the nfs equivalent to ufs's inode. Any similarity
|
|
|
|
* is purely coincidental.
|
|
|
|
* There is a unique nfsnode allocated for each active file,
|
|
|
|
* each current directory, each mounted-on file, text file, and the root.
|
|
|
|
* An nfsnode is 'named' by its file handle. (nget/nfs_node.c)
|
1995-06-27 11:07:30 +00:00
|
|
|
* If this structure exceeds 256 bytes (it is currently 256 using 4.4BSD-Lite
|
|
|
|
* type definitions), file handles of > 32 bytes should probably be split out
|
|
|
|
* into a separate MALLOC()'d data structure. (Reduce the size of nfsfh_t by
|
1998-05-31 18:32:23 +00:00
|
|
|
* changing the definition in nfsproto.h of NFS_SMALLFH.)
|
1995-06-27 11:07:30 +00:00
|
|
|
* NB: Hopefully the current order of the fields is such that everything will
|
|
|
|
* be well aligned and, therefore, tightly packed.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
struct nfsnode {
|
2000-05-26 02:09:24 +00:00
|
|
|
LIST_ENTRY(nfsnode) n_hash; /* Hash chain */
|
2000-11-14 08:00:39 +00:00
|
|
|
TAILQ_ENTRY(nfsnode) n_timer; /* Nqnfs timer chain */
|
1995-06-27 11:07:30 +00:00
|
|
|
u_quad_t n_size; /* Current size of file */
|
|
|
|
u_quad_t n_brev; /* Modify rev when cached */
|
|
|
|
u_quad_t n_lrev; /* Modify rev for lease */
|
|
|
|
struct vattr n_vattr; /* Vnode attribute cache */
|
|
|
|
time_t n_attrstamp; /* Attr. cache timestamp */
|
1998-11-13 02:39:09 +00:00
|
|
|
u_int32_t n_mode; /* ACCESS mode cache */
|
Reimplement the NFS ACCESS RPC cache as an "accelerator" rather than a true
cache. If the cached result lets us say "yes", then go with that. If
we're not sure, or we think the answer might be "no", go to the wire to be
certain. This avoids all of the possible false veto cases, and allows us
to key the cached value with just the UID for which the cached value holds,
reducing the bloat of the nfsnode structure from 104 bytes to just 12 bytes.
Since the "yes" case is by far the most common, this should still provide
a substantial performance improvement. Also default the cache to on, with
a conservative timeout (2 seconds). This improves performance if NFS is
loaded as a KLD module, as there's not (yet) code to parse an option out
of the module arguments to set it, and sysctl doesn't work (yet) for OIDs
in modules.
The 'accelerator' mode was suggested by Bjoern Groenvall (bg@sics.se)
Feedback on this would be appreciated as testing has been necessarily
limited by Comdex, and it would be valuable to have this in 2.2.8.
1998-11-15 20:36:18 +00:00
|
|
|
uid_t n_modeuid; /* credentials having mode */
|
1998-11-13 02:39:09 +00:00
|
|
|
time_t n_modestamp; /* mode cache timestamp */
|
1995-06-27 11:07:30 +00:00
|
|
|
time_t n_mtime; /* Prev modify time. */
|
|
|
|
time_t n_ctime; /* Prev create time. */
|
|
|
|
time_t n_expiry; /* Lease expiry time */
|
|
|
|
nfsfh_t *n_fhp; /* NFS File Handle */
|
|
|
|
struct vnode *n_vnode; /* associated vnode */
|
|
|
|
struct lockf *n_lockf; /* Locking record of file */
|
|
|
|
int n_error; /* Save write error value */
|
|
|
|
union {
|
|
|
|
struct timespec nf_atim; /* Special file times */
|
|
|
|
nfsuint64 nd_cookieverf; /* Cookie verifier (dir only) */
|
|
|
|
} n_un1;
|
|
|
|
union {
|
|
|
|
struct timespec nf_mtim;
|
|
|
|
off_t nd_direof; /* Dir. EOF offset cache */
|
|
|
|
} n_un2;
|
|
|
|
union {
|
|
|
|
struct sillyrename *nf_silly; /* Ptr to silly rename struct */
|
2000-05-26 02:09:24 +00:00
|
|
|
LIST_HEAD(, nfsdmap) nd_cook; /* cookies */
|
1995-06-27 11:07:30 +00:00
|
|
|
} n_un3;
|
|
|
|
short n_fhsize; /* size in bytes, of fh */
|
|
|
|
short n_flag; /* Flag for locking.. */
|
|
|
|
nfsfh_t n_fh; /* Small File Handle */
|
1999-12-14 19:07:54 +00:00
|
|
|
struct lock n_rslock;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
|
|
|
|
1995-06-27 11:07:30 +00:00
|
|
|
#define n_atim n_un1.nf_atim
|
|
|
|
#define n_mtim n_un2.nf_mtim
|
|
|
|
#define n_sillyrename n_un3.nf_silly
|
|
|
|
#define n_cookieverf n_un1.nd_cookieverf
|
|
|
|
#define n_direofoffset n_un2.nd_direof
|
|
|
|
#define n_cookies n_un3.nd_cook
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Flags for n_flag
|
|
|
|
*/
|
|
|
|
#define NFLUSHWANT 0x0001 /* Want wakeup from a flush in prog. */
|
|
|
|
#define NFLUSHINPROG 0x0002 /* Avoid multiple calls to vinvalbuf() */
|
|
|
|
#define NMODIFIED 0x0004 /* Might have a modified buffer in bio */
|
|
|
|
#define NWRITEERR 0x0008 /* Flag write errors so close will know */
|
|
|
|
#define NQNFSNONCACHE 0x0020 /* Non-cachable lease */
|
|
|
|
#define NQNFSWRITE 0x0040 /* Write lease */
|
|
|
|
#define NQNFSEVICTED 0x0080 /* Has been evicted */
|
|
|
|
#define NACC 0x0100 /* Special file accessed */
|
|
|
|
#define NUPD 0x0200 /* Special file updated */
|
|
|
|
#define NCHG 0x0400 /* Special file times changed */
|
1995-06-27 11:07:30 +00:00
|
|
|
#define NLOCKED 0x0800 /* node is locked */
|
|
|
|
#define NWANTED 0x0100 /* someone wants to lock */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert between nfsnode pointers and vnode pointers
|
|
|
|
*/
|
|
|
|
#define VTONFS(vp) ((struct nfsnode *)(vp)->v_data)
|
|
|
|
#define NFSTOV(np) ((struct vnode *)(np)->n_vnode)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Queue head for nfsiod's
|
|
|
|
*/
|
2000-05-26 02:09:24 +00:00
|
|
|
extern TAILQ_HEAD(nfs_bufq, buf) nfs_bufq;
|
1996-11-06 10:53:16 +00:00
|
|
|
extern struct proc *nfs_iodwant[NFS_MAXASYNCDAEMON];
|
|
|
|
extern struct nfsmount *nfs_iodmount[NFS_MAXASYNCDAEMON];
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
#if defined(_KERNEL)
|
1999-12-14 19:07:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* nfs_rslock - Attempt to obtain lock on nfsnode
|
|
|
|
*
|
|
|
|
* Attempt to obtain a lock on the passed nfsnode, returning ENOLCK
|
|
|
|
* if the lock could not be obtained due to our having to sleep. This
|
|
|
|
* function is generally used to lock around code that modifies an
|
|
|
|
* NFS file's size. In order to avoid deadlocks the lock
|
|
|
|
* should not be obtained while other locks are being held.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
nfs_rslock(struct nfsnode *np, struct thread *td)
|
1999-12-14 19:07:54 +00:00
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
return(lockmgr(&np->n_rslock, LK_EXCLUSIVE | LK_CANRECURSE | LK_SLEEPFAIL, NULL, td));
|
1999-12-14 19:07:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
void
|
2001-09-12 08:38:13 +00:00
|
|
|
nfs_rsunlock(struct nfsnode *np, struct thread *td)
|
1999-12-14 19:07:54 +00:00
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
(void)lockmgr(&np->n_rslock, LK_RELEASE, NULL, td);
|
1999-12-14 19:07:54 +00:00
|
|
|
}
|
|
|
|
|
1995-11-09 08:17:23 +00:00
|
|
|
extern vop_t **fifo_nfsv2nodeop_p;
|
|
|
|
extern vop_t **nfsv2_vnodeop_p;
|
|
|
|
extern vop_t **spec_nfsv2nodeop_p;
|
1995-03-16 18:17:34 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Prototypes for NFS vnode operations
|
|
|
|
*/
|
1997-05-19 14:36:56 +00:00
|
|
|
int nfs_getpages __P((struct vop_getpages_args *));
|
1998-03-06 09:46:52 +00:00
|
|
|
int nfs_putpages __P((struct vop_putpages_args *));
|
1994-05-24 10:09:53 +00:00
|
|
|
int nfs_write __P((struct vop_write_args *));
|
1997-02-10 02:22:35 +00:00
|
|
|
int nqnfs_vop_lease_check __P((struct vop_lease_args *));
|
1994-05-24 10:09:53 +00:00
|
|
|
int nfs_inactive __P((struct vop_inactive_args *));
|
|
|
|
int nfs_reclaim __P((struct vop_reclaim_args *));
|
1994-10-02 17:27:07 +00:00
|
|
|
|
|
|
|
/* other stuff */
|
|
|
|
int nfs_removeit __P((struct sillyrename *));
|
1995-06-27 11:07:30 +00:00
|
|
|
int nfs_nget __P((struct mount *,nfsfh_t *,int,struct nfsnode **));
|
|
|
|
nfsuint64 *nfs_getcookie __P((struct nfsnode *, off_t, int));
|
|
|
|
void nfs_invaldir __P((struct vnode *));
|
|
|
|
|
|
|
|
#define nqnfs_lease_updatetime nfs_lease_updatetime
|
1994-10-02 17:27:07 +00:00
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
#endif /* _KERNEL */
|
1994-08-21 06:50:16 +00:00
|
|
|
|
|
|
|
#endif
|