Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Apr 2015 00:53:53 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r281676 - in user/ngie/more-tests: . sys/amd64/vmm sys/arm/allwinner sys/arm/arm sys/arm64/arm64 sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/conf sys/dev/cxgbe/tom sys/dev/usb/vi...
Message-ID:  <201504180053.t3I0rrdL004128@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sat Apr 18 00:53:52 2015
New Revision: 281676
URL: https://svnweb.freebsd.org/changeset/base/281676

Log:
  MFhead @ r281675

Added:
  user/ngie/more-tests/sys/pc98/pc98/genassym.c
     - copied unchanged from r281675, head/sys/pc98/pc98/genassym.c
Deleted:
  user/ngie/more-tests/sys/fs/ext2fs/ext2_hash.c
  user/ngie/more-tests/sys/fs/ext2fs/ext2_htree.c
  user/ngie/more-tests/sys/net/altq/altqconf.h
  user/ngie/more-tests/usr.sbin/crunch/crunchide/exec_aout.c
Modified:
  user/ngie/more-tests/Makefile
  user/ngie/more-tests/Makefile.inc1
  user/ngie/more-tests/sys/amd64/vmm/vmm_lapic.c
  user/ngie/more-tests/sys/arm/allwinner/if_emac.c
  user/ngie/more-tests/sys/arm/allwinner/if_emacreg.h
  user/ngie/more-tests/sys/arm/arm/trap-v6.c
  user/ngie/more-tests/sys/arm/arm/vm_machdep.c
  user/ngie/more-tests/sys/arm64/arm64/trap.c
  user/ngie/more-tests/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
  user/ngie/more-tests/sys/conf/Makefile.pc98
  user/ngie/more-tests/sys/conf/kern.pre.mk
  user/ngie/more-tests/sys/conf/kmod.mk
  user/ngie/more-tests/sys/dev/cxgbe/tom/t4_listen.c
  user/ngie/more-tests/sys/dev/usb/video/udl.c
  user/ngie/more-tests/sys/dev/usb/video/udl.h
  user/ngie/more-tests/sys/fs/ext2fs/ext2_dir.h
  user/ngie/more-tests/sys/fs/ext2fs/ext2_extern.h
  user/ngie/more-tests/sys/fs/ext2fs/ext2_lookup.c
  user/ngie/more-tests/sys/fs/ext2fs/ext2_vfsops.c
  user/ngie/more-tests/sys/fs/ext2fs/ext2fs.h
  user/ngie/more-tests/sys/fs/nfs/nfs.h
  user/ngie/more-tests/sys/fs/nfs/nfs_commonport.c
  user/ngie/more-tests/sys/fs/nfs/nfsproto.h
  user/ngie/more-tests/sys/fs/nfsserver/nfs_nfsdserv.c
  user/ngie/more-tests/sys/modules/ext2fs/Makefile
  user/ngie/more-tests/sys/modules/usb/Makefile
  user/ngie/more-tests/sys/net/altq/altq.h
  user/ngie/more-tests/sys/net/altq/altq_cbq.c
  user/ngie/more-tests/sys/net/altq/altq_cdnr.c
  user/ngie/more-tests/sys/net/altq/altq_classq.h
  user/ngie/more-tests/sys/net/altq/altq_hfsc.c
  user/ngie/more-tests/sys/net/altq/altq_priq.c
  user/ngie/more-tests/sys/net/altq/altq_red.c
  user/ngie/more-tests/sys/net/altq/altq_rio.c
  user/ngie/more-tests/sys/net/altq/altq_rmclass.c
  user/ngie/more-tests/sys/net/altq/altq_rmclass_debug.h
  user/ngie/more-tests/sys/net/altq/altq_subr.c
  user/ngie/more-tests/sys/net/altq/altq_var.h
  user/ngie/more-tests/sys/net/altq/if_altq.h
  user/ngie/more-tests/sys/net/if_types.h
  user/ngie/more-tests/sys/netinet/in.c
  user/ngie/more-tests/sys/netinet/in.h
  user/ngie/more-tests/sys/netinet6/in6.c
  user/ngie/more-tests/sys/netinet6/in6.h
  user/ngie/more-tests/usr.bin/gzip/gzip.c
  user/ngie/more-tests/usr.bin/w/Makefile
  user/ngie/more-tests/usr.bin/w/w.c
  user/ngie/more-tests/usr.sbin/bhyve/pci_ahci.c
  user/ngie/more-tests/usr.sbin/crunch/crunchide/Makefile
  user/ngie/more-tests/usr.sbin/crunch/crunchide/crunchide.c
  user/ngie/more-tests/usr.sbin/crunch/crunchide/exec_elf32.c
  user/ngie/more-tests/usr.sbin/crunch/crunchide/extern.h
Directory Properties:
  user/ngie/more-tests/   (props changed)
  user/ngie/more-tests/sys/   (props changed)
  user/ngie/more-tests/sys/amd64/vmm/   (props changed)
  user/ngie/more-tests/sys/cddl/contrib/opensolaris/   (props changed)
  user/ngie/more-tests/sys/conf/   (props changed)
  user/ngie/more-tests/usr.sbin/bhyve/   (props changed)

Modified: user/ngie/more-tests/Makefile
==============================================================================
--- user/ngie/more-tests/Makefile	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/Makefile	Sat Apr 18 00:53:52 2015	(r281676)
@@ -374,6 +374,17 @@ kernel-toolchains:
 #
 .if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
 TARGETS?=amd64 arm i386 mips pc98 powerpc sparc64
+# XXX Add arm64 to universe only if we have an external binutils installed.
+# It does not build with the in-tree linnker.
+.if exists(/usr/local/aarch64-freebsd/bin/ld)
+TARGETS+=arm64
+TARGET_ARCHES_arm64?=	aarch64
+.else
+universe: universe_arm64_skip
+universe_epilogue: universe_arm64_skip
+universe_arm64_skip: universe_prologue
+	@echo ">> arm64 skipped - install aarch64-binutils port or package to build"
+.endif
 TARGET_ARCHES_arm?=	arm armeb armv6 armv6hf
 TARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
 TARGET_ARCHES_powerpc?=	powerpc powerpc64

