From: Garrett Wollman Date: Wed, 10 Aug 2011 04:18:28 +0000 (-0400) Subject: FBSD: catch up with the disappearance of VOP_GETVOBJECT X-Git-Tag: openafs-devel-1_7_1~168 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=7d0cd1393ff5c69cba2f14fc76aa8f7ca588ccc3 FBSD: catch up with the disappearance of VOP_GETVOBJECT The vnode operation VOP_GETVOBJECT disappeared in FreeBSD 6.0, an embarrassingly long time ago. Six years ago, a kluge was added to emulate its behavior, but it did not correctly emulate the return value of the old VOP implementation. As a result, osi_VM_StoreAllSegments() could never actually do anything. Since we don't support FreeBSD before 8.0, remove all references to VOP_GETVOBJECT and examine vp->v_object directly instead. This has the result that osi_VM_StoreAllSegments() will actually do something now, which may not be desirable. (Previously, if somehow the vnode had no associated VM object, it would crash, and otherwise it would do nothing at all.) Change-Id: Ifdad92ae8e393e85c3f97907af7119ce342b25dd Found-by: clang static analyzer Reviewed-on: http://gerrit.openafs.org/5183 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/afs/FBSD/osi_vm.c b/src/afs/FBSD/osi_vm.c index c49d0c2..072142d 100644 --- a/src/afs/FBSD/osi_vm.c +++ b/src/afs/FBSD/osi_vm.c @@ -35,11 +35,9 @@ * FreeBSD implementation notes: * Most of these operations require us to frob vm_objects. Most * functions require that the object be locked (with VM_OBJECT_LOCK) - * on entry and leave it locked on exit. In order to get the - * vm_object itself we call VOP_GETVOBJECT on the vnode; the - * locking protocol requires that we do so with the heavy vnode lock - * held and the vnode interlock unlocked, and it returns the same - * way. + * on entry and leave it locked on exit. The locking protocol + * requires that we access vp->v_object with the heavy vnode lock + * held and the vnode interlock unlocked. * * The locking protocol for vnodes is defined in * kern/vnode_if.src and sys/vnode.h; unfortunately, it is not *quite* @@ -47,10 +45,6 @@ * check the VCS history of those files. */ -#ifdef AFS_FBSD60_ENV -#define VOP_GETVOBJECT(vp, objp) (*(objp) = (vp)->v_object) -#endif - #if defined(AFS_FBSD80_ENV) #define lock_vnode(v, f) vn_lock((v), (f)) #define ilock_vnode(v) vn_lock((v), LK_INTERLOCK|LK_EXCLUSIVE|LK_RETRY); @@ -154,9 +148,12 @@ osi_VM_StoreAllSegments(struct vcache *avc) */ do { anyio = 0; - if (VOP_GETVOBJECT(vp, &obj) == 0 && (obj->flags & OBJ_MIGHTBEDIRTY)) { + + obj = vp->v_object; + if (obj != NULL && obj->flags & OBJ_MIGHTBEDIRTY) { if (!vget(vp, LK_EXCLUSIVE | LK_RETRY, curthread)) { - if (VOP_GETVOBJECT(vp, &obj) == 0) { + obj = vp->v_object; + if (obj != NULL) { VM_OBJECT_LOCK(obj); vm_object_page_clean(obj, 0, 0, OBJPC_SYNC); VM_OBJECT_UNLOCK(obj); @@ -249,7 +246,8 @@ osi_VM_FlushPages(struct vcache *avc, afs_ucred_t *credp) vp = AFSTOV(avc); ASSERT_VOP_LOCKED(vp, __func__); - if (VOP_GETVOBJECT(vp, &obj) == 0) { + obj = vp->v_object; + if (obj != NULL) { VM_OBJECT_LOCK(obj); vm_object_page_remove(obj, 0, 0, FALSE); VM_OBJECT_UNLOCK(obj);