vfs: make relookup take an additional argument
instead of looking at SAVESTART This is a step towards removing the flag. Reviewed by: mckusick Tested by: pho Differential Revision: https://reviews.freebsd.org/D34468
This commit is contained in:
parent
65127e982b
commit
8f874e92eb
@ -910,7 +910,7 @@ ext2_rename(struct vop_rename_args *ap)
|
||||
if (error)
|
||||
goto out;
|
||||
VREF(tdvp);
|
||||
error = vfs_relookup(tdvp, &tvp, tcnp);
|
||||
error = vfs_relookup(tdvp, &tvp, tcnp, true);
|
||||
if (error)
|
||||
goto out;
|
||||
vrele(tdvp);
|
||||
@ -1036,7 +1036,7 @@ ext2_rename(struct vop_rename_args *ap)
|
||||
fcnp->cn_flags &= ~MODMASK;
|
||||
fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
|
||||
VREF(fdvp);
|
||||
error = vfs_relookup(fdvp, &fvp, fcnp);
|
||||
error = vfs_relookup(fdvp, &fvp, fcnp, true);
|
||||
if (error == 0)
|
||||
vrele(fdvp);
|
||||
if (fvp != NULL) {
|
||||
|
@ -662,6 +662,7 @@ unionfs_relookup(struct vnode *dvp, struct vnode **vpp,
|
||||
char *path, int pathlen, u_long nameiop)
|
||||
{
|
||||
int error;
|
||||
bool refstart;
|
||||
|
||||
cn->cn_namelen = pathlen;
|
||||
cn->cn_pnbuf = path;
|
||||
@ -671,17 +672,20 @@ unionfs_relookup(struct vnode *dvp, struct vnode **vpp,
|
||||
cn->cn_cred = cnp->cn_cred;
|
||||
cn->cn_nameptr = cn->cn_pnbuf;
|
||||
|
||||
if (nameiop == DELETE)
|
||||
cn->cn_flags |= (cnp->cn_flags & (DOWHITEOUT | SAVESTART));
|
||||
else if (RENAME == nameiop)
|
||||
cn->cn_flags |= (cnp->cn_flags & SAVESTART);
|
||||
else if (nameiop == CREATE)
|
||||
refstart = false;
|
||||
if (nameiop == DELETE) {
|
||||
cn->cn_flags |= (cnp->cn_flags & DOWHITEOUT);
|
||||
refstart = (cnp->cn_flags & SAVESTART) != 0;
|
||||
} else if (RENAME == nameiop) {
|
||||
refstart = (cnp->cn_flags & SAVESTART) != 0;
|
||||
} else if (nameiop == CREATE) {
|
||||
cn->cn_flags |= NOCACHE;
|
||||
}
|
||||
|
||||
vref(dvp);
|
||||
VOP_UNLOCK(dvp);
|
||||
|
||||
if ((error = vfs_relookup(dvp, vpp, cn))) {
|
||||
if ((error = vfs_relookup(dvp, vpp, cn, refstart))) {
|
||||
vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
|
||||
} else
|
||||
vrele(dvp);
|
||||
@ -1017,7 +1021,7 @@ unionfs_vn_create_on_upper(struct vnode **vpp, struct vnode *udvp,
|
||||
NDPREINIT(&nd);
|
||||
|
||||
vref(udvp);
|
||||
if ((error = vfs_relookup(udvp, &vp, &nd.ni_cnd)) != 0)
|
||||
if ((error = vfs_relookup(udvp, &vp, &nd.ni_cnd, false)) != 0)
|
||||
goto unionfs_vn_create_on_upper_free_out2;
|
||||
vrele(udvp);
|
||||
|
||||
|
@ -1435,7 +1435,8 @@ vfs_lookup(struct nameidata *ndp)
|
||||
* Used by lookup to re-acquire things.
|
||||
*/
|
||||
int
|
||||
vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
|
||||
vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp,
|
||||
bool refstart)
|
||||
{
|
||||
struct vnode *dp = NULL; /* the directory we are searching */
|
||||
int rdonly; /* lookup read-only flag bit */
|
||||
@ -1479,7 +1480,7 @@ vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
|
||||
VOP_UNLOCK(dp);
|
||||
*vpp = dp;
|
||||
/* XXX This should probably move to the top of function. */
|
||||
if (cnp->cn_flags & SAVESTART)
|
||||
if (refstart)
|
||||
panic("lookup: SAVESTART");
|
||||
return (0);
|
||||
}
|
||||
@ -1506,7 +1507,7 @@ vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
|
||||
goto bad;
|
||||
}
|
||||
/* ASSERT(dvp == ndp->ni_startdir) */
|
||||
if (cnp->cn_flags & SAVESTART)
|
||||
if (refstart)
|
||||
VREF(dvp);
|
||||
if ((cnp->cn_flags & LOCKPARENT) == 0)
|
||||
VOP_UNLOCK(dp);
|
||||
@ -1544,7 +1545,7 @@ vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
|
||||
("relookup: symlink found.\n"));
|
||||
|
||||
/* ASSERT(dvp == ndp->ni_startdir) */
|
||||
if (cnp->cn_flags & SAVESTART)
|
||||
if (refstart)
|
||||
VREF(dvp);
|
||||
|
||||
if ((cnp->cn_flags & LOCKLEAF) == 0)
|
||||
|
@ -293,7 +293,7 @@ do { \
|
||||
int namei(struct nameidata *ndp);
|
||||
int vfs_lookup(struct nameidata *ndp);
|
||||
int vfs_relookup(struct vnode *dvp, struct vnode **vpp,
|
||||
struct componentname *cnp);
|
||||
struct componentname *cnp, bool refstart);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user