From 0c4ee80a72d058265b291f82c819bc3631ed1813 Mon Sep 17 00:00:00 2001 From: Jim Rees Date: Wed, 9 Oct 2002 19:25:54 +0000 Subject: [PATCH] openbsd-continues-20021009 More OpenBSD merge. Please let me know if this breaks other architectures. --- src/afs/afs.h | 48 +++++++++++++------- src/afs/afs_callback.c | 2 +- src/afs/afs_daemons.c | 9 ++-- src/afs/afs_dcache.c | 5 ++- src/afs/afs_init.c | 95 ++++++++++++++++++++++------------------ src/afs/afs_osi.c | 19 ++++---- src/afs/afs_osi.h | 18 ++++++-- src/afs/afs_osi_pag.c | 8 ++-- src/afs/afs_prototypes.h | 16 ++++--- src/afs/afs_server.c | 5 ++- src/afs/afs_stat.c | 12 ++--- src/afs/afs_vcache.c | 11 +++++ 12 files changed, 153 insertions(+), 95 deletions(-) diff --git a/src/afs/afs.h b/src/afs/afs.h index 9a411be22..ff9463b92 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -552,10 +552,14 @@ struct SimpleLocks { #define VPageCleaning 0x2 /* Solaris - Cache Trunc Daemon sez keep out */ #define CPSIZE 2 -#if !defined(AFS_FBSD_ENV) -#define vrefCount v.v_count -#else +#if defined(AFS_FBSD_ENV) #define vrefCount v.v_usecount +#else +#if defined(AFS_OBSD_ENV) +#define vrefCount v->v_usecount +#else +#define vrefCount v.v_count +#endif /* AFS_OBSD_ENV */ #endif /* AFS_FBSD_ENV */ #ifdef AFS_LINUX24_ENV @@ -590,20 +594,25 @@ extern afs_int32 vmPageHog; /* counter for # of vnodes which are page hogs. */ /* * Fast map from vcache to dcache */ -struct vtodc - { - struct dcache * dc; - afs_uint32 stamp; - struct osi_file * f; - afs_offs_t minLoc; /* smallest offset into dc. */ - afs_offs_t len; /* largest offset into dc. */ - }; +struct vtodc { + struct dcache * dc; + afs_uint32 stamp; + struct osi_file * f; + afs_offs_t minLoc; /* smallest offset into dc. */ + afs_offs_t len; /* largest offset into dc. */ +}; extern afs_uint32 afs_stampValue; /* stamp for pair's usage */ #define MakeStamp() (++afs_stampValue) -#define VTOAFS(V) ((struct vcache*)(V)) +#if defined(AFS_OBSD_ENV) +#define VTOAFS(v) ((struct vcache *)(v)->v_data) +#define AFSTOV(vc) ((vc)->v) +#else +#define VTOAFS(V) ((struct vcache *)(V)) #define AFSTOV(V) (&(V)->v) +#endif + #ifdef AFS_LINUX22_ENV #define ITOAFS(V) ((struct vcache*)(V)) #define AFSTOI(V) (struct inode *)(&(V)->v) @@ -614,7 +623,12 @@ extern afs_uint32 afs_stampValue; /* stamp for pair's usage */ * !(avc->nextfree) && !avc->vlruq.next => (FreeVCList == avc->nextfree) */ struct vcache { +#if defined(AFS_OBSD_ENV) + struct vnode *v; + struct lock rwlock; /* vnode lock */ +#else struct vnode v; /* Has reference count in v.v_count */ +#endif struct afs_q vlruq; /* lru q next and prev */ struct vcache *nextfree; /* next on free list (if free) */ struct vcache *hnext; /* Hash next */ @@ -678,10 +692,10 @@ struct vcache { afs_int32 activeV; #endif /* defined(AFS_SUN5_ENV) */ struct SimpleLocks *slocks; - short opens; /* The numbers of opens, read or write, on this file. */ - short execsOrWriters; /* The number of execs (if < 0) or writers (if > 0) of - this file. */ - short flockCount; /* count of flock readers, or -1 if writer */ + short opens; /* The numbers of opens, read or write, on this file. */ + short execsOrWriters; /* The number of execs (if < 0) or writers (if > 0) of + this file. */ + short flockCount; /* count of flock readers, or -1 if writer */ char mvstat; /* 0->normal, 1->mt pt, 2->root. */ afs_uint32 states; /* state bits */ #if defined(AFS_SUN5_ENV) @@ -717,7 +731,7 @@ struct vcache { struct AFS_UCRED *uncred; int asynchrony; /* num kbytes to store behind */ #ifdef AFS_SUN5_ENV - short multiPage; /* count of multi-page getpages in progress */ + short multiPage; /* count of multi-page getpages in progress */ #endif }; diff --git a/src/afs/afs_callback.c b/src/afs/afs_callback.c index d194c5d5f..4b3c2dc38 100644 --- a/src/afs/afs_callback.c +++ b/src/afs/afs_callback.c @@ -1110,7 +1110,7 @@ int SRXAFSCB_GetServerPrefs(struct rx_call *a_call, afs_int32 a_index, int SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index, char **a_name, serverList *a_hosts) { - afs_int32 i, j; + afs_int32 i, j = 0; struct cell *tcell; char *t_name, *p_name = NULL; diff --git a/src/afs/afs_daemons.c b/src/afs/afs_daemons.c index 28c9dcef7..43a8cc7d2 100644 --- a/src/afs/afs_daemons.c +++ b/src/afs/afs_daemons.c @@ -541,8 +541,12 @@ struct brequest *afs_BQueue(register short aopcode, register struct vcache *avc, if (avc) { #ifdef AFS_DEC_ENV avc->vrefCount++; +#else +#ifdef AFS_NETBSD_ENV + AFS_HOLD(AFSTOV(avc)); #else VN_HOLD(AFSTOV(avc)); +#endif #endif } tb->refCount = ause+1; @@ -1223,8 +1227,8 @@ void afs_BackgroundDaemon(void) MObtainWriteLock(&afs_xbrs,302); while (1) { - int min_ts; - struct brequest *min_tb; + int min_ts = 0; + struct brequest *min_tb = NULL; if (afs_termState == AFSOP_STOP_BKG) { if (--afs_nbrs <= 0) @@ -1237,7 +1241,6 @@ void afs_BackgroundDaemon(void) /* find a request */ tb = afs_brs; foundAny = 0; - min_tb = NULL; for(i=0; irefCount > 0) && !(tb->flags & BSTARTED)) { diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 0499a9df7..d2d7bee7c 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -1478,7 +1478,10 @@ struct dcache *afs_GetDCache(register struct vcache *avc, afs_size_t abyte, register struct vrequest *areq, afs_size_t *aoffset, afs_size_t *alen, int aflags) { - register afs_int32 i, code, code1=0, shortcut, adjustsize=0; + register afs_int32 i, code, code1=0, shortcut; +#if defined(AFS_AIX32_ENV) || defined(AFS_SGI_ENV) + register afs_int32 adjustsize = 0; +#endif int setLocks; afs_int32 index; afs_int32 us; diff --git a/src/afs/afs_init.c b/src/afs/afs_init.c index 0a9c49970..fbf765025 100644 --- a/src/afs/afs_init.c +++ b/src/afs/afs_init.c @@ -78,7 +78,7 @@ int afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks, afs_int32 aDentries, afs_int32 aVolumes, afs_int32 achunk, afs_int32 aflags, afs_int32 ninodes, afs_int32 nusers) { - register afs_int32 i, preallocs; + register afs_int32 i; register struct volume *tv; AFS_STATCNT(afs_CacheInit); @@ -108,24 +108,28 @@ int afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) - /* - * We want to also reserve space for the gnode struct which is associated - * with each vnode (vcache) one; we want to use the pinned pool for them - * since they're referenced at interrupt level. - */ - if (afs_stats_cmperf.SmallBlocksAlloced + astatSize < 3600) - preallocs = astatSize; - else { - preallocs = 3600 - afs_stats_cmperf.SmallBlocksAlloced; - if (preallocs <= 0) preallocs = 10; + { + afs_int32 preallocs; + + /* + * We want to also reserve space for the gnode struct which is associated + * with each vnode (vcache) one; we want to use the pinned pool for them + * since they're referenced at interrupt level. + */ + if (afs_stats_cmperf.SmallBlocksAlloced + astatSize < 3600) + preallocs = astatSize; + else { + preallocs = 3600 - afs_stats_cmperf.SmallBlocksAlloced; + if (preallocs <= 0) preallocs = 10; + } + osi_AllocMoreSSpace(preallocs); } - osi_AllocMoreSSpace(preallocs); #endif /* * create volume list structure */ - if ( aVolumes < 50 ) aVolumes = 50; - if (aVolumes > 3000) aVolumes = 3000; + if (aVolumes < 50) aVolumes = 50; + else if (aVolumes > 3000) aVolumes = 3000; tv = (struct volume *) afs_osi_Alloc(aVolumes * sizeof(struct volume)); for (i=0;iv_vfsp, &st, NULL, code); - if (!code) + VFS_STATVFS(filevp->v_vfsp, &st, NULL, code); + if (!code) #else - if (!VFS_STATFS(filevp->v_vfsp, &st, NULL)) + if (!VFS_STATFS(filevp->v_vfsp, &st, NULL)) #endif /* AFS_SGI65_ENV */ -#else /* AFS_SGI_ENV */ +#else /* AFS_SGI_ENV */ #if defined(AFS_SUN5_ENV) || defined(AFS_HPUX100_ENV) - if (!VFS_STATVFS(filevp->v_vfsp, &st)) + if (!VFS_STATVFS(filevp->v_vfsp, &st)) #else #ifdef AFS_OSF_ENV - VFS_STATFS(filevp->v_vfsp, code); - /* struct copy */ - st = filevp->v_vfsp->m_stat; - if (code == 0) -#else /* AFS_OSF_ENV */ + VFS_STATFS(filevp->v_vfsp, code); + /* struct copy */ + st = filevp->v_vfsp->m_stat; + if (code == 0) +#else /* AFS_OSF_ENV */ #ifdef AFS_AIX41_ENV - if (!VFS_STATFS(filevp->v_vfsp, &st, &afs_osi_cred)) + if (!VFS_STATFS(filevp->v_vfsp, &st, &afs_osi_cred)) #else #ifdef AFS_LINUX20_ENV - { - KERNEL_SPACE_DECL; - TO_USER_SPACE(); + { + KERNEL_SPACE_DECL; + TO_USER_SPACE(); - VFS_STATFS(filevp->v_vfsp, &st); - TO_KERNEL_SPACE(); - } + VFS_STATFS(filevp->v_vfsp, &st); + TO_KERNEL_SPACE(); + } #else #if defined(AFS_DARWIN_ENV) - if (!VFS_STATFS(filevp->v_mount, &st, current_proc())) + if (!VFS_STATFS(filevp->v_mount, &st, current_proc())) #else #if defined(AFS_XBSD_ENV) - if (!VFS_STATFS(filevp->v_mount, &st, curproc)) + if (!VFS_STATFS(filevp->v_mount, &st, curproc)) #else if (!VFS_STATFS(filevp->v_vfsp, &st)) -#endif /* AFS_FBSD_ENV */ +#endif /* AFS_XBSD_ENV */ #endif /* AFS_DARWIN_ENV */ #endif /* AFS_LINUX20_ENV */ #endif /* AIX41 */ @@ -380,21 +384,28 @@ int afs_InitCacheInfo(register char *afile) #endif /* SUN5 HP10 */ #endif /* SGI */ #if defined(AFS_SUN5_ENV) || defined(AFS_HPUX100_ENV) - afs_fsfragsize = st.f_frsize - 1; + afs_fsfragsize = st.f_frsize - 1; #else - afs_fsfragsize = st.f_bsize - 1; + afs_fsfragsize = st.f_bsize - 1; #endif } #ifdef AFS_LINUX20_ENV cacheInode = filevp->i_ino; afs_cacheSBp = filevp->i_sb; #else +#ifdef AFS_OBSD_ENV + cacheInode = VTOI(filevp)->i_number; + cacheDev.mp = filevp->v_mount; + cacheDev.held_vnode = filevp; + AFS_HOLD(filevp); /* Make sure mount point stays busy. XXX */ +#else #if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS) || defined(AFS_DARWIN_ENV) afs_InitDualFSCacheOps(filevp); #endif cacheInode = afs_vnodeToInumber(filevp); cacheDev.dev = afs_vnodeToDev(filevp); afs_cacheVfsp = filevp->v_vfsp; +#endif /* AFS_OBSD_ENV */ #endif /* AFS_LINUX20_ENV */ AFS_RELE((struct vnode *)filevp); #endif /* AFS_LINUX22_ENV */ @@ -409,7 +420,7 @@ int afs_InitCacheInfo(register char *afile) theader.firstCSize == AFS_FIRSTCSIZE && theader.otherCSize == AFS_OTHERCSIZE && theader.version == AFS_CI_VERSION - ) + ) goodFile = 1; } if (!goodFile) { diff --git a/src/afs/afs_osi.c b/src/afs/afs_osi.c index 5ea37277b..6f2d54fd8 100644 --- a/src/afs/afs_osi.c +++ b/src/afs/afs_osi.c @@ -331,7 +331,7 @@ void afs_osi_Invisible(void) #ifndef AFS_LINUX20_ENV /* Linux version in osi_misc.c */ /* set the real time */ -int afs_osi_SetTime(register osi_timeval_t *atv) +void afs_osi_SetTime(osi_timeval_t *atv) { #ifdef AFS_AIX32_ENV struct timestruc_t t; @@ -397,17 +397,17 @@ int afs_osi_SetTime(register osi_timeval_t *atv) #endif #ifdef AFS_HPUX_ENV { - register ulong_t s; - struct timeval t; - t.tv_sec = atv->tv_sec; - t.tv_usec = atv->tv_usec; - s = spl7(); time = t; (void) splx(s); - resettodr(atv); + register ulong_t s; + struct timeval t; + t.tv_sec = atv->tv_sec; + t.tv_usec = atv->tv_usec; + s = spl7(); time = t; (void) splx(s); + resettodr(atv); } #else { - register int s; - s = splclock(); time = *atv; (void) splx(s); + register int s; + s = splclock(); time = *atv; (void) splx(s); } resettodr(); #endif @@ -421,7 +421,6 @@ int afs_osi_SetTime(register osi_timeval_t *atv) #endif /* AFS_SUN5_ENV */ #endif /* AFS_AIX32_ENV */ AFS_STATCNT(osi_SetTime); - return 0; } #endif /* AFS_LINUX20_ENV */ diff --git a/src/afs/afs_osi.h b/src/afs/afs_osi.h index 9a7381b54..c311a7fdf 100644 --- a/src/afs/afs_osi.h +++ b/src/afs/afs_osi.h @@ -62,7 +62,12 @@ struct osi_file { }; struct osi_dev { +#ifdef AFS_OBSD_ENV + struct mount *mp; + struct vnode *held_vnode; +#else afs_int32 dev; +#endif }; struct afs_osi_WaitHandle { @@ -97,6 +102,7 @@ struct afs_osi_WaitHandle { /* * Vnode related macros */ +#ifndef AFS_OBSD_ENV #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) extern int (**afs_vnodeop_p)(); #define IsAfsVnode(vc) ((vc)->v_op == afs_vnodeop_p) @@ -109,15 +115,18 @@ extern struct vnodeops *afs_ops; #define vType(vc) (vc)->v.v_type #define vSetType(vc,type) (vc)->v.v_type = (type) #define vSetVfsp(vc,vfsp) (vc)->v.v_vfsp = (vfsp) +#endif #ifdef AFS_SGI65_ENV #define gop_lookupname(fnamep,segflg,followlink,dirvpp,compvpp) \ lookupname((fnamep),(segflg),(followlink),(dirvpp),(compvpp),\ NULL) #else +#ifndef AFS_OBSD_ENV #define gop_lookupname(fnamep,segflg,followlink,dirvpp,compvpp) \ lookupname((fnamep),(segflg),(followlink),(dirvpp),(compvpp)) #endif +#endif /* * In IRIX 6.5 we cannot have DEBUG turned on since certain @@ -216,6 +225,7 @@ typedef struct timeval osi_timeval_t; #define USERPRI #endif +#ifndef AFS_OBSD_ENV /* * vnode/vcache ref count manipulation */ @@ -224,6 +234,8 @@ typedef struct timeval osi_timeval_t; #else /* defined(UKERNEL) */ #define AFS_RELE(vp) do { AFS_GUNLOCK(); VN_RELE(vp); AFS_GLOCK(); } while (0) #endif /* defined(UKERNEL) */ +#endif + /* * For some reason we do bare refcount manipulation in some places, for some * platforms. The assumption is apparently that either we wouldn't call @@ -239,7 +251,7 @@ typedef struct timeval osi_timeval_t; #else #define AFS_FAST_HOLD(vp) VN_HOLD(&(vp)->v) #endif -#define AFS_FAST_RELE(vp) AFS_RELE(&(vp)->v) +#define AFS_FAST_RELE(vp) AFS_RELE(AFSTOV(vp)) /* * MP safe versions of routines to copy memory between user space @@ -289,7 +301,7 @@ typedef struct timeval osi_timeval_t; if (haveGlock) \ AFS_GLOCK(); \ } while(0) -#else /* AFS_OSF_ENV || AFS_FBSD_ENV */ +#else #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \ do { \ int haveGlock = ISAFS_GLOCK(); \ @@ -299,7 +311,7 @@ typedef struct timeval osi_timeval_t; if (haveGlock) \ AFS_GLOCK(); \ } while(0) -#endif /* AFS_OSF_ENV || AFS_FBSD_ENV */ +#endif #else /* AFS_GLOBAL_SUNLOCK */ diff --git a/src/afs/afs_osi_pag.c b/src/afs/afs_osi_pag.c index 6853aaa29..4ee71a0cf 100644 --- a/src/afs/afs_osi_pag.c +++ b/src/afs/afs_osi_pag.c @@ -329,7 +329,7 @@ int afs_getpag_val() /* Note - needs to be available on AIX, others can be static - rework this */ #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) int AddPag(struct proc *p, afs_int32 aval, struct AFS_UCRED **credpp) -#else /* AFS_OSF_ENV || AFS_XBSD_ENV */ +#else int AddPag(afs_int32 aval, struct AFS_UCRED **credpp) #endif { @@ -340,10 +340,10 @@ int AddPag(afs_int32 aval, struct AFS_UCRED **credpp) #else /* AFS_OSF_ENV */ if ((code = setpag(credpp, aval, &newpag, 0))) #endif -#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - return (code); -#else +#if defined(KERNEL_HAVE_UERROR) return (setuerror(code), code); +#else + return (code); #endif return 0; } diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index fc763f4b1..1b42071f9 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -405,6 +405,11 @@ extern const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr); /* afs_osi_pag.c */ extern afs_uint32 genpag(void); extern afs_uint32 getpag(void); +#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) +extern int AddPag(struct proc *p, afs_int32 aval, struct AFS_UCRED **credpp); +#else +extern int AddPag(afs_int32 aval, struct AFS_UCRED **credpp); +#endif extern int afs_InitReq(register struct vrequest *av, struct AFS_UCRED *acred); extern afs_uint32 afs_get_pag_from_groups(gid_t g0a, gid_t g1a); extern void afs_get_groups_from_pag(afs_uint32 pag, gid_t *g0p, gid_t *g1p); @@ -428,6 +433,7 @@ extern char *osi_AllocSmall(register afs_int32 size, register afs_int32 morespac /* ARCH/osi_misc.c */ extern void osi_iput(struct inode *ip); +extern void afs_osi_SetTime(osi_timeval_t *atv); /* LINUX/osi_misc.c */ #if AFS_LINUX24_ENV @@ -441,7 +447,6 @@ extern void setup_uio(uio_t *uiop, struct iovec *iovecp, char *buf, afs_offs_t pos, int count, uio_flag_t flag, uio_seg_t seg); extern int uiomove(char *dp, int length, uio_flag_t rw, uio_t *uiop); -extern void afs_osi_SetTime(osi_timeval_t *tvp); extern void osi_linux_free_inode_pages(void); extern void osi_clear_inode(struct inode *ip); extern void check_bad_parent(struct dentry *dp); @@ -599,9 +604,9 @@ extern struct afs_stats_CMPerf afs_stats_cmperf; extern struct afs_stats_CMFullPerf afs_stats_cmfullperf; extern afs_int32 afs_stats_XferSumBytes[AFS_STATS_NUM_FS_XFER_OPS]; extern void afs_InitStats(void); -extern int afs_GetCMStat(char **ptr, unsigned *size); +extern void afs_GetCMStat(char **ptr, unsigned *size); #ifndef AFS_NOSTATS -extern int afs_AddToMean(struct afs_MeanStats *oldMean, afs_int32 newValue); +extern void afs_AddToMean(struct afs_MeanStats *oldMean, afs_int32 newValue); #endif @@ -857,8 +862,8 @@ extern u_short afs_uuid_hash (afsUUID *uuid); /* MISC PROTOTYPES - THESE SHOULD NOT BE HERE */ /* MOVE THEM TO APPROPRIATE LOCATIONS */ -extern int RXAFSCB_ExecuteRequest(); -extern int RXSTATS_ExecuteRequest(); +extern afs_int32 RXAFSCB_ExecuteRequest(struct rx_call *acall); +extern afs_int32 RXSTATS_ExecuteRequest(struct rx_call *acall); @@ -867,4 +872,3 @@ extern int RXSTATS_ExecuteRequest(); #endif #endif /* _AFS_PROTOTYPES_H_ */ - diff --git a/src/afs/afs_server.c b/src/afs/afs_server.c index c83ba2906..10ba950ba 100644 --- a/src/afs/afs_server.c +++ b/src/afs/afs_server.c @@ -1298,15 +1298,16 @@ static int afs_SetServerPrefs(struct srvAddr *sa) } #endif + end: #endif /* USEIFADDR */ #endif /* AFS_SUN5_ENV */ #endif /* else AFS_USERSPACE_IP_ADDR */ - end: if (sa) sa->sa_iprank += afs_randomMod15(); -return 0; + return 0; } /* afs_SetServerPrefs */ + #undef TOPR #undef HI #undef MED diff --git a/src/afs/afs_stat.c b/src/afs/afs_stat.c index 502040d26..591a6a814 100644 --- a/src/afs/afs_stat.c +++ b/src/afs/afs_stat.c @@ -70,16 +70,16 @@ void afs_InitStats(void) } } -int afs_GetCMStat(char **ptr, unsigned *size) +void afs_GetCMStat(char **ptr, unsigned *size) { #ifndef AFS_NOSTATS - AFS_STATCNT(afs_GetCMStat); - *ptr = (char *)&afs_cmstats; - *size = sizeof(afs_cmstats); + AFS_STATCNT(afs_GetCMStat); + *ptr = (char *)&afs_cmstats; + *size = sizeof(afs_cmstats); #endif /* AFS_NOSTATS */ } -int afs_AddToMean(struct afs_MeanStats *oldMean, afs_int32 newValue) +void afs_AddToMean(struct afs_MeanStats *oldMean, afs_int32 newValue) { - AFS_STATCNT(afs_AddToMean); + AFS_STATCNT(afs_AddToMean); } diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 9eb4ff4d4..d5fb0aaa4 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -824,6 +824,11 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) vm_info_ptr = tvc->v.v_vm_info; #endif /* AFS_MACH_ENV */ +#if defined(AFS_OBSD_ENV) + if (tvc->v) + panic("afs_NewVCache(): free vcache with vnode attached"); +#endif + #if !defined(AFS_SGI_ENV) && !defined(AFS_OSF_ENV) memset((char *)tvc, 0, sizeof(struct vcache)); #else @@ -839,6 +844,10 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) tvc->v.v_vm_info = vm_info_ptr; tvc->v.v_vm_info->pager = MEMORY_OBJECT_NULL; #endif /* AFS_MACH_ENV */ +#ifdef AFS_OBSD_ENV + afs_nbsd_getnewvnode(tvc); /* includes one refcount */ + lockinit(&tvc->rwlock, PINOD, "vcache", 0, 0); +#endif tvc->parentVnode = 0; tvc->mvid = NULL; tvc->linkData = NULL; @@ -863,7 +872,9 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) /* Hold it for the LRU (should make count 2) */ VN_HOLD(AFSTOV(tvc)); #else /* AFS_OSF_ENV */ +#ifndef AFS_OBSD_ENV VREFCOUNT_SET(tvc, 1); /* us */ +#endif /* AFS_OBSD_ENV */ #endif /* AFS_OSF_ENV */ #ifdef AFS_AIX32_ENV LOCK_INIT(&tvc->pvmlock, "vcache pvmlock"); -- 2.39.5