From 3c91f1d88165dca085a26b87f2c0148e84e179d2 Mon Sep 17 00:00:00 2001 From: Ben Kaduk Date: Thu, 13 Jan 2011 20:16:44 -0500 Subject: [PATCH] FBSD: remove vestiges of Giant We do not support versions of FreeBSD that used Giant to serialize access to vnode fields, and we always use the same locking (which really ought to be MPSAFE). Always set the MPSAFE flags as needed, and do not bother to call VFS_[UN]LOCK_GIANT which will never do anything for us. Change-Id: I973a24d43563f289d4a2baa6e067fbba72d17ed9 Reviewed-on: http://gerrit.openafs.org/3656 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/FBSD/osi_misc.c | 4 +--- src/afs/FBSD/osi_vfsops.c | 19 ++++++++++++++++--- src/afs/FBSD/osi_vm.c | 6 +++--- src/afs/FBSD/osi_vnodeops.c | 2 -- src/afs/afs_dcache.c | 14 -------------- src/afs/afs_osi_vm.c | 9 --------- 6 files changed, 20 insertions(+), 34 deletions(-) diff --git a/src/afs/FBSD/osi_misc.c b/src/afs/FBSD/osi_misc.c index 6c2876d..2ece43d 100644 --- a/src/afs/FBSD/osi_misc.c +++ b/src/afs/FBSD/osi_misc.c @@ -37,9 +37,7 @@ osi_lookupname(char *aname, enum uio_seg seg, int followlink, flags |= FOLLOW; else flags |= NOFOLLOW; -#ifdef AFS_FBSD80_ENV - flags |= MPSAFE; /* namei must take GIANT if needed */ -#endif + flags |= MPSAFE; /* namei must take Giant if needed */ NDINIT(&n, LOOKUP, flags, seg, aname, curthread); if ((error = namei(&n)) != 0) { if (glocked) diff --git a/src/afs/FBSD/osi_vfsops.c b/src/afs/FBSD/osi_vfsops.c index b956b80..b300ff4 100644 --- a/src/afs/FBSD/osi_vfsops.c +++ b/src/afs/FBSD/osi_vfsops.c @@ -123,11 +123,26 @@ afs_omount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp, 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 mp->mnt_kern_flag |= MNTK_MPSAFE; /* solid steel */ +#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) @@ -139,9 +154,7 @@ afs_omount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp, 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); diff --git a/src/afs/FBSD/osi_vm.c b/src/afs/FBSD/osi_vm.c index fbff37f..cbbe5c0 100644 --- a/src/afs/FBSD/osi_vm.c +++ b/src/afs/FBSD/osi_vm.c @@ -43,9 +43,9 @@ * way. * * The locking protocol for vnodes is defined in - * kern/vnode_if.src and sys/vnode.h; the locking is still a work in - * progress, so some fields are (as of 5.1) still protected by Giant - * rather than an explicit lock. + * kern/vnode_if.src and sys/vnode.h; unfortunately, it is not *quite* + * constant from version to version so to be properly correct we must + * check the VCS history of those files. */ #ifdef AFS_FBSD60_ENV diff --git a/src/afs/FBSD/osi_vnodeops.c b/src/afs/FBSD/osi_vnodeops.c index 99a3d71..5352b64 100644 --- a/src/afs/FBSD/osi_vnodeops.c +++ b/src/afs/FBSD/osi_vnodeops.c @@ -501,9 +501,7 @@ afs_vop_lookup(ap) lockparent = flags & LOCKPARENT; wantparent = flags & (LOCKPARENT | WANTPARENT); -#ifdef AFS_FBSD80_ENV cnp->cn_flags |= MPSAFE; /* steel */ -#endif #ifndef AFS_FBSD70_ENV if (flags & ISDOTDOT) diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index fa569c9..91c4ae0 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -564,13 +564,6 @@ afs_GetDownD(int anumber, int *aneedSpace, afs_int32 buckethint) afs_uint32 maxVictimPtr; /* where it is */ int discard; int curbucket; -#if defined(AFS_FBSD80_ENV) && !defined(UKERNEL) - int vfslocked; -#endif - -#if defined(AFS_FBSD80_ENV) && !defined(UKERNEL) - vfslocked = VFS_LOCK_GIANT(afs_globalVFS); -#endif AFS_STATCNT(afs_GetDownD); @@ -582,9 +575,6 @@ afs_GetDownD(int anumber, int *aneedSpace, afs_int32 buckethint) if (!aneedSpace || *aneedSpace <= 0) { anumber -= afs_freeDCCount; if (anumber <= 0) { -#if defined(AFS_FBSD80_ENV) && !defined(UKERNEL) - VFS_UNLOCK_GIANT(vfslocked); -#endif return; /* enough already free */ } } @@ -862,10 +852,6 @@ afs_GetDownD(int anumber, int *aneedSpace, afs_int32 buckethint) } } /* big while loop */ -#if defined(AFS_FBSD80_ENV) && !defined(UKERNEL) - VFS_UNLOCK_GIANT(vfslocked); -#endif - return; } /*afs_GetDownD */ diff --git a/src/afs/afs_osi_vm.c b/src/afs/afs_osi_vm.c index 434d062..c26df6d 100644 --- a/src/afs/afs_osi_vm.c +++ b/src/afs/afs_osi_vm.c @@ -47,9 +47,6 @@ osi_Active(struct vcache *avc) void osi_FlushPages(struct vcache *avc, afs_ucred_t *credp) { -#ifdef AFS_FBSD70_ENV - int vfslocked; -#endif afs_hyper_t origDV; #if defined(AFS_CACHE_BYPASS) /* The optimization to check DV under read lock below is identical a @@ -90,9 +87,6 @@ osi_FlushPages(struct vcache *avc, afs_ucred_t *credp) ICL_TYPE_INT32, origDV.low, ICL_TYPE_INT32, avc->f.m.Length); ReleaseWriteLock(&avc->lock); -#ifdef AFS_FBSD70_ENV - vfslocked = VFS_LOCK_GIANT(AFSTOV(avc)->v_mount); -#endif #ifndef AFS_FBSD70_ENV AFS_GUNLOCK(); #endif @@ -100,9 +94,6 @@ osi_FlushPages(struct vcache *avc, afs_ucred_t *credp) #ifndef AFS_FBSD70_ENV AFS_GLOCK(); #endif -#ifdef AFS_FBSD70_ENV - VFS_UNLOCK_GIANT(vfslocked); -#endif ObtainWriteLock(&avc->lock, 88); /* do this last, and to original version, since stores may occur -- 1.9.4