Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Jan 2007 23:09:42 GMT
From:      Matt Jacob <mjacob@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 112577 for review
Message-ID:  <200701052309.l05N9gLU060479@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=112577

Change 112577 by mjacob@mjexp_6 on 2007/01/05 23:08:55

	Integrate from vendor branch.

Affected files ...

.. //depot/projects/mjexp_6/sys/contrib/pf/net/pf_ioctl.c#2 integrate
.. //depot/projects/mjexp_6/sys/dev/md/md.c#2 integrate
.. //depot/projects/mjexp_6/sys/fs/msdosfs/bpb.h#2 integrate
.. //depot/projects/mjexp_6/sys/kern/vfs_bio.c#2 integrate
.. //depot/projects/mjexp_6/sys/nfsclient/nfs_node.c#2 integrate
.. //depot/projects/mjexp_6/sys/sys/vnode.h#2 integrate

Differences ...

==== //depot/projects/mjexp_6/sys/contrib/pf/net/pf_ioctl.c#2 (text+ko) ====

@@ -1,4 +1,4 @@
-/*	$FreeBSD: src/sys/contrib/pf/net/pf_ioctl.c,v 1.20.2.4 2006/09/09 00:50:25 mlaier Exp $	*/
+/*	$FreeBSD: src/sys/contrib/pf/net/pf_ioctl.c,v 1.20.2.5 2007/01/04 18:31:43 mlaier Exp $	*/
 /*	$OpenBSD: pf_ioctl.c,v 1.139 2005/03/03 07:13:39 dhartmei Exp $	*/
 /* add:	$OpenBSD: pf_ioctl.c,v 1.168 2006/07/21 01:21:17 dhartmei Exp $ */
 
@@ -256,6 +256,7 @@
 	UMA_DESTROY(pf_cache_pl);
 	UMA_DESTROY(pf_cent_pl);
 	UMA_DESTROY(pfr_ktable_pl);
+	UMA_DESTROY(pfr_kentry_pl2);
 	UMA_DESTROY(pfr_kentry_pl);
 	UMA_DESTROY(pf_state_scrub_pl);
 	UMA_DESTROY(pfi_addr_pl);

==== //depot/projects/mjexp_6/sys/dev/md/md.c#2 (text+ko) ====

@@ -6,7 +6,7 @@
  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
  * ----------------------------------------------------------------------------
  *
- * $FreeBSD: src/sys/dev/md/md.c,v 1.153.2.6 2006/02/14 14:46:22 luigi Exp $
+ * $FreeBSD: src/sys/dev/md/md.c,v 1.153.2.8 2007/01/05 09:51:14 kib Exp $
  *
  */
 
@@ -67,6 +67,7 @@
 #include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/mdioctl.h>
+#include <sys/mount.h>
 #include <sys/mutex.h>
 #include <sys/sx.h>
 #include <sys/namei.h>
@@ -88,7 +89,8 @@
 
 #define MD_MODVER 1
 
-#define MD_SHUTDOWN 0x10000	/* Tell worker thread to terminate. */
+#define MD_SHUTDOWN	0x10000		/* Tell worker thread to terminate. */
+#define	MD_EXITING	0x20000		/* Worker thread is exiting. */
 
 #ifndef MD_NSECT
 #define MD_NSECT (10000 * 2)
@@ -482,12 +484,11 @@
 static int
 mdstart_vnode(struct md_s *sc, struct bio *bp)
 {
-	int error;
+	int error, vfslocked;
 	struct uio auio;
 	struct iovec aiov;
 	struct mount *mp;
 
-	mtx_assert(&Giant, MA_OWNED);
 	/*
 	 * VNODE I/O
 	 *
@@ -516,6 +517,7 @@
 	 * When reading set IO_DIRECT to try to avoid double-caching
 	 * the data.  When writing IO_DIRECT is not optimal.
 	 */
+	vfslocked = VFS_LOCK_GIANT(sc->vnode->v_mount);
 	if (bp->bio_cmd == BIO_READ) {
 		vn_lock(sc->vnode, LK_EXCLUSIVE | LK_RETRY, curthread);
 		error = VOP_READ(sc->vnode, &auio, IO_DIRECT, sc->cred);
@@ -528,6 +530,7 @@
 		VOP_UNLOCK(sc->vnode, 0, curthread);
 		vn_finished_write(mp);
 	}
+	VFS_UNLOCK_GIANT(vfslocked);
 	bp->bio_resid = auio.uio_resid;
 	return (error);
 }
