More OpenBSD merge.
Please let me know if this breaks other architectures.
#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
/*
* 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)
* !(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 */
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)
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
};
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;
#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;
tb->size_parm[0] = asparm0;
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)
/* find a request */
tb = afs_brs;
foundAny = 0;
- min_tb = NULL;
for(i=0; i<NBRS; i++, tb++) {
/* look for request with smallest ts */
if ((tb->refCount > 0) && !(tb->flags & BSTARTED)) {
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;
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);
#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;i<aVolumes-1;i++)
if (code || !filevp) return ENOENT;
{
#if defined(AFS_SUN56_ENV)
- struct statvfs64 st;
+ struct statvfs64 st;
#else
#if defined(AFS_HPUX102_ENV)
- struct k_statvfs st;
+ struct k_statvfs st;
#else
#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) ||defined(AFS_HPUX100_ENV)
- struct statvfs st;
+ struct statvfs st;
#else
#if defined(AFS_DUX40_ENV)
- struct nstatfs st;
+ struct nstatfs st;
#else
- struct statfs st;
+ struct statfs st;
#endif /* DUX40 */
#endif /* SUN5 SGI */
#endif /* HP 10.20 */
#if defined(AFS_SGI_ENV)
#ifdef AFS_SGI65_ENV
- VFS_STATVFS(filevp->v_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 */
#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 */
theader.firstCSize == AFS_FIRSTCSIZE &&
theader.otherCSize == AFS_OTHERCSIZE &&
theader.version == AFS_CI_VERSION
- )
+ )
goodFile = 1;
}
if (!goodFile) {
#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;
#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
#endif /* AFS_SUN5_ENV */
#endif /* AFS_AIX32_ENV */
AFS_STATCNT(osi_SetTime);
- return 0;
}
#endif /* AFS_LINUX20_ENV */
};
struct osi_dev {
+#ifdef AFS_OBSD_ENV
+ struct mount *mp;
+ struct vnode *held_vnode;
+#else
afs_int32 dev;
+#endif
};
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)
#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
#define USERPRI
#endif
+#ifndef AFS_OBSD_ENV
/*
* vnode/vcache ref count manipulation
*/
#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
#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
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(); \
if (haveGlock) \
AFS_GLOCK(); \
} while(0)
-#endif /* AFS_OSF_ENV || AFS_FBSD_ENV */
+#endif
#else /* AFS_GLOBAL_SUNLOCK */
/* 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
{
#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;
}
/* 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);
/* 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
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);
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
/* 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);
#endif
#endif /* _AFS_PROTOTYPES_H_ */
-
}
#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
}
}
-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);
}
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
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;
/* 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");