darwin-vnops-make-unlink-fix-fake-references-20020422
[openafs.git] / src / afs / VNOPS / afs_vnop_remove.c
index 97c979a..1528d31 100644 (file)
@@ -442,6 +442,17 @@ afs_remunlink(avc, doit)
            cred = avc->uncred;
            avc->uncred = NULL;
 
+#ifdef AFS_DARWIN_ENV
+           /* this is called by vrele (via VOP_INACTIVE) when the refcount
+              is 0. we can't just call VN_HOLD since vref will panic.
+              we can't just call osi_vnhold because a later AFS_RELE will call
+              vrele again, which will try to call VOP_INACTIVE again after
+              vn_locking the vnode. which would be fine except that our vrele
+              caller also locked the vnode... So instead, we just gimmick the
+              refcounts and hope nobody else can touch the file now */
+           osi_Assert(VREFCOUNT(avc) == 0);
+           VREFCOUNT_SET(avc, 1);
+#endif
            VN_HOLD(&avc->v);
 
            /* We'll only try this once. If it fails, just release the vnode.
@@ -472,6 +483,10 @@ afs_remunlink(avc, doit)
            }
            osi_FreeSmallSpace(unlname);
            crfree(cred);
+#ifdef AFS_DARWIN_ENV
+           osi_Assert(VREFCOUNT(avc) == 1);
+           VREFCOUNT_SET(avc, 0);
+#endif
         }
     }
     else {