extern int Afs_xsetgroups();
extern int afs_xioctl();
-#if !defined(AFS_FBSD90_ENV)
+#if !defined(AFS_FBSD90_ENV) && !defined(AFS_FBSD82_ENV)
static sy_call_t *old_handler;
#else
static struct sysent old_sysent;
static struct sysent afs_sysent = {
5, /* int sy_narg */
- afs3_syscall, /* sy_call_t *sy_call */
+ (sy_call_t *) afs3_syscall, /* sy_call_t *sy_call */
#ifdef AFS_FBSD60_ENV
AUE_NULL, /* au_event_t sy_auevent */
#ifdef AFS_FBSD70_ENV
{
int code;
int offset = AFS_SYSCALL;
-#if defined(AFS_FBSD90_ENV)
+#if defined(AFS_FBSD90_ENV) || defined(AFS_FBSD82_ENV)
+# if defined(FBSD_SYSCALL_REGISTER_FOUR_ARGS)
+ code = syscall_register(&offset, &afs_sysent, &old_sysent, 0);
+# else
code = syscall_register(&offset, &afs_sysent, &old_sysent);
+# endif
if (code) {
printf("AFS_SYSCALL in use, error %i. aborting\n", code);
return code;
}
#else
- if (sysent[AFS_SYSCALL].sy_call != nosys
- && sysent[AFS_SYSCALL].sy_call != lkmnosys) {
+ if (sysent[AFS_SYSCALL].sy_call != (sy_call_t *)nosys
+ && sysent[AFS_SYSCALL].sy_call != (sy_call_t *)lkmnosys) {
printf("AFS_SYSCALL in use. aborting\n");
return EBUSY;
}
#endif
osi_Init();
afs_pbuf_freecnt = nswbuf / 2 + 1;
-#if !defined(AFS_FBSD90_ENV)
+#if !defined(AFS_FBSD90_ENV) && !defined(AFS_FBSD82_ENV)
old_handler = sysent[AFS_SYSCALL].sy_call;
sysent[AFS_SYSCALL].sy_call = afs3_syscall;
sysent[AFS_SYSCALL].sy_narg = 5;
int
afs_uninit(struct vfsconf *vfc)
{
-#if defined(AFS_FBSD90_ENV)
+#if defined(AFS_FBSD90_ENV) || defined(AFS_FBSD82_ENV)
int offset = AFS_SYSCALL;
#endif
if (afs_globalVFS)
return EBUSY;
-#if defined(AFS_FBSD90_ENV)
+#if defined(AFS_FBSD90_ENV) || defined(AFS_FBSD82_ENV)
syscall_deregister(&offset, &old_sysent);
#else
sysent[AFS_SYSCALL].sy_narg = 0;
afs_globalVFS = mp;
mp->vfs_bsize = 8192;
vfs_getnewfsid(mp);
-#ifdef AFS_FBSD70_ENV /* XXX 70? */
+ /*
+ * This is kind of ugly, as the interlock has grown to encompass
+ * more fields over time and there's not a good way to group the
+ * code without duplication.
+ */
+#ifdef AFS_FBSD62_ENV
MNT_ILOCK(mp);
+#endif
mp->mnt_flag &= ~MNT_LOCAL;
+#if defined(AFS_FBSD61_ENV) && !defined(AFS_FBSD62_ENV)
+ MNT_ILOCK(mp);
+#endif
+#if __FreeBSD_version < 1000021
mp->mnt_kern_flag |= MNTK_MPSAFE; /* solid steel */
#endif
+#ifndef AFS_FBSD61_ENV
+ MNT_ILOCK(mp);
+#endif
+ /*
+ * XXX mnt_stat "is considered stable as long as a ref is held".
+ * We should check that we hold the only ref.
+ */
mp->mnt_stat.f_iosize = 8192;
if (path != NULL)
strcpy(mp->mnt_stat.f_mntfromname, "AFS");
/* null terminated string "AFS" will fit, just leave it be. */
strcpy(mp->mnt_stat.f_fstypename, "afs");
-#ifdef AFS_FBSD70_ENV
MNT_IUNLOCK(mp);
-#endif
AFS_GUNLOCK();
#ifdef AFS_FBSD80_ENV
afs_statfs(mp, &mp->mnt_stat);
#ifdef AFS_FBSD60_ENV
static int
-#ifdef AFS_FBSD80_ENV
+#if (__FreeBSD_version >= 900503 && __FreeBSD_version < 1000000) || __FreeBSD_version >= 1000004
+afs_cmount(struct mntarg *ma, void *data, uint64_t flags)
+#elif defined(AFS_FBSD80_ENV)
afs_cmount(struct mntarg *ma, void *data, int flags)
#else
afs_cmount(struct mntarg *ma, void *data, int flags, struct thread *td)
{
int error = 0;
+ AFS_GLOCK();
+ if (afs_globalVp &&
+ ((flags & MNT_FORCE) || !VREFCOUNT_GT(afs_globalVp, 1))) {
+ /* Put back afs_root's ref */
+ struct vcache *gvp = afs_globalVp;
+ afs_globalVp = NULL;
+ afs_PutVCache(gvp);
+ }
+ if (afs_globalVp)
+ error = EBUSY;
+ AFS_GUNLOCK();
+
/*
* Release any remaining vnodes on this mount point.
* The `1' means that we hold one extra reference on
* the root vnode (this is just a guess right now).
* This has to be done outside the global lock.
*/
+ if (!error) {
#if defined(AFS_FBSD80_ENV)
- error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, curthread);
+ error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, curthread);
#elif defined(AFS_FBSD53_ENV)
- error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p);
+ error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p);
#else
- error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0);
+ error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0);
#endif
+ }
if (error)
goto out;
AFS_GLOCK();
int error;
struct vrequest treq;
struct vcache *tvp = 0;
+ struct vcache *gvp;
#if !defined(AFS_FBSD53_ENV) || defined(AFS_FBSD80_ENV)
struct thread *td = curthread;
#endif
AFS_GLOCK();
AFS_STATCNT(afs_root);
crhold(cr);
+tryagain:
if (afs_globalVp && (afs_globalVp->f.states & CStatd)) {
tvp = afs_globalVp;
error = 0;
} else {
-tryagain:
- if (afs_globalVp) {
- afs_PutVCache(afs_globalVp);
- /* vrele() needed here or not? */
- afs_globalVp = NULL;
- }
if (!(error = afs_InitReq(&treq, cr)) && !(error = afs_CheckInit())) {
tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
/* we really want this to stay around */
- if (tvp)
+ if (tvp) {
+ gvp = afs_globalVp;
afs_globalVp = tvp;
- else
+ if (gvp) {
+ afs_PutVCache(gvp);
+ if (tvp != afs_globalVp) {
+ /* someone raced us and won */
+ afs_PutVCache(tvp);
+ goto tryagain;
+ }
+ }
+ } else
error = ENOENT;
}
}
ASSERT_VI_UNLOCKED(vp, "afs_root");
AFS_GUNLOCK();
+ error = vget(vp, LK_EXCLUSIVE | LK_RETRY, td);
+ AFS_GLOCK();
+ /* we dropped the glock, so re-check everything it had serialized */
+ if (!afs_globalVp || !(afs_globalVp->f.states & CStatd) ||
+ tvp != afs_globalVp) {
+ vput(vp);
+ afs_PutVCache(tvp);
+ goto tryagain;
+ }
+ if (error != 0)
+ goto tryagain;
/*
* I'm uncomfortable about this. Shouldn't this happen at a
* higher level, and shouldn't we busy the top-level directory
* to prevent recycling?
*/
- error = vget(vp, LK_EXCLUSIVE | LK_RETRY, td);
vp->v_vflag |= VV_ROOT;
- AFS_GLOCK();
- if (error != 0)
- goto tryagain;
afs_globalVFS = mp;
*vpp = vp;
abp->f_bsize = mp->vfs_bsize;
abp->f_iosize = mp->vfs_bsize;
- /* Fake a high number below to satisfy programs that use the statfs call
- * to make sure that there's enough space in the device partition before
- * storing something there.
- */
abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
- abp->f_ffree = 2000000;
+ abp->f_ffree = AFS_VFS_FAKEFREE;
abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];