fix .zfs-related cases in zfs_lookup that were broken by r303763
The problem is that the special .zfs nodes are not represented by znodes but by special gfs-based nodes. r303763 changed interface of zfs_dirlook such that started operating on znodes rather than on vnodes and, thus, the function became unsuitable for handling .zfs entities. The solution is to move the handling of the special cases to zfs_lookup, the only consumer of zfs_dirlook. I already had this solution applied in D7421, but for different reasons. Reported by: asomers MFC after: 3 days X-MFC with: r303763
This commit is contained in:
parent
8478efdf71
commit
e3997b40b9
@ -173,7 +173,6 @@ zfs_dd_lookup(znode_t *dzp, znode_t **zpp)
|
||||
{
|
||||
zfsvfs_t *zfsvfs = dzp->z_zfsvfs;
|
||||
znode_t *zp;
|
||||
vnode_t *vp;
|
||||
uint64_t parent;
|
||||
int error;
|
||||
|
||||
@ -187,19 +186,7 @@ zfs_dd_lookup(znode_t *dzp, znode_t **zpp)
|
||||
SA_ZPL_PARENT(zfsvfs), &parent, sizeof (parent))) != 0)
|
||||
return (error);
|
||||
|
||||
/*
|
||||
* If we are a snapshot mounted under .zfs, return
|
||||
* the snapshot directory.
|
||||
*/
|
||||
if (parent == dzp->z_id && zfsvfs->z_parent != zfsvfs) {
|
||||
error = zfsctl_root_lookup(zfsvfs->z_parent->z_ctldir,
|
||||
"snapshot", &vp, NULL, 0, NULL, kcred,
|
||||
NULL, NULL, NULL);
|
||||
if (error == 0)
|
||||
zp = VTOZ(vp);
|
||||
} else {
|
||||
error = zfs_zget(zfsvfs, parent, &zp);
|
||||
}
|
||||
error = zfs_zget(zfsvfs, parent, &zp);
|
||||
if (error == 0)
|
||||
*zpp = zp;
|
||||
return (error);
|
||||
@ -222,8 +209,6 @@ zfs_dirlook(znode_t *dzp, const char *name, znode_t **zpp)
|
||||
*zpp = dzp;
|
||||
} else if (name[0] == '.' && name[1] == '.' && name[2] == 0) {
|
||||
error = zfs_dd_lookup(dzp, zpp);
|
||||
} else if (zfs_has_ctldir(dzp) && strcmp(name, ZFS_CTLDIR_NAME) == 0) {
|
||||
*zpp = VTOZ(zfsctl_root(dzp));
|
||||
} else {
|
||||
error = zfs_dirent_lookup(dzp, name, &zp, ZEXISTS);
|
||||
if (error == 0) {
|
||||
|
@ -1605,6 +1605,39 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct componentname *cnp,
|
||||
return (SET_ERROR(EILSEQ));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* First handle the special cases.
|
||||
*/
|
||||
if ((cnp->cn_flags & ISDOTDOT) != 0) {
|
||||
/*
|
||||
* If we are a snapshot mounted under .zfs, return
|
||||
* the vp for the snapshot directory.
|
||||
*/
|
||||
if (zdp->z_id == zfsvfs->z_root && zfsvfs->z_parent != zfsvfs) {
|
||||
error = zfsctl_root_lookup(zfsvfs->z_parent->z_ctldir,
|
||||
"snapshot", vpp, NULL, 0, NULL, kcred,
|
||||
NULL, NULL, NULL);
|
||||
ZFS_EXIT(zfsvfs);
|
||||
if (error == 0) {
|
||||
error = zfs_lookup_lock(dvp, *vpp, nm,
|
||||
cnp->cn_lkflags);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
if (zfs_has_ctldir(zdp) && strcmp(nm, ZFS_CTLDIR_NAME) == 0) {
|
||||
error = 0;
|
||||
if ((cnp->cn_flags & ISLASTCN) != 0 && nameiop != LOOKUP)
|
||||
error = SET_ERROR(ENOTSUP);
|
||||
else
|
||||
*vpp = zfsctl_root(zdp);
|
||||
ZFS_EXIT(zfsvfs);
|
||||
if (error == 0)
|
||||
error = zfs_lookup_lock(dvp, *vpp, nm, cnp->cn_lkflags);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* The loop is retry the lookup if the parent-child relationship
|
||||
* changes during the dot-dot locking complexities.
|
||||
@ -1653,6 +1686,7 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct componentname *cnp,
|
||||
vput(ZTOV(zp));
|
||||
}
|
||||
|
||||
out:
|
||||
if (error != 0)
|
||||
*vpp = NULL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user