MFC r270207:
Rework ".." lookup; previous one failed to properly busy the mountpoint. Reviewed by: kib@ Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
e8d76f86d2
commit
35b1298891
@ -197,6 +197,15 @@ autofs_trigger_vn(struct vnode *vp, const char *path, int pathlen,
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
autofs_vget_callback(struct mount *mp, void *arg, int lkflags __unused,
|
||||||
|
struct vnode **vpp)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
return (autofs_node_vn(arg, mp, vpp));
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
autofs_lookup(struct vop_lookup_args *ap)
|
autofs_lookup(struct vop_lookup_args *ap)
|
||||||
{
|
{
|
||||||
@ -217,24 +226,19 @@ autofs_lookup(struct vop_lookup_args *ap)
|
|||||||
if (cnp->cn_flags & ISDOTDOT) {
|
if (cnp->cn_flags & ISDOTDOT) {
|
||||||
KASSERT(anp->an_parent != NULL, ("NULL parent"));
|
KASSERT(anp->an_parent != NULL, ("NULL parent"));
|
||||||
/*
|
/*
|
||||||
* Note that in this case, dvp is the child vnode, and we are
|
* Note that in this case, dvp is the child vnode, and we
|
||||||
* looking up the parent vnode - exactly reverse from normal
|
* are looking up the parent vnode - exactly reverse from
|
||||||
* operation. To preserve lock order, we unlock the child
|
* normal operation. Unlocking dvp requires some rather
|
||||||
* (dvp), obtain the lock on parent (*vpp) in autofs_node_vn(),
|
* tricky unlock/relock dance to prevent mp from being freed;
|
||||||
* then relock the child. We use vhold()/vdrop() to prevent
|
* use vn_vget_ino_gen() which takes care of all that.
|
||||||
* dvp from being freed in the meantime.
|
|
||||||
*/
|
*/
|
||||||
lock_flags = VOP_ISLOCKED(dvp);
|
error = vn_vget_ino_gen(dvp, autofs_vget_callback,
|
||||||
vhold(dvp);
|
anp->an_parent, 0, vpp);
|
||||||
VOP_UNLOCK(dvp, 0);
|
|
||||||
error = autofs_node_vn(anp->an_parent, mp, vpp);
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
AUTOFS_WARN("autofs_node_vn() failed with error %d",
|
AUTOFS_WARN("vn_vget_ino_gen() failed with error %d",
|
||||||
error);
|
error);
|
||||||
|
return (error);
|
||||||
}
|
}
|
||||||
vn_lock(dvp, lock_flags | LK_RETRY);
|
|
||||||
vdrop(dvp);
|
|
||||||
|
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user