svn commit: r249018 - in projects/camlock: crypto/openssh share/man/man4 sys/cam sys/cam/ctl sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/modules sys/modules/ctl usr.bin/ctlstat usr.sbin/ctladm

Alexander Motin mav at FreeBSD.org
Tue Apr 2 11:48:10 UTC 2013


Author: mav
Date: Tue Apr  2 11:48:06 2013
New Revision: 249018
URL: http://svnweb.freebsd.org/changeset/base/249018

Log:
  MFC @ r249017

Added:
  projects/camlock/share/man/man4/ctl.4
     - copied unchanged from r249017, head/share/man/man4/ctl.4
  projects/camlock/sys/modules/ctl/
     - copied from r249017, head/sys/modules/ctl/
Modified:
  projects/camlock/crypto/openssh/krl.c
  projects/camlock/crypto/openssh/readconf.c
  projects/camlock/crypto/openssh/readconf.h
  projects/camlock/crypto/openssh/ssh.c
  projects/camlock/crypto/openssh/sshconnect2.c
  projects/camlock/share/man/man4/Makefile
  projects/camlock/sys/cam/cam_periph.c
  projects/camlock/sys/cam/ctl/README.ctl.txt
  projects/camlock/sys/cam/ctl/ctl.c
  projects/camlock/sys/cam/ctl/ctl_frontend_cam_sim.c
  projects/camlock/sys/cam/ctl/ctl_frontend_internal.c
  projects/camlock/sys/cam/ctl/scsi_ctl.c
  projects/camlock/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
  projects/camlock/sys/modules/Makefile
  projects/camlock/usr.bin/ctlstat/ctlstat.8
  projects/camlock/usr.sbin/ctladm/ctladm.8
Directory Properties:
  projects/camlock/   (props changed)
  projects/camlock/crypto/openssh/   (props changed)
  projects/camlock/share/man/man4/   (props changed)
  projects/camlock/sys/   (props changed)
  projects/camlock/sys/cddl/contrib/opensolaris/   (props changed)

Modified: projects/camlock/crypto/openssh/krl.c
==============================================================================
--- projects/camlock/crypto/openssh/krl.c	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/crypto/openssh/krl.c	Tue Apr  2 11:48:06 2013	(r249018)
@@ -502,8 +502,11 @@ choose_next_state(int current_state, u_i
 	}
 	debug3("%s: contig %llu last_gap %llu next_gap %llu final %d, costs:"
 	    "list %llu range %llu bitmap %llu new bitmap %llu, "
-	    "selected 0x%02x%s", __func__, contig, last_gap, next_gap, final,
-	    cost_list, cost_range, cost_bitmap, cost_bitmap_restart, new_state,
+	    "selected 0x%02x%s", __func__, (unsigned long long)contig,
+	    (unsigned long long)last_gap, (unsigned long long)next_gap, final,
+	    (unsigned long long)cost_list, (unsigned long long)cost_range,
+	    (unsigned long long)cost_bitmap,
+	    (unsigned long long)cost_bitmap_restart, new_state,
 	    *force_new_section ? " restart" : "");
 	return new_state;
 }
@@ -539,7 +542,8 @@ revoked_certs_generate(struct revoked_ce
 	     rs != NULL;
 	     rs = RB_NEXT(revoked_serial_tree, &rc->revoked_serials, rs)) {
 		debug3("%s: serial %llu:%llu state 0x%02x", __func__,
-		    rs->lo, rs->hi, state);
+		    (unsigned long long)rs->lo, (unsigned long long)rs->hi,
+		    state);
 
 		/* Check contiguous length and gap to next section (if any) */
 		nrs = RB_NEXT(revoked_serial_tree, &rc->revoked_serials, rs);
@@ -928,8 +932,9 @@ ssh_krl_from_blob(Buffer *buf, struct ss
 	}
 
 	format_timestamp(krl->generated_date, timestamp, sizeof(timestamp));
