2005-01-07 01:45:51 +00:00
|
|
|
/*-
|
2017-11-20 19:43:44 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
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.
|
2017-02-28 23:42:47 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-05-24 10:09:53 +00:00
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
2001-09-18 23:32:09 +00:00
|
|
|
#ifndef _NFSCLIENT_NFSNODE_H_
|
|
|
|
#define _NFSCLIENT_NFSNODE_H_
|
1997-02-10 02:22:35 +00:00
|
|
|
|
2011-08-02 11:24:42 +00:00
|
|
|
#include <sys/_task.h>
|
2001-09-18 23:32:09 +00:00
|
|
|
#if !defined(_NFSCLIENT_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 {
|
2011-08-02 11:24:42 +00:00
|
|
|
struct task s_task;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct ucred *s_cred;
|
|
|
|
struct vnode *s_dvp;
|
2003-11-14 20:54:10 +00:00
|
|
|
int (*s_removeit)(struct sillyrename *sp);
|
1994-05-24 10:09:53 +00:00
|
|
|
long s_namlen;
|
2004-12-16 19:28:37 +00:00
|
|
|
char s_name[32];
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
|
|
|
|
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;
|
2003-11-14 20:54:10 +00:00
|
|
|
union {
|
|
|
|
nfsuint64 ndmu3_cookies[NFSNUMCOOKIES];
|
|
|
|
uint64_t ndmu4_cookies[NFSNUMCOOKIES];
|
|
|
|
} ndm_un1;
|
1995-06-27 11:07:30 +00:00
|
|
|
};
|
|
|
|
|
2003-11-14 20:54:10 +00:00
|
|
|
#define ndm_cookies ndm_un1.ndmu3_cookies
|
|
|
|
#define ndm4_cookies ndm_un1.ndmu4_cookies
|
|
|
|
|
2009-03-20 21:12:38 +00:00
|
|
|
struct nfs_accesscache {
|
|
|
|
u_int32_t mode; /* ACCESS mode cache */
|
|
|
|
uid_t uid; /* credentials having mode */
|
|
|
|
time_t stamp; /* mode cache timestamp */
|
|
|
|
};
|
|
|
|
|
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
|
2018-01-25 22:25:13 +00:00
|
|
|
* 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 {
|
2006-05-19 00:04:24 +00:00
|
|
|
struct mtx n_mtx; /* Protects all of these members */
|
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 */
|
2009-03-20 21:12:38 +00:00
|
|
|
struct nfs_accesscache n_accesscache[NFS_ACCESSCACHESIZE];
|
2004-12-06 19:18:00 +00:00
|
|
|
struct timespec n_mtime; /* Prev modify time. */
|
1995-06-27 11:07:30 +00:00
|
|
|
nfsfh_t *n_fhp; /* NFS File Handle */
|
|
|
|
struct vnode *n_vnode; /* associated vnode */
|
2003-11-14 20:54:10 +00:00
|
|
|
struct vnode *n_dvp; /* parent vnode */
|
1995-06-27 11:07:30 +00:00
|
|
|
int n_error; /* Save write error value */
|
|
|
|
union {
|
|
|
|
struct timespec nf_atim; /* Special file times */
|
|
|
|
nfsuint64 nd_cookieverf; /* Cookie verifier (dir only) */
|
2003-11-14 20:54:10 +00:00
|
|
|
u_char nd4_cookieverf[NFSX_V4VERF];
|
1995-06-27 11:07:30 +00:00
|
|
|
} 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 */
|
2003-11-22 02:21:49 +00:00
|
|
|
u_char *n_name; /* leaf name, for v4 OPEN op */
|
2003-11-14 20:54:10 +00:00
|
|
|
uint32_t n_namelen;
|
2004-12-15 22:20:22 +00:00
|
|
|
int n_directio_opens;
|
2006-05-19 00:04:24 +00:00
|
|
|
int n_directio_asyncwr;
|
2012-05-12 12:02:51 +00:00
|
|
|
struct ucred *n_writecred; /* Cred. for putpages */
|
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
|
2003-11-14 20:54:10 +00:00
|
|
|
#define n4_cookieverf n_un1.nd4_cookieverf
|
1995-06-27 11:07:30 +00:00
|
|
|
#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
|
|
|
|
*/
|
2006-05-19 00:04:24 +00:00
|
|
|
#define NFSYNCWAIT 0x0002 /* fsync waiting for all directio async writes
|
|
|
|
to drain */
|
1994-05-24 10:09:53 +00:00
|
|
|
#define NMODIFIED 0x0004 /* Might have a modified buffer in bio */
|
|
|
|
#define NWRITEERR 0x0008 /* Flag write errors so close will know */
|
2001-09-18 23:32:09 +00:00
|
|
|
/* 0x20, 0x40, 0x80 free */
|
1994-05-24 10:09:53 +00:00
|
|
|
#define NACC 0x0100 /* Special file accessed */
|
|
|
|
#define NUPD 0x0200 /* Special file updated */
|
|
|
|
#define NCHG 0x0400 /* Special file times changed */
|
2003-11-14 20:54:10 +00:00
|
|
|
#define NCREATED 0x0800 /* Opened by nfs_create() */
|
|
|
|
#define NTRUNCATE 0x1000 /* Opened by nfs_setattr() */
|
2004-04-14 23:23:55 +00:00
|
|
|
#define NSIZECHANGED 0x2000 /* File size has changed: need cache inval */
|
2004-12-15 22:20:22 +00:00
|
|
|
#define NNONCACHE 0x4000 /* Node marked as noncacheable */
|
2006-05-19 00:04:24 +00:00
|
|
|
#define NDIRCOOKIELK 0x8000 /* Lock to serialize access to directory cookies */
|
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)
|
|
|
|
|
2004-12-06 19:18:00 +00:00
|
|
|
#define NFS_TIMESPEC_COMPARE(T1, T2) (((T1)->tv_sec != (T2)->tv_sec) || ((T1)->tv_nsec != (T2)->tv_nsec))
|
|
|
|
|
2010-01-27 15:22:20 +00:00
|
|
|
/*
|
2010-10-18 19:06:46 +00:00
|
|
|
* NFS iod threads can be in one of these two states once spawned.
|
2010-01-27 15:22:20 +00:00
|
|
|
* NFSIOD_NOT_AVAILABLE - Cannot be assigned an I/O operation at this time.
|
|
|
|
* NFSIOD_AVAILABLE - Available to be assigned an I/O operation.
|
|
|
|
*/
|
|
|
|
enum nfsiod_state {
|
|
|
|
NFSIOD_NOT_AVAILABLE = 0,
|
|
|
|
NFSIOD_AVAILABLE = 1,
|
|
|
|
};
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Queue head for nfsiod's
|
|
|
|
*/
|
2000-05-26 02:09:24 +00:00
|
|
|
extern TAILQ_HEAD(nfs_bufq, buf) nfs_bufq;
|
2010-01-27 15:22:20 +00:00
|
|
|
extern enum nfsiod_state nfs_iodwant[NFS_MAXASYNCDAEMON];
|
1996-11-06 10:53:16 +00:00
|
|
|
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
|
|
|
|
2004-12-01 23:16:38 +00:00
|
|
|
extern struct vop_vector nfs_fifoops;
|
|
|
|
extern struct vop_vector nfs_vnodeops;
|
2004-10-24 20:03:41 +00:00
|
|
|
extern struct buf_ops buf_ops_nfs;
|
2003-11-14 20:54:10 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Prototypes for NFS vnode operations
|
|
|
|
*/
|
2001-09-18 23:32:09 +00:00
|
|
|
int nfs_getpages(struct vop_getpages_args *);
|
|
|
|
int nfs_putpages(struct vop_putpages_args *);
|
|
|
|
int nfs_write(struct vop_write_args *);
|
|
|
|
int nfs_inactive(struct vop_inactive_args *);
|
|
|
|
int nfs_reclaim(struct vop_reclaim_args *);
|
1994-10-02 17:27:07 +00:00
|
|
|
|
|
|
|
/* other stuff */
|
2001-09-18 23:32:09 +00:00
|
|
|
int nfs_removeit(struct sillyrename *);
|
2006-09-13 18:39:09 +00:00
|
|
|
int nfs_nget(struct mount *, nfsfh_t *, int, struct nfsnode **, int flags);
|
2001-09-18 23:32:09 +00:00
|
|
|
nfsuint64 *nfs_getcookie(struct nfsnode *, off_t, int);
|
|
|
|
void nfs_invaldir(struct vnode *);
|
2008-02-09 20:13:19 +00:00
|
|
|
int nfs_upgrade_vnlock(struct vnode *vp);
|
|
|
|
void nfs_downgrade_vnlock(struct vnode *vp, int old_lock);
|
2006-05-19 00:04:24 +00:00
|
|
|
void nfs_printf(const char *fmt, ...);
|
|
|
|
|
|
|
|
void nfs_dircookie_lock(struct nfsnode *np);
|
|
|
|
void nfs_dircookie_unlock(struct nfsnode *np);
|
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
|