Modified: user/ngie/more-tests/Makefile.inc1
==============================================================================
--- user/ngie/more-tests/Makefile.inc1	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/Makefile.inc1	Sat Apr 18 00:53:52 2015	(r281676)
@@ -1281,10 +1281,6 @@ _m4=		lib/libohash \
 ${_bt}-usr.bin/m4: ${_bt}-lib/libohash
 .endif
 
-.if ${BOOTSTRAPPING} < 1000014
-_crunch=	usr.sbin/crunch
-.endif
-
 .if ${BOOTSTRAPPING} < 1000026
 _nmtree=	lib/libnetbsd \
 		usr.sbin/nmtree
@@ -1300,6 +1296,10 @@ _cat=		bin/cat
 _lex=		usr.bin/lex
 .endif
 
+.if ${BOOTSTRAPPING} < 1001507
+_crunch=	usr.sbin/crunch
+.endif
+
 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
 _awk=		usr.bin/awk
 .endif
@@ -1469,12 +1469,9 @@ _btxld=		usr.sbin/btxld
 .endif
 .endif
 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
-.if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
+.if ${MK_RESCUE} != "no"
 _crunchide=	usr.sbin/crunch/crunchide
 .endif
-.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
-_kgzip=		usr.sbin/kgzip
-.endif
 .endif
 
 # If we're given an XAS, don't build binutils.
@@ -1520,7 +1517,6 @@ cross-tools: .MAKE
     ${_cc} \
     ${_btxld} \
     ${_crunchide} \
-    ${_kgzip} \
     sys/boot/usb/tools
 	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
 		cd ${.CURDIR}/${_tool} && \

Modified: user/ngie/more-tests/sys/amd64/vmm/vmm_lapic.c
==============================================================================
--- user/ngie/more-tests/sys/amd64/vmm/vmm_lapic.c	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/amd64/vmm/vmm_lapic.c	Sat Apr 18 00:53:52 2015	(r281676)
@@ -57,7 +57,11 @@ lapic_set_intr(struct vm *vm, int cpu, i
 	if (cpu < 0 || cpu >= VM_MAXCPU)
 		return (EINVAL);
 
-	if (vector < 32 || vector > 255)
+	/*
+	 * According to section "Maskable Hardware Interrupts" in Intel SDM
+	 * vectors 16 through 255 can be delivered through the local APIC.
+	 */
+	if (vector < 16 || vector > 255)
 		return (EINVAL);
 
 	vlapic = vm_lapic(vm, cpu);

Modified: user/ngie/more-tests/sys/arm/allwinner/if_emac.c
==============================================================================
--- user/ngie/more-tests/sys/arm/allwinner/if_emac.c	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/arm/allwinner/if_emac.c	Sat Apr 18 00:53:52 2015	(r281676)
@@ -101,6 +101,7 @@ struct emac_softc {
 	int			emac_watchdog_timer;
 	int			emac_rx_process_limit;
 	int			emac_link;
+	uint32_t		emac_fifo_mask;
 };
 
 static int	emac_probe(device_t);
@@ -121,7 +122,7 @@ static void	emac_intr(void *);
 static int	emac_ioctl(struct ifnet *, u_long, caddr_t);
 
 static void	emac_rxeof(struct emac_softc *, int);
-static void	emac_txeof(struct emac_softc *);
+static void	emac_txeof(struct emac_softc *, uint32_t);
 
 static int	emac_miibus_readreg(device_t, int, int);
 static int	emac_miibus_writereg(device_t, int, int, int);
@@ -253,14 +254,28 @@ emac_reset(struct emac_softc *sc)
 }
 
 static void