-	debug("KRL version %llu generated at %s%s%s", krl->krl_version,
-	    timestamp, *krl->comment ? ": " : "", krl->comment);
+	debug("KRL version %llu generated at %s%s%s",
+	    (unsigned long long)krl->krl_version, timestamp,
+	    *krl->comment ? ": " : "", krl->comment);
 
 	/*
 	 * 1st pass: verify signatures, if any. This is done to avoid

Modified: projects/camlock/crypto/openssh/readconf.c
==============================================================================
--- projects/camlock/crypto/openssh/readconf.c	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/crypto/openssh/readconf.c	Tue Apr  2 11:48:06 2013	(r249018)
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.c,v 1.194 2011/09/23 07:45:05 markus Exp $ */
+/* $OpenBSD: readconf.c,v 1.195 2013/02/17 23:16:57 dtucker Exp $ */
 /* $FreeBSD$ */
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
@@ -356,6 +356,26 @@ clear_forwardings(Options *options)
 	options->tun_open = SSH_TUNMODE_NO;
 }
 
+void
+add_identity_file(Options *options, const char *dir, const char *filename,
+    int userprovided)
+{
+	char *path;
+
+	if (options->num_identity_files >= SSH_MAX_IDENTITY_FILES)
+		fatal("Too many identity files specified (max %d)",
+		    SSH_MAX_IDENTITY_FILES);
+
+	if (dir == NULL) /* no dir, filename is absolute */
+		path = xstrdup(filename);
+	else
+		(void)xasprintf(&path, "%.100s%.100s", dir, filename);
+
+	options->identity_file_userprovided[options->num_identity_files] =
+	    userprovided;
+	options->identity_files[options->num_identity_files++] = path;
+}
+
 /*
  * Returns the number of the token pointed to by cp or oBadOption.
  */
@@ -616,9 +636,7 @@ parse_yesnoask:
 			if (*intptr >= SSH_MAX_IDENTITY_FILES)
 				fatal("%.200s line %d: Too many identity files specified (max %d).",
 				    filename, linenum, SSH_MAX_IDENTITY_FILES);
-			charptr = &options->identity_files[*intptr];
-			*charptr = xstrdup(arg);
-			*intptr = *intptr + 1;
+			add_identity_file(options, NULL, arg, 1);
 		}
 		break;
 

Modified: projects/camlock/crypto/openssh/readconf.h
==============================================================================
--- projects/camlock/crypto/openssh/readconf.h	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/crypto/openssh/readconf.h	Tue Apr  2 11:48:06 2013	(r249018)
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.h,v 1.91 2011/09/23 07:45:05 markus Exp $ */
+/* $OpenBSD: readconf.h,v 1.92 2013/02/17 23:16:57 dtucker Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -97,6 +97,7 @@ typedef struct {
 
 	int     num_identity_files;	/* Number of files for RSA/DSA identities. */
 	char   *identity_files[SSH_MAX_IDENTITY_FILES];
+	int    identity_file_userprovided[SSH_MAX_IDENTITY_FILES];
 	Key    *identity_keys[SSH_MAX_IDENTITY_FILES];
 
 	/* Local TCP/IP forward requests. */
@@ -172,5 +173,6 @@ process_config_line(Options *, const cha
 
 void	 add_local_forward(Options *, const Forward *);
 void	 add_remote_forward(Options *, const Forward *);
+void	 add_identity_file(Options *, const char *, const char *, int);
 
 #endif				/* READCONF_H */

Modified: projects/camlock/crypto/openssh/ssh.c
==============================================================================
--- projects/camlock/crypto/openssh/ssh.c	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/crypto/openssh/ssh.c	Tue Apr  2 11:48:06 2013	(r249018)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.c,v 1.370 2012/07/06 01:47:38 djm Exp $ */
+/* $OpenBSD: ssh.c,v 1.371 2013/02/17 23:16:57 dtucker Exp $ */
 /* $FreeBSD$ */
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
@@ -407,12 +407,7 @@ main(int ac, char **av)
 				    strerror(errno));
 				break;
 			}
