Home | History | Annotate | Line # | Download | only in coda
cnode.h revision 1.7.12.2
      1  1.7.12.2  nathanw /*	$NetBSD: cnode.h,v 1.7.12.2 2002/11/11 22:06:36 nathanw 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 #ifndef	_CNODE_H_
     48       1.1      rvb #define	_CNODE_H_
     49       1.1      rvb 
     50       1.1      rvb #include <sys/vnode.h>
     51       1.1      rvb 
     52       1.1      rvb /*
     53       1.1      rvb  * tmp below since we need struct queue
     54       1.1      rvb  */
     55       1.4      rvb #include <coda/coda_kernel.h>
     56       1.1      rvb 
     57       1.1      rvb /*
     58       1.1      rvb  * Cnode lookup stuff.
     59       1.3      rvb  * NOTE: CODA_CACHESIZE must be a power of 2 for cfshash to work!
     60       1.1      rvb  */
     61       1.3      rvb #define CODA_CACHESIZE 512
     62       1.1      rvb 
     63       1.3      rvb #define CODA_ALLOC(ptr, cast, size)                                        \
     64       1.1      rvb do {                                                                      \
     65       1.3      rvb     ptr = (cast)malloc((unsigned long) size, M_CODA, M_WAITOK);            \
     66       1.1      rvb     if (ptr == 0) {                                                       \
     67       1.1      rvb 	panic("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__);  \
     68       1.1      rvb     }                                                                     \
     69  1.7.12.2  nathanw } while (/*CONSTCOND*/ 0)
     70       1.1      rvb 
     71       1.3      rvb #define CODA_FREE(ptr, size)  free((ptr), M_CODA)
     72       1.1      rvb 
     73       1.1      rvb /*
     74       1.1      rvb  * global cache state control
     75       1.1      rvb  */
     76       1.3      rvb extern int coda_nc_use;
     77       1.1      rvb 
     78       1.1      rvb /*
     79       1.1      rvb  * Used to select debugging statements throughout the cfs code.
     80       1.1      rvb  */
     81       1.3      rvb extern int codadebug;
     82       1.3      rvb extern int coda_nc_debug;
     83       1.3      rvb extern int coda_printf_delay;
     84       1.3      rvb extern int coda_vnop_print_entry;
     85       1.3      rvb extern int coda_psdev_print_entry;
     86       1.3      rvb extern int coda_vfsop_print_entry;
     87       1.1      rvb 
     88       1.3      rvb #define CODADBGMSK(N)            (1 << N)
     89       1.3      rvb #define CODADEBUG(N, STMT)       { if (codadebug & CODADBGMSK(N)) { STMT } }
     90       1.1      rvb #define myprintf(args)          \
     91       1.1      rvb do {                            \
     92       1.3      rvb     if (coda_printf_delay)       \
     93       1.3      rvb 	DELAY(coda_printf_delay);\
     94       1.1      rvb     printf args ;               \
     95  1.7.12.2  nathanw } while (/*CONSTCOND*/ 0)
     96       1.1      rvb 
     97       1.1      rvb struct cnode {
     98       1.1      rvb     struct vnode	*c_vnode;
     99       1.1      rvb     u_short		 c_flags;	/* flags (see below) */
    100       1.1      rvb     ViceFid		 c_fid;		/* file handle */
    101       1.1      rvb     struct vnode	*c_ovp;		/* open vnode pointer */
    102       1.1      rvb     u_short		 c_ocount;	/* count of openers */
    103       1.1      rvb     u_short		 c_owrite;	/* count of open for write */
    104       1.1      rvb     struct vattr	 c_vattr; 	/* attributes */
    105       1.1      rvb     char		*c_symlink;	/* pointer to symbolic link */
    106       1.1      rvb     u_short		 c_symlen;	/* length of symbolic link */
    107       1.1      rvb     dev_t		 c_device;	/* associated vnode device */
    108       1.1      rvb     ino_t		 c_inode;	/* associated vnode inode */
    109       1.1      rvb     struct cnode	*c_next;	/* links if on NetBSD machine */
    110       1.1      rvb };
    111       1.1      rvb #define	VTOC(vp)	((struct cnode *)(vp)->v_data)
    112  1.7.12.1  nathanw #define	SET_VTOC(vp)	((vp)->v_data)
    113       1.1      rvb #define	CTOV(cp)	((struct vnode *)((cp)->c_vnode))
    114       1.1      rvb 
    115       1.1      rvb /* flags */
    116       1.1      rvb #define C_VATTR		0x01	/* Validity of vattr in the cnode */
    117       1.1      rvb #define C_SYMLINK	0x02	/* Validity of symlink pointer in the Code */
    118       1.1      rvb #define C_WANTED	0x08	/* Set if lock wanted */
    119       1.1      rvb #define C_LOCKED	0x10	/* Set if lock held */
    120       1.1      rvb #define C_UNMOUNTING	0X20	/* Set if unmounting */
    121       1.1      rvb #define C_PURGING	0x40	/* Set if purging a fid */
    122       1.1      rvb 
    123       1.1      rvb #define VALID_VATTR(cp)		((cp->c_flags) & C_VATTR)
    124       1.1      rvb #define VALID_SYMLINK(cp)	((cp->c_flags) & C_SYMLINK)
    125       1.1      rvb #define IS_UNMOUNTING(cp)	((cp)->c_flags & C_UNMOUNTING)
    126       1.1      rvb 
    127       1.1      rvb struct vcomm {
    128       1.1      rvb 	u_long		vc_seq;
    129       1.1      rvb 	struct selinfo	vc_selproc;
    130       1.1      rvb 	struct queue	vc_requests;
    131       1.1      rvb 	struct queue	vc_replys;
    132       1.1      rvb };
    133       1.1      rvb 
    134       1.1      rvb #define	VC_OPEN(vcp)	    ((vcp)->vc_requests.forw != NULL)
    135       1.1      rvb #define MARK_VC_CLOSED(vcp) (vcp)->vc_requests.forw = NULL;
    136       1.1      rvb #define MARK_VC_OPEN(vcp)    /* MT */
    137       1.1      rvb 
    138       1.3      rvb struct coda_clstat {
    139       1.1      rvb 	int	ncalls;			/* client requests */
    140       1.1      rvb 	int	nbadcalls;		/* upcall failures */
    141       1.3      rvb 	int	reqs[CODA_NCALLS];	/* count of each request */
    142       1.1      rvb };
    143       1.3      rvb extern struct coda_clstat coda_clstat;
    144       1.1      rvb 
    145       1.1      rvb /*
    146       1.3      rvb  * CODA structure to hold mount/file system information
    147       1.1      rvb  */
    148       1.3      rvb struct coda_mntinfo {
    149       1.1      rvb     struct vnode	*mi_rootvp;
    150       1.1      rvb     struct mount	*mi_vfsp;
    151       1.1      rvb     struct vcomm	 mi_vcomm;
    152       1.1      rvb };
    153       1.3      rvb extern struct coda_mntinfo coda_mnttbl[]; /* indexed by minor device number */
    154       1.1      rvb 
    155       1.1      rvb /*
    156       1.1      rvb  * vfs pointer to mount info
    157       1.1      rvb  */
    158       1.3      rvb #define vftomi(vfsp)    ((struct coda_mntinfo *)(vfsp->mnt_data))
    159       1.3      rvb #define	CODA_MOUNTED(vfsp)   (vftomi((vfsp)) != (struct coda_mntinfo *)0)
    160       1.1      rvb 
    161       1.1      rvb /*
    162       1.1      rvb  * vnode pointer to mount info
    163       1.1      rvb  */
    164       1.3      rvb #define vtomi(vp)       ((struct coda_mntinfo *)(vp->v_mount->mnt_data))
    165       1.1      rvb 
    166       1.1      rvb /*
    167       1.1      rvb  * Used for identifying usage of "Control" object
    168       1.1      rvb  */
    169       1.3      rvb extern struct vnode *coda_ctlvp;
    170       1.3      rvb #define	IS_CTL_VP(vp)		((vp) == coda_ctlvp)
    171       1.3      rvb #define	IS_CTL_NAME(vp, name, l)((l == CODA_CONTROLLEN) \
    172       1.1      rvb  				 && ((vp) == vtomi((vp))->mi_rootvp)    \
    173       1.3      rvb 				 && strncmp(name, CODA_CONTROL, l) == 0)
    174       1.1      rvb 
    175       1.1      rvb /*
    176       1.1      rvb  * An enum to tell us whether something that will remove a reference
    177       1.1      rvb  * to a cnode was a downcall or not
    178       1.1      rvb  */
    179       1.1      rvb enum dc_status {
    180       1.1      rvb     IS_DOWNCALL = 6,
    181       1.1      rvb     NOT_DOWNCALL = 7
    182       1.1      rvb };
    183       1.1      rvb 
    184       1.1      rvb /* cfs_psdev.h */
    185       1.5      rvb extern int coda_call(struct coda_mntinfo *mntinfo, int inSize, int *outSize, caddr_t buffer);
    186       1.5      rvb extern int coda_kernel_version;
    187       1.1      rvb 
    188       1.1      rvb /* cfs_subr.h */
    189       1.5      rvb extern int  handleDownCall(int opcode, union outputArgs *out);
    190       1.5      rvb extern void coda_unmounting(struct mount *whoIam);
    191       1.5      rvb extern int  coda_vmflush(struct cnode *cp);
    192       1.1      rvb 
    193       1.1      rvb /* cfs_vnodeops.h */
    194       1.5      rvb extern struct cnode *make_coda_node(ViceFid *fid, struct mount *vfsp, short type);
    195       1.5      rvb extern int coda_vnodeopstats_init(void);
    196       1.1      rvb 
    197       1.3      rvb /* coda_vfsops.h */
    198       1.5      rvb extern struct mount *devtomp(dev_t dev);
    199       1.1      rvb 
    200       1.1      rvb /* sigh */
    201       1.3      rvb #define CODA_RDWR ((u_long) 31)
    202       1.1      rvb 
    203       1.1      rvb #endif	/* _CNODE_H_ */
    204       1.1      rvb 
    205