Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Feb 2009 16:01:00 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r188817 - in stable/7/sys: . cddl/contrib/opensolaris/uts/common/fs cddl/contrib/opensolaris/uts/common/fs/zfs contrib/pf dev/ath/ath_hal dev/cxgb
Message-ID:  <200902191601.n1JG10YG001669@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Feb 19 16:01:00 2009
New Revision: 188817
URL: http://svn.freebsd.org/changeset/base/188817

Log:
  Unbreak ZFS after the r188610:
  
  MFC r182781 (by pjd):
  Catch up after last insmntque() changes:
  - The vnode has to be locked exclusively before calling insmntque().
  - Until I find a way to handle insmntque() failures use VV_FORCEINSMQ flag
    to force insmntque() to always succeed.
  
  MFC r182824 (by pjd):
  Lock vnode exclusively around insmntque().
  
  MFC r182840 (by pjd):
  Initialize vp, so we don't call VOP_UNLOCK() with NULL vnode pointer.
  
  Tested by:	cy, pjd
  No objections by:	pjd

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c
  stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
  stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)

Modified: stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c
==============================================================================
--- stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c	Thu Feb 19 15:37:43 2009	(r188816)
+++ stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c	Thu Feb 19 16:01:00 2009	(r188817)
@@ -358,6 +358,7 @@ gfs_file_create(size_t size, vnode_t *pv
 	fp = kmem_zalloc(size, KM_SLEEP);
 	error = getnewvnode("zfs", vfsp, ops, &vp);
 	ASSERT(error == 0);
+	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curthread);
 	vp->v_data = (caddr_t)fp;
 
 	/*
@@ -368,7 +369,9 @@ gfs_file_create(size_t size, vnode_t *pv
 	fp->gfs_size = size;
 	fp->gfs_type = GFS_FILE;
 
+	vp->v_vflag |= VV_FORCEINSMQ;
 	error = insmntque(vp, vfsp);
+	vp->v_vflag &= ~VV_FORCEINSMQ;
 	KASSERT(error == 0, ("insmntque() failed: error %d", error));
 
 	/*

Modified: stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
==============================================================================
--- stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c	Thu Feb 19 15:37:43 2009	(r188816)
+++ stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c	Thu Feb 19 16:01:00 2009	(r188817)
@@ -176,6 +176,8 @@ zfsctl_create(zfsvfs_t *zfsvfs)
 	vp->v_vflag &= ~VV_ROOT;
 
 	zfsvfs->z_ctldir = vp;
+
+	VOP_UNLOCK(vp, 0, curthread);
 }
 
 /*
@@ -789,6 +791,7 @@ zfsctl_mknode_snapdir(vnode_t *pvp)
 	mutex_init(&sdp->sd_lock, NULL, MUTEX_DEFAULT, NULL);
 	avl_create(&sdp->sd_snaps, snapentry_compare,
 	    sizeof (zfs_snapentry_t), offsetof(zfs_snapentry_t, se_node));
+	VOP_UNLOCK(vp, 0, curthread);
 	return (vp);
 }
 
@@ -862,6 +865,7 @@ zfsctl_snapshot_mknode(vnode_t *pvp, uin
 	    &zfsctl_ops_snapshot, NULL, NULL, MAXNAMELEN, NULL, NULL);
 	zcp = vp->v_data;
 	zcp->zc_id = objset;
+	VOP_UNLOCK(vp, 0, curthread);
 
 	return (vp);
 }

Modified: stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==============================================================================
--- stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Thu Feb 19 15:37:43 2009	(r188816)
+++ stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Thu Feb 19 16:01:00 2009	(r188817)
@@ -1303,12 +1303,6 @@ top:
 		}
 	}
 out:
-
-	if (error == 0) {
-		*vpp = ZTOV(zp);
-		vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, td);
-	}
-
 	if (dl)
 		zfs_dirent_unlock(dl);
 
@@ -1588,8 +1582,6 @@ top:
 	zfs_log_create(zilog, tx, TX_MKDIR, dzp, zp, dirname);
 	dmu_tx_commit(tx);
 
-	vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curthread);
-
 	zfs_dirent_unlock(dl);
 
 	ZFS_EXIT(zfsvfs);
@@ -2773,7 +2765,6 @@ out:
 	if (error == 0) {
 		zfs_log_symlink(zilog, tx, TX_SYMLINK, dzp, zp, name, link);
 		*vpp = ZTOV(zp);
-		vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, td);
 	}
 
 	dmu_tx_commit(tx);

Modified: stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
==============================================================================
--- stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c	Thu Feb 19 15:37:43 2009	(r188816)
+++ stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c	Thu Feb 19 16:01:00 2009	(r188817)
@@ -113,6 +113,7 @@ zfs_znode_cache_constructor(void *buf, v
 	if (cdrarg != NULL) {
 		error = getnewvnode("zfs", vfsp, &zfs_vnodeops, &vp);
 		ASSERT(error == 0);
+		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curthread);
 		zp->z_vnode = vp;
 		vp->v_data = (caddr_t)zp;
 		vp->v_vnlock->lk_flags |= LK_CANRECURSE;
@@ -348,7 +349,9 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_bu
 	if (vp == NULL)
 		return (zp);
 
+	vp->v_vflag |= VV_FORCEINSMQ;
 	error = insmntque(vp, zfsvfs->z_vfs);
+	vp->v_vflag &= ~VV_FORCEINSMQ;
 	KASSERT(error == 0, ("insmntque() failed: error %d", error));
 
 	vp->v_type = IFTOVT((mode_t)zp->z_phys->zp_mode);
@@ -535,8 +538,10 @@ zfs_mknode(znode_t *dzp, vattr_t *vap, u
 
 		*zpp = zp;
 	} else {
-		if (ZTOV(zp) != NULL)
+		if (ZTOV(zp) != NULL) {
 			ZTOV(zp)->v_count = 0;
+			VOP_UNLOCK(ZTOV(zp), 0, curthread);
+		}
 		dmu_buf_rele(dbp, NULL);
 		zfs_znode_free(zp);
 	}
@@ -598,14 +603,18 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_
 			    &zp->z_vnode);
 			ASSERT(err == 0);
 			vp = ZTOV(zp);
+			vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curthread);
 			vp->v_data = (caddr_t)zp;
 			vp->v_vnlock->lk_flags |= LK_CANRECURSE;
 			vp->v_vnlock->lk_flags &= ~LK_NOSHARE;
 			vp->v_type = IFTOVT((mode_t)zp->z_phys->zp_mode);
 			if (vp->v_type == VDIR)
 				zp->z_zn_prefetch = B_TRUE;	/* z_prefetch default is enabled */
+			vp->v_vflag |= VV_FORCEINSMQ;
 			err = insmntque(vp, zfsvfs->z_vfs);
+			vp->v_vflag &= ~VV_FORCEINSMQ;
 			KASSERT(err == 0, ("insmntque() failed: error %d", err));
+			VOP_UNLOCK(vp, 0, curthread);
 		}
 		mutex_exit(&zp->z_lock);
 		ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
@@ -621,6 +630,8 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_
 	zfs_znode_dmu_init(zp);
 	ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
 	*zpp = zp;
+	if ((vp = ZTOV(zp)) != NULL)
+		VOP_UNLOCK(vp, 0, curthread);
 	return (0);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902191601.n1JG10YG001669>