mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
FBSD: Use vrefl() when available
Commit 81ea6544
(FBSD: avoid vrefl()) removed our reference to
vrefl(), since it was only introduced with FreeBSD 11.0. However, it
was replaced with calls to vref() and vrele(), the latter of which can
lock the vnode, and generally is allowed to sleep.
Many osi_vnhold callers hold AFS_GLOCK, which is a non-sleepable lock,
so this can cause a panic if the vnode is VI_DOOMED and locked by
another thread.
To avoid this on at least modern FreeBSD releases, use vrefl() when it
is available (since <https://reviews.freebsd.org/D4953>).
Change-Id: I535af9d58380bb1fd108b8a953b6c26a1c818d94
Reviewed-on: https://gerrit.openafs.org/14796
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
This commit is contained in:
parent
8d4d197f0a
commit
8495165c3d
@ -13,6 +13,12 @@
|
||||
#include "afs/sysincludes.h" /*Standard vendor system headers */
|
||||
#include "afsincludes.h" /*AFS-based standard headers */
|
||||
|
||||
#if __FreeBSD_version >= 1100095
|
||||
# define HAVE_VREFL 1
|
||||
#else
|
||||
# define HAVE_VREFL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
|
||||
{
|
||||
@ -126,6 +132,24 @@ osi_PostPopulateVCache(struct vcache *avc)
|
||||
vSetType(avc, VREG);
|
||||
}
|
||||
|
||||
#if HAVE_VREFL
|
||||
int
|
||||
osi_vnhold(struct vcache *avc)
|
||||
{
|
||||
struct vnode *vp = AFSTOV(avc);
|
||||
|
||||
VI_LOCK(vp);
|
||||
if ((vp->v_iflag & VI_DOOMED) != 0) {
|
||||
VI_UNLOCK(vp);
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
vrefl(vp);
|
||||
|
||||
VI_UNLOCK(vp);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int
|
||||
osi_vnhold(struct vcache *avc)
|
||||
{
|
||||
@ -142,3 +166,4 @@ osi_vnhold(struct vcache *avc)
|
||||
VI_UNLOCK(vp);
|
||||
return 0;
|
||||
}
|
||||
#endif /* HAVE_VREFL */
|
||||
|
Loading…
Reference in New Issue
Block a user