@@ -638,35 +641,22 @@
 {
 	struct md_s *sc;
 	struct bio *bp;
-	int error, hasgiant;
+	int error;
 
 	sc = arg;
 	mtx_lock_spin(&sched_lock);
 	sched_prio(curthread, PRIBIO);
 	mtx_unlock_spin(&sched_lock);
+	if (sc->type == MD_VNODE)
+		curthread->td_pflags |= TDP_NORUNNINGBUF;
 
-	switch (sc->type) {
-	case MD_VNODE:
-		mtx_lock(&Giant);
-		hasgiant = 1;
-		break;
-	case MD_MALLOC:
-	case MD_PRELOAD:
-	case MD_SWAP:
-	default:
-		hasgiant = 0;
-		break;
-	}
-	
 	for (;;) {
+		mtx_lock(&sc->queue_mtx);
 		if (sc->flags & MD_SHUTDOWN) {
-			sc->procp = NULL;
-			wakeup(&sc->procp);
-			if (hasgiant)
-				mtx_unlock(&Giant);
+			sc->flags |= MD_EXITING;
+			mtx_unlock(&sc->queue_mtx);
 			kthread_exit(0);
 		}
-		mtx_lock(&sc->queue_mtx);
 		bp = bioq_takefirst(&sc->bio_queue);
 		if (!bp) {
 			msleep(sc, &sc->queue_mtx, PRIBIO | PDROP, "mdwait", 0);
@@ -864,7 +854,7 @@
 {
 	struct vattr vattr;
 	struct nameidata nd;
-	int error, flags;
+	int error, flags, vfslocked;
 
 	error = copyinstr(mdio->md_file, sc->file, sizeof(sc->file), NULL);
 	if (error != 0)
@@ -881,12 +871,15 @@
 	if (error != 0)
 		return (error);
 	NDFREE(&nd, NDF_ONLY_PNBUF);
+	vfslocked = VFS_LOCK_GIANT(nd.ni_vp->v_mount);
 	if (nd.ni_vp->v_type != VREG ||
 	    (error = VOP_GETATTR(nd.ni_vp, &vattr, td->td_ucred, td))) {
 		VOP_UNLOCK(nd.ni_vp, 0, td);
 		(void)vn_close(nd.ni_vp, flags, td->td_ucred, td);
+		VFS_UNLOCK_GIANT(vfslocked);
 		return (error ? error : EINVAL);
 	}
+	nd.ni_vp->v_vflag |= VV_MD;
 	VOP_UNLOCK(nd.ni_vp, 0, td);
 
 	if (mdio->md_fwsectors != 0)
@@ -900,16 +893,21 @@
 
 	error = mdsetcred(sc, td->td_ucred);
 	if (error != 0) {
+		vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY, td);
+		nd.ni_vp->v_vflag &= ~VV_MD;
+		VOP_UNLOCK(nd.ni_vp, 0, td);
 		(void)vn_close(nd.ni_vp, flags, td->td_ucred, td);
+		VFS_UNLOCK_GIANT(vfslocked);
 		return (error);
 	}
+	VFS_UNLOCK_GIANT(vfslocked);
 	return (0);
 }
 
 static int
 mddestroy(struct md_s *sc, struct thread *td)
 {
-
+	int vfslocked;
 
 	if (sc->gp) {
 		sc->gp->softc = NULL;
@@ -919,16 +917,21 @@
 		sc->gp = NULL;
 		sc->pp = NULL;
 	}
+	mtx_lock(&sc->queue_mtx);
 	sc->flags |= MD_SHUTDOWN;
 	wakeup(sc);
-	while (sc->procp != NULL)
-		tsleep(&sc->procp, PRIBIO, "mddestroy", hz / 10);
+	while (!(sc->flags & MD_EXITING))
+		msleep(sc->procp, &sc->queue_mtx, PRIBIO, "mddestroy", hz / 10);
+	mtx_unlock(&sc->queue_mtx);
 	mtx_destroy(&sc->queue_mtx);
 	if (sc->vnode != NULL) {
-		mtx_lock(&Giant);
+		vfslocked = VFS_LOCK_GIANT(sc->vnode->v_mount);
+		vn_lock(sc->vnode, LK_EXCLUSIVE | LK_RETRY, td);
+		sc->vnode->v_vflag &= ~VV_MD;
+		VOP_UNLOCK(sc->vnode, 0, td);
 		(void)vn_close(sc->vnode, sc->flags & MD_READONLY ?
 		    FREAD : (FREAD|FWRITE), sc->cred, td);
-		mtx_unlock(&Giant);
+		VFS_UNLOCK_GIANT(vfslocked);
 	}
 	if (sc->cred != NULL)
 		crfree(sc->cred);

==== //depot/projects/mjexp_6/sys/fs/msdosfs/bpb.h#2 (text+ko) ====

@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/fs/msdosfs/bpb.h,v 1.11 2005/01/06 18:10:38 imp Exp $ */
+/* $FreeBSD: src/sys/fs/msdosfs/bpb.h,v 1.11.2.1 2007/01/05 05:50:36 rodrigc Exp $ */
 /*	$NetBSD: bpb.h,v 1.7 1997/11/17 15:36:24 ws Exp $	*/
 
 /*-
@@ -86,35 +86,14 @@
  * and longs are just character arrays of the appropriate length.  This is
  * because the compiler forces shorts and longs to align on word or
  * halfword boundaries.
- *
- * XXX The little-endian code here assumes that the processor can access
- * 16-bit and 32-bit quantities on byte boundaries.  If this is not true,
- * use the macros for the big-endian case.
  */
 
-#include <machine/endian.h>
+#include <sys/endian.h>
 
-#ifdef __i386__
-#define	UNLALIGNED_ACCESS
-#endif
-
-#if (BYTE_ORDER == LITTLE_ENDIAN) && defined(UNALIGNED_ACCESS)
-#define	getushort(x)	*((u_int16_t *)(x))
-#define	getulong(x)	*((u_int32_t *)(x))
-#define	putushort(p, v)	(*((u_int16_t *)(p)) = (v))
-#define	putulong(p, v)	(*((u_int32_t *)(p)) = (v))
-#else
-#define getushort(x)	(((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8))
-#define getulong(x)	(((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8) \
-			 + (((u_int8_t *)(x))[2] << 16)	\
-			 + (((u_int8_t *)(x))[3] << 24))
-#define putushort(p, v)	(((u_int8_t *)(p))[0] = (v),	\
-			 ((u_int8_t *)(p))[1] = (v) >> 8)
-#define putulong(p, v)	(((u_int8_t *)(p))[0] = (v),	\
-			 ((u_int8_t *)(p))[1] = (v) >> 8, \
-			 ((u_int8_t *)(p))[2] = (v) >> 16,\
-			 ((u_int8_t *)(p))[3] = (v) >> 24)
-#endif
+#define	getushort(x)	le16dec(x)
+#define	getulong(x)	le32dec(x)
+#define	putushort(p, v)	le16enc(p, v)
+#define	putulong(p, v)	le32enc(p, v)
 
 /*
  * BIOS Parameter Block (BPB) for DOS 3.3

==== //depot/projects/mjexp_6/sys/kern/vfs_bio.c#2 (text+ko) ====

@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/vfs_bio.c,v 1.491.2.9 2006/10/13 07:05:46 pjd Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/vfs_bio.c,v 1.491.2.10 2007/01/05 09:51:14 kib Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -796,6 +796,8 @@
 bufwrite(struct buf *bp)
 {
 	int oldflags;
+	struct vnode *vp;
+	int vp_md;
 
 	CTR3(KTR_BUF, "bufwrite(%p) vp %p flags %X", bp, bp->b_vp, bp->b_flags);
 	if (bp->b_flags & B_INVAL) {
@@ -810,6 +812,12 @@
 	KASSERT(!(bp->b_vflags & BV_BKGRDINPROG),
 	    ("FFS background buffer should not get here %p", bp));
 
+	vp = bp->b_vp;
+	if (vp)
+		vp_md = vp->v_vflag & VV_MD;
+	else
+		vp_md = 0;
+
 	/* Mark the buffer clean */
 	bundirty(bp);
 
