From: Jim Rees Date: Thu, 14 Nov 2002 23:53:36 +0000 (+0000) Subject: openbsd-20021114 X-Git-Tag: openafs-devel-1_3_50~507 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=4caeeb438887b94d70e23ed4bc7317d23b48edee openbsd-20021114 OpenBSD: Fix more vnode refcount screwups Implement AFS_KALLOC, AFS_KFREE and eliminate #ifdefs in afs/afs_osi.c More prototypes Move a bunch of stuff from param.h to osi_machdep.h Don't bind afs_vnop_fid.o in with nonfs module --- diff --git a/src/afs/OBSD/osi_machdep.h b/src/afs/OBSD/osi_machdep.h index 9d48b5f..bbcdce5 100644 --- a/src/afs/OBSD/osi_machdep.h +++ b/src/afs/OBSD/osi_machdep.h @@ -43,54 +43,62 @@ extern struct timeval time; #define AFS_UCRED ucred #define AFS_PROC struct proc -#define afs_bufferpages bufpages - -#define osi_vnhold(avc, r) afs_vget(AFSTOV(avc), 0) - -#define afs_suser() afs_osi_suser(osi_curcred()) - -extern int (**afs_vnodeop_p)(); #define SetAfsVnode(vn) /* nothing; done in getnewvnode() */ #define IsAfsVnode(vn) ((vn)->v_op == afs_vnodeop_p) -#define AFS_HOLD(vp) afs_nbsd_ref(vp) -#define AFS_RELE(vp) afs_nbsd_rele(vp) -extern int afs_vget(); -extern void afs_nbsd_ref(struct vnode *); -extern void afs_nbsd_rele(struct vnode *); +#define p_rcred p_ucred -#define va_nodeid va_fileid -#define v_vfsp v_mount -#define vfs_vnodecovered mnt_vnodecovered -#define vfs_bsize mnt_stat.f_bsize -typedef void (*osi_timeout_t)(void *); -#define osi_timeout_t_done -#define osi_curproc() (curproc) -#define osi_curcred() (curproc->p_cred->pc_ucred) +#define AFS_HOLD(vp) afs_nbsd_ref(vp) +#define AFS_RELE(vp) afs_nbsd_rele(vp) +#define osi_vnhold(avc, r) afs_vget(AFSTOV(avc), 0) + +#define afsio_iov uio_iov +#define afsio_iovcnt uio_iovcnt +#define afsio_offset uio_offset +#define afsio_resid uio_resid +#define afsio_seg uio_segflg +#define AFS_KALLOC(s) afs_nbsd_Alloc(s) +#define AFS_KFREE(p, s) afs_nbsd_Free((p), (s)) +#define AFS_UIOSYS UIO_SYSSPACE +#define AFS_UIOUSER UIO_USERSPACE +#define afs_bufferpages bufpages +#define afs_suser() afs_osi_suser(osi_curcred()) +#define osi_curcred() (curproc->p_cred->pc_ucred) +#define osi_curproc() (curproc) +#define osi_GetTime(x) microtime(x) #define osi_vfs mount -#define osi_vfs_bsize mnt_stat.f_bsize -#define osi_vfs_fsid mnt_stat.f_fsid -#define afs_osi_alloc osi_Alloc -#define afs_osi_free osi_Free +#define osi_vfs_bsize mnt_stat.f_bsize +#define osi_vfs_fsid mnt_stat.f_fsid #define printk printf /* for RX version of xdr_* */ -#define vType(vc) (vc)->v->v_type -#define vSetType(vc, type) AFSTOV(vc)->v_type = (type) -#define vSetVfsp(vc, vfsp) AFSTOV(vc)->v_mount = (vfsp) -#define FTRUNC O_TRUNC -#define FEXLOCK O_EXLOCK -#define FSHLOCK O_SHLOCK +#define setgroups sys_setgroups #define UVM +#define va_nodeid va_fileid +#define vfs_bsize mnt_stat.f_bsize +#define vfs_fsid mnt_stat.f_fsid +#define vfs_vnodecovered mnt_vnodecovered +#define vnode_t struct vnode +#define vSetType(vc, type) AFSTOV(vc)->v_type = (type) +#define vSetVfsp(vc, vfsp) AFSTOV(vc)->v_mount = (vfsp) +#define vType(vc) (vc)->v->v_type +#define v_vfsp v_mount -/* no protoytpe 'cuz our includers don't always have uio_rw in scope first */ -extern int afs_nbsd_rdwr(); -extern int afs_nbsd_lookupname(); -extern void afs_nbsd_getnewvnode(); +/* This is not always in scope yet */ +struct vcache; + +extern int afs_nbsd_lookupname(char *fnamep, enum uio_seg segflg, int followlink, + struct vnode **dirvpp, struct vnode **compvpp); +extern void afs_nbsd_getnewvnode(struct vcache *tvc); +extern void afs_nbsd_ref(struct vnode *); +extern void afs_nbsd_rele(struct vnode *); +extern void *afs_nbsd_Alloc(size_t asize); +extern void afs_nbsd_Free(void *p, size_t asize); +extern int afs_vget(); -#define VOP_RDWR afs_nbsd_rdwr #define gop_lookupname(fnamep, segflg, followlink, dirvpp, compvpp) \ afs_nbsd_lookupname((fnamep), (segflg), (followlink), (dirvpp), (compvpp)) #ifdef KERNEL +extern int (**afs_vnodeop_p)(); extern struct simplelock afs_global_lock; #ifndef AFS_GLOBAL_SUNLOCK diff --git a/src/afs/OBSD/osi_misc.c b/src/afs/OBSD/osi_misc.c index fa568bc..25d5252 100644 --- a/src/afs/OBSD/osi_misc.c +++ b/src/afs/OBSD/osi_misc.c @@ -1,3 +1,39 @@ +/* + * osi_misc.c + * + * $Id$ + */ + +/* +copyright 2002 +the regents of the university of michigan +all rights reserved + +permission is granted to use, copy, create derivative works +and redistribute this software and such derivative works +for any purpose, so long as the name of the university of +michigan is not used in any advertising or publicity +pertaining to the use or distribution of this software +without specific, written prior authorization. if the +above copyright notice or any other identification of the +university of michigan is included in any copy of any +portion of this software, then the disclaimer below must +also be included. + +this software is provided as is, without representation +from the university of michigan as to its fitness for any +purpose, and without warranty by the university of +michigan of any kind, either express or implied, including +without limitation the implied warranties of +merchantability and fitness for a particular purpose. the +regents of the university of michigan shall not be liable +for any damages, including special, indirect, incidental, or +consequential damages, with respect to any claim arising +out of or in connection with the use of the software, even +if it has been or is hereafter advised of the possibility of +such damages. +*/ + /* * Copyright 2000, International Business Machines Corporation and others. * All Rights Reserved. @@ -7,14 +43,6 @@ * directory or online at http://www.openafs.org/dl/license10.html */ -/* - * osi_misc.c - * - * OpenBSD version of afs_osi_suser() by Jim Rees. - * See osi_machdep.h for afs_suser macro. It simply calls afs_osi_suser() - * with the creds of the current process. - */ - #include #include "afs/param.h" @@ -29,31 +57,52 @@ RCSID("$Header$"); * Note that it must NOT set errno. */ +/* + * OpenBSD version of afs_osi_suser() by Jim Rees. + * See osi_machdep.h for afs_suser macro. It simply calls afs_osi_suser() + * with the creds of the current process. + */ + int afs_osi_suser(void *credp) { return (suser((struct ucred *) credp, &curproc->p_acflag) ? 0 : 1); } +void * +afs_nbsd_Alloc(size_t asize) +{ + void *p; + + MALLOC(p, void *, asize, M_AFSGENERIC, M_WAITOK); + return p; +} + +void +afs_nbsd_Free(void *p, size_t asize) +{ + FREE(p, M_AFSGENERIC); +} + int afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval) - long *retval; - long dev, near_inode, param1, param2, param3, param4; +long *retval; +long dev, near_inode, param1, param2, param3, param4; { return EINVAL; } int afs_syscall_iopen(dev, inode, usrmod, retval) - long *retval; - int dev, inode, usrmod; +long *retval; +int dev, inode, usrmod; { return EINVAL; } int afs_syscall_iincdec(dev, inode, inode_p1, amount) - int dev, inode, inode_p1, amount; +int dev, inode, inode_p1, amount; { return EINVAL; } diff --git a/src/afs/OBSD/osi_vfsops.c b/src/afs/OBSD/osi_vfsops.c index f94e7a2..a7fbbcf 100644 --- a/src/afs/OBSD/osi_vfsops.c +++ b/src/afs/OBSD/osi_vfsops.c @@ -177,23 +177,6 @@ afs_nbsd_lookupname(char *fnamep, return error; } -#if 0 -int -afs_rdwr(struct vnode *vp, struct uio *uiop, enum uio_rw op, - int flags, struct AFS_UCRED *cred) -{ - uiop->uio_rw = op; - if (op == UIO_READ) - return VOP_READ(vp, uiop, flags, cred); - if (op == UIO_WRITE) - return VOP_WRITE(vp, uiop, flags, cred); -#ifdef DIAGNOSTIC - panic("afs_rdwr mode"); -#endif - return EINVAL; -} -#endif - int afs_quotactl() { diff --git a/src/afs/VNOPS/afs_vnop_fid.c b/src/afs/VNOPS/afs_vnop_fid.c index 74d1878..1a62ce7 100644 --- a/src/afs/VNOPS/afs_vnop_fid.c +++ b/src/afs/VNOPS/afs_vnop_fid.c @@ -65,6 +65,8 @@ int afs_iauth_initd = 0; extern int afs_NFSRootOnly; /* 1 => only allow NFS mounts of /afs. */ + +int #if !defined(AFS_DEC_ENV) && !defined(AFS_ATHENA_ENV) #ifdef AFS_AIX41_ENV afs_fid(OSI_VC_ARG(avc), fidpp, credp) @@ -115,7 +117,9 @@ struct fid **fidpp; SizeOfSmallFid = sizeof(addr); #endif /* defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64) */ addr[0] = (long)avc; -#ifndef AFS_AIX41_ENV +#if defined(AFS_OBSD_ENV) + osi_vnhold(avc, 0); +#elif !defined(AFS_AIX41_ENV) /* No post processing, so don't hold ref count. */ VN_HOLD(AFSTOV(avc)); #endif diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c index df25bee..ca09e04 100644 --- a/src/afs/VNOPS/afs_vnop_lookup.c +++ b/src/afs/VNOPS/afs_vnop_lookup.c @@ -12,11 +12,6 @@ * afs_lookup * EvalMountPoint * afs_DoBulkStat - * - * Locals: - * afs_strcat - * AFS_EQ_ATSYS (macro) - * afs_index */ #include @@ -992,6 +987,7 @@ tagain: /* was: (AFS_DEC_ENV) || defined(AFS_OSF30_ENV) || defined(AFS_NCR_ENV) */ static int AFSDOBULK = 1; +int #ifdef AFS_OSF_ENV afs_lookup(adp, ndp) struct vcache *adp; diff --git a/src/afs/VNOPS/afs_vnop_remove.c b/src/afs/VNOPS/afs_vnop_remove.c index 135a996..e94c717 100644 --- a/src/afs/VNOPS/afs_vnop_remove.c +++ b/src/afs/VNOPS/afs_vnop_remove.c @@ -204,6 +204,7 @@ char *Tnam1; /* Note that we don't set CDirty here, this is OK because the unlink * RPC is called synchronously */ +int #ifdef AFS_OSF_ENV afs_remove(ndp) struct nameidata *ndp; { @@ -429,7 +430,7 @@ int afs_remunlink(register struct vcache *avc, register int doit) cred = avc->uncred; avc->uncred = NULL; -#ifdef AFS_DARWIN_ENV +#if defined(AFS_DARWIN_ENV) /* this is called by vrele (via VOP_INACTIVE) when the refcount is 0. we can't just call VN_HOLD since vref will panic. we can't just call osi_vnhold because a later AFS_RELE will call @@ -439,8 +440,15 @@ int afs_remunlink(register struct vcache *avc, register int doit) refcounts and hope nobody else can touch the file now */ osi_Assert(VREFCOUNT(avc) == 0); VREFCOUNT_SET(avc, 1); +#elif defined(AFS_OBSD_ENV) + /* + * I suspect OpenBSD has the same problem as Darwin, but I'm + * going to be brave and try it this way for now. + */ + osi_vnhold(avc, 0); +#else + VN_HOLD(AFSTOV(avc)); #endif - VN_HOLD(&avc->v); /* We'll only try this once. If it fails, just release the vnode. * Clear after doing hold so that NewVCache doesn't find us yet. diff --git a/src/afs/afs_daemons.c b/src/afs/afs_daemons.c index a913e2e..e93ba66 100644 --- a/src/afs/afs_daemons.c +++ b/src/afs/afs_daemons.c @@ -542,7 +542,7 @@ struct brequest *afs_BQueue(register short aopcode, register struct vcache *avc, #ifdef AFS_DEC_ENV avc->vrefCount++; #else -#ifdef AFS_NETBSD_ENV +#if defined(AFS_NETBSD_ENV) || defined(AFS_OBSD_ENV) AFS_HOLD(AFSTOV(avc)); #else VN_HOLD(AFSTOV(avc)); diff --git a/src/afs/afs_osi.c b/src/afs/afs_osi.c index 983fbff..baf2b34 100644 --- a/src/afs/afs_osi.c +++ b/src/afs/afs_osi.c @@ -429,11 +429,7 @@ void *afs_osi_Alloc(size_t x) return osi_linux_alloc(x, 1); #else size = x; -#ifdef AFS_OBSD_ENV - MALLOC(tm, struct osimem *, size, M_AFSGENERIC, M_WAITOK); -#else tm = (struct osimem *) AFS_KALLOC(size); -#endif #ifdef AFS_SUN_ENV if (!tm) osi_Panic("osi_Alloc: Couldn't allocate %d bytes; out of memory!\n", @@ -458,11 +454,7 @@ void *afs_osi_Alloc_NoSleep(size_t x) size = x; AFS_STATS(afs_stats_cmperf.OutStandingAllocs++); AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x); -#ifdef AFS_OBSD_ENV - MALLOC(tm, struct osimem *, size, M_AFSGENERIC, 0); -#else tm = (struct osimem *) AFS_KALLOC_NOSLEEP(size); -#endif return (void *) tm; } @@ -477,8 +469,6 @@ void afs_osi_Free(void *x, size_t asize) AFS_STATS(afs_stats_cmperf.OutStandingMemUsage -= asize); #if defined(AFS_LINUX20_ENV) osi_linux_free(x); -#elif defined(AFS_OBSD_ENV) - FREE(x, M_AFSGENERIC); #else AFS_KFREE((struct osimem *)x, asize); #endif diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 9a9e13f..2c9a8bd 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -406,6 +406,7 @@ extern const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr); #endif /* afs_osi_pag.c */ +extern int afs_setpag(); extern afs_uint32 genpag(void); extern afs_uint32 getpag(void); #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) @@ -487,6 +488,13 @@ extern void afs_osi_Sleep(void *event); extern int afs_osi_SleepSig(void *event); #endif + +/* ARCH/osi_inode.c */ +extern int afs_syscall_icreate(); +extern int afs_syscall_iopen(); +extern int afs_syscall_iincdec(); + + /* ARCH/osi_file.c */ extern int afs_osicred_initialized; #if defined(AFS_SUN57_64BIT_ENV) || defined(AFS_SGI62_ENV) @@ -786,8 +794,6 @@ extern int HandleFlock(register struct vcache *avc, int acom, /* VNOPS/afs_vnop_lookup.c */ -extern char *afs_strcat(register char *s1, register char *s2); -extern char *afs_index(register char *a, register char c); extern int EvalMountPoint(register struct vcache *avc, struct vcache *advc, struct volume **avolpp, register struct vrequest *areq); extern void afs_InitFakeStat(struct afs_fakestat_state *state); @@ -804,7 +810,7 @@ extern void Check_AtSys(register struct vcache *avc, const char *aname, extern int Next_AtSys(register struct vcache *avc, struct vrequest *areq, struct sysname_info *state); extern int afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp); - +extern int afs_lookup(); /* VNOPS/afs_vnop_read.c */ @@ -825,6 +831,10 @@ extern int afsremove(register struct vcache *adp, register struct dcache *tdc, extern int afs_remunlink(register struct vcache *avc, register int doit); +/* VNOPS/afs_vnop_rename.c */ +extern int afsrename(); + + /* VNOPS/afs_vnop_symlink.c */ extern int afs_MemHandleLink(register struct vcache *avc, struct vrequest *areq); diff --git a/src/afs/afs_volume.c b/src/afs/afs_volume.c index 1286028..4b3d679 100644 --- a/src/afs/afs_volume.c +++ b/src/afs/afs_volume.c @@ -65,7 +65,7 @@ afs_int32 fvTable[NFENTRIES]; static struct volume *afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, struct vrequest *areq, afs_int32 locktype); static struct volume *afs_NewDynrootVolume(struct VenusFid *fid); -static inVolList(); +static int inVolList(struct VenusFid *fid, afs_int32 nvols, afs_int32 *vID, afs_int32 *cID); /* Convert a volume name to a #; return 0 if can't parse as a number */ diff --git a/src/config/param.i386_obsd31.h b/src/config/param.i386_obsd31.h index 198d053..29b14a1 100644 --- a/src/config/param.i386_obsd31.h +++ b/src/config/param.i386_obsd31.h @@ -21,23 +21,11 @@ #define AFS_OBSD_ENV 1 #define AFS_NONFSTRANS 1 #define AFS_KERBEROS_ENV 1 -#define FTRUNC O_TRUNC - -#define IUPD 0x0010 -#define IACC 0x0020 -#define ICHG 0x0040 -#define IMOD 0x0080 - -#define IN_LOCK(ip) lockmgr(&ip->i_lock, LK_EXCLUSIVE, \ - NULL, curproc) -#define IN_UNLOCK(ip) lockmgr(&ip->i_lock, LK_RELEASE, \ - NULL, curproc) - -#define AFS_VM_RDWR_ENV 0 +#define AFS_VM_RDWR_ENV 1 #define AFS_VFS_ENV 1 #define AFS_VFSINCL_ENV 1 -#define AFS_GREEDY43_ENV 1 -#define AFS_ENV 1 + +#define FTRUNC O_TRUNC #define AFS_SYSCALL 210 #define AFS_MOUNT_AFS "afs" @@ -45,9 +33,6 @@ #define SYS_NAME "i386_obsd31" #define SYS_NAME_ID 2002 -#define AFS_HAVE_FFS 1 /* Use system's ffs. */ -#define AFS_HAVE_STATVFS 0 /* System doesn't supports statvfs */ - #define RXK_LISTENER_ENV 1 #define AFS_GCPAGS 0 /* if nonzero, garbage collect PAGs */ #define AFS_USE_GETTIMEOFDAY 1 /* use gettimeofday to implement rx clock */ @@ -56,53 +41,17 @@ /* Extra kernel definitions (from kdefs file) */ #ifdef _KERNEL -/* #define AFS_GLOBAL_SUNLOCK 1 */ -#define AFS_VFS34 1 /* What is VFS34??? */ #define AFS_SHORTGID 0 /* are group id's short? */ -#define afsio_iov uio_iov -#define afsio_iovcnt uio_iovcnt -#define afsio_offset uio_offset -#define afsio_seg uio_segflg -#define afsio_resid uio_resid -#define AFS_UIOSYS UIO_SYSSPACE -#define AFS_UIOUSER UIO_USERSPACE -#define AFS_CLBYTES MB_CLBYTES -#define osi_GetTime(x) microtime(x) -#define AFS_KALLOC(x) osi_Alloc(x) -#define AFS_KFREE(x, y) osi_Free((x), (y)) -#define v_count v_usecount -#define v_vfsp v_mount -#define vfs_bsize mnt_stat.f_bsize -#define vfs_fsid mnt_stat.f_fsid -#define va_nodeid va_fileid -#define vfs_vnodecovered mnt_vnodecovered -#define vnode_t struct vnode -#define setgroups sys_setgroups - -#ifndef MUTEX_DEFAULT -#define MUTEX_DEFAULT 0 -#endif /* MUTEX_DEFAULT */ - -#ifndef SSYS -#define SSYS 0x00002 -#endif /* SSYS */ - -#define p_rcred p_ucred - -#define VN_RELE(vp) vrele(((struct vnode *)(vp))) -#define VN_HOLD(vp) VREF(((struct vnode *)(vp))) #if !defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__) enum vcexcl {NONEXCL, EXCL}; -#ifdef KERNEL #ifndef MIN #define MIN(A,B) ((A) < (B) ? (A) : (B)) #endif #ifndef MAX #define MAX(A,B) ((A) > (B) ? (A) : (B)) #endif -#endif /* KERNEL */ #endif /* ! ASSEMBLER & ! __LANGUAGE_ASSEMBLY__ */ #endif /* _KERNEL */ diff --git a/src/libafs/Makefile.common.in b/src/libafs/Makefile.common.in index a533ec1..327fa8a 100644 --- a/src/libafs/Makefile.common.in +++ b/src/libafs/Makefile.common.in @@ -105,7 +105,6 @@ AFSAOBJS = \ afs_vnop_attrs.o \ afs_vnop_create.o \ afs_vnop_dirops.o \ - afs_vnop_fid.o \ afs_vnop_flock.o \ afs_vnop_link.o \ afs_vnop_lookup.o \ @@ -159,6 +158,7 @@ AFSNFSOBJS = \ afs_nfsdisp.o \ afs_call_nfs.o \ afs_pioctl_nfs.o \ + afs_vnop_fid.o \ $(AFS_OS_NFSOBJS) AFSNONFSOBJS = \ diff --git a/src/volser/volser_prototypes.h b/src/volser/volser_prototypes.h index df2ad20..e4c0f71 100644 --- a/src/volser/volser_prototypes.h +++ b/src/volser/volser_prototypes.h @@ -13,6 +13,7 @@ /* common.c */ /* vsprocs.c */ +struct nvldbentry; extern void MapPartIdIntoName(afs_int32 partId, char *partName); extern int yesprompt(char *str); extern int PrintError(char *msg, afs_int32 errcode);