-			if (options.num_identity_files >=
-			    SSH_MAX_IDENTITY_FILES)
-				fatal("Too many identity files specified "
-				    "(max %d)", SSH_MAX_IDENTITY_FILES);
-			options.identity_files[options.num_identity_files++] =
-			    xstrdup(optarg);
+			add_identity_file(&options, NULL, optarg, 1);
 			break;
 		case 'I':
 #ifdef ENABLE_PKCS11

Modified: projects/camlock/crypto/openssh/sshconnect2.c
==============================================================================
--- projects/camlock/crypto/openssh/sshconnect2.c	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/crypto/openssh/sshconnect2.c	Tue Apr  2 11:48:06 2013	(r249018)
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshconnect2.c,v 1.191 2013/02/15 00:21:01 dtucker Exp $ */
+/* $OpenBSD: sshconnect2.c,v 1.192 2013/02/17 23:16:57 dtucker Exp $ */
 /* $FreeBSD$ */
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
@@ -1418,7 +1418,7 @@ pubkey_prepare(Authctxt *authctxt)
 		id = xcalloc(1, sizeof(*id));
 		id->key = key;
 		id->filename = xstrdup(options.identity_files[i]);
-		id->userprovided = 1;
+		id->userprovided = options.identity_file_userprovided[i];
 		TAILQ_INSERT_TAIL(&files, id, next);
 	}
 	/* Prefer PKCS11 keys that are explicitly listed */

Modified: projects/camlock/share/man/man4/Makefile
==============================================================================
--- projects/camlock/share/man/man4/Makefile	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/share/man/man4/Makefile	Tue Apr  2 11:48:06 2013	(r249018)
@@ -99,6 +99,7 @@ MAN=	aac.4 \
 	${_cpuctl.4} \
 	cpufreq.4 \
 	crypto.4 \
+	ctl.4 \
 	cue.4 \
 	cxgb.4 \
 	cxgbe.4 \

Copied: projects/camlock/share/man/man4/ctl.4 (from r249017, head/share/man/man4/ctl.4)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/camlock/share/man/man4/ctl.4	Tue Apr  2 11:48:06 2013	(r249018, copy of r249017, head/share/man/man4/ctl.4)
@@ -0,0 +1,90 @@
+.\" Copyright (c) 2013 Edward Tomasz Napierala
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.Dd April 2, 2013
+.Dt CTL 4
+.Os
+.Sh NAME
+.Nm ctl
+.Nd CAM Target Layer
+.Sh SYNOPSIS
+To compile this driver into the kernel,
+place the following line in your
+kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device ctl"
+.Ed
+.Pp
+Alternatively, to load the driver as a
+module at boot time, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+ctl_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+subsystem provides SCSI disk and processor emulation.
+It supports features such as:
+.Pp
+.Bl -bullet -compact
+.It
+Disk and processor device emulation
+.It
+Tagged queueing
+.It
+SCSI task attribute support (ordered, head of queue, simple tags)
+.It
+SCSI implicit command ordering support.
+.It
+Full task management support (abort, LUN reset, target reset, etc.)
+.It
+Support for multiple ports
+.It
+Support for multiple simultaneous initiators
+.It
+Support for multiple simultaneous backing stores
+.It
+Persistent reservation support
+.It
+Mode sense/select support
+.It
+Error injection support
+.It
+All I/O handled in-kernel, no userland context switch overhead
+.El
+.Sh SEE ALSO
+.Xr ctladm 8 ,
+.Xr ctlstat 8
+.Sh HISTORY
+The
+.Nm
+subsystem first appeared in
+.Fx 9.1 .
+.Sh AUTHORS
+The
+.Nm
+subsystem was written by
+.An Kenneth Merry Aq ken at FreeBSD.org .

