From 2a8e7dad33f5a14c19fc5e3404cdb9c4fa34dd15 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Sat, 12 Sep 2009 19:27:54 +0000 Subject: [PATCH] Tighten up the check for race in zfs_zget() - ZTOV(zp) can not only contain NULL, but also can point to dead vnode, take that into account. PR: kern/132068 Reported by: Edward Fisk" <7ogcg7g02@sneakemail.com>, kris Fix based on patch from: Jaakko Heinonen MFC after: 1 week --- .../opensolaris/uts/common/fs/zfs/zfs_znode.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c index a6172f81a03a..f90b413ddafe 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c @@ -890,8 +890,16 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp) if (zp->z_unlinked) { err = ENOENT; } else { - if (ZTOV(zp) != NULL) - VN_HOLD(ZTOV(zp)); + if ((vp = ZTOV(zp)) != NULL) { + VI_LOCK(vp); + if ((vp->v_iflag & VI_DOOMED) != 0) { + VI_UNLOCK(vp); + vp = NULL; + } else + VI_UNLOCK(vp); + } + if (vp != NULL) + VN_HOLD(vp); else { if (first) { ZFS_LOG(1, "dying znode detected (zp=%p)", zp);