-emac_txeof(struct emac_softc *sc)
+emac_drain_rxfifo(struct emac_softc *sc)
+{
+	uint32_t data;
+
+	while (EMAC_READ_REG(sc, EMAC_RX_FBC) > 0)
+		data = EMAC_READ_REG(sc, EMAC_RX_IO_DATA);
+}
+
+static void
+emac_txeof(struct emac_softc *sc, uint32_t status)
 {
 	struct ifnet *ifp;
 
 	EMAC_ASSERT_LOCKED(sc);
 
 	ifp = sc->emac_ifp;
-	if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+	status &= (EMAC_TX_FIFO0 | EMAC_TX_FIFO1);
+	sc->emac_fifo_mask &= ~status;
+	if (status == (EMAC_TX_FIFO0 | EMAC_TX_FIFO1))
+		if_inc_counter(ifp, IFCOUNTER_OPACKETS, 2);
+	else
+		if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 
 	/* Unarm watchdog timer if no TX */
@@ -275,7 +290,7 @@ emac_rxeof(struct emac_softc *sc, int co
 	uint32_t reg_val, rxcount;
 	int16_t len;
 	uint16_t status;
-	int good_packet, i;
+	int i;
 
 	ifp = sc->emac_ifp;
 	for (; count > 0 &&
@@ -327,20 +342,19 @@ emac_rxeof(struct emac_softc *sc, int co
 			return;
 		}
 
-		good_packet = 1;
-
 		/* Get packet size and status */
 		reg_val = EMAC_READ_REG(sc, EMAC_RX_IO_DATA);
 		len = reg_val & 0xffff;
 		status = (reg_val >> 16) & 0xffff;
 
-		if (len < 64) {
-			good_packet = 0;
+		if (len < 64 || (status & EMAC_PKT_OK) == 0) {
 			if (bootverbose)
 				if_printf(ifp,
 				    "bad packet: len = %i status = %i\n",
 				    len, status);
 			if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+			emac_drain_rxfifo(sc);
+			continue;
 		}
 #if 0
 		if (status & (EMAC_CRCERR | EMAC_LENERR)) {
@@ -352,63 +366,58 @@ emac_rxeof(struct emac_softc *sc, int co
 				if_printf(ifp, "length error\n");
 		}
 #endif
-		if (good_packet) {
-			m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
-			if (m == NULL)
-				return;
-			m->m_len = m->m_pkthdr.len = MCLBYTES;
+		m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
+		if (m == NULL) {
+			emac_drain_rxfifo(sc);
+			return;
+		}
+		m->m_len = m->m_pkthdr.len = MCLBYTES;
 
-			len -= ETHER_CRC_LEN;
+		/* Copy entire frame to mbuf first. */
+		bus_space_read_multi_4(sc->emac_tag, sc->emac_handle,
+		    EMAC_RX_IO_DATA, mtod(m, uint32_t *), roundup2(len, 4) / 4);
 
-			/* Copy entire frame to mbuf first. */
-			bus_space_read_multi_4(sc->emac_tag, sc->emac_handle,
-			    EMAC_RX_IO_DATA, mtod(m, uint32_t *),
-			    roundup2(len, 4) / 4);
-
-			m->m_pkthdr.rcvif = ifp;
-			m->m_len = m->m_pkthdr.len = len;
-
-			/*
-			 * Emac controller needs strict aligment, so to avoid
-			 * copying over an entire frame to align, we allocate
-			 * a new mbuf and copy ethernet header + IP header to
-			 * the new mbuf. The new mbuf is prepended into the
-			 * existing mbuf chain.
-			 */
-			if (m->m_len <= (MHLEN - ETHER_HDR_LEN)) {
-				bcopy(m->m_data, m->m_data + ETHER_HDR_LEN,
-				    m->m_len);
-				m->m_data += ETHER_HDR_LEN;
-			} else if (m->m_len <= (MCLBYTES - ETHER_HDR_LEN) &&
-			    m->m_len > (MHLEN - ETHER_HDR_LEN)) {
-				MGETHDR(m0, M_NOWAIT, MT_DATA);
-				if (m0 != NULL) {
-					len = ETHER_HDR_LEN +
-					    m->m_pkthdr.l2hlen;
-					bcopy(m->m_data, m0->m_data, len);
-					m->m_data += len;
-					m->m_len -= len;
-					m0->m_len = len;
-					M_MOVE_PKTHDR(m0, m);
-					m0->m_next = m;
-					m = m0;
-				} else {
-					if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
-					m_freem(m);
-					m = NULL;
-					continue;
-				}
-			} else if (m->m_len > EMAC_MAC_MAXF) {
+		m->m_pkthdr.rcvif = ifp;
+		m->m_len = m->m_pkthdr.len = len - ETHER_CRC_LEN;
+
+		/*
+		 * Emac controller needs strict aligment, so to avoid
+		 * copying over an entire frame to align, we allocate
+		 * a new mbuf and copy ethernet header + IP header to
+		 * the new mbuf. The new mbuf is prepended into the
+		 * existing mbuf chain.
+		 */
+		if (m->m_len <= (MHLEN - ETHER_HDR_LEN)) {
+			bcopy(m->m_data, m->m_data + ETHER_HDR_LEN, m->m_len);
+			m->m_data += ETHER_HDR_LEN;
+		} else if (m->m_len <= (MCLBYTES - ETHER_HDR_LEN) &&
+		    m->m_len > (MHLEN - ETHER_HDR_LEN)) {
+			MGETHDR(m0, M_NOWAIT, MT_DATA);
+			if (m0 != NULL) {
+				len = ETHER_HDR_LEN + m->m_pkthdr.l2hlen;
+				bcopy(m->m_data, m0->m_data, len);
+				m->m_data += len;
+				m->m_len -= len;
+				m0->m_len = len;
+				M_MOVE_PKTHDR(m0, m);
+				m0->m_next = m;
+				m = m0;
+			} else {
 				if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
 				m_freem(m);
 				m = NULL;
 				continue;
 			}
-			if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
-			EMAC_UNLOCK(sc);
-			(*ifp->if_input)(ifp, m);
-			EMAC_LOCK(sc);
+		} else if (m->m_len > EMAC_MAC_MAXF) {
+			if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+			m_freem(m);
+			m = NULL;
+			continue;
 		}
+		if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
+		EMAC_UNLOCK(sc);
+		(*ifp->if_input)(ifp, m);
+		EMAC_LOCK(sc);
 	}
 }
 
@@ -582,11 +591,13 @@ emac_start_locked(struct ifnet *ifp)
 {
 	struct emac_softc *sc;
 	struct mbuf *m, *m0;
-	uint32_t reg_val;
+	uint32_t fifo, reg;
 
 	sc = ifp->if_softc;
 	if (ifp->if_drv_flags & IFF_DRV_OACTIVE)
 		return;
+	if (sc->emac_fifo_mask == (EMAC_TX_FIFO0 | EMAC_TX_FIFO1))
+		return;
 	if (sc->emac_link == 0)
 		return;
 	IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
@@ -594,7 +605,14 @@ emac_start_locked(struct ifnet *ifp)
 		return;
 
 	/* Select channel */
-	EMAC_WRITE_REG(sc, EMAC_TX_INS, 0);
+	if (sc->emac_fifo_mask & EMAC_TX_FIFO0)
+		fifo = 1;
+	else
+		fifo = 0;
+	sc->emac_fifo_mask |= (1 << fifo);
+	if (sc->emac_fifo_mask == (EMAC_TX_FIFO0 | EMAC_TX_FIFO1))
+		ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+	EMAC_WRITE_REG(sc, EMAC_TX_INS, fifo);
 
 	/*
 	 * Emac controller wants 4 byte aligned TX buffers.
@@ -615,17 +633,17 @@ emac_start_locked(struct ifnet *ifp)
 	    roundup2(m->m_len, 4) / 4);
 
 	/* Send the data lengh. */
-	EMAC_WRITE_REG(sc, EMAC_TX_PL0, m->m_len);
+	reg = (fifo == 0) ? EMAC_TX_PL0 : EMAC_TX_PL1;
+	EMAC_WRITE_REG(sc, reg, m->m_len);
 
 	/* Start translate from fifo to phy. */
-	reg_val = EMAC_READ_REG(sc, EMAC_TX_CTL0);
-	reg_val |= 1;
-	EMAC_WRITE_REG(sc, EMAC_TX_CTL0, reg_val);
+	reg = (fifo == 0) ? EMAC_TX_CTL0 : EMAC_TX_CTL1;
+	EMAC_WRITE_REG(sc, reg, EMAC_READ_REG(sc, reg) | 1);
 
 	/* Set timeout */
 	sc->emac_watchdog_timer = 5;
 
-	ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+	/* Data have been sent to hardware, it is okay to free the mbuf now. */
 	BPF_MTAP(ifp, m);
 	m_freem(m);
 }
@@ -664,9 +682,6 @@ emac_intr(void *arg)
 
 	sc = (struct emac_softc *)arg;
 	EMAC_LOCK(sc);
-	ifp = sc->emac_ifp;
-	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
-		return;
 
 	/* Disable all interrupts */
 	EMAC_WRITE_REG(sc, EMAC_INT_CTL, 0);
@@ -680,18 +695,17 @@ emac_intr(void *arg)
 		emac_rxeof(sc, sc->emac_rx_process_limit);
 
 	/* Transmit Interrupt check */
-	if (reg_val & EMAC_INT_STA_TX){
-		emac_txeof(sc);
+	if (reg_val & EMAC_INT_STA_TX) {
+		emac_txeof(sc, reg_val);
+		ifp = sc->emac_ifp;
 		if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
 			emac_start_locked(ifp);
 	}
 
-	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
-		/* Re-enable interrupt mask */
-		reg_val = EMAC_READ_REG(sc, EMAC_INT_CTL);
-		reg_val |= EMAC_INT_EN;
-		EMAC_WRITE_REG(sc, EMAC_INT_CTL, reg_val);
-	}
+	/* Re-enable interrupt mask */
+	reg_val = EMAC_READ_REG(sc, EMAC_INT_CTL);
+	reg_val |= EMAC_INT_EN;
+	EMAC_WRITE_REG(sc, EMAC_INT_CTL, reg_val);
 	EMAC_UNLOCK(sc);
 }
 

Modified: user/ngie/more-tests/sys/arm/allwinner/if_emacreg.h
==============================================================================
--- user/ngie/more-tests/sys/arm/allwinner/if_emacreg.h	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/arm/allwinner/if_emacreg.h	Sat Apr 18 00:53:52 2015	(r281676)
@@ -51,6 +51,8 @@
 #define	EMAC_TX_TSVH0		0x30
 #define	EMAC_TX_TSVL1		0x34
 #define	EMAC_TX_TSVH1		0x38
+#define	EMAC_TX_FIFO0		(1 << 0)
+#define	EMAC_TX_FIFO1		(1 << 1)
 
 #define	EMAC_RX_CTL		0x3C
 #define	EMAC_RX_HASH0		0x40
@@ -61,7 +63,7 @@
 
 #define	EMAC_INT_CTL		0x54
 #define	EMAC_INT_STA		0x58
-#define	EMAC_INT_STA_TX		(0x01 | 0x02)
+#define	EMAC_INT_STA_TX		(EMAC_TX_FIFO0 | EMAC_TX_FIFO1)
 #define	EMAC_INT_STA_RX		0x100
 #define	EMAC_INT_EN		(0xf << 0) | (1 << 8)
 
@@ -223,6 +225,7 @@
 /* Receive status */
 #define	EMAC_CRCERR		(1 << 4)
 #define	EMAC_LENERR		(3 << 5)
+#define	EMAC_PKT_OK		(1 << 7)
 
 #define	EMAC_RX_FLUSH_FIFO	(1 << 3)
 #define	EMAC_PHY_RESET		(1 << 15)

Modified: user/ngie/more-tests/sys/arm/arm/trap-v6.c
==============================================================================
--- user/ngie/more-tests/sys/arm/arm/trap-v6.c	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/arm/arm/trap-v6.c	Sat Apr 18 00:53:52 2015	(r281676)
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_extern.h>
 #include <vm/vm_param.h>
 
+#include <machine/acle-compat.h>
 #include <machine/cpu.h>
 #include <machine/cpu-v6.h>
 #include <machine/frame.h>
@@ -287,7 +288,11 @@ abort_handler(struct trapframe *tf, int 
 #endif
 	td = curthread;
 	fsr = (prefetch) ? cp15_ifsr_get(): cp15_dfsr_get();
+#if __ARM_ARCH >= 7
+	far = (prefetch) ? cp15_ifar_get() : cp15_dfar_get();
+#else
 	far = (prefetch) ? TRAPF_PC(tf) : cp15_dfar_get();
+#endif
 
 	idx = FSR_TO_FAULT(fsr);
 	usermode = TRAPF_USERMODE(tf);	/* Abort came from user mode? */

Modified: user/ngie/more-tests/sys/arm/arm/vm_machdep.c
==============================================================================
--- user/ngie/more-tests/sys/arm/arm/vm_machdep.c	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/arm/arm/vm_machdep.c	Sat Apr 18 00:53:52 2015	(r281676)
@@ -178,11 +178,7 @@ cpu_set_syscall_retval(struct thread *td
 	 * place the returned data into r1. As the lseek and frerebsd6_lseek
 	 * syscalls also return an off_t they do not need this fixup.
 	 */
-#ifdef __ARM_EABI__
 	call = frame->tf_r7;
-#else
-	call = *(u_int32_t *)(frame->tf_pc - INSN_SIZE) & 0x000fffff;
-#endif
 	if (call == SYS___syscall) {
 		register_t *ap = &frame->tf_r0;
 		register_t code = ap[_QUAD_LOWWORD];

Modified: user/ngie/more-tests/sys/arm64/arm64/trap.c
==============================================================================
--- user/ngie/more-tests/sys/arm64/arm64/trap.c	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/arm64/arm64/trap.c	Sat Apr 18 00:53:52 2015	(r281676)
@@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
 #include <ddb/db_output.h>
 #endif
 
-extern uintptr_t fsu_intr_fault;
+extern register_t fsu_intr_fault;
 
 /* Called from exception.S */
 void do_el1h_sync(struct trapframe *);
@@ -154,7 +154,7 @@ data_abort(struct trapframe *frame, uint
 	 * Special case for fuswintr and suswintr. These can't sleep so
 	 * handle them early on in the trap handler.
 	 */
-	if (__predict_false(pcb->pcb_onfault == fsu_intr_fault)) {
+	if (__predict_false(pcb->pcb_onfault == (vm_offset_t)&fsu_intr_fault)) {
 		frame->tf_elr = pcb->pcb_onfault;
 		return;
 	}

Modified: user/ngie/more-tests/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==============================================================================
--- user/ngie/more-tests/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c	Sat Apr 18 00:53:52 2015	(r281676)
@@ -195,11 +195,6 @@
 
 CTASSERT(sizeof(zfs_cmd_t) < IOCPARM_MAX);
 
-static int snapshot_list_prefetch;
-SYSCTL_DECL(_vfs_zfs);
-SYSCTL_INT(_vfs_zfs, OID_AUTO, snapshot_list_prefetch, CTLFLAG_RWTUN,
-    &snapshot_list_prefetch, 0, "Prefetch data when listing snapshots");
-
 static struct cdev *zfsdev;
 
 extern void zfs_init(void);

Modified: user/ngie/more-tests/sys/conf/Makefile.pc98
==============================================================================
--- user/ngie/more-tests/sys/conf/Makefile.pc98	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/conf/Makefile.pc98	Sat Apr 18 00:53:52 2015	(r281676)
@@ -28,6 +28,9 @@ S=	./@
 S=	../../..
 .endif
 .endif
+
+LDSCRIPT_NAME?= ldscript.${MACHINE_ARCH}
+
 .include "$S/conf/kern.pre.mk"
 
 ASM_CFLAGS.mpboot.s=		${CLANG_NO_IAS34}

Modified: user/ngie/more-tests/sys/conf/kern.pre.mk
==============================================================================
--- user/ngie/more-tests/sys/conf/kern.pre.mk	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/conf/kern.pre.mk	Sat Apr 18 00:53:52 2015	(r281676)
@@ -26,7 +26,7 @@ KODIR?=		/boot/${KERNEL}
 LDSCRIPT_NAME?=	ldscript.$M
 LDSCRIPT?=	$S/conf/${LDSCRIPT_NAME}
 
-M=		${MACHINE_CPUARCH}
+M=		${MACHINE}
 
 AWK?=		awk
 CP?=		cp

Modified: user/ngie/more-tests/sys/conf/kmod.mk
==============================================================================
--- user/ngie/more-tests/sys/conf/kmod.mk	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/conf/kmod.mk	Sat Apr 18 00:53:52 2015	(r281676)
@@ -425,10 +425,10 @@ genassym.o: opt_global.h
 .endif
 assym.s: ${SYSDIR}/kern/genassym.sh
 	sh ${SYSDIR}/kern/genassym.sh genassym.o > ${.TARGET}
-genassym.o: ${SYSDIR}/${MACHINE_CPUARCH}/${MACHINE_CPUARCH}/genassym.c
+genassym.o: ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c
 genassym.o: ${SRCS:Mopt_*.h}
 	${CC} -c ${CFLAGS:N-fno-common} \
-	    ${SYSDIR}/${MACHINE_CPUARCH}/${MACHINE_CPUARCH}/genassym.c
+	    ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c
 .endif
 
 lint: ${SRCS}

Modified: user/ngie/more-tests/sys/dev/cxgbe/tom/t4_listen.c
==============================================================================
--- user/ngie/more-tests/sys/dev/cxgbe/tom/t4_listen.c	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/dev/cxgbe/tom/t4_listen.c	Sat Apr 18 00:53:52 2015	(r281676)
@@ -1090,35 +1090,6 @@ pass_accept_req_to_protohdrs(const struc
 	}
 }
 
-static int
-ifnet_has_ip6(struct ifnet *ifp, struct in6_addr *ip6)
-{
-	struct ifaddr *ifa;
-	struct sockaddr_in6 *sin6;
-	int found = 0;
-	struct in6_addr in6 = *ip6;
-
-	/* Just as in ip6_input */
-	if (in6_clearscope(&in6) || in6_clearscope(&in6))
-		return (0);
-	in6_setscope(&in6, ifp, NULL);
-
-	if_addr_rlock(ifp);
-	TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
-		sin6 = (void *)ifa->ifa_addr;
-		if (sin6->sin6_family != AF_INET6)
-			continue;
-
-		if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &in6)) {
-			found = 1;
-			break;
-		}
-	}
-	if_addr_runlock(ifp);
-
-	return (found);
-}
-
 static struct l2t_entry *
 get_l2te_for_nexthop(struct port_info *pi, struct ifnet *ifp,
     struct in_conninfo *inc)
@@ -1166,29 +1137,6 @@ get_l2te_for_nexthop(struct port_info *p
 	return (e);
 }
 
-static int
-ifnet_has_ip(struct ifnet *ifp, struct in_addr in)
-{
-	struct ifaddr *ifa;
-	struct sockaddr_in *sin;
-	int found = 0;
-
-	if_addr_rlock(ifp);
-	TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
-		sin = (void *)ifa->ifa_addr;
-		if (sin->sin_family != AF_INET)
-			continue;
-
-		if (sin->sin_addr.s_addr == in.s_addr) {
-			found = 1;
-			break;
-		}
-	}
-	if_addr_runlock(ifp);
-
-	return (found);
-}
-
 #define REJECT_PASS_ACCEPT()	do { \
 	reject_reason = __LINE__; \
 	goto reject; \
@@ -1281,7 +1229,7 @@ do_pass_accept_req(struct sge_iq *iq, co
 		 * SYN must be directed to an IP6 address on this ifnet.  This
 		 * is more restrictive than in6_localip.
 		 */
-		if (!ifnet_has_ip6(ifp, &inc.inc6_laddr))
+		if (!in6_ifhasaddr(ifp, &inc.inc6_laddr))
 			REJECT_PASS_ACCEPT();
 	} else {
 
@@ -1293,7 +1241,7 @@ do_pass_accept_req(struct sge_iq *iq, co
 		 * SYN must be directed to an IP address on this ifnet.  This
 		 * is more restrictive than in_localip.
 		 */
-		if (!ifnet_has_ip(ifp, inc.inc_laddr))
+		if (!in_ifhasaddr(ifp, inc.inc_laddr))
 			REJECT_PASS_ACCEPT();
 	}
 

Modified: user/ngie/more-tests/sys/dev/usb/video/udl.c
==============================================================================
--- user/ngie/more-tests/sys/dev/usb/video/udl.c	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/dev/usb/video/udl.c	Sat Apr 18 00:53:52 2015	(r281676)
@@ -76,6 +76,11 @@ static int udl_fps = 25;
 SYSCTL_INT(_hw_usb_udl, OID_AUTO, fps, CTLFLAG_RWTUN,
     &udl_fps, 0, "Frames Per Second, 1-60");
 
+static struct mtx udl_buffer_mtx;
+static struct udl_buffer_head udl_buffer_head;
+
+MALLOC_DEFINE(M_USB_DL, "USB", "USB DisplayLink");
+
 /*
  * Prototypes.
  */
@@ -175,6 +180,56 @@ static const STRUCT_USB_HOST_ID udl_devs
 	{USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_LT1421, DLUNK)}
 };
 
+static void
+udl_buffer_init(void *arg)
+{
+	mtx_init(&udl_buffer_mtx, "USB", "UDL", MTX_DEF);
+	TAILQ_INIT(&udl_buffer_head);
+}
+SYSINIT(udl_buffer_init, SI_SUB_LOCK, SI_ORDER_FIRST, udl_buffer_init, NULL);
+
+CTASSERT(sizeof(struct udl_buffer) < PAGE_SIZE);
+
+static void *
+udl_buffer_alloc(uint32_t size)
+{
+	struct udl_buffer *buf;
+	mtx_lock(&udl_buffer_mtx);
+	TAILQ_FOREACH(buf, &udl_buffer_head, entry) {
+		if (buf->size == size) {
+			TAILQ_REMOVE(&udl_buffer_head, buf, entry);
+			break;
+		}
+	}
+	mtx_unlock(&udl_buffer_mtx);
+	if (buf != NULL) {
+		/* wipe and recycle buffer */
+		memset(buf, 0, size);
+		return (buf);
+	}
+	/* allocate new buffer */
+	return (malloc(size, M_USB_DL, M_WAITOK | M_ZERO));
+}
+
+static void
+udl_buffer_free(void *_buf, uint32_t size)
+{
+	struct udl_buffer *buf;
+
+	buf = (struct udl_buffer *)_buf;
+	if (buf == NULL)
+		return;
+
+	/*
+	 * Memory mapped buffers should never be freed.
+	 * Put display buffer into a recycle list.
+	 */
+	mtx_lock(&udl_buffer_mtx);
+	buf->size = size;
+	TAILQ_INSERT_TAIL(&udl_buffer_head, buf, entry);
+	mtx_unlock(&udl_buffer_mtx);
+}
+
 static uint32_t
 udl_get_fb_size(struct udl_softc *sc)
 {
@@ -403,11 +458,11 @@ udl_detach(device_t dev)
 	mtx_destroy(&sc->sc_mtx);
 	cv_destroy(&sc->sc_cv);
 
-	/*
-	 * Free framebuffer memory, if any.
-	 */
-	free(sc->sc_fb_addr, M_DEVBUF);
-	free(sc->sc_fb_copy, M_DEVBUF);
+	/* put main framebuffer into a recycle list, if any */
+	udl_buffer_free(sc->sc_fb_addr, sc->sc_fb_size);
+
+	/* free shadow framebuffer memory, if any */
+	free(sc->sc_fb_copy, M_USB_DL);
 
 	return (0);
 }
@@ -782,13 +837,15 @@ udl_fbmem_alloc(struct udl_softc *sc)
 
 	size = udl_get_fb_size(sc);
 	size = round_page(size);
-
+	/* check for zero size */
+	if (size == 0)
+		size = PAGE_SIZE;
 	/*
 	 * It is assumed that allocations above PAGE_SIZE bytes will
 	 * be PAGE_SIZE aligned for use with mmap()
 	 */
-	sc->sc_fb_addr = malloc(size, M_DEVBUF, M_WAITOK | M_ZERO);
-	sc->sc_fb_copy = malloc(size, M_DEVBUF, M_WAITOK | M_ZERO);
+	sc->sc_fb_addr = udl_buffer_alloc(size);
+	sc->sc_fb_copy = malloc(size, M_USB_DL, M_WAITOK | M_ZERO);
 	sc->sc_fb_size = size;
 }
 

Modified: user/ngie/more-tests/sys/dev/usb/video/udl.h
==============================================================================
--- user/ngie/more-tests/sys/dev/usb/video/udl.h	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/dev/usb/video/udl.h	Sat Apr 18 00:53:52 2015	(r281676)
@@ -34,6 +34,15 @@
 #define	UDL_FONT_HEIGHT		16	/* pixels */
 #define	UDL_MAX_MODES		25	/* units */
 
+MALLOC_DECLARE(M_USB_DL);
+
+struct udl_buffer {
+	TAILQ_ENTRY(udl_buffer) entry;
+	uint32_t size;
+};
+
+TAILQ_HEAD(udl_buffer_head, udl_buffer);
+
 struct udl_cmd_buf {
 	TAILQ_ENTRY(udl_cmd_buf) entry;
 	uint32_t off;

Modified: user/ngie/more-tests/sys/fs/ext2fs/ext2_dir.h
==============================================================================
--- user/ngie/more-tests/sys/fs/ext2fs/ext2_dir.h	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/fs/ext2fs/ext2_dir.h	Sat Apr 18 00:53:52 2015	(r281676)
@@ -40,21 +40,6 @@ struct	ext2fs_direct {
 	uint16_t e2d_namlen;		/* length of string in e2d_name */
 	char e2d_name[EXT2FS_MAXNAMLEN];/* name with length<=EXT2FS_MAXNAMLEN */
 };
-
-enum slotstatus {
-	NONE,
-	COMPACT,
-	FOUND
-};
-
-struct ext2fs_searchslot {
-	enum slotstatus slotstatus;
-	doff_t slotoffset;	/* offset of area with free space */
-	int slotsize;		/* size of area at slotoffset */
-	int slotfreespace;	/* amount of space free in slot */
-	int slotneeded;		/* sizeof the entry we are seeking */
-};
-
 /*
  * The new version of the directory entry.  Since EXT2 structures are
  * stored in intel byte order, and the name_len field could never be

Modified: user/ngie/more-tests/sys/fs/ext2fs/ext2_extern.h
==============================================================================
--- user/ngie/more-tests/sys/fs/ext2fs/ext2_extern.h	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/fs/ext2fs/ext2_extern.h	Sat Apr 18 00:53:52 2015	(r281676)
@@ -40,15 +40,12 @@
 #define	_FS_EXT2FS_EXT2_EXTERN_H_
 
 struct ext2fs_dinode;
-struct ext2fs_direct_2;
-struct ext2fs_searchslot;
 struct indir;
 struct inode;
 struct mount;
 struct vfsconf;
 struct vnode;
 
-int	ext2_add_entry(struct vnode *, struct ext2fs_direct_2 *);
 int	ext2_alloc(struct inode *, daddr_t, e4fs_daddr_t, int,
 	    struct ucred *, e4fs_daddr_t *);
 int	ext2_balloc(struct inode *,
@@ -86,18 +83,6 @@ int	ext2_dirempty(struct inode *, ino_t,
 int	ext2_checkpath(struct inode *, struct inode *, struct ucred *);
 int	cg_has_sb(int i);
 int	ext2_inactive(struct vop_inactive_args *);
-int	ext2_htree_add_entry(struct vnode *, struct ext2fs_direct_2 *,
-	    struct componentname *);
-int	ext2_htree_create_index(struct vnode *, struct componentname *,
-	    struct ext2fs_direct_2 *);
-int	ext2_htree_has_idx(struct inode *);
-int	ext2_htree_hash(const char *, int, uint32_t *, int, uint32_t *,
-	    uint32_t *);
-int	ext2_htree_lookup(struct inode *, const char *, int, struct buf **,
-	    int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *);
-int	ext2_search_dirblock(struct inode *, void *, int *, const char *, int,
-	    int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *);
-
 
 /* Flags to low-level allocation routines.
  * The low 16-bits are reserved for IO_ flags from vnode.h.

Modified: user/ngie/more-tests/sys/fs/ext2fs/ext2_lookup.c
==============================================================================
--- user/ngie/more-tests/sys/fs/ext2fs/ext2_lookup.c	Sat Apr 18 00:35:00 2015	(r281675)
+++ user/ngie/more-tests/sys/fs/ext2fs/ext2_lookup.c	Sat Apr 18 00:53:52 2015	(r281676)
@@ -113,19 +113,9 @@ static u_char dt_to_ext2_ft[] = {
 
 static int	ext2_dirbadentry(struct vnode *dp, struct ext2fs_direct_2 *de,
 		    int entryoffsetinblock);
-static int	ext2_is_dot_entry(struct componentname *cnp);
 static int	ext2_lookup_ino(struct vnode *vdp, struct vnode **vpp,
 		    struct componentname *cnp, ino_t *dd_ino);
 
-static int
-ext2_is_dot_entry(struct componentname *cnp)
-{
-	if (cnp->cn_namelen <= 2 && cnp->cn_nameptr[0] == '.' &&
-	    (cnp->cn_nameptr[1] == '.' || cnp->cn_nameptr[1] == '0'))
-		return (1);
-	return (0);
-}
-
 /*
  * Vnode op for reading directories.
  */
@@ -306,9 +296,13 @@ ext2_lookup_ino(struct vnode *vdp, struc
 	struct buf *bp;			/* a buffer of directory entries */
 	struct ext2fs_direct_2 *ep;	/* the current directory entry */
 	int entryoffsetinblock;		/* offset of ep in bp's buffer */
-	struct ext2fs_searchslot ss;
+	enum {NONE, COMPACT, FOUND} slotstatus;
+	doff_t slotoffset;		/* offset of area with free space */
 	doff_t i_diroff;		/* cached i_diroff value */
 	doff_t i_offset;		/* cached i_offset value */
+	int slotsize;			/* size of area at slotoffset */
+	int slotfreespace;		/* amount of space free in slot */
+	int slotneeded;			/* size of the entry we're seeking */
 	int numdirpasses;		/* strategy for directory search */
 	doff_t endsearch;		/* offset to end directory search */
 	doff_t prevoff;			/* prev entry dp->i_offset */
@@ -316,13 +310,12 @@ ext2_lookup_ino(struct vnode *vdp, struc
 	struct vnode *tdp;		/* returned by VFS_VGET */
 	doff_t enduseful;		/* pointer past last used dir slot */
 	u_long bmask;			/* block offset mask */
-	int error;
+	int namlen, error;
 	struct ucred *cred = cnp->cn_cred;
 	int flags = cnp->cn_flags;
 	int nameiop = cnp->cn_nameiop;
 	ino_t ino, ino1;
 	int ltype;
-	int entry_found = 0;
 
 	int	DIRBLKSIZ = VTOI(vdp)->i_e2fs->e2fs_bsize;
 
@@ -333,57 +326,31 @@ ext2_lookup_ino(struct vnode *vdp, struc
 	bmask = VFSTOEXT2(vdp->v_mount)->um_mountp->mnt_stat.f_iosize - 1;
 restart:
 	bp = NULL;
-	ss.slotoffset = -1;
+	slotoffset = -1;
 
 	/*
 	 * We now have a segment name to search for, and a directory to search.
-	 *
+	 */
+
+	/*
 	 * Suppress search for slots unless creating
 	 * file and at end of pathname, in which case
 	 * we watch for a place to put the new file in
 	 * case it doesn't already exist.
 	 */
 	i_diroff = dp->i_diroff;
-	ss.slotstatus = FOUND;
-	ss.slotfreespace = ss.slotsize = ss.slotneeded = 0;
+	slotstatus = FOUND;
+	slotfreespace = slotsize = slotneeded = 0;
 	if ((nameiop == CREATE || nameiop == RENAME) &&
 	    (flags & ISLASTCN)) {
-		ss.slotstatus = NONE;
-		ss.slotneeded = EXT2_DIR_REC_LEN(cnp->cn_namelen);
+		slotstatus = NONE;
+		slotneeded = EXT2_DIR_REC_LEN(cnp->cn_namelen);
 		/* was
-		ss.slotneeded = (sizeof(struct direct) - MAXNAMLEN +
+		slotneeded = (sizeof(struct direct) - MAXNAMLEN +
 			cnp->cn_namelen + 3) &~ 3; */
 	}
 
 	/*
-	 * Try to lookup dir entry using htree directory index.
-	 *
-	 * If we got an error or we want to find '.' or '..' entry,
-	 * we will fall back to linear search.
-	 */
-	if (!ext2_is_dot_entry(cnp) && ext2_htree_has_idx(dp)) {
-		numdirpasses = 1;
-		entryoffsetinblock = 0;
-		switch (ext2_htree_lookup(dp, cnp->cn_nameptr, cnp->cn_namelen,
-				&bp, &entryoffsetinblock, &i_offset, &prevoff,
-				&enduseful, &ss)) {
-		case 0:
-			ep = (struct ext2fs_direct_2 *)((char *)bp->b_data +
-				(i_offset & bmask));
-			goto foundentry;
-		case ENOENT:
-			i_offset = roundup2(dp->i_size, DIRBLKSIZ);
-			goto notfound;
-		default:
-			/*
-			 * Something failed; just fallback to do a linear
-			 * search.
-			 */
-			break;
-		}
-	}
-
-	/*
 	 * If there is cached information on a previous search of
 	 * this directory, pick up where we last left off.
 	 * We cache only lookups as these are the most common
@@ -417,38 +384,96 @@ searchloop:
 		/*
 		 * If necessary, get the next directory block.
 		 */
-		if (bp != NULL)
-			brelse(bp);
-		error = ext2_blkatoff(vdp, (off_t)i_offset, NULL, &bp);
-		if (error != 0)
-			return (error);
-		entryoffsetinblock = 0;
+		if ((i_offset & bmask) == 0) {
+			if (bp != NULL)
+				brelse(bp);
+			if ((error =
+			    ext2_blkatoff(vdp, (off_t)i_offset, NULL,
+			    &bp)) != 0)
+				return (error);
+			entryoffsetinblock = 0;
+		}
 		/*
 		 * If still looking for a slot, and at a DIRBLKSIZE
 		 * boundary, have to start looking for free space again.
 		 */
-		if (ss.slotstatus == NONE &&
+		if (slotstatus == NONE &&
 		    (entryoffsetinblock & (DIRBLKSIZ - 1)) == 0) {
-			ss.slotoffset = -1;
-			ss.slotfreespace = 0;
+			slotoffset = -1;
+			slotfreespace = 0;
 		}
-		error = ext2_search_dirblock(dp, bp->b_data, &entry_found,
-				cnp->cn_nameptr, cnp->cn_namelen,
-				&entryoffsetinblock, &i_offset, &prevoff,
-				&enduseful, &ss);
-		if (error != 0) {
-			brelse(bp);
-			return (error);
+		/*
+		 * Get pointer to next entry.
+		 * Full validation checks are slow, so we only check
+		 * enough to insure forward progress through the
+		 * directory. Complete checks can be run by setting
+		 * "vfs.e2fs.dirchk" to be true.
+		 */
+		ep = (struct ext2fs_direct_2 *)
+			((char *)bp->b_data + entryoffsetinblock);
+		if (ep->e2d_reclen == 0 ||
+		    (dirchk && ext2_dirbadentry(vdp, ep, entryoffsetinblock))) {
+			int i;
+			ext2_dirbad(dp, i_offset, "mangled entry");
+			i = DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1));
+			i_offset += i;
+			entryoffsetinblock += i;
+			continue;
 		}
-		if (entry_found) {
-			ep = (struct ext2fs_direct_2 *)((char *)bp->b_data +
-				(entryoffsetinblock & bmask));
-foundentry:
-			ino = ep->e2d_ino;
-			goto found;
+
+		/*
+		 * If an appropriate sized slot has not yet been found,
+		 * check to see if one is available. Also accumulate space
+		 * in the current block so that we can determine if
+		 * compaction is viable.
+		 */
+		if (slotstatus != FOUND) {
+			int size = ep->e2d_reclen;
+
+			if (ep->e2d_ino != 0)
+				size -= EXT2_DIR_REC_LEN(ep->e2d_namlen);
+			if (size > 0) {
+				if (size >= slotneeded) {
+					slotstatus = FOUND;
+					slotoffset = i_offset;
+					slotsize = ep->e2d_reclen;
+				} else if (slotstatus == NONE) {
+					slotfreespace += size;
+					if (slotoffset == -1)
+						slotoffset = i_offset;
+					if (slotfreespace >= slotneeded) {
+						slotstatus = COMPACT;
+						slotsize = i_offset +
+						      ep->e2d_reclen - slotoffset;
+					}
+				}
+			}
 		}
+
+		/*
+		 * Check for a name match.
+		 */
+		if (ep->e2d_ino) {
+			namlen = ep->e2d_namlen;
+			if (namlen == cnp->cn_namelen &&
+			    !bcmp(cnp->cn_nameptr, ep->e2d_name,
+				(unsigned)namlen)) {
+				/*
+				 * Save directory entry's inode number and
+				 * reclen in ndp->ni_ufs area, and release
+				 * directory buffer.
+				 */
+				ino = ep->e2d_ino;
+				goto found;
+			}
+		}
+		prevoff = i_offset;
+		i_offset += ep->e2d_reclen;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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