svn commit: r238246 - in user/attilio/vmcontention: sbin/mdconfig share/syscons/keymaps sys/cam/scsi sys/dev/acpica sys/dev/e1000 sys/dev/md sys/geom sys/geom/mountver sys/geom/nop sys/kern sys/net...

Attilio Rao attilio at FreeBSD.org
Sun Jul 8 14:06:27 UTC 2012


Author: attilio
Date: Sun Jul  8 14:06:26 2012
New Revision: 238246
URL: http://svn.freebsd.org/changeset/base/238246

Log:
  MFC

Modified:
  user/attilio/vmcontention/sbin/mdconfig/mdconfig.8
  user/attilio/vmcontention/sbin/mdconfig/mdconfig.c
  user/attilio/vmcontention/share/syscons/keymaps/INDEX.keymaps
  user/attilio/vmcontention/sys/cam/scsi/scsi_da.c
  user/attilio/vmcontention/sys/dev/acpica/acpi_cpu.c
  user/attilio/vmcontention/sys/dev/e1000/if_em.c
  user/attilio/vmcontention/sys/dev/e1000/if_igb.c
  user/attilio/vmcontention/sys/dev/md/md.c
  user/attilio/vmcontention/sys/geom/geom.h
  user/attilio/vmcontention/sys/geom/geom_disk.c
  user/attilio/vmcontention/sys/geom/geom_disk.h
  user/attilio/vmcontention/sys/geom/geom_subr.c
  user/attilio/vmcontention/sys/geom/mountver/g_mountver.c
  user/attilio/vmcontention/sys/geom/nop/g_nop.c
  user/attilio/vmcontention/sys/geom/nop/g_nop.h
  user/attilio/vmcontention/sys/kern/kern_descrip.c
  user/attilio/vmcontention/sys/kern/kern_exec.c
  user/attilio/vmcontention/sys/netinet6/in6.c
  user/attilio/vmcontention/sys/sys/file.h
  user/attilio/vmcontention/sys/sys/mdioctl.h
  user/attilio/vmcontention/sys/sys/vmmeter.h
  user/attilio/vmcontention/sys/vm/uma_core.c
  user/attilio/vmcontention/sys/vm/vm_pageout.c
  user/attilio/vmcontention/usr.sbin/ancontrol/ancontrol.c
Directory Properties:
  user/attilio/vmcontention/   (props changed)
  user/attilio/vmcontention/sbin/   (props changed)
  user/attilio/vmcontention/sys/   (props changed)

Modified: user/attilio/vmcontention/sbin/mdconfig/mdconfig.8
==============================================================================
--- user/attilio/vmcontention/sbin/mdconfig/mdconfig.8	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sbin/mdconfig/mdconfig.8	Sun Jul  8 14:06:26 2012	(r238246)
@@ -64,6 +64,11 @@
 .Fl u Ar unit
 .Op Fl o Oo Cm no Oc Ns Ar force
 .Nm
+.Fl r
+.Fl u Ar unit
+.Fl s Ar size
+.Op Fl o Oo Cm no Oc Ns Ar force
+.Nm
 .Fl l
 .Op Fl n
 .Op Fl v
@@ -85,6 +90,8 @@ This will configure and attach a memory 
 parameters specified and attach it to the system.
 .It Fl d
 Detach a memory disk from the system and release all resources.
+.It Fl r
+Resize a memory disk.
 .It Fl t Ar type
 Select the type of the memory disk.
 .Bl -tag -width "malloc"

Modified: user/attilio/vmcontention/sbin/mdconfig/mdconfig.c
==============================================================================
--- user/attilio/vmcontention/sbin/mdconfig/mdconfig.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sbin/mdconfig/mdconfig.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -54,7 +54,7 @@
 #include <unistd.h>
 
 static struct md_ioctl mdio;
-static enum {UNSET, ATTACH, DETACH, LIST} action = UNSET;
+static enum {UNSET, ATTACH, DETACH, RESIZE, LIST} action = UNSET;
 static int nflag;
 
 static void usage(void);
@@ -81,6 +81,7 @@ usage(void)
 "                [-s size] [-S sectorsize] [-u unit]\n"
 "                [-x sectors/track] [-y heads/cylinder]\n"
 "       mdconfig -d -u unit [-o [no]force]\n"
+"       mdconfig -r -u unit -s size [-o [no]force]\n"
 "       mdconfig -l [-v] [-n] [-u unit]\n"
 "       mdconfig file\n");
 	fprintf(stderr, "\t\ttype = {malloc, preload, vnode, swap}\n");
