138414Smckusick /* 263236Sbostic * Copyright (c) 1989, 1993 363236Sbostic * The Regents of the University of California. All rights reserved. 438414Smckusick * 538414Smckusick * This code is derived from software contributed to Berkeley by 638414Smckusick * Rick Macklem at The University of Guelph. 738414Smckusick * 844515Sbostic * %sccs.include.redist.c% 938414Smckusick * 10*68653Smckusick * @(#)nfsnode.h 8.8 (Berkeley) 03/30/95 1138414Smckusick */ 1238414Smckusick 13*68653Smckusick 14*68653Smckusick #ifndef _NFS_NFSNODE_H_ 15*68653Smckusick #define _NFS_NFSNODE_H_ 16*68653Smckusick 17*68653Smckusick #ifndef _NFS_NFS_H_ 18*68653Smckusick #include <nfs/nfs.h> 19*68653Smckusick #endif 20*68653Smckusick 2138414Smckusick /* 2252196Smckusick * Silly rename structure that hangs off the nfsnode until the name 2352196Smckusick * can be removed by nfs_inactive() 2452196Smckusick */ 2552196Smckusick struct sillyrename { 2652196Smckusick struct ucred *s_cred; 2752196Smckusick struct vnode *s_dvp; 2852196Smckusick long s_namlen; 2952196Smckusick char s_name[20]; 3052196Smckusick }; 3152196Smckusick 3252196Smckusick /* 33*68653Smckusick * This structure is used to save the logical directory offset to 34*68653Smckusick * NFS cookie mappings. 35*68653Smckusick * The mappings are stored in a list headed 36*68653Smckusick * by n_cookies, as required. 37*68653Smckusick * There is one mapping for each NFS_DIRBLKSIZ bytes of directory information 38*68653Smckusick * stored in increasing logical offset byte order. 39*68653Smckusick */ 40*68653Smckusick #define NFSNUMCOOKIES 31 41*68653Smckusick 42*68653Smckusick struct nfsdmap { 43*68653Smckusick LIST_ENTRY(nfsdmap) ndm_list; 44*68653Smckusick int ndm_eocookie; 45*68653Smckusick nfsuint64 ndm_cookies[NFSNUMCOOKIES]; 46*68653Smckusick }; 47*68653Smckusick 48*68653Smckusick /* 4938414Smckusick * The nfsnode is the nfs equivalent to ufs's inode. Any similarity 5038414Smckusick * is purely coincidental. 5138414Smckusick * There is a unique nfsnode allocated for each active file, 5238414Smckusick * each current directory, each mounted-on file, text file, and the root. 5338414Smckusick * An nfsnode is 'named' by its file handle. (nget/nfs_node.c) 54*68653Smckusick * If this structure exceeds 256 bytes (it is currently 256 using 4.4BSD-Lite 55*68653Smckusick * type definitions), file handles of > 32 bytes should probably be split out 56*68653Smckusick * into a separate MALLOC()'d data structure. (Reduce the size of nfsfh_t by 57*68653Smckusick * changing the definition in sys/mount.h of NFS_SMALLFH.) 58*68653Smckusick * NB: Hopefully the current order of the fields is such that everything will 59*68653Smckusick * be well aligned and, therefore, tightly packed. 6038414Smckusick */ 6138414Smckusick struct nfsnode { 62*68653Smckusick LIST_ENTRY(nfsnode) n_hash; /* Hash chain */ 63*68653Smckusick CIRCLEQ_ENTRY(nfsnode) n_timer; /* Nqnfs timer chain */ 64*68653Smckusick u_quad_t n_size; /* Current size of file */ 65*68653Smckusick u_quad_t n_brev; /* Modify rev when cached */ 66*68653Smckusick u_quad_t n_lrev; /* Modify rev for lease */ 67*68653Smckusick struct vattr n_vattr; /* Vnode attribute cache */ 68*68653Smckusick time_t n_attrstamp; /* Attr. cache timestamp */ 69*68653Smckusick time_t n_mtime; /* Prev modify time. */ 70*68653Smckusick time_t n_ctime; /* Prev create time. */ 71*68653Smckusick time_t n_expiry; /* Lease expiry time */ 72*68653Smckusick nfsfh_t *n_fhp; /* NFS File Handle */ 73*68653Smckusick struct vnode *n_vnode; /* associated vnode */ 74*68653Smckusick struct lockf *n_lockf; /* Locking record of file */ 75*68653Smckusick int n_error; /* Save write error value */ 76*68653Smckusick union { 77*68653Smckusick struct timespec nf_atim; /* Special file times */ 78*68653Smckusick nfsuint64 nd_cookieverf; /* Cookie verifier (dir only) */ 79*68653Smckusick } n_un1; 80*68653Smckusick union { 81*68653Smckusick struct timespec nf_mtim; 82*68653Smckusick off_t nd_direof; /* Dir. EOF offset cache */ 83*68653Smckusick } n_un2; 84*68653Smckusick union { 85*68653Smckusick struct sillyrename *nf_silly; /* Ptr to silly rename struct */ 86*68653Smckusick LIST_HEAD(, nfsdmap) nd_cook; /* cookies */ 87*68653Smckusick } n_un3; 88*68653Smckusick short n_fhsize; /* size in bytes, of fh */ 89*68653Smckusick short n_flag; /* Flag for locking.. */ 90*68653Smckusick nfsfh_t n_fh; /* Small File Handle */ 9138414Smckusick }; 9238414Smckusick 93*68653Smckusick #define n_atim n_un1.nf_atim 94*68653Smckusick #define n_mtim n_un2.nf_mtim 95*68653Smckusick #define n_sillyrename n_un3.nf_silly 96*68653Smckusick #define n_cookieverf n_un1.nd_cookieverf 97*68653Smckusick #define n_direofoffset n_un2.nd_direof 98*68653Smckusick #define n_cookies n_un3.nd_cook 99*68653Smckusick 10038414Smckusick /* 10138414Smckusick * Flags for n_flag 10238414Smckusick */ 10357776Smckusick #define NFLUSHWANT 0x0001 /* Want wakeup from a flush in prog. */ 10456660Smckusick #define NFLUSHINPROG 0x0002 /* Avoid multiple calls to vinvalbuf() */ 10552196Smckusick #define NMODIFIED 0x0004 /* Might have a modified buffer in bio */ 10652196Smckusick #define NWRITEERR 0x0008 /* Flag write errors so close will know */ 10752196Smckusick #define NQNFSNONCACHE 0x0020 /* Non-cachable lease */ 10852196Smckusick #define NQNFSWRITE 0x0040 /* Write lease */ 10952196Smckusick #define NQNFSEVICTED 0x0080 /* Has been evicted */ 11053626Smckusick #define NACC 0x0100 /* Special file accessed */ 11153626Smckusick #define NUPD 0x0200 /* Special file updated */ 11253626Smckusick #define NCHG 0x0400 /* Special file times changed */ 11348043Smckusick 11448043Smckusick /* 11555658Sbostic * Convert between nfsnode pointers and vnode pointers 11655658Sbostic */ 11755658Sbostic #define VTONFS(vp) ((struct nfsnode *)(vp)->v_data) 11855658Sbostic #define NFSTOV(np) ((struct vnode *)(np)->n_vnode) 11955658Sbostic 12065247Smckusick /* 12165247Smckusick * Queue head for nfsiod's 12265247Smckusick */ 123*68653Smckusick TAILQ_HEAD(, buf) nfs_bufq; 12465247Smckusick 12555658Sbostic #ifdef KERNEL 12655658Sbostic /* 12748043Smckusick * Prototypes for NFS vnode operations 12848043Smckusick */ 12953556Sheideman int nfs_lookup __P((struct vop_lookup_args *)); 13053556Sheideman int nfs_create __P((struct vop_create_args *)); 13153556Sheideman int nfs_mknod __P((struct vop_mknod_args *)); 13253556Sheideman int nfs_open __P((struct vop_open_args *)); 13353556Sheideman int nfs_close __P((struct vop_close_args *)); 13453626Smckusick int nfsspec_close __P((struct vop_close_args *)); 13553626Smckusick int nfsfifo_close __P((struct vop_close_args *)); 13653556Sheideman int nfs_access __P((struct vop_access_args *)); 13756365Smckusick int nfsspec_access __P((struct vop_access_args *)); 13853556Sheideman int nfs_getattr __P((struct vop_getattr_args *)); 13953556Sheideman int nfs_setattr __P((struct vop_setattr_args *)); 14053556Sheideman int nfs_read __P((struct vop_read_args *)); 14153556Sheideman int nfs_write __P((struct vop_write_args *)); 142*68653Smckusick #define nfs_lease_check ((int (*) __P((struct vop_lease_args *)))nullop) 143*68653Smckusick #define nqnfs_vop_lease_check lease_check 14453626Smckusick int nfsspec_read __P((struct vop_read_args *)); 14553626Smckusick int nfsspec_write __P((struct vop_write_args *)); 14653626Smckusick int nfsfifo_read __P((struct vop_read_args *)); 14753626Smckusick int nfsfifo_write __P((struct vop_write_args *)); 14853556Sheideman #define nfs_ioctl ((int (*) __P((struct vop_ioctl_args *)))enoioctl) 14953556Sheideman #define nfs_select ((int (*) __P((struct vop_select_args *)))seltrue) 150*68653Smckusick #define nfs_revoke vop_revoke 15153556Sheideman int nfs_mmap __P((struct vop_mmap_args *)); 15253556Sheideman int nfs_fsync __P((struct vop_fsync_args *)); 15353556Sheideman #define nfs_seek ((int (*) __P((struct vop_seek_args *)))nullop) 15453556Sheideman int nfs_remove __P((struct vop_remove_args *)); 15553556Sheideman int nfs_link __P((struct vop_link_args *)); 15653556Sheideman int nfs_rename __P((struct vop_rename_args *)); 15753556Sheideman int nfs_mkdir __P((struct vop_mkdir_args *)); 15853556Sheideman int nfs_rmdir __P((struct vop_rmdir_args *)); 15953556Sheideman int nfs_symlink __P((struct vop_symlink_args *)); 16053556Sheideman int nfs_readdir __P((struct vop_readdir_args *)); 16153556Sheideman int nfs_readlink __P((struct vop_readlink_args *)); 16253556Sheideman int nfs_abortop __P((struct vop_abortop_args *)); 16353556Sheideman int nfs_inactive __P((struct vop_inactive_args *)); 16453556Sheideman int nfs_reclaim __P((struct vop_reclaim_args *)); 16553556Sheideman int nfs_lock __P((struct vop_lock_args *)); 16653556Sheideman int nfs_unlock __P((struct vop_unlock_args *)); 16753556Sheideman int nfs_bmap __P((struct vop_bmap_args *)); 16853556Sheideman int nfs_strategy __P((struct vop_strategy_args *)); 16953556Sheideman int nfs_print __P((struct vop_print_args *)); 17053556Sheideman int nfs_islocked __P((struct vop_islocked_args *)); 17160399Smckusick int nfs_pathconf __P((struct vop_pathconf_args *)); 17253556Sheideman int nfs_advlock __P((struct vop_advlock_args *)); 17353556Sheideman int nfs_blkatoff __P((struct vop_blkatoff_args *)); 174*68653Smckusick int nfs_bwrite __P((struct vop_bwrite_args *)); 17554663Smckusick int nfs_vget __P((struct mount *, ino_t, struct vnode **)); 17653556Sheideman int nfs_valloc __P((struct vop_valloc_args *)); 17766078Shibler #define nfs_reallocblks \ 17866078Shibler ((int (*) __P((struct vop_reallocblks_args *)))eopnotsupp) 17953581Sheideman int nfs_vfree __P((struct vop_vfree_args *)); 18053556Sheideman int nfs_truncate __P((struct vop_truncate_args *)); 18153556Sheideman int nfs_update __P((struct vop_update_args *)); 182*68653Smckusick 183*68653Smckusick /* other stuff */ 184*68653Smckusick int nfs_removeit __P((struct sillyrename *)); 185*68653Smckusick int nfs_nget __P((struct mount *,nfsfh_t *,int,struct nfsnode **)); 186*68653Smckusick int nfs_lookitup __P((struct vnode *,char *,int,struct ucred *,struct proc *,struct nfsnode **)); 187*68653Smckusick int nfs_sillyrename __P((struct vnode *,struct vnode *,struct componentname *)); 188*68653Smckusick nfsuint64 *nfs_getcookie __P((struct nfsnode *, off_t, int)); 189*68653Smckusick void nfs_invaldir __P((struct vnode *)); 190*68653Smckusick #define nqnfs_lease_updatetime lease_updatetime 191*68653Smckusick 19255658Sbostic #endif /* KERNEL */ 193*68653Smckusick 194*68653Smckusick #endif 195