Home | History | Annotate | Line # | Download | only in coda
cnode.h revision 1.5.6.1
      1  1.5.6.1  thorpej /*	$NetBSD: cnode.h,v 1.5.6.1 1999/08/02 21:50:08 thorpej Exp $	*/
      2      1.2      rvb 
      3      1.1      rvb /*
      4      1.2      rvb  *
      5      1.2      rvb  *             Coda: an Experimental Distributed File System
      6      1.2      rvb  *                              Release 3.1
      7      1.2      rvb  *
      8      1.2      rvb  *           Copyright (c) 1987-1998 Carnegie Mellon University
      9      1.2      rvb  *                          All Rights Reserved
     10      1.2      rvb  *
     11      1.2      rvb  * Permission  to  use, copy, modify and distribute this software and its
     12      1.2      rvb  * documentation is hereby granted,  provided  that  both  the  copyright
     13      1.2      rvb  * notice  and  this  permission  notice  appear  in  all  copies  of the
     14      1.2      rvb  * software, derivative works or  modified  versions,  and  any  portions
     15      1.2      rvb  * thereof, and that both notices appear in supporting documentation, and
     16      1.2      rvb  * that credit is given to Carnegie Mellon University  in  all  documents
     17      1.2      rvb  * and publicity pertaining to direct or indirect use of this code or its
     18      1.2      rvb  * derivatives.
     19      1.2      rvb  *
     20      1.2      rvb  * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS  KNOWN  TO  HAVE  BUGS,
     21      1.2      rvb  * SOME  OF  WHICH MAY HAVE SERIOUS CONSEQUENCES.  CARNEGIE MELLON ALLOWS
     22      1.2      rvb  * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.   CARNEGIE  MELLON
     23      1.2      rvb  * DISCLAIMS  ANY  LIABILITY  OF  ANY  KIND  FOR  ANY  DAMAGES WHATSOEVER
     24      1.2      rvb  * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE  OR  OF
     25      1.2      rvb  * ANY DERIVATIVE WORK.
     26      1.2      rvb  *
     27      1.2      rvb  * Carnegie  Mellon  encourages  users  of  this  software  to return any
     28      1.2      rvb  * improvements or extensions that  they  make,  and  to  grant  Carnegie
     29      1.2      rvb  * Mellon the rights to redistribute these changes without encumbrance.
     30      1.2      rvb  *
     31      1.4      rvb  * 	@(#) coda/cnode.h,v 1.1.1.1 1998/08/29 21:26:46 rvb Exp $
     32      1.2      rvb  */
     33      1.1      rvb 
     34      1.1      rvb /*
     35      1.1      rvb  * Mach Operating System
     36      1.1      rvb  * Copyright (c) 1990 Carnegie-Mellon University
     37      1.1      rvb  * Copyright (c) 1989 Carnegie-Mellon University
     38      1.1      rvb  * All rights reserved.  The CMU software License Agreement specifies
     39      1.1      rvb  * the terms and conditions for use and redistribution.
     40      1.1      rvb  */
     41      1.1      rvb 
     42      1.1      rvb /*
     43      1.1      rvb  * This code was written for the Coda file system at Carnegie Mellon University.
     44      1.1      rvb  * Contributers include David Steere, James Kistler, and M. Satyanarayanan.
     45      1.1      rvb  */
     46      1.1      rvb 
     47      1.1      rvb /*
     48      1.1      rvb  * HISTORY
     49      1.1      rvb  * $Log: cnode.h,v $
     50  1.5.6.1  thorpej  * Revision 1.5.6.1  1999/08/02 21:50:08  thorpej
     51  1.5.6.1  thorpej  * Update from trunk.
     52  1.5.6.1  thorpej  *
     53  1.5.6.1  thorpej  * Revision 1.6  1999/07/08 01:26:23  wrstuden
     54  1.5.6.1  thorpej  * Bump osrelease to 1.4E. Add layerfs files, remove null_subr.c.
     55  1.5.6.1  thorpej  *
     56  1.5.6.1  thorpej  * Update coda to new struct lock in struct vnode.
     57  1.5.6.1  thorpej  *
     58  1.5.6.1  thorpej  * make fdescfs, kernfs, portalfs, and procfs actually lock their vnodes.
     59  1.5.6.1  thorpej  * It's not that hard.
     60  1.5.6.1  thorpej  *
     61  1.5.6.1  thorpej  * Make unionfs set v_vnlock = NULL so any overlayed fs will call its
     62  1.5.6.1  thorpej  * VOP_LOCK.
     63  1.5.6.1  thorpej  *
     64  1.5.6.1  thorpej  * Revision 1.5  1998/11/11 19:22:08  rvb
     65  1.5.6.1  thorpej  * Lookup now passes up an extra flag.  But old veni will
     66  1.5.6.1  thorpej  * be ok; new veni will check /dev/cfs0 to make sure that a new
     67  1.5.6.1  thorpej  * kernel is running.
     68      1.5      rvb  * Also, a bug in vc_nb_close iff CODA_SIGNAL's were seen has been
     69      1.5      rvb  * fixed.
     70      1.5      rvb  *
     71      1.4      rvb  * Revision 1.4  1998/09/15 02:02:58  rvb
     72      1.4      rvb  * Final piece of rename cfs->coda
     73      1.4      rvb  *
     74      1.4      rvb  * Revision 1.3  1998/09/12 15:05:50  rvb
     75      1.3      rvb  * Change cfs/CFS in symbols, strings and constants to coda/CODA
     76      1.3      rvb  * to avoid fs conflicts.
     77      1.3      rvb  *
     78      1.2      rvb  * Revision 1.2  1998/09/08 17:12:49  rvb
     79      1.2      rvb  * Pass2 complete
     80      1.2      rvb  *
     81      1.1      rvb  * Revision 1.1.1.1  1998/08/29 21:26:46  rvb
     82      1.1      rvb  * Very Preliminary Coda
     83      1.1      rvb  *
     84      1.1      rvb  * Revision 1.10  1998/08/28 18:12:25  rvb
     85      1.1      rvb  * Now it also works on FreeBSD -current.  This code will be
     86      1.1      rvb  * committed to the FreeBSD -current and NetBSD -current
     87      1.1      rvb  * trees.  It will then be tailored to the particular platform
     88      1.1      rvb  * by flushing conditional code.
     89      1.1      rvb  *
     90      1.1      rvb  * Revision 1.9  1998/08/18 17:05:24  rvb
     91      1.1      rvb  * Don't use __RCSID now
     92      1.1      rvb  *
     93      1.1      rvb  * Revision 1.8  1998/08/18 16:31:49  rvb
     94      1.1      rvb  * Sync the code for NetBSD -current; test on 1.3 later
     95      1.1      rvb  *
     96      1.1      rvb  * Revision 1.7  98/02/24  22:22:53  rvb
     97      1.1      rvb  * Fixes up mainly to flush iopen and friends
     98      1.1      rvb  *
     99      1.1      rvb  * Revision 1.6  98/01/31  20:53:19  rvb
    100      1.3      rvb  * First version that works on FreeBSD 2.2.5
    101      1.1      rvb  *
    102      1.1      rvb  * Revision 1.5  98/01/23  11:53:51  rvb
    103      1.1      rvb  * Bring RVB_CODA1_1 to HEAD
    104      1.1      rvb  *
    105      1.1      rvb  * Revision 1.4.2.5  98/01/23  11:21:14  rvb
    106      1.1      rvb  * Sync with 2.2.5
    107      1.1      rvb  *
    108      1.1      rvb  * Revision 1.4.2.4  98/01/22  13:03:38  rvb
    109      1.1      rvb  * Had Breaken ls .
    110      1.1      rvb  *
    111      1.1      rvb  * Revision 1.4.2.3  97/12/19  14:26:09  rvb
    112      1.1      rvb  * session id
    113      1.1      rvb  *
    114      1.1      rvb  * Revision 1.4.2.2  97/12/16  12:40:24  rvb
    115      1.1      rvb  * Sync with 1.3
    116      1.1      rvb  *
    117      1.1      rvb  * Revision 1.4.2.1  97/12/06  17:41:28  rvb
    118      1.1      rvb  * Sync with peters coda.h
    119      1.1      rvb  *
    120      1.1      rvb  * Revision 1.4  97/12/05  10:39:30  rvb
    121      1.1      rvb  * Read CHANGES
    122      1.1      rvb  *
    123      1.1      rvb  * Revision 1.3.18.2  97/11/12  12:09:45  rvb
    124      1.1      rvb  * reorg pass1
    125      1.1      rvb  *
    126      1.1      rvb  * Revision 1.3.18.1  97/10/29  16:06:31  rvb
    127      1.1      rvb  * Kill DYING
    128      1.1      rvb  *
    129      1.1      rvb  * Revision 1.3  1996/12/12 22:11:03  bnoble
    130      1.1      rvb  * Fixed the "downcall invokes venus operation" deadlock in all known cases.
    131      1.1      rvb  *  There may be more.
    132      1.1      rvb  *
    133      1.1      rvb  * Revision 1.2  1996/01/02 16:57:26  bnoble
    134      1.3      rvb  * Added support for Coda MiniCache and raw inode calls (final commit)
    135      1.1      rvb  *
    136      1.1      rvb  * Revision 1.1.2.1  1995/12/20 01:57:53  bnoble
    137      1.1      rvb  * Added CODA-specific files
    138      1.1      rvb  *
    139      1.1      rvb  * Revision 3.1.1.1  1995/03/04  19:08:23  bnoble
    140      1.1      rvb  * Branch for NetBSD port revisions
    141      1.1      rvb  *
    142      1.1      rvb  * Revision 3.1  1995/03/04  19:08:23  bnoble
    143      1.1      rvb  * Bump to major revision 3 to prepare for NetBSD port
    144      1.1      rvb  *
    145      1.1      rvb  * Revision 2.2  1994/12/06  13:39:18  dcs
    146      1.1      rvb  * Add a flag value to indicate a cnode was orphaned, e.g. the venus
    147      1.1      rvb  * that created it has exited. This will allow one to restart venus
    148      1.1      rvb  * even though some process may be cd'd into /coda.
    149      1.1      rvb  *
    150      1.1      rvb  * Revision 2.1  94/07/21  16:25:33  satya
    151      1.1      rvb  * Conversion to C++ 3.0; start of Coda Release 2.0
    152      1.1      rvb  *
    153      1.1      rvb  * Revision 1.2.7.1  94/06/16  11:26:02  raiff
    154      1.1      rvb  * Branch for release beta-16Jun1994_39118
    155      1.1      rvb  *
    156      1.1      rvb  * Revision 1.2  92/10/27  17:58:41  lily
    157      1.1      rvb  * merge kernel/latest and alpha/src/cfs
    158      1.1      rvb  *
    159      1.1      rvb  * Revision 2.3  92/09/30  14:16:53  mja
    160      1.1      rvb  * 	Picked up fixed #ifdef _KERNEL. Also...
    161      1.1      rvb  *
    162      1.1      rvb  * 	Substituted rvb's history blurb so that we agree with Mach 2.5 sources.
    163      1.1      rvb  * 	[91/02/09            jjk]
    164      1.1      rvb  *
    165      1.1      rvb  * 	Added contributors blurb.
    166      1.1      rvb  * 	[90/12/13            jjk]
    167      1.1      rvb  *
    168      1.1      rvb  * Revision 2.2  90/07/05  11:27:24  mrt
    169      1.1      rvb  * 	Created for the Coda File System.
    170      1.1      rvb  * 	[90/05/23            dcs]
    171      1.1      rvb  *
    172      1.1      rvb  * Revision 1.4  90/05/31  17:02:16  dcs
    173      1.1      rvb  * Prepare for merge with facilities kernel.
    174      1.1      rvb  *
    175      1.1      rvb  *
    176      1.1      rvb  *
    177      1.1      rvb  */
    178      1.1      rvb 
    179      1.1      rvb #ifndef	_CNODE_H_
    180      1.1      rvb #define	_CNODE_H_
    181      1.1      rvb 
    182      1.1      rvb #include <sys/vnode.h>
    183      1.1      rvb 
    184      1.4      rvb /*
    185      1.1      rvb  * tmp below since we need struct queue
    186      1.1      rvb  */
    187      1.1      rvb #include <coda/coda_kernel.h>
    188      1.3      rvb 
    189      1.1      rvb /*
    190      1.3      rvb  * Cnode lookup stuff.
    191      1.1      rvb  * NOTE: CODA_CACHESIZE must be a power of 2 for cfshash to work!
    192      1.3      rvb  */
    193      1.1      rvb #define CODA_CACHESIZE 512
    194      1.3      rvb 
    195      1.1      rvb #define CODA_ALLOC(ptr, cast, size)                                        \
    196      1.1      rvb do {                                                                      \
    197      1.1      rvb     ptr = (cast)malloc((unsigned long) size, M_CODA, M_WAITOK);            \
    198      1.1      rvb     if (ptr == 0) {                                                       \
    199      1.1      rvb 	panic("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__);  \
    200      1.3      rvb     }                                                                     \
    201      1.1      rvb } while (0)
    202      1.1      rvb 
    203      1.1      rvb #define CODA_FREE(ptr, size)  free((ptr), M_CODA)
    204      1.1      rvb 
    205      1.3      rvb /*
    206      1.1      rvb  * global cache state control
    207      1.1      rvb  */
    208      1.1      rvb extern int coda_nc_use;
    209      1.1      rvb 
    210      1.3      rvb /*
    211      1.3      rvb  * Used to select debugging statements throughout the cfs code.
    212      1.3      rvb  */
    213      1.3      rvb extern int codadebug;
    214      1.3      rvb extern int coda_nc_debug;
    215      1.3      rvb extern int coda_printf_delay;
    216      1.1      rvb extern int coda_vnop_print_entry;
    217      1.3      rvb extern int coda_psdev_print_entry;
    218      1.3      rvb extern int coda_vfsop_print_entry;
    219      1.1      rvb 
    220      1.1      rvb #define CODADBGMSK(N)            (1 << N)
    221      1.3      rvb #define CODADEBUG(N, STMT)       { if (codadebug & CODADBGMSK(N)) { STMT } }
    222      1.3      rvb #define myprintf(args)          \
    223      1.1      rvb do {                            \
    224      1.1      rvb     if (coda_printf_delay)       \
    225      1.1      rvb 	DELAY(coda_printf_delay);\
    226      1.1      rvb     printf args ;               \
    227      1.1      rvb } while (0)
    228      1.1      rvb 
    229      1.1      rvb struct cnode {
    230      1.1      rvb     struct vnode	*c_vnode;
    231      1.1      rvb     u_short		 c_flags;	/* flags (see below) */
    232      1.1      rvb     ViceFid		 c_fid;		/* file handle */
    233      1.1      rvb     struct vnode	*c_ovp;		/* open vnode pointer */
    234      1.1      rvb     u_short		 c_ocount;	/* count of openers */
    235      1.1      rvb     u_short		 c_owrite;	/* count of open for write */
    236      1.1      rvb     struct vattr	 c_vattr; 	/* attributes */
    237      1.1      rvb     char		*c_symlink;	/* pointer to symbolic link */
    238      1.1      rvb     u_short		 c_symlen;	/* length of symbolic link */
    239      1.1      rvb     dev_t		 c_device;	/* associated vnode device */
    240      1.1      rvb     ino_t		 c_inode;	/* associated vnode inode */
    241      1.1      rvb     struct cnode	*c_next;	/* links if on NetBSD machine */
    242      1.1      rvb };
    243      1.1      rvb #define	VTOC(vp)	((struct cnode *)(vp)->v_data)
    244      1.1      rvb #define	CTOV(cp)	((struct vnode *)((cp)->c_vnode))
    245      1.1      rvb 
    246      1.1      rvb /* flags */
    247      1.1      rvb #define C_VATTR		0x01	/* Validity of vattr in the cnode */
    248      1.1      rvb #define C_SYMLINK	0x02	/* Validity of symlink pointer in the Code */
    249      1.1      rvb #define C_WANTED	0x08	/* Set if lock wanted */
    250      1.1      rvb #define C_LOCKED	0x10	/* Set if lock held */
    251      1.1      rvb #define C_UNMOUNTING	0X20	/* Set if unmounting */
    252      1.1      rvb #define C_PURGING	0x40	/* Set if purging a fid */
    253      1.1      rvb 
    254      1.1      rvb #define VALID_VATTR(cp)		((cp->c_flags) & C_VATTR)
    255      1.1      rvb #define VALID_SYMLINK(cp)	((cp->c_flags) & C_SYMLINK)
    256      1.1      rvb #define IS_UNMOUNTING(cp)	((cp)->c_flags & C_UNMOUNTING)
    257      1.1      rvb 
    258      1.1      rvb struct vcomm {
    259      1.1      rvb 	u_long		vc_seq;
    260      1.1      rvb 	struct selinfo	vc_selproc;
    261      1.1      rvb 	struct queue	vc_requests;
    262      1.1      rvb 	struct queue	vc_replys;
    263      1.1      rvb };
    264      1.1      rvb 
    265      1.1      rvb #define	VC_OPEN(vcp)	    ((vcp)->vc_requests.forw != NULL)
    266      1.3      rvb #define MARK_VC_CLOSED(vcp) (vcp)->vc_requests.forw = NULL;
    267      1.1      rvb #define MARK_VC_OPEN(vcp)    /* MT */
    268      1.1      rvb 
    269      1.3      rvb struct coda_clstat {
    270      1.1      rvb 	int	ncalls;			/* client requests */
    271      1.3      rvb 	int	nbadcalls;		/* upcall failures */
    272      1.1      rvb 	int	reqs[CODA_NCALLS];	/* count of each request */
    273      1.1      rvb };
    274      1.3      rvb extern struct coda_clstat coda_clstat;
    275      1.1      rvb 
    276      1.3      rvb /*
    277      1.1      rvb  * CODA structure to hold mount/file system information
    278      1.1      rvb  */
    279      1.1      rvb struct coda_mntinfo {
    280      1.1      rvb     struct vnode	*mi_rootvp;
    281      1.3      rvb     struct mount	*mi_vfsp;
    282      1.1      rvb     struct vcomm	 mi_vcomm;
    283      1.1      rvb };
    284      1.1      rvb extern struct coda_mntinfo coda_mnttbl[]; /* indexed by minor device number */
    285      1.1      rvb 
    286      1.3      rvb /*
    287      1.3      rvb  * vfs pointer to mount info
    288      1.1      rvb  */
    289      1.1      rvb #define vftomi(vfsp)    ((struct coda_mntinfo *)(vfsp->mnt_data))
    290      1.1      rvb #define	CODA_MOUNTED(vfsp)   (vftomi((vfsp)) != (struct coda_mntinfo *)0)
    291      1.1      rvb 
    292      1.3      rvb /*
    293      1.1      rvb  * vnode pointer to mount info
    294      1.1      rvb  */
    295      1.1      rvb #define vtomi(vp)       ((struct coda_mntinfo *)(vp->v_mount->mnt_data))
    296      1.1      rvb 
    297      1.3      rvb /*
    298      1.3      rvb  * Used for identifying usage of "Control" object
    299      1.3      rvb  */
    300      1.1      rvb extern struct vnode *coda_ctlvp;
    301      1.3      rvb #define	IS_CTL_VP(vp)		((vp) == coda_ctlvp)
    302      1.1      rvb #define	IS_CTL_NAME(vp, name, l)((l == CODA_CONTROLLEN) \
    303      1.1      rvb  				 && ((vp) == vtomi((vp))->mi_rootvp)    \
    304      1.1      rvb 				 && strncmp(name, CODA_CONTROL, l) == 0)
    305      1.1      rvb 
    306      1.1      rvb /*
    307      1.1      rvb  * An enum to tell us whether something that will remove a reference
    308      1.1      rvb  * to a cnode was a downcall or not
    309      1.1      rvb  */
    310      1.1      rvb enum dc_status {
    311      1.1      rvb     IS_DOWNCALL = 6,
    312      1.1      rvb     NOT_DOWNCALL = 7
    313      1.5      rvb };
    314      1.5      rvb 
    315      1.1      rvb /* cfs_psdev.h */
    316      1.1      rvb extern int coda_call(struct coda_mntinfo *mntinfo, int inSize, int *outSize, caddr_t buffer);
    317      1.5      rvb extern int coda_kernel_version;
    318      1.5      rvb 
    319      1.5      rvb /* cfs_subr.h */
    320      1.1      rvb extern int  handleDownCall(int opcode, union outputArgs *out);
    321      1.1      rvb extern void coda_unmounting(struct mount *whoIam);
    322      1.5      rvb extern int  coda_vmflush(struct cnode *cp);
    323      1.5      rvb 
    324      1.1      rvb /* cfs_vnodeops.h */
    325      1.3      rvb extern struct cnode *make_coda_node(ViceFid *fid, struct mount *vfsp, short type);
    326      1.5      rvb extern int coda_vnodeopstats_init(void);
    327      1.1      rvb 
    328      1.1      rvb /* coda_vfsops.h */
    329      1.3      rvb extern struct mount *devtomp(dev_t dev);
    330      1.1      rvb 
    331      1.1      rvb /* sigh */
    332      1.1      rvb #define CODA_RDWR ((u_long) 31)
    333                   
    334                   #endif	/* _CNODE_H_ */
    335                   
    336