Modified: projects/camlock/sys/cam/cam_periph.c
==============================================================================
--- projects/camlock/sys/cam/cam_periph.c	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/sys/cam/cam_periph.c	Tue Apr  2 11:48:06 2013	(r249018)
@@ -218,9 +218,9 @@ cam_periph_alloc(periph_ctor_t *periph_c
 	}
 	if (*p_drv == NULL) {
 		printf("cam_periph_alloc: invalid periph name '%s'\n", name);
+		xpt_unlock_buses();
 		xpt_free_path(periph->path);
 		free(periph, M_CAMPERIPH);
-		xpt_unlock_buses();
 		return (CAM_REQ_INVALID);
 	}
 	periph->unit_number = camperiphunit(*p_drv, path_id, target_id, lun_id);

Modified: projects/camlock/sys/cam/ctl/README.ctl.txt
==============================================================================
--- projects/camlock/sys/cam/ctl/README.ctl.txt	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/sys/cam/ctl/README.ctl.txt	Tue Apr  2 11:48:06 2013	(r249018)
@@ -227,9 +227,6 @@ Revision 1.2 Changes
 To Do List:
 ==========
 
- - Make CTL buildable as a module.  Work needs to be done on initialization,
-   and on freeing resources and LUNs when it is built as a module.
-
  - Use devstat(9) for CTL's statistics collection.  CTL uses a home-grown
    statistics collection system that is similar to devstat(9).  ctlstat
    should be retired in favor of iostat, etc., once aggregation modes are

Modified: projects/camlock/sys/cam/ctl/ctl.c
==============================================================================
--- projects/camlock/sys/cam/ctl/ctl.c	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/sys/cam/ctl/ctl.c	Tue Apr  2 11:48:06 2013	(r249018)
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/bio.h>
 #include <sys/fcntl.h>
 #include <sys/lock.h>
+#include <sys/module.h>
 #include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/malloc.h>