@@ -96,7 +97,7 @@ main(int argc, char **argv)
 {
 	int ch, fd, i, vflag;
 	char *p;
-	char *fflag = NULL, *tflag = NULL, *uflag = NULL;
+	char *fflag = NULL, *sflag = NULL, *tflag = NULL, *uflag = NULL;
 
 	bzero(&mdio, sizeof(mdio));
 	mdio.md_file = malloc(PATH_MAX);
@@ -108,25 +109,32 @@ main(int argc, char **argv)
 	if (argc == 1)
 		usage();
 
-	while ((ch = getopt(argc, argv, "ab:df:lno:s:S:t:u:vx:y:")) != -1) {
+	while ((ch = getopt(argc, argv, "ab:df:lno:rs:S:t:u:vx:y:")) != -1) {
 		switch (ch) {
 		case 'a':
 			if (action != UNSET && action != ATTACH)
-				errx(1,
-				    "-a is mutually exclusive with -d and -l");
+				errx(1, "-a is mutually exclusive "
+				    "with -d, -r, and -l");
 			action = ATTACH;
 			break;
 		case 'd':
 			if (action != UNSET && action != DETACH)
-				errx(1,
-				    "-d is mutually exclusive with -a and -l");
+				errx(1, "-d is mutually exclusive "
+				    "with -a, -r, and -l");
 			action = DETACH;
 			mdio.md_options |= MD_AUTOUNIT;
 			break;
+		case 'r':
+			if (action != UNSET && action != RESIZE)
+				errx(1, "-r is mutually exclusive "
+				    "with -a, -d, and -l");
+			action = RESIZE;
+			mdio.md_options |= MD_AUTOUNIT;
+			break;
 		case 'l':
 			if (action != UNSET && action != LIST)
-				errx(1,
-				    "-l is mutually exclusive with -a and -d");
+				errx(1, "-l is mutually exclusive "
+				    "with -a, -r, and -d");
 			action = LIST;
 			mdio.md_options |= MD_AUTOUNIT;
 			break;
@@ -188,6 +196,9 @@ main(int argc, char **argv)
 			mdio.md_sectorsize = strtoul(optarg, &p, 0);
 			break;
 		case 's':
+			if (sflag != NULL)
+				errx(1, "-s can be passed only once");
+			sflag = optarg;
 			mdio.md_mediasize = (off_t)strtoumax(optarg, &p, 0);
 			if (p == NULL || *p == '\0')
 				mdio.md_mediasize *= DEV_BSIZE;
@@ -242,7 +253,7 @@ main(int argc, char **argv)
 				mdio.md_type = MD_VNODE;
 				mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT |
 				    MD_COMPRESS;
-			} else if (mdio.md_mediasize != 0) {
+			} else if (sflag != NULL) {
 				/* Imply ``-t swap'' */
 				mdio.md_type = MD_SWAP;
 				mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT |
@@ -276,15 +287,15 @@ main(int argc, char **argv)
 		}
 
 		if ((mdio.md_type == MD_MALLOC || mdio.md_type == MD_SWAP) &&
-		    mdio.md_mediasize == 0)
+		    sflag == NULL)
 			errx(1, "must specify -s for -t malloc or -t swap");
 		if (mdio.md_type == MD_VNODE && mdio.md_file[0] == '\0')
 			errx(1, "must specify -f for -t vnode");
 	} else {
 		if (mdio.md_sectorsize != 0)
 			errx(1, "-S can only be used with -a");
-		if (mdio.md_mediasize != 0)
-			errx(1, "-s can only be used with -a");
+		if (action != RESIZE && sflag != NULL)
+			errx(1, "-s can only be used with -a and -r");
 		if (mdio.md_fwsectors != 0)
 			errx(1, "-x can only be used with -a");
 		if (mdio.md_fwheads != 0)
@@ -295,13 +306,20 @@ main(int argc, char **argv)
 			errx(1, "-t can only be used with -a");
 		if (argc > 0)
 			errx(1, "file can only be used with -a");
-		if (action != DETACH && (mdio.md_options & ~MD_AUTOUNIT) != 0)
-			errx(1, "-o can only be used with -a and -d");
+		if ((action != DETACH && action != RESIZE) &&
+		    (mdio.md_options & ~MD_AUTOUNIT) != 0)
+			errx(1, "-o can only be used with -a, -d, and -r");
 		if (action == DETACH &&
 		    (mdio.md_options & ~(MD_FORCE | MD_AUTOUNIT)) != 0)
 			errx(1, "only -o [no]force can be used with -d");
+		if (action == RESIZE &&
+		    (mdio.md_options & ~(MD_FORCE | MD_RESERVE | MD_AUTOUNIT)) != 0)
+			errx(1, "only -o [no]force and -o [no]reserve can be used with -r");
 	}
 
+	if (action == RESIZE && sflag == NULL)
+		errx(1, "must specify -s for -r");
+
 	if (action != LIST && vflag == OPT_VERBOSE)
 		errx(1, "-v can only be used with -l");
 
@@ -333,6 +351,12 @@ main(int argc, char **argv)
 		i = ioctl(fd, MDIOCDETACH, &mdio);
 		if (i < 0)
 			err(1, "ioctl(/dev/%s)", MDCTL_NAME);
+	} else if (action == RESIZE) {
+		if (mdio.md_options & MD_AUTOUNIT)
+			errx(1, "-r requires -u");
+		i = ioctl(fd, MDIOCRESIZE, &mdio);
+		if (i < 0)
+			err(1, "ioctl(/dev/%s)", MDCTL_NAME);
 	} else if (action == LIST) {
 		if (mdio.md_options & MD_AUTOUNIT) {
 			/*
@@ -342,7 +366,6 @@ main(int argc, char **argv)
 			md_list(NULL, OPT_LIST | vflag);
 		} else
 			return (md_query(uflag));
-
 	} else
 		usage();
 	close(fd);

Modified: user/attilio/vmcontention/share/syscons/keymaps/INDEX.keymaps
==============================================================================
--- user/attilio/vmcontention/share/syscons/keymaps/INDEX.keymaps	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/share/syscons/keymaps/INDEX.keymaps	Sun Jul  8 14:06:26 2012	(r238246)
@@ -378,6 +378,8 @@ ru.koi8-r.win.kbd:pt:Russo koi8-r (winke
 ru.koi8-r.win.kbd:es:Ruso koi8-r (winkeys)
 ru.koi8-r.win.kbd:uk:òÏÓ¦ÊÓØËÁ koi8-r (winkeys)
 
+spanish.dvorak.kbd:en:Spanish Dvorak
+
 spanish.iso.kbd:en:Spanish ISO-8859-1
 spanish.iso.kbd:de:Spanisch ISO-8859-1
 spanish.iso.kbd:fr:Espagnol ISO-8859-1

Modified: user/attilio/vmcontention/sys/cam/scsi/scsi_da.c
==============================================================================
--- user/attilio/vmcontention/sys/cam/scsi/scsi_da.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/cam/scsi/scsi_da.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -2644,6 +2644,8 @@ dasetgeom(struct cam_periph *periph, uin
 		softc->disk->d_flags |= DISKFLAG_CANDELETE;
 	else
 		softc->disk->d_flags &= ~DISKFLAG_CANDELETE;
+
+	disk_resize(softc->disk);
 }
 
 static void

Modified: user/attilio/vmcontention/sys/dev/acpica/acpi_cpu.c
==============================================================================
--- user/attilio/vmcontention/sys/dev/acpica/acpi_cpu.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/dev/acpica/acpi_cpu.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -918,14 +918,12 @@ acpi_cpu_startup_cx(struct acpi_cpu_soft
 		    (void *)sc, 0, acpi_cpu_usage_sysctl, "A",
 		    "percent usage for each Cx state");
 
-#ifdef notyet
     /* Signal platform that we can handle _CST notification. */
     if (!cpu_cx_generic && cpu_cst_cnt != 0) {
 	ACPI_LOCK(acpi);
 	AcpiOsWritePort(cpu_smi_cmd, cpu_cst_cnt, 8);
 	ACPI_UNLOCK(acpi);
     }
-#endif
 }
 
 /*

Modified: user/attilio/vmcontention/sys/dev/e1000/if_em.c
==============================================================================
--- user/attilio/vmcontention/sys/dev/e1000/if_em.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/dev/e1000/if_em.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -289,6 +289,7 @@ static void	em_handle_link(void *context
 static void	em_set_sysctl_value(struct adapter *, const char *,
 		    const char *, int *, int);
 static int	em_set_flowcntl(SYSCTL_HANDLER_ARGS);
+static int	em_sysctl_eee(SYSCTL_HANDLER_ARGS);
 
 static __inline void em_rx_discard(struct rx_ring *, int);
 
@@ -389,7 +390,7 @@ SYSCTL_INT(_hw_em, OID_AUTO, rx_process_
     "at a time, -1 means unlimited");
 
 /* Energy efficient ethernet - default to OFF */
-static int eee_setting = 0;
+static int eee_setting = 1;
 TUNABLE_INT("hw.em.eee_setting", &eee_setting);
 SYSCTL_INT(_hw_em, OID_AUTO, eee_setting, CTLFLAG_RDTUN, &eee_setting, 0,
     "Enable Energy Efficient Ethernet");
@@ -636,9 +637,12 @@ em_attach(device_t dev)
 		    " due to SOL/IDER session.\n");
 
 	/* Sysctl for setting Energy Efficient Ethernet */
