From 2c458e1fd5745de1507adc1409fd8f65bcd994e9 Mon Sep 17 00:00:00 2001 From: Chaskiel M Grundman Date: Mon, 22 Apr 2002 17:06:36 +0000 Subject: [PATCH] STABLE12-darwin-vnops-make-unlink-fix-fake-references-20020422 so unlink doesn't panic us (cherry picked from commit 6d43ab450a907bb1eccf9561c37c108202cd8e52) --- src/afs/VNOPS/afs_vnop_remove.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/afs/VNOPS/afs_vnop_remove.c b/src/afs/VNOPS/afs_vnop_remove.c index 3bdb16cfd..2dd60107d 100644 --- a/src/afs/VNOPS/afs_vnop_remove.c +++ b/src/afs/VNOPS/afs_vnop_remove.c @@ -415,6 +415,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. @@ -444,6 +455,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 { -- 2.39.5