@@ -338,7 +339,7 @@ TUNABLE_INT("kern.cam.ctl.disable", &ctl
 static void ctl_isc_event_handler(ctl_ha_channel chanel, ctl_ha_event event,
 				  int param);
 static void ctl_copy_sense_data(union ctl_ha_msg *src, union ctl_io *dest);
-static void ctl_init(void);
+static int ctl_init(void);
 void ctl_shutdown(void);
 static int ctl_open(struct cdev *dev, int flags, int fmt, struct thread *td);
 static int ctl_close(struct cdev *dev, int flags, int fmt, struct thread *td);
@@ -458,11 +459,16 @@ static struct cdevsw ctl_cdevsw = {
 
 MALLOC_DEFINE(M_CTL, "ctlmem", "Memory used for CTL");
 
-/*
- * If we have the CAM SIM, we may or may not have another SIM that will
- * cause CTL to get initialized.  If not, we need to initialize it.
- */
-SYSINIT(ctl_init, SI_SUB_CONFIGURE, SI_ORDER_THIRD, ctl_init, NULL);
+static int ctl_module_event_handler(module_t, int /*modeventtype_t*/, void *);
+
+static moduledata_t ctl_moduledata = {
+	"ctl",
+	ctl_module_event_handler,
+	NULL
+};
+
+DECLARE_MODULE(ctl, ctl_moduledata, SI_SUB_CONFIGURE, SI_ORDER_THIRD);
+MODULE_VERSION(ctl, 1);
 
 static void
 ctl_isc_handler_finish_xfer(struct ctl_softc *ctl_softc,
@@ -942,7 +948,7 @@ ctl_copy_sense_data(union ctl_ha_msg *sr
 	dest->io_hdr.status = src->hdr.status;
 }
 
-static void
+static int
 ctl_init(void)
 {
 	struct ctl_softc *softc;
@@ -953,7 +959,7 @@ ctl_init(void)
 #if 0
 	int i;
 #endif
-	int retval;
+	int error, retval;
 	//int isc_retval;
 
 	retval = 0;
@@ -962,7 +968,7 @@ ctl_init(void)
 
 	/* If we're disabled, don't initialize. */
 	if (ctl_disable != 0)
-		return;
+		return (0);
 
 	control_softc = malloc(sizeof(*control_softc), M_DEVBUF,
 			       M_WAITOK | M_ZERO);
@@ -991,7 +997,7 @@ ctl_init(void)
 		destroy_dev(softc->dev);
 		free(control_softc, M_DEVBUF);
 		control_softc = NULL;
-		return;
+		return (ENOMEM);
 	}
 
 	SYSCTL_ADD_INT(&softc->sysctl_ctx,
@@ -1053,7 +1059,7 @@ ctl_init(void)
 			    &internal_pool)!= 0){
 		printf("ctl: can't allocate %d entry internal pool, "
 		       "exiting\n", CTL_POOL_ENTRIES_INTERNAL);
-		return;
+		return (ENOMEM);
 	}
 
 	if (ctl_pool_create(softc, CTL_POOL_EMERGENCY,
@@ -1061,7 +1067,7 @@ ctl_init(void)
 		printf("ctl: can't allocate %d entry emergency pool, "
 		       "exiting\n", CTL_POOL_ENTRIES_EMERGENCY);
 		ctl_pool_free(softc, internal_pool);
-		return;
+		return (ENOMEM);
 	}
 
 	if (ctl_pool_create(softc, CTL_POOL_4OTHERSC, CTL_POOL_ENTRIES_OTHER_SC,
@@ -1071,7 +1077,7 @@ ctl_init(void)
 		       "exiting\n", CTL_POOL_ENTRIES_OTHER_SC);
 		ctl_pool_free(softc, internal_pool);
 		ctl_pool_free(softc, emergency_pool);
-		return;
+		return (ENOMEM);
 	}
 
 	softc->internal_pool = internal_pool;
@@ -1092,14 +1098,15 @@ ctl_init(void)
 	mtx_unlock(&softc->ctl_lock);
 #endif
 
-	if (kproc_create(ctl_work_thread, softc, &softc->work_thread, 0, 0,
-			 "ctl_thrd") != 0) {
+	error = kproc_create(ctl_work_thread, softc, &softc->work_thread, 0, 0,
+			 "ctl_thrd");
+	if (error != 0) {
 		printf("error creating CTL work thread!\n");
 		ctl_free_lun(lun);
 		ctl_pool_free(softc, internal_pool);
 		ctl_pool_free(softc, emergency_pool);
 		ctl_pool_free(softc, other_pool);
-		return;
+		return (error);
 	}
 	printf("ctl: CAM Target Layer loaded\n");
 
@@ -1139,10 +1146,11 @@ ctl_init(void)
 	if (sizeof(struct callout) > CTL_TIMER_BYTES) {
 		printf("sizeof(struct callout) %zd > CTL_TIMER_BYTES %zd\n",
 		       sizeof(struct callout), CTL_TIMER_BYTES);
-		return;
+		return (EINVAL);
 	}
 #endif /* CTL_IO_DELAY */
 
+	return (0);
 }
 
 void
@@ -1199,6 +1207,20 @@ ctl_shutdown(void)
 	printf("ctl: CAM Target Layer unloaded\n");
 }
 
+static int
+ctl_module_event_handler(module_t mod, int what, void *arg)
+{
+
+	switch (what) {
+	case MOD_LOAD:
+		return (ctl_init());
+	case MOD_UNLOAD:
+		return (EBUSY);
+	default:
+		return (EOPNOTSUPP);
+	}
+}
+
 /*
  * XXX KDM should we do some access checks here?  Bump a reference count to
  * prevent a CTL module from being unloaded while someone has it open?

Modified: projects/camlock/sys/cam/ctl/ctl_frontend_cam_sim.c
==============================================================================
--- projects/camlock/sys/cam/ctl/ctl_frontend_cam_sim.c	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/sys/cam/ctl/ctl_frontend_cam_sim.c	Tue Apr  2 11:48:06 2013	(r249018)
@@ -121,12 +121,23 @@ struct cfcs_softc cfcs_softc;
 static int cfcs_max_sense = sizeof(struct scsi_sense_data);
 extern int ctl_disable;
 
-SYSINIT(cfcs_init, SI_SUB_CONFIGURE, SI_ORDER_FOURTH, cfcs_init, NULL);
 SYSCTL_NODE(_kern_cam, OID_AUTO, ctl2cam, CTLFLAG_RD, 0,
 	    "CAM Target Layer SIM frontend");
 SYSCTL_INT(_kern_cam_ctl2cam, OID_AUTO, max_sense, CTLFLAG_RW,
            &cfcs_max_sense, 0, "Maximum sense data size");
 
+static int cfcs_module_event_handler(module_t, int /*modeventtype_t*/, void *);
+
+static moduledata_t cfcs_moduledata = {
+	"ctlcfcs",
+	cfcs_module_event_handler,
+	NULL
+};
+
+DECLARE_MODULE(ctlcfcs, cfcs_moduledata, SI_SUB_CONFIGURE, SI_ORDER_FOURTH);
+MODULE_VERSION(ctlcfcs, 1);
+MODULE_DEPEND(ctlcfi, ctl, 1, 1, 1);
+MODULE_DEPEND(ctlcfi, cam, 1, 1, 1);
 
 int
 cfcs_init(void)
@@ -176,7 +187,7 @@ cfcs_init(void)
 		printf("%s: ctl_frontend_register() failed with error %d!\n",
 		       __func__, retval);
 		mtx_destroy(&softc->lock);
-		return (1);
+		return (retval);
 	}
 
 	/*
@@ -236,7 +247,7 @@ cfcs_init(void)
 			    CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 		printf("%s: error creating path\n", __func__);
 		xpt_bus_deregister(cam_sim_path(softc->sim));
-		retval = 1;
+		retval = EINVAL;
 		goto bailout;
 	}
 
@@ -274,6 +285,20 @@ cfcs_shutdown(void)
 
 }
 
+static int
+cfcs_module_event_handler(module_t mod, int what, void *arg)
+{
+
+	switch (what) {
+	case MOD_LOAD:
+		return (cfcs_init());
+	case MOD_UNLOAD:
+		return (EBUSY);
+	default:
+		return (EOPNOTSUPP);
+	}
+}
+
 static void
 cfcs_onoffline(void *arg, int online)
 {

Modified: projects/camlock/sys/cam/ctl/ctl_frontend_internal.c
==============================================================================
--- projects/camlock/sys/cam/ctl/ctl_frontend_internal.c	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/sys/cam/ctl/ctl_frontend_internal.c	Tue Apr  2 11:48:06 2013	(r249018)
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/types.h>
 #include <sys/malloc.h>
+#include <sys/module.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/condvar.h>
@@ -189,7 +190,7 @@ MALLOC_DEFINE(M_CTL_CFI, "ctlcfi", "CTL 
 static struct cfi_softc fetd_internal_softc;
 extern int ctl_disable;
 
-void cfi_init(void);
+int cfi_init(void);
 void cfi_shutdown(void) __unused;
 static void cfi_online(void *arg);
 static void cfi_offline(void *arg);
@@ -217,9 +218,19 @@ static void cfi_metatask_io_done(union c
 static void cfi_err_recovery_done(union ctl_io *io);
 static void cfi_lun_io_done(union ctl_io *io);
 
-SYSINIT(cfi_init, SI_SUB_CONFIGURE, SI_ORDER_FOURTH, cfi_init, NULL);
+static int cfi_module_event_handler(module_t, int /*modeventtype_t*/, void *);
 