-	em_set_sysctl_value(adapter, "eee_control",
-	    "enable Energy Efficient Ethernet",
-	    (int *)&hw->dev_spec.ich8lan.eee_disable, eee_setting);
+	hw->dev_spec.ich8lan.eee_disable = eee_setting;
+	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
+	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+	    OID_AUTO, "eee_control", CTLTYPE_INT|CTLFLAG_RW,
+	    adapter, 0, em_sysctl_eee, "I",
+	    "Disable Energy Efficient Ethernet");
 
 	/*
 	** Start from a known state, this is
@@ -5695,6 +5699,27 @@ em_set_flowcntl(SYSCTL_HANDLER_ARGS)
         return (error);
 }
 
+/*
+** Manage Energy Efficient Ethernet:
+** Control values:
+**     0/1 - enabled/disabled
+*/
+static int
+em_sysctl_eee(SYSCTL_HANDLER_ARGS)
+{
+       struct adapter *adapter = (struct adapter *) arg1;
+       int             error, value;
+
+       value = adapter->hw.dev_spec.ich8lan.eee_disable;
+       error = sysctl_handle_int(oidp, &value, 0, req);
+       if (error || req->newptr == NULL)
+               return (error);
+       EM_CORE_LOCK(adapter);
+       adapter->hw.dev_spec.ich8lan.eee_disable = (value != 0);
+       em_init_locked(adapter);
+       EM_CORE_UNLOCK(adapter);
+       return (0);
+}
 
 static int
 em_sysctl_debug_info(SYSCTL_HANDLER_ARGS)

Modified: user/attilio/vmcontention/sys/dev/e1000/if_igb.c
==============================================================================
--- user/attilio/vmcontention/sys/dev/e1000/if_igb.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/dev/e1000/if_igb.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -277,6 +277,7 @@ static void	igb_set_sysctl_value(struct 
 		    const char *, int *, int);
 static int	igb_set_flowcntl(SYSCTL_HANDLER_ARGS);
 static int	igb_sysctl_dmac(SYSCTL_HANDLER_ARGS);
+static int	igb_sysctl_eee(SYSCTL_HANDLER_ARGS);
 
 #ifdef DEVICE_POLLING
 static poll_handler_t igb_poll;
@@ -586,10 +587,11 @@ igb_attach(device_t dev)
 		    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
 		    OID_AUTO, "dmac", CTLTYPE_INT|CTLFLAG_RW,
 		    adapter, 0, igb_sysctl_dmac, "I", "DMA Coalesce");
-		igb_set_sysctl_value(adapter, "eee_disabled",
-		    "enable Energy Efficient Ethernet",
-		    (int *)&adapter->hw.dev_spec._82575.eee_disable,
-		    TRUE);
+		SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
+		    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+		    OID_AUTO, "eee_disabled", CTLTYPE_INT|CTLFLAG_RW,
+		    adapter, 0, igb_sysctl_eee, "I",
+		    "Disable Energy Efficient Ethernet");
 		if (adapter->hw.phy.media_type == e1000_media_type_copper)
 			e1000_set_eee_i350(&adapter->hw);
 	}
@@ -5988,3 +5990,25 @@ igb_sysctl_dmac(SYSCTL_HANDLER_ARGS)
 	igb_init(adapter);
 	return (error);
 }
