Initialize zfs vnode v_hash when the vnode is allocated, instead of

postponing it to zfs_vget().  zfs_root() returned vnode with the
default value of v_hash, which caused inconsistent v_hash value when
root vnode was obtained from zfs_vget().

Nullfs allocated two upper vnodes for the root zfs vnode due to
different hashes, causing consistency problems.

Reported and tested by:	Harald Schmalzbauer <h.schmalzbauer@omnilan.de>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2014-07-28 14:24:18 +00:00
parent 9a0f8af7d4
commit fe0e9a63e0
2 changed files with 3 additions and 4 deletions

View File

@ -2075,8 +2075,6 @@ zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t **vpp)
err = vn_lock(*vpp, flags);
if (err != 0)
*vpp = NULL;
else
(*vpp)->v_hash = ino;
return (err);
}

View File

@ -1228,9 +1228,10 @@ again:
vnode_t *vp = ZTOV(zp);
err = insmntque(vp, zfsvfs->z_vfs);
if (err == 0)
if (err == 0) {
vp->v_hash = obj_num;
VOP_UNLOCK(vp, 0);
else {
} else {
zp->z_vnode = NULL;
zfs_znode_dmu_fini(zp);
zfs_znode_free(zp);