-void
+static moduledata_t cfi_moduledata = {
+	"ctlcfi",
+	cfi_module_event_handler,
+	NULL
+};
+
+DECLARE_MODULE(ctlcfi, cfi_moduledata, SI_SUB_CONFIGURE, SI_ORDER_FOURTH);
+MODULE_VERSION(ctlcfi, 1);
+MODULE_DEPEND(ctlcfi, ctl, 1, 1, 1);
+
+int
 cfi_init(void)
 {
 	struct cfi_softc *softc;
@@ -234,7 +245,7 @@ cfi_init(void)
 
 	/* If we're disabled, don't initialize */
 	if (ctl_disable != 0)
-		return;
+		return (0);
 
 	if (sizeof(struct cfi_lun_io) > CTL_PORT_PRIV_SIZE) {
 		printf("%s: size of struct cfi_lun_io %zd > "
@@ -292,7 +303,7 @@ cfi_init(void)
 	}
 bailout:
 
-	return;
+	return (0);
 
 bailout_error:
 
@@ -309,6 +320,8 @@ bailout_error:
 	default:
 		break;
 	}
+
+	return (ENOMEM);
 }
 
 void
@@ -331,6 +344,20 @@ cfi_shutdown(void)
 		printf("%s: error shrinking LUN pool\n", __func__);
 }
 