+
+/*
+** Manage Energy Efficient Ethernet:
+** Control values:
+**     0/1 - enabled/disabled
+*/
+static int
+igb_sysctl_eee(SYSCTL_HANDLER_ARGS)
+{
+	struct adapter	*adapter = (struct adapter *) arg1;
+	int		error, value;
+
+	value = adapter->hw.dev_spec._82575.eee_disable;
+	error = sysctl_handle_int(oidp, &value, 0, req);
+	if (error || req->newptr == NULL)
+		return (error);
+	IGB_CORE_LOCK(adapter);
+	adapter->hw.dev_spec._82575.eee_disable = (value != 0);
+	igb_init_locked(adapter);
+	IGB_CORE_UNLOCK(adapter);
+	return (0);
+}

Modified: user/attilio/vmcontention/sys/dev/md/md.c
==============================================================================
--- user/attilio/vmcontention/sys/dev/md/md.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/dev/md/md.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -1081,6 +1081,64 @@ mddestroy(struct md_s *sc, struct thread
 }
 
 static int
+mdresize(struct md_s *sc, struct md_ioctl *mdio)
+{
+	int error, res;
+	vm_pindex_t oldpages, newpages;
+
+	switch (sc->type) {
+	case MD_VNODE:
+		break;
+	case MD_SWAP:
+		if (mdio->md_mediasize == 0 ||
+		    (mdio->md_mediasize % PAGE_SIZE) != 0)
+			return (EDOM);
+		oldpages = OFF_TO_IDX(round_page(sc->mediasize));
+		newpages = OFF_TO_IDX(round_page(mdio->md_mediasize));
+		if (newpages < oldpages) {
+			VM_OBJECT_LOCK(sc->object);
+			vm_object_page_remove(sc->object, newpages, 0, 0);
+			swap_pager_freespace(sc->object, newpages,
+			    oldpages - newpages);
+			swap_release_by_cred(IDX_TO_OFF(oldpages -
+			    newpages), sc->cred);
+			sc->object->charge = IDX_TO_OFF(newpages);
+			sc->object->size = newpages;
+			VM_OBJECT_UNLOCK(sc->object);
+		} else if (newpages > oldpages) {
+			res = swap_reserve_by_cred(IDX_TO_OFF(newpages -
+			    oldpages), sc->cred);
+			if (!res)
+				return (ENOMEM);
+			if ((mdio->md_options & MD_RESERVE) ||
+			    (sc->flags & MD_RESERVE)) {
+				error = swap_pager_reserve(sc->object,
+				    oldpages, newpages - oldpages);
+				if (error < 0) {
+					swap_release_by_cred(
+					    IDX_TO_OFF(newpages - oldpages),
+					    sc->cred);
+					return (EDOM);
+				}
+			}
+			VM_OBJECT_LOCK(sc->object);
+			sc->object->charge = IDX_TO_OFF(newpages);
+			sc->object->size = newpages;
+			VM_OBJECT_UNLOCK(sc->object);
+		}
+		break;
+	default:
+		return (EOPNOTSUPP);
+	}
+
+	sc->mediasize = mdio->md_mediasize;
+	g_topology_lock();
+	g_resize_provider(sc->pp, sc->mediasize);
+	g_topology_unlock();
+	return (0);
+}
+
+static int
 mdcreate_swap(struct md_s *sc, struct md_ioctl *mdio, struct thread *td)
 {
 	vm_ooffset_t npage;
@@ -1108,7 +1166,7 @@ mdcreate_swap(struct md_s *sc, struct md
 	    VM_PROT_DEFAULT, 0, td->td_ucred);
 	if (sc->object == NULL)
 		return (ENOMEM);
-	sc->flags = mdio->md_options & MD_FORCE;
+	sc->flags = mdio->md_options & (MD_FORCE | MD_RESERVE);
 	if (mdio->md_options & MD_RESERVE) {
 		if (swap_pager_reserve(sc->object, 0, npage) < 0) {
 			error = EDOM;
@@ -1217,6 +1275,18 @@ xmdctlioctl(struct cdev *dev, u_long cmd
 		    !(mdio->md_options & MD_FORCE))
 			return (EBUSY);
 		return (mddestroy(sc, td));
+	case MDIOCRESIZE:
+		if ((mdio->md_options & ~(MD_FORCE | MD_RESERVE)) != 0)
+			return (EINVAL);
+
+		sc = mdfind(mdio->md_unit);
+		if (sc == NULL)
+			return (ENOENT);
+		if (mdio->md_mediasize < sc->mediasize &&
+		    !(sc->flags & MD_FORCE) &&
+		    !(mdio->md_options & MD_FORCE))
+			return (EBUSY);
+		return (mdresize(sc, mdio));
 	case MDIOCQUERY:
 		sc = mdfind(mdio->md_unit);
 		if (sc == NULL)

Modified: user/attilio/vmcontention/sys/geom/geom.h
==============================================================================
--- user/attilio/vmcontention/sys/geom/geom.h	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/geom/geom.h	Sun Jul  8 14:06:26 2012	(r238246)
@@ -79,6 +79,7 @@ typedef void g_attrchanged_t (struct g_c
 typedef void g_provgone_t (struct g_provider *);
 typedef void g_dumpconf_t (struct sbuf *, const char *indent, struct g_geom *,
     struct g_consumer *, struct g_provider *);
+typedef void g_resize_t(struct g_consumer *cp);
 
 /*
  * The g_class structure describes a transformation class.  In other words
@@ -108,7 +109,7 @@ struct g_class {
 	g_orphan_t		*orphan;
 	g_ioctl_t		*ioctl;
 	g_provgone_t		*providergone;
-	void			*spare2;
+	g_resize_t		*resize;
 	/*
 	 * The remaining elements are private
 	 */
@@ -139,7 +140,7 @@ struct g_geom {
 	g_orphan_t		*orphan;
 	g_ioctl_t		*ioctl;
 	g_provgone_t		*providergone;
-	void			*spare1;
+	g_resize_t		*resize;
 	void			*softc;
 	unsigned		flags;
 #define	G_GEOM_WITHER		1
@@ -265,6 +266,7 @@ int g_handleattr_str(struct bio *bp, con
 struct g_consumer * g_new_consumer(struct g_geom *gp);
 struct g_geom * g_new_geomf(struct g_class *mp, const char *fmt, ...);
 struct g_provider * g_new_providerf(struct g_geom *gp, const char *fmt, ...);
+void g_resize_provider(struct g_provider *pp, off_t size);
 int g_retaste(struct g_class *mp);
 void g_spoil(struct g_provider *pp, struct g_consumer *cp);
 int g_std_access(struct g_provider *pp, int dr, int dw, int de);

Modified: user/attilio/vmcontention/sys/geom/geom_disk.c
==============================================================================
--- user/attilio/vmcontention/sys/geom/geom_disk.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/geom/geom_disk.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 #include <sys/sbuf.h>
 #include <sys/sysctl.h>
+#include <sys/taskqueue.h>
 #include <sys/devicestat.h>
 #include <machine/md_var.h>
 
@@ -65,6 +66,7 @@ struct g_disk_softc {
 	struct sysctl_oid	*sysctl_tree;
 	char			led[64];
 	uint32_t		state;
+	struct task		resize_task;
 };
 
 static struct mtx g_disk_done_mtx;
@@ -445,6 +447,27 @@ g_disk_dumpconf(struct sbuf *sb, const c
 }
 
 static void
+g_disk_resize_task(void *context, int pending)
+{
+	struct g_geom *gp;
+	struct g_provider *pp;
+	struct disk *dp;
+	struct g_disk_softc *sc;
+
+	sc = (struct g_disk_softc *)context;
+	dp = sc->dp;
+	gp = dp->d_geom;
+
+	LIST_FOREACH(pp, &gp->provider, provider) {
+		if (pp->sectorsize != 0 &&
+		    pp->sectorsize != dp->d_sectorsize)
+			g_wither_provider(pp, ENXIO);
+		else
+			g_resize_provider(pp, dp->d_mediasize);
+	}
+}
+
+static void
 g_disk_create(void *arg, int flag)
 {
 	struct g_geom *gp;
@@ -484,6 +507,7 @@ g_disk_create(void *arg, int flag)
 		    CTLFLAG_RW | CTLFLAG_TUN, sc->led, sizeof(sc->led),
 		    "LED name");
 	}
+	TASK_INIT(&sc->resize_task, 0, g_disk_resize_task, sc);
 	pp->private = sc;
 	dp->d_geom = gp;
 	g_error_provider(pp, 0);
@@ -635,6 +659,24 @@ disk_attr_changed(struct disk *dp, const
 			(void)g_attr_changed(pp, attr, flag);
 }
 
+void
+disk_resize(struct disk *dp)
+{
+	struct g_geom *gp;
+	struct g_disk_softc *sc;
+	int error;
+
+	gp = dp->d_geom;
+
+	if (gp == NULL)
+		return;
+
+	sc = gp->softc;
+
+	error = taskqueue_enqueue(taskqueue_thread, &sc->resize_task);
+	KASSERT(error == 0, ("taskqueue_enqueue(9) failed."));
+}
+
 static void
 g_kern_disks(void *p, int flag __unused)
 {

Modified: user/attilio/vmcontention/sys/geom/geom_disk.h
==============================================================================
--- user/attilio/vmcontention/sys/geom/geom_disk.h	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/geom/geom_disk.h	Sun Jul  8 14:06:26 2012	(r238246)
@@ -109,6 +109,7 @@ void disk_create(struct disk *disk, int 
 void disk_destroy(struct disk *disk);
 void disk_gone(struct disk *disk);
 void disk_attr_changed(struct disk *dp, const char *attr, int flag);
+void disk_resize(struct disk *dp);
 
 #define DISK_VERSION_00		0x58561059
 #define DISK_VERSION_01		0x5856105a

Modified: user/attilio/vmcontention/sys/geom/geom_subr.c
==============================================================================
--- user/attilio/vmcontention/sys/geom/geom_subr.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/geom/geom_subr.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -68,9 +68,11 @@ static struct g_tailq_head geoms = TAILQ
 char *g_wait_event, *g_wait_up, *g_wait_down, *g_wait_sim;
 
 struct g_hh00 {
-	struct g_class	*mp;
-	int		error;
-	int		post;
+	struct g_class		*mp;
+	struct g_provider	*pp;
+	off_t			size;
+	int			error;
+	int			post;
 };
 
 /*
@@ -356,6 +358,7 @@ g_new_geomf(struct g_class *mp, const ch
 	gp->access = mp->access;
 	gp->orphan = mp->orphan;
 	gp->ioctl = mp->ioctl;
+	gp->resize = mp->resize;
 	return (gp);
 }
 
@@ -601,6 +604,76 @@ g_error_provider(struct g_provider *pp, 
 	pp->error = error;
 }
 
+static void
+g_resize_provider_event(void *arg, int flag)
+{
+	struct g_hh00 *hh;
+	struct g_class *mp;
+	struct g_geom *gp;
+	struct g_provider *pp;
+	struct g_consumer *cp, *cp2;
+	off_t size;
+
+	g_topology_assert();
+	if (flag == EV_CANCEL)
+		return;
+	if (g_shutdown)
+		return;
+
+	hh = arg;
+	pp = hh->pp;
+	size = hh->size;
+
+	G_VALID_PROVIDER(pp);
+	g_trace(G_T_TOPOLOGY, "g_resize_provider_event(%p)", pp);
+
+	LIST_FOREACH_SAFE(cp, &pp->consumers, consumers, cp2) {
+		gp = cp->geom;
+		if (gp->resize == NULL && size < pp->mediasize)
+			cp->geom->orphan(cp);
+	}
+
+	pp->mediasize = size;
+	
+	LIST_FOREACH_SAFE(cp, &pp->consumers, consumers, cp2) {
+		gp = cp->geom;
+		if (gp->resize != NULL)
+			gp->resize(cp);
+	}
+
+	/*
+	 * After resizing, the previously invalid GEOM class metadata
+	 * might become valid.  This means we should retaste.
+	 */
+	LIST_FOREACH(mp, &g_classes, class) {
+		if (mp->taste == NULL)
+			continue;
+		LIST_FOREACH(cp, &pp->consumers, consumers)
+			if (cp->geom->class == mp)
+				break;
+		if (cp != NULL)
+			continue;
+		mp->taste(mp, pp, 0);
+		g_topology_assert();
+	}
+}
+
+void
+g_resize_provider(struct g_provider *pp, off_t size)
+{
+	struct g_hh00 *hh;
+
+	G_VALID_PROVIDER(pp);
+
+	if (size == pp->mediasize)
+		return;
+
+	hh = g_malloc(sizeof *hh, M_WAITOK | M_ZERO);
+	hh->pp = pp;
+	hh->size = size;
+	g_post_event(g_resize_provider_event, hh, M_WAITOK, NULL);
+}
+
 struct g_provider *
 g_provider_by_name(char const *arg)
 {

Modified: user/attilio/vmcontention/sys/geom/mountver/g_mountver.c
==============================================================================
--- user/attilio/vmcontention/sys/geom/mountver/g_mountver.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/geom/mountver/g_mountver.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -59,6 +59,7 @@ static eventhandler_tag g_mountver_pre_s
 
 static void g_mountver_queue(struct bio *bp);
 static void g_mountver_orphan(struct g_consumer *cp);
+static void g_mountver_resize(struct g_consumer *cp);
 static int g_mountver_destroy(struct g_geom *gp, boolean_t force);
 static g_taste_t g_mountver_taste;
 static int g_mountver_destroy_geom(struct gctl_req *req, struct g_class *mp,
@@ -257,6 +258,7 @@ g_mountver_create(struct gctl_req *req, 
 	gp->softc = sc;
 	gp->start = g_mountver_start;
 	gp->orphan = g_mountver_orphan;
+	gp->resize = g_mountver_resize;
 	gp->access = g_mountver_access;
 	gp->dumpconf = g_mountver_dumpconf;
 
@@ -457,6 +459,18 @@ g_mountver_orphan(struct g_consumer *cp)
 	G_MOUNTVER_DEBUG(0, "%s is offline.  Mount verification in progress.", sc->sc_provider_name);
 }
 
+static void
+g_mountver_resize(struct g_consumer *cp)
+{
+	struct g_geom *gp;
+	struct g_provider *pp;
+
+	gp = cp->geom;
+
+	LIST_FOREACH(pp, &gp->provider, provider)
+		g_resize_provider(pp, cp->provider->mediasize);
+}
+
 static int
 g_mountver_ident_matches(struct g_geom *gp)
 {

Modified: user/attilio/vmcontention/sys/geom/nop/g_nop.c
==============================================================================
--- user/attilio/vmcontention/sys/geom/nop/g_nop.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/geom/nop/g_nop.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -72,6 +72,30 @@ g_nop_orphan(struct g_consumer *cp)
 }
 
 static void
+g_nop_resize(struct g_consumer *cp)
+{
+	struct g_nop_softc *sc;
+	struct g_geom *gp;
+	struct g_provider *pp;
+	off_t size;
+
+	g_topology_assert();
+
+	gp = cp->geom;
+	sc = gp->softc;
+
+	if (sc->sc_explicitsize != 0)
+		return;
+	if (cp->provider->mediasize < sc->sc_offset) {
+		g_nop_destroy(gp, 1);
+		return;
+	}
+	size = cp->provider->mediasize - sc->sc_offset;
+	LIST_FOREACH(pp, &gp->provider, provider)
+		g_resize_provider(pp, size);
+}
+
+static void
 g_nop_start(struct bio *bp)
 {
 	struct g_nop_softc *sc;
@@ -146,6 +170,7 @@ g_nop_create(struct gctl_req *req, struc
 	struct g_consumer *cp;
 	char name[64];
 	int error;
+	off_t explicitsize;
 
 	g_topology_assert();
 
@@ -165,6 +190,7 @@ g_nop_create(struct gctl_req *req, struc
 		gctl_error(req, "Invalid offset for provider %s.", pp->name);
 		return (EINVAL);
 	}
+	explicitsize = size;
 	if (size == 0)
 		size = pp->mediasize - offset;
 	if (offset + size > pp->mediasize) {
@@ -192,6 +218,7 @@ g_nop_create(struct gctl_req *req, struc
 	gp = g_new_geomf(mp, name);
 	sc = g_malloc(sizeof(*sc), M_WAITOK);
 	sc->sc_offset = offset;
+	sc->sc_explicitsize = explicitsize;
 	sc->sc_error = ioerror;
 	sc->sc_rfailprob = rfailprob;
 	sc->sc_wfailprob = wfailprob;
@@ -202,6 +229,7 @@ g_nop_create(struct gctl_req *req, struc
 	gp->softc = sc;
 	gp->start = g_nop_start;
 	gp->orphan = g_nop_orphan;
+	gp->resize = g_nop_resize;
 	gp->access = g_nop_access;
 	gp->dumpconf = g_nop_dumpconf;
 

Modified: user/attilio/vmcontention/sys/geom/nop/g_nop.h
==============================================================================
--- user/attilio/vmcontention/sys/geom/nop/g_nop.h	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/geom/nop/g_nop.h	Sun Jul  8 14:06:26 2012	(r238246)
@@ -57,6 +57,7 @@
 struct g_nop_softc {
 	int		sc_error;
 	off_t		sc_offset;
+	off_t		sc_explicitsize;
 	u_int		sc_rfailprob;
 	u_int		sc_wfailprob;
 	uintmax_t	sc_reads;

Modified: user/attilio/vmcontention/sys/kern/kern_descrip.c
==============================================================================
--- user/attilio/vmcontention/sys/kern/kern_descrip.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/kern/kern_descrip.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -2340,11 +2340,11 @@ _fget(struct thread *td, int fd, struct 
 
 	/*
 	 * FREAD and FWRITE failure return EBADF as per POSIX.
-	 *
-	 * Only one flag, or 0, may be specified.
 	 */
 	if ((flags == FREAD && (fp->f_flag & FREAD) == 0) ||
-	    (flags == FWRITE && (fp->f_flag & FWRITE) == 0)) {
+	    (flags == FWRITE && (fp->f_flag & FWRITE) == 0) ||
+	    (flags == (FREAD | FEXEC) &&
+	    (((fp->f_flag & flags) == 0) || ((fp->f_flag & FWRITE) != 0)))) {
 		fdrop(fp, td);
 		return (EBADF);
 	}
@@ -2444,6 +2444,13 @@ fgetvp_read(struct thread *td, int fd, c
 	return (_fgetvp(td, fd, FREAD, rights, NULL, vpp));
 }
 
+int
+fgetvp_exec(struct thread *td, int fd, cap_rights_t rights, struct vnode **vpp)
+{
+
+	return (_fgetvp(td, fd, FREAD | FEXEC, rights, NULL, vpp));
+}
+
 #ifdef notyet
 int
 fgetvp_write(struct thread *td, int fd, cap_rights_t rights,

Modified: user/attilio/vmcontention/sys/kern/kern_exec.c
==============================================================================
--- user/attilio/vmcontention/sys/kern/kern_exec.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/kern/kern_exec.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -443,8 +443,10 @@ interpret:
 		/*
 		 * Some might argue that CAP_READ and/or CAP_MMAP should also
 		 * be required here; such arguments will be entertained.
+		 *
+		 * Descriptors opened only with O_EXEC or O_RDONLY are allowed.
 		 */
-		error = fgetvp_read(td, args->fd, CAP_FEXECVE, &binvp);
+		error = fgetvp_exec(td, args->fd, CAP_FEXECVE, &binvp);
 		if (error)
 			goto exec_fail;
 		vfslocked = VFS_LOCK_GIANT(binvp->v_mount);

Modified: user/attilio/vmcontention/sys/netinet6/in6.c
==============================================================================
--- user/attilio/vmcontention/sys/netinet6/in6.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/netinet6/in6.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -1367,7 +1367,9 @@ in6_purgeaddr_mc(struct ifnet *ifp, stru
 		sin6.sin6_family = AF_INET6;
 		memcpy(&sin6.sin6_addr, &satosin6(ifa0->ifa_addr)->sin6_addr, 
 		    sizeof(sin6.sin6_addr));
-		in6_setscope(&sin6.sin6_addr, ifa0->ifa_ifp, NULL);
+		error = in6_setscope(&sin6.sin6_addr, ifa0->ifa_ifp, NULL);
+		if (error != 0)
+			return (error);
 	}
 
 	rt = in6_rtalloc1((struct sockaddr *)&mltaddr, 0, 0UL, RT_DEFAULT_FIB);

Modified: user/attilio/vmcontention/sys/sys/file.h
==============================================================================
--- user/attilio/vmcontention/sys/sys/file.h	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/sys/file.h	Sun Jul  8 14:06:26 2012	(r238246)
@@ -238,6 +238,8 @@ fo_chown_t	invfo_chown;
 
 void finit(struct file *, u_int, short, void *, struct fileops *);
 int fgetvp(struct thread *td, int fd, cap_rights_t rights, struct vnode **vpp);
+int fgetvp_exec(struct thread *td, int fd, cap_rights_t rights,
+    struct vnode **vpp);
 int fgetvp_rights(struct thread *td, int fd, cap_rights_t need,
     cap_rights_t *have, struct vnode **vpp);
 int fgetvp_read(struct thread *td, int fd, cap_rights_t rights,

Modified: user/attilio/vmcontention/sys/sys/mdioctl.h
==============================================================================
--- user/attilio/vmcontention/sys/sys/mdioctl.h	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/sys/mdioctl.h	Sun Jul  8 14:06:26 2012	(r238246)
@@ -79,6 +79,7 @@ struct md_ioctl {
 #define MDIOCDETACH	_IOWR('m', 1, struct md_ioctl)	/* detach disk */
 #define MDIOCQUERY	_IOWR('m', 2, struct md_ioctl)	/* query status */
 #define MDIOCLIST	_IOWR('m', 3, struct md_ioctl)	/* query status */
+#define MDIOCRESIZE	_IOWR('m', 4, struct md_ioctl)	/* resize disk */
 
 #define MD_CLUSTER	0x01	/* Don't cluster */
 #define MD_RESERVE	0x02	/* Pre-reserve swap */

Modified: user/attilio/vmcontention/sys/sys/vmmeter.h
==============================================================================
--- user/attilio/vmcontention/sys/sys/vmmeter.h	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/sys/vmmeter.h	Sun Jul  8 14:06:26 2012	(r238246)
@@ -79,7 +79,7 @@ struct vmmeter {
 	u_int v_pdpages;	/* (q) pages analyzed by daemon */
 
 	u_int v_tcached;	/* (p) total pages cached */
-	u_int v_dfree;		/* (q) pages freed by daemon */
+	u_int v_dfree;		/* (p) pages freed by daemon */
 	u_int v_pfree;		/* (p) pages freed by exiting processes */
 	u_int v_tfree;		/* (p) total pages freed */
 	/*

Modified: user/attilio/vmcontention/sys/vm/uma_core.c
==============================================================================
--- user/attilio/vmcontention/sys/vm/uma_core.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/vm/uma_core.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -2193,6 +2193,7 @@ keg_fetch_slab(uma_keg_t keg, uma_zone_t
 				zone->uz_flags |= UMA_ZFLAG_FULL;
 			if (flags & M_NOWAIT)
 				break;
+			zone->uz_sleeps++;
 			msleep(keg, &keg->uk_lock, PVM, "keglimit", 0);
 			continue;
 		}

Modified: user/attilio/vmcontention/sys/vm/vm_pageout.c
==============================================================================
--- user/attilio/vmcontention/sys/vm/vm_pageout.c	Sun Jul  8 14:01:25 2012	(r238245)
+++ user/attilio/vmcontention/sys/vm/vm_pageout.c	Sun Jul  8 14:06:26 2012	(r238246)
@@ -743,6 +743,7 @@ vm_pageout_scan(int pass)
 	int actcount;
 	int vnodes_skipped = 0;
 	int maxlaunder;
+	boolean_t queues_locked;
 
 	/*
 	 * Decrease registered cache sizes.
@@ -784,6 +785,7 @@ vm_pageout_scan(int pass)
 	if (pass)
 		maxlaunder = 10000;
 	vm_page_lock_queues();
+	queues_locked = TRUE;
 rescan0:
 	addl_page_shortage = addl_page_shortage_init;
 	maxscan = cnt.v_inactive_count;
@@ -791,6 +793,8 @@ rescan0:
 	for (m = TAILQ_FIRST(&vm_page_queues[PQ_INACTIVE].pl);
 	     m != NULL && maxscan-- > 0 && page_shortage > 0;
 	     m = next) {
+		KASSERT(queues_locked, ("unlocked queues"));
+		mtx_assert(&vm_page_queue_mtx, MA_OWNED);
 
 		cnt.v_pdpages++;
 
@@ -850,6 +854,16 @@ rescan0:
 		}
 
 		/*
+		 * We unlock vm_page_queue_mtx, invalidating the
+		 * 'next' pointer.  Use our marker to remember our
+		 * place.
+		 */
+		TAILQ_INSERT_AFTER(&vm_page_queues[PQ_INACTIVE].pl,
+		    m, &marker, pageq);
+		vm_page_unlock_queues();
+		queues_locked = FALSE;
+
+		/*
 		 * If the object is not being used, we ignore previous 
 		 * references.
 		 */
@@ -873,7 +887,7 @@ rescan0:
 			vm_page_unlock(m);
 			m->act_count += actcount + ACT_ADVANCE;
 			VM_OBJECT_UNLOCK(object);
-			continue;
+			goto relock_queues;
 		}
 
 		/*
@@ -889,7 +903,7 @@ rescan0:
 			vm_page_unlock(m);
 			m->act_count += actcount + ACT_ADVANCE + 1;
 			VM_OBJECT_UNLOCK(object);
-			continue;
+			goto relock_queues;
 		}
 
 		/*
@@ -924,7 +938,7 @@ rescan0:
 			 * Invalid pages can be easily freed
 			 */
 			vm_page_free(m);
-			cnt.v_dfree++;
+			PCPU_INC(cnt.v_dfree);
 			--page_shortage;
 		} else if (m->dirty == 0) {
 			/*
@@ -947,6 +961,8 @@ rescan0:
 			 * the thrash point for a heavily loaded machine.
 			 */
 			m->flags |= PG_WINATCFLS;
+			vm_page_lock_queues();
+			queues_locked = TRUE;
 			vm_page_requeue(m);
 		} else if (maxlaunder > 0) {
 			/*
@@ -976,21 +992,13 @@ rescan0:
 			if (!swap_pageouts_ok || (object->flags & OBJ_DEAD)) {
 				vm_page_unlock(m);
 				VM_OBJECT_UNLOCK(object);
+				vm_page_lock_queues();
+				queues_locked = TRUE;
 				vm_page_requeue(m);
-				continue;
+				goto relock_queues;
 			}
 
 			/*
-			 * Following operations may unlock
-			 * vm_page_queue_mtx, invalidating the 'next'
-			 * pointer.  To prevent an inordinate number
-			 * of restarts we use our marker to remember
-			 * our place.
-			 *
-			 */
-			TAILQ_INSERT_AFTER(&vm_page_queues[PQ_INACTIVE].pl,
-					   m, &marker, pageq);
-			/*
 			 * The object is already known NOT to be dead.   It
 			 * is possible for the vget() to block the whole
 			 * pageout daemon, but the new low-memory handling
@@ -1014,7 +1022,6 @@ rescan0:
 			 * of time.
 			 */
 			if (object->type == OBJT_VNODE) {
-				vm_page_unlock_queues();
 				vm_page_unlock(m);
 				vp = object->handle;
 				if (vp->v_type == VREG &&
@@ -1044,6 +1051,7 @@ rescan0:
 				VM_OBJECT_LOCK(object);
 				vm_page_lock(m);
 				vm_page_lock_queues();
+				queues_locked = TRUE;
 				/*
 				 * The page might have been moved to another
 				 * queue during potential blocking in vget()
@@ -1075,6 +1083,8 @@ rescan0:
 				 * be undergoing I/O, so skip it
 				 */
 				if (m->hold_count) {
+					vm_page_lock_queues();
+					queues_locked = TRUE;
 					vm_page_unlock(m);
 					vm_page_requeue(m);
 					if (object->flags & OBJ_MIGHTBEDIRTY)
@@ -1093,32 +1103,37 @@ rescan0:
 			 * the (future) cleaned page.  Otherwise we could wind
 			 * up laundering or cleaning too many pages.
 			 */
-			vm_page_unlock_queues();
 			if (vm_pageout_clean(m) != 0) {
 				--page_shortage;
 				--maxlaunder;
 			}

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


More information about the svn-src-user mailing list