@@ -847,7 +855,7 @@
 		 * or syncer daemon trying to clean up as that can lead
 		 * to deadlock.
 		 */
-		if ((curthread->td_pflags & TDP_NORUNNINGBUF) == 0)
+		if ((curthread->td_pflags & TDP_NORUNNINGBUF) == 0 && !vp_md)
 			waitrunningbufspace();
 	}
 

==== //depot/projects/mjexp_6/sys/nfsclient/nfs_node.c#2 (text+ko) ====

@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/nfsclient/nfs_node.c,v 1.76.2.3 2006/09/13 19:25:44 mohans Exp $");
+__FBSDID("$FreeBSD: src/sys/nfsclient/nfs_node.c,v 1.76.2.4 2007/01/03 20:19:02 mohans Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -163,23 +163,22 @@
 	 */
 	vp->v_vnlock->lk_flags |= LK_CANRECURSE;
 	vp->v_vnlock->lk_flags &= ~LK_NOSHARE;
+	if (fhsize > NFS_SMALLFH) {
+		MALLOC(np->n_fhp, nfsfh_t *, fhsize, M_NFSBIGFH, M_WAITOK);
+	} else
+		np->n_fhp = &np->n_fh;
+	bcopy((caddr_t)fhp, (caddr_t)np->n_fhp, fhsize);
+	np->n_fhsize = fhsize;
+	lockinit(&np->n_rslock, PVFS | rsflags, "nfrslk", 0, 0);
 	error = vfs_hash_insert(vp, hash, LK_EXCLUSIVE,
 	    td, &nvp, nfs_vncmpf, &ncmp);
 	if (error)
 		return (error);
 	if (nvp != NULL) {
 		*npp = VTONFS(nvp);
-		/* vrele() the duplicate allocated here, to get it recycled */
-		vrele(vp);
+		/* vfs_hash_insert() vput()'s the losing vnode */
 		return (0);
 	}
-	if (fhsize > NFS_SMALLFH) {
-		MALLOC(np->n_fhp, nfsfh_t *, fhsize, M_NFSBIGFH, M_WAITOK);
-	} else
-		np->n_fhp = &np->n_fh;
-	bcopy((caddr_t)fhp, (caddr_t)np->n_fhp, fhsize);
-	np->n_fhsize = fhsize;
-	lockinit(&np->n_rslock, PVFS | rsflags, "nfrslk", 0, 0);
 	*npp = np;
 
 	return (0);

==== //depot/projects/mjexp_6/sys/sys/vnode.h#2 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)vnode.h	8.7 (Berkeley) 2/4/94
- * $FreeBSD: src/sys/sys/vnode.h,v 1.304.2.7 2006/03/13 03:07:27 jeff Exp $
+ * $FreeBSD: src/sys/sys/vnode.h,v 1.304.2.8 2007/01/05 09:51:14 kib Exp $
  */
 
 #ifndef _SYS_VNODE_H_
@@ -253,6 +253,7 @@
 #define	VV_SYSTEM	0x0080	/* vnode being used by kernel */
 #define	VV_PROCDEP	0x0100	/* vnode is process dependent */
 #define	VV_NOKNOTE	0x0200	/* don't activate knotes on this vnode */
+#define	VV_MD		0x0800	/* vnode backs the md device */
 
 /*
  * Vnode attributes.  A field value of VNOVAL represents a field whose value



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