+static int
+cfi_module_event_handler(module_t mod, int what, void *arg)
+{
+
+	switch (what) {
+	case MOD_LOAD:
+		return (cfi_init());
+	case MOD_UNLOAD:
+		return (EBUSY);
+	default:
+		return (EOPNOTSUPP);
+	}
+}
+
 static void
 cfi_online(void *arg)
 {

Modified: projects/camlock/sys/cam/ctl/scsi_ctl.c
==============================================================================
--- projects/camlock/sys/cam/ctl/scsi_ctl.c	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/sys/cam/ctl/scsi_ctl.c	Tue Apr  2 11:48:06 2013	(r249018)
@@ -225,38 +225,26 @@ static struct periph_driver ctlfe_driver
 	ctlfeinit, "ctl",
 	TAILQ_HEAD_INITIALIZER(ctlfe_driver.units), /*generation*/ 0
 };
-PERIPHDRIVER_DECLARE(ctl, ctlfe_driver);
 
-extern struct ctl_softc *control_softc;
-extern int ctl_disable;
-
-int
-ctlfeinitialize(void)
-{
-	cam_status status;
-
-	/* Don't initialize if we're disabled */
-	if (ctl_disable != 0)
-		return (0);
+static int ctlfe_module_event_handler(module_t, int /*modeventtype_t*/, void *);
 
-	STAILQ_INIT(&ctlfe_softc_list);
-
-	mtx_init(&ctlfe_list_mtx, ctlfe_mtx_desc, NULL, MTX_DEF);
-
-	xpt_lock_buses();
-	periphdriver_register(&ctlfe_driver);
-	xpt_unlock_buses();
+/*
+ * We're not using PERIPHDRIVER_DECLARE(), because it runs at SI_SUB_DRIVERS,
+ * and that happens before CTL gets initialised.
+ */
+static moduledata_t ctlfe_moduledata = {
+	"ctlfe",
+	ctlfe_module_event_handler,
+	NULL
+};
 
-	status = xpt_register_async(AC_PATH_REGISTERED | AC_PATH_DEREGISTERED | 
-				    AC_CONTRACT, ctlfeasync, NULL, NULL);
+DECLARE_MODULE(ctlfe, ctlfe_moduledata, SI_SUB_CONFIGURE, SI_ORDER_FOURTH);
+MODULE_VERSION(ctlfe, 1);
+MODULE_DEPEND(ctlfe, ctl, 1, 1, 1);
+MODULE_DEPEND(ctlfe, cam, 1, 1, 1);
 
-	if (status != CAM_REQ_CMP) {
-		printf("ctl: Failed to attach async callback due to CAM "
-		       "status 0x%x!\n", status);
-	}
-
-	return (0);
-}
+extern struct ctl_softc *control_softc;
+extern int ctl_disable;
 
 void
 ctlfeshutdown(void)
@@ -288,6 +276,21 @@ ctlfeinit(void)
 	}
 }
 
+static int
+ctlfe_module_event_handler(module_t mod, int what, void *arg)
+{
+
+	switch (what) {
+	case MOD_LOAD:
+		periphdriver_register(&ctlfe_driver);
+		return (0);
+	case MOD_UNLOAD:
+		return (EBUSY);
+	default:
+		return (EOPNOTSUPP);
+	}
+}
+
 static void
 ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
 {
@@ -1971,7 +1974,6 @@ ctlfe_lun_enable(void *arg, struct ctl_i
 	struct cam_sim *sim;
 	cam_status status;
 
-	
 	bus_softc = (struct ctlfe_softc *)arg;
 	sim = bus_softc->sim;
 

Modified: projects/camlock/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==============================================================================
--- projects/camlock/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c	Tue Apr  2 11:48:06 2013	(r249018)
@@ -5713,11 +5713,11 @@ zfsdev_ioctl(struct cdev *dev, u_long zc
 {
 	zfs_cmd_t *zc;
 	uint_t vecnum;
-	int error, rc, len;
 #ifdef illumos
+	int error, rc, len;
 	minor_t minor = getminor(dev);
 #else
-	int cflag, cmd, oldvecnum;
+	int error, len, cflag, cmd, oldvecnum;
 	cred_t *cr = td->td_ucred;
 #endif
 	const zfs_ioc_vec_t *vec;
@@ -5904,8 +5904,11 @@ zfsdev_ioctl(struct cdev *dev, u_long zc
 
 out:
 	nvlist_free(innvl);
+#ifdef illumos
+	rc = ddi_copyout(zc, (void *)arg, sizeof (zfs_cmd_t), flag);
 	if (error == 0 && rc != 0)
 		error = EFAULT;
+#endif
 	if (error == 0 && vec->zvec_allow_log) {
 		char *s = tsd_get(zfs_allow_log_key);
 		if (s != NULL)

Modified: projects/camlock/sys/modules/Makefile
==============================================================================
--- projects/camlock/sys/modules/Makefile	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/sys/modules/Makefile	Tue Apr  2 11:48:06 2013	(r249018)
@@ -78,6 +78,7 @@ SUBDIR=	\
 	${_cs} \
 	${_ct} \
 	${_ctau} \
+	ctl \
 	${_cxgb} \
 	cxgbe \
 	${_cyclic} \

Modified: projects/camlock/usr.bin/ctlstat/ctlstat.8
==============================================================================
--- projects/camlock/usr.bin/ctlstat/ctlstat.8	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/usr.bin/ctlstat/ctlstat.8	Tue Apr  2 11:48:06 2013	(r249018)
@@ -34,7 +34,7 @@
 .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.bin/ctlstat/ctlstat.8#2 $
 .\" $FreeBSD$
 .\"
-.Dd June 4, 2010
+.Dd March 6, 2013
 .Dt CTLSTAT 8
 .Os
 .Sh NAME
@@ -113,6 +113,7 @@ every 10 seconds.
 .Sh SEE ALSO
 .Xr cam 3 ,
 .Xr cam 4 ,
+.Xr ctl 4 ,
 .Xr xpt 4 ,
 .Xr camcontrol 8 ,
 .Xr ctladm 8 ,

Modified: projects/camlock/usr.sbin/ctladm/ctladm.8
==============================================================================
--- projects/camlock/usr.sbin/ctladm/ctladm.8	Tue Apr  2 11:45:38 2013	(r249017)
+++ projects/camlock/usr.sbin/ctladm/ctladm.8	Tue Apr  2 11:48:06 2013	(r249018)
@@ -34,7 +34,7 @@
 .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
 .\" $FreeBSD$
 .\"
-.Dd March 6, 2012
+.Dd April 2, 2013
 .Dt CTLADM 8
 .Os
 .Sh NAME
@@ -975,6 +975,7 @@ This will result in a sense key of NOT R
 .Xr cam 3 ,
 .Xr cam_cdbparse 3 ,
 .Xr cam 4 ,
+.Xr ctl 4 ,
 .Xr xpt 4 ,
 .Xr camcontrol 8
 .Sh HISTORY


More information about the svn-src-projects mailing list