Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Apr 2003 19:01:27 -0700 (PDT)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 30229 for review
Message-ID:  <200305010201.h4121Rkk092670@repoman.freebsd.org>

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

Change 30229 by peter@peter_daintree on 2003/04/30 19:00:59

	IFC @30228

Affected files ...

.. //depot/projects/hammer/sys/boot/i386/libi386/bootinfo32.c#4 integrate
.. //depot/projects/hammer/sys/boot/i386/libi386/bootinfo64.c#5 integrate
.. //depot/projects/hammer/sys/boot/i386/libi386/elf32_freebsd.c#3 integrate
.. //depot/projects/hammer/sys/boot/i386/libi386/elf64_freebsd.c#12 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinum.c#3 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinumconfig.c#4 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinumext.h#4 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinumio.c#5 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinumioctl.c#5 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinumkw.h#2 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinumlock.c#2 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinummemory.c#3 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinumparser.c#3 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinumraid5.c#2 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinumrequest.c#4 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinumrevive.c#4 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinumutil.c#2 integrate
.. //depot/projects/hammer/sys/dev/vinum/vinumvar.h#2 integrate
.. //depot/projects/hammer/sys/geom/geom_gpt.c#11 integrate

Differences ...

==== //depot/projects/hammer/sys/boot/i386/libi386/bootinfo32.c#4 (text+ko) ====


==== //depot/projects/hammer/sys/boot/i386/libi386/bootinfo64.c#5 (text+ko) ====


==== //depot/projects/hammer/sys/boot/i386/libi386/elf32_freebsd.c#3 (text+ko) ====


==== //depot/projects/hammer/sys/boot/i386/libi386/elf64_freebsd.c#12 (text+ko) ====


==== //depot/projects/hammer/sys/dev/vinum/vinum.c#3 (text+ko) ====

@@ -35,8 +35,8 @@
  * otherwise) arising in any way out of the use of this software, even if
  * advised of the possibility of such damage.
  *
- * $Id: vinum.c,v 1.34 2001/05/22 04:07:22 grog Exp grog $
- * $FreeBSD: src/sys/dev/vinum/vinum.c,v 1.55 2003/03/08 08:01:30 phk Exp $
+ * $Id: vinum.c,v 1.41 2003/04/28 06:15:36 grog Exp grog $
+ * $FreeBSD: src/sys/dev/vinum/vinum.c,v 1.56 2003/05/01 01:28:42 grog Exp $
  */
 
 #define STATIC static					    /* nothing while we're testing XXX */
@@ -54,23 +54,21 @@
 
 struct cdevsw vinum_cdevsw =
 {
-	.d_open =	vinumopen,
-	.d_close =	vinumclose,
-	.d_read =	physread,
-	.d_write =	physwrite,
-	.d_ioctl =	vinumioctl,
-	.d_strategy =	vinumstrategy,
-	.d_name =	"vinum",
-	.d_maj =	VINUM_CDEV_MAJOR,
-	.d_flags =	D_DISK
+    .d_open = vinumopen,
+    .d_close = vinumclose,
+    .d_read = physread,
+    .d_write = physwrite,
+    .d_ioctl = vinumioctl,
+    .d_strategy = vinumstrategy,
+    .d_name = "vinum",
+    .d_maj = VINUM_CDEV_MAJOR,
+    .d_flags = D_DISK
 };
 
 /* Called by main() during pseudo-device attachment. */
-STATIC void vinumattach(void *);
-
+void vinumattach(void *);
 STATIC int vinum_modevent(module_t mod, modeventtype_t type, void *unused);
-
-STATIC void vinum_clone(void *arg, char *name, int namelen, dev_t *dev);
+STATIC void vinum_clone(void *arg, char *name, int namelen, dev_t * dev);
 
 struct _vinum_conf vinum_conf;				    /* configuration information */
 
@@ -90,8 +88,7 @@
     int i, rv;
     char *cp, *cp1, *cp2, **drives, *drivep;
     size_t alloclen;
-
-    /* modload should prevent multiple loads, so this is worth a panic */
+/* modload should prevent multiple loads, so this is worth a panic */
     if ((vinum_conf.flags & VF_LOADED) != 0)
 	panic("vinum: already loaded");
 
@@ -106,13 +103,13 @@
     dqend = NULL;
 
     vinum_daemon_dev = make_dev(&vinum_cdevsw,
-	VINUM_DAEMON_DEV,
+	VINUM_DAEMON_MINOR,
 	UID_ROOT,
 	GID_WHEEL,
 	S_IRUSR | S_IWUSR,
 	"vinum/controld");
     vinum_super_dev = make_dev(&vinum_cdevsw,
-	VINUM_SUPERDEV,
+	VINUM_SUPERDEV_MINOR,
 	UID_ROOT,
 	GID_WHEEL,
 	S_IRUSR | S_IWUSR,
@@ -147,12 +144,11 @@
     bzero(SD, sizeof(struct sd) * INITIAL_SUBDISKS);
     vinum_conf.subdisks_allocated = INITIAL_SUBDISKS;	    /* number of sd slots allocated */
     vinum_conf.subdisks_used = 0;			    /* and number in use */
-
     dev_clone_tag = EVENTHANDLER_REGISTER(dev_clone, vinum_clone, 0, 1000);
 
     /*
-     * See if the loader has passed us any of the
-     * autostart options.
+     * See if the loader has passed us any of the autostart
+     * options.
      */
     cp = drivep = NULL;
 #ifndef VINUM_AUTOSTART
@@ -160,50 +156,47 @@
 	freeenv(cp);
 	cp = NULL;
 #endif
-	rv = kernel_sysctlbyname(&thread0, "kern.disks",
-				 NULL, NULL,
-				 NULL, 0,
-				 &alloclen);
+
+	rv = kernel_sysctlbyname(&thread0, "kern.disks", NULL,
+	    NULL, NULL, 0, &alloclen);
 	if (rv)
 	    log(LOG_NOTICE,
-		"sysctlbyname(\"kern.disks\") failed, rv = %d\n",
+		"sysctlbyname (\"kern.disks\") failed, rv = %d\n",
 		rv);
 	else {
-	    drivep = malloc(alloclen, M_TEMP, 0 /* M_WAITOK */);
-	    (void)kernel_sysctlbyname(&thread0, "kern.disks",
-				      drivep, &alloclen,
-				      NULL, 0,
-				      NULL);
+	    drivep = malloc(alloclen, M_TEMP, M_WAITOK);
+	    kernel_sysctlbyname(&thread0, "kern.disks", drivep,
+		&alloclen, NULL, 0, NULL);
 	    goto start;
 	}
 #ifndef VINUM_AUTOSTART
     } else
 #endif
-	if ((cp = getenv("vinum.drives")) != NULL) {
-	  start:
-	    for (cp1 = cp? cp: drivep, i = 0, drives = 0;
-		 *cp1 != '\0';
-		 i++) {
-		cp2 = cp1;
-		while (*cp1 != '\0' && *cp1 != ',' && *cp1 != ' ')
-		    cp1++;
-		if (*cp1 != '\0')
-		    *cp1++ = '\0';
-		drives = realloc(drives,
-				 (unsigned long)((i + 1) * sizeof(char *)),
-				 M_TEMP, 0 /* M_WAITOK */);
-		drives[i] = cp2;
-	    }
-	    if (i == 0)
-		goto bailout;
+    if ((cp = getenv("vinum.drives")) != NULL) {
+      start:
+	for (cp1 = cp ? cp : drivep, i = 0, drives = 0;
+	    *cp1 != '\0';
+	    i++) {
+	    cp2 = cp1;
+	    while (*cp1 != '\0' && *cp1 != ',' && *cp1 != ' ')
+		cp1++;
+	    if (*cp1 != '\0')
+		*cp1++ = '\0';
+
+	    drives = realloc(drives,
+		(unsigned long) ((i + 1) * sizeof(char *)),
+		M_TEMP, M_WAITOK);
+	    drives[i] = cp2;
+	}
+	if (i != 0) {
 	    rv = vinum_scandisk(drives, i);
 	    if (rv)
 		log(LOG_NOTICE, "vinum_scandisk() returned %d\n", rv);
-	  bailout:
-	    freeenv(cp);
-	    free(drives, M_TEMP);
-	    free(drivep, M_TEMP);
 	}
+	freeenv(cp);
+	free(drives, M_TEMP);
+	free(drivep, M_TEMP);
+    }
 }
 
 /*
@@ -291,6 +284,7 @@
 	Free(VOL);
     }
     bzero(&vinum_conf, sizeof(vinum_conf));
+    vinum_conf.version = VINUMVERSION;			    /* reinstate version number */
 }
 
 STATIC int
@@ -375,6 +369,23 @@
     /* First, decide what we're looking at */
     switch (DEVTYPE(dev)) {
     case VINUM_VOLUME_TYPE:
+	/*
+	 * The super device and daemon device are the last two
+	 * volume numbers, so check for them first.
+	 */
+	if ((devminor == VINUM_DAEMON_MINOR)		    /* daemon device */
+	||(devminor == VINUM_SUPERDEV_MINOR)) {		    /* or normal super device */
+	    error = suser(td);				    /* are we root? */
+
+	    if (error == 0) {				    /* yes, can do */
+		if (devminor == VINUM_DAEMON_MINOR)	    /* daemon device */
+		    vinum_conf.flags |= VF_DAEMONOPEN;	    /* we're open */
+		else					    /* superdev */
+		    vinum_conf.flags |= VF_OPEN;	    /* we're open */
+	    }
+	    return error;
+	}
+	/* Must be a real volume.  Check. */
 	index = Volno(dev);
 	if (index >= vinum_conf.volumes_allocated)
 	    return ENXIO;				    /* no such device */
@@ -397,19 +408,16 @@
 	}
 
     case VINUM_PLEX_TYPE:
-	if (Volno(dev) >= vinum_conf.volumes_allocated)
-	    return ENXIO;
-	/* FALLTHROUGH */
-
-    case VINUM_RAWPLEX_TYPE:
 	index = Plexno(dev);				    /* get plex index in vinum_conf */
 	if (index >= vinum_conf.plexes_allocated)
 	    return ENXIO;				    /* no such device */
 	plex = &PLEX[index];
 
 	switch (plex->state) {
+	case plex_unallocated:
+	    return ENXIO;
+
 	case plex_referenced:
-	case plex_unallocated:
 	    return EINVAL;
 
 	default:
@@ -418,51 +426,31 @@
 	}
 
     case VINUM_SD_TYPE:
-	if ((Volno(dev) >= vinum_conf.volumes_allocated)    /* no such volume */
-	||(Plexno(dev) >= vinum_conf.plexes_allocated))	    /* or no such plex */
-	    return ENXIO;				    /* no such device */
-
-	/* FALLTHROUGH */
-
-    case VINUM_RAWSD_TYPE:
+    case VINUM_SD2_TYPE:
 	index = Sdno(dev);				    /* get the subdisk number */
-	if ((index >= vinum_conf.subdisks_allocated)	    /* not a valid SD entry */
-	||(SD[index].state < sd_init))			    /* or SD is not real */
+	if (index >= vinum_conf.subdisks_allocated)	    /* not a valid SD entry */
 	    return ENXIO;				    /* no such device */
 	sd = &SD[index];
 
 	/*
-	 * Opening a subdisk is always a special operation, so we
-	 * ignore the state as long as it represents a real subdisk
+	 * Opening a subdisk is always a special operation, so
+	 * we ignore the state as long as it represents a real
+	 * subdisk.
 	 */
 	switch (sd->state) {
 	case sd_unallocated:
+	    return ENXIO;
+
 	case sd_uninit:
+	case sd_referenced:
 	    return EINVAL;
 
 	default:
 	    sd->flags |= VF_OPEN;			    /* note we're open */
 	    return 0;
 	}
-
-    case VINUM_SUPERDEV_TYPE:
-	error = suser(td);				    /* are we root? */
-	if (error == 0) {				    /* yes, can do */
-	    if (devminor == VINUM_DAEMON_DEV)		    /* daemon device */
-		vinum_conf.flags |= VF_DAEMONOPEN;	    /* we're open */
-	    else if (devminor == VINUM_SUPERDEV)
-		vinum_conf.flags |= VF_OPEN;		    /* we're open */
-	    else
-		error = ENODEV;				    /* nothing, maybe a debug mismatch */
-	}
-	return error;
-
-	/* Vinum drives are disks.  We already have a disk
-	 * driver, so don't handle them here */
-    case VINUM_DRIVE_TYPE:
-    default:
-	return ENODEV;					    /* don't know what to do with these */
     }
+    return 0;						    /* to keep the compiler happy */
 }
 
 /* ARGSUSED */
@@ -477,10 +465,30 @@
     int devminor;
 
     devminor = minor(dev);
-    index = Volno(dev);
     /* First, decide what we're looking at */
     switch (DEVTYPE(dev)) {
     case VINUM_VOLUME_TYPE:
+	/*
+	 * The super device and daemon device are the last two
+	 * volume numbers, so check for them first.
+	 */
+	if ((devminor == VINUM_DAEMON_MINOR)		    /* daemon device */
+	||(devminor == VINUM_SUPERDEV_MINOR)) {		    /* or normal super device */
+	    /*
+	     * don't worry about whether we're root:
+	     * nobody else would get this far.
+	     */
+	    if (devminor == VINUM_SUPERDEV_MINOR)	    /* normal superdev */
+		vinum_conf.flags &= ~VF_OPEN;		    /* no longer open */
+	    else {					    /* the daemon device */
+		vinum_conf.flags &= ~VF_DAEMONOPEN;	    /* no longer open */
+		if (vinum_conf.flags & VF_STOPPING)	    /* we're trying to stop, */
+		    wakeup(&vinumclose);		    /* we can continue now */
+	    }
+	    return 0;
+	}
+	/* Real volume */
+	index = Volno(dev);
 	if (index >= vinum_conf.volumes_allocated)
 	    return ENXIO;				    /* no such device */
 	vol = &VOL[index];
@@ -506,65 +514,37 @@
 	    return ENXIO;
 	/* FALLTHROUGH */
 
-    case VINUM_RAWPLEX_TYPE:
-	index = Plexno(dev);				    /* get plex index in vinum_conf */
-	if (index >= vinum_conf.plexes_allocated)
-	    return ENXIO;				    /* no such device */
-	PLEX[index].flags &= ~VF_OPEN;			    /* reset our flags */
-	return 0;
-
     case VINUM_SD_TYPE:
 	if ((Volno(dev) >= vinum_conf.volumes_allocated) || /* no such volume */
 	    (Plexno(dev) >= vinum_conf.plexes_allocated))   /* or no such plex */
 	    return ENXIO;				    /* no such device */
 	/* FALLTHROUGH */
 
-    case VINUM_RAWSD_TYPE:
-	index = Sdno(dev);				    /* get the subdisk number */
-	if (index >= vinum_conf.subdisks_allocated)
-	    return ENXIO;				    /* no such device */
-	SD[index].flags &= ~VF_OPEN;			    /* reset our flags */
-	return 0;
-
-    case VINUM_SUPERDEV_TYPE:
-	/*
-	 * don't worry about whether we're root:
-	 * nobody else would get this far.
-	 */
-	if (devminor == VINUM_SUPERDEV)			    /* normal superdev */
-	    vinum_conf.flags &= ~VF_OPEN;		    /* no longer open */
-	else if (devminor == VINUM_DAEMON_DEV) {	    /* the daemon device */
-	    vinum_conf.flags &= ~VF_DAEMONOPEN;		    /* no longer open */
-	    if (vinum_conf.flags & VF_STOPPING)		    /* we're stopping, */
-		wakeup(&vinumclose);			    /* we can continue stopping now */
-	}
-	return 0;
-
-    case VINUM_DRIVE_TYPE:
     default:
 	return ENODEV;					    /* don't know what to do with these */
     }
 }
 
 void
-vinum_clone(void *arg, char *name, int namelen, dev_t *dev)
+vinum_clone(void *arg, char *name, int namelen, dev_t * dev)
 {
-	struct volume *vol;
-	int i;
+    struct volume *vol;
+    int i;
 
-	if (*dev != NODEV)
-		return;
-	if (strncmp(name, "vinum/", sizeof("vinum/") - 1) != 0)
-		return;
+    if (*dev != NODEV)
+	return;
+    if (strncmp(name, "vinum/", sizeof("vinum/") - 1) != 0)
+	return;
 
-	name += sizeof("vinum/") - 1;
-	if ((i = find_volume(name, 0)) == -1)
-		return;
+    name += sizeof("vinum/") - 1;
+    if ((i = find_volume(name, 0)) == -1)
+	return;
 
-	vol = &VOL[i];
-	*dev = vol->dev;
+    vol = &VOL[i];
+    *dev = vol->dev;
 }
 
+
 /* Local Variables: */
-/* fill-column: 50 */
+/* fill-column: 60 */
 /* End: */

==== //depot/projects/hammer/sys/dev/vinum/vinumconfig.c#4 (text+ko) ====

@@ -1,15 +1,3 @@
-/*
- * To do:
- *
- * Don't store drive configuration on the config DB: read each drive's header
- * to decide where it is.
- *
- * Accept any old crap in the config_<foo> functions, and complain when
- * we try to bring it up.
- *
- * When trying to bring volumes up, check that the complete address range
- * is covered.
- */
 /*-
  * Copyright (c) 1997, 1998
  *	Nan Yang Computer Services Limited.  All rights reserved.
@@ -45,8 +33,8 @@
  * otherwise) arising in any way out of the use of this software, even if
  * advised of the possibility of such damage.
  *
- * $Id: vinumconfig.c,v 1.30 2000/05/01 09:45:50 grog Exp grog $
- * $FreeBSD: src/sys/dev/vinum/vinumconfig.c,v 1.53 2003/01/16 23:47:04 joerg Exp $
+ * $Id: vinumconfig.c,v 1.38 2003/04/28 02:54:07 grog Exp $
+ * $FreeBSD: src/sys/dev/vinum/vinumconfig.c,v 1.54 2003/05/01 01:29:24 grog Exp $
  */
 
 #define STATIC static
@@ -85,10 +73,11 @@
 
 #define MSG_MAX 1024					    /* maximum length of a formatted message */
 /*
- * Format an error message and return to the user in the reply.
- * CARE: This routine is designed to be called only from the
- * configuration routines, so it assumes it's the owner of
- * the configuration lock, and unlocks it on exit
+ * Format an error message and return to the user
+ * in the reply.  CARE: This routine is designed
+ * to be called only from the configuration
+ * routines, so it assumes it's the owner of the
+ * configuration lock, and unlocks it on exit.
  */
 void
 throw_rude_remark(int error, char *msg,...)
@@ -99,8 +88,8 @@
     static int finishing;				    /* don't recurse */
     int was_finishing;
 
-    if ((vinum_conf.flags & VF_LOCKED) == 0)    	    /* bug catcher */
-	panic ("throw_rude_remark: called without config lock");
+    if ((vinum_conf.flags & VF_LOCKED) == 0)		    /* bug catcher */
+	panic("throw_rude_remark: called without config lock");
     va_start(ap, msg);
     if ((ioctl_reply != NULL)				    /* we're called from the user */
     &&(!(vinum_conf.flags & VF_READING_CONFIG))) {	    /* and not reading from disk: return msg */
@@ -139,9 +128,9 @@
     /*
      * We have a problem here: we want to unlock the
      * configuration, which implies tidying up, but
-     * if we find an error while tidying up, we could
-     * recurse for ever.  Use this kludge to only try
-     * once
+     * if we find an error while tidying up, we
+     * could recurse for ever.  Use this kludge to
+     * only try once.
      */
     was_finishing = finishing;
     finishing = 1;
@@ -472,7 +461,7 @@
     bzero(drive, sizeof(struct drive));
     drive->driveno = driveno;				    /* put number in structure */
     drive->flags |= VF_NEWBORN;				    /* newly born drive */
-    strcpy("unknown", drive->devicename);		    /* and make the name ``unknown'' */
+    strcpy(drive->devicename, "unknown");		    /* and make the name ``unknown'' */
     return driveno;					    /* return the index */
 }
 
@@ -519,7 +508,7 @@
  * Otherwise the same as find_drive above
  */
 int
-find_drive_by_dev(const char *devname, int create)
+find_drive_by_name(const char *devname, int create)
 {
     int driveno;
     struct drive *drive;
@@ -562,6 +551,11 @@
 	 * We've run out of space.  sdno is pointing
 	 * where we want it, but at the moment we
 	 * don't have the space.  Get it.
+	 *
+	 * XXX We should check for overflow here.  We
+	 * shouldn't allocate more than VINUM_MAXSD
+	 * subdisks (currently at least a quarter of a
+	 * million).
 	 */
 	EXPAND(SD, struct sd, vinum_conf.subdisks_allocated, INITIAL_SUBDISKS);
 
@@ -814,7 +808,7 @@
 	Free(plex->sdnos);
     if (plex->lock)
 	Free(plex->lock);
-    if (isstriped (plex))
+    if (isstriped(plex))
 	mtx_destroy(&plex->lockmtx);
     destroy_dev(plex->dev);
     bzero(plex, sizeof(struct plex));			    /* and clear it out */
@@ -927,7 +921,7 @@
 	switch (get_keyword(token[parameter], &keyword_set)) {
 	case kw_device:
 	    parameter++;
-	    otherdriveno = find_drive_by_dev(token[parameter], 0); /* see if it exists already */
+	    otherdriveno = find_drive_by_name(token[parameter], 0); /* see if it exists already */
 	    if (otherdriveno >= 0) {			    /* yup, */
 		drive->state = drive_unallocated;	    /* deallocate the drive */
 		throw_rude_remark(EEXIST,		    /* and complain */
@@ -1231,10 +1225,18 @@
 	throw_rude_remark(EINVAL, "sd %s has no length spec", sd->name);
 
     if (sd->dev == NULL)
-        sd->dev = make_dev(&vinum_cdevsw, VINUMRMINOR(sdno, VINUM_RAWSD_TYPE),
+	/*
+	 * sdno can (at least theoretically) overflow
+	 * into the low order bit of the type field.
+	 * This gives rise to a subdisk with type
+	 * VINUM_SD2_TYPE.  This is a feature, not a
+	 * bug.
+	 */
+	sd->dev = make_dev(&vinum_cdevsw,
+	    VINUMMINOR(sdno, VINUM_SD_TYPE),
 	    UID_ROOT,
 	    GID_OPERATOR,
- 	    S_IRUSR | S_IWUSR | S_IRGRP,
+	    S_IRUSR | S_IWUSR | S_IRGRP,
 	    "vinum/sd/%s",
 	    sd->name);
     if (state != sd_unallocated)			    /* we had a specific state to set */
@@ -1425,14 +1427,14 @@
     plex->state = state;				    /* set whatever state we chose */
     vinum_conf.plexes_used++;				    /* one more in use */
     if (plex->dev == NULL)
-        plex->dev = make_dev(&vinum_cdevsw,
-	    VINUMRMINOR(plexno, VINUM_RAWPLEX_TYPE),
+	plex->dev = make_dev(&vinum_cdevsw,
+	    VINUMMINOR(plexno, VINUM_PLEX_TYPE),
 	    UID_ROOT,
 	    GID_OPERATOR,
-            S_IRUSR | S_IWUSR | S_IRGRP,
-            "vinum/plex/%s",
-            plex->name);
-    }
+	    S_IRUSR | S_IWUSR | S_IRGRP,
+	    "vinum/plex/%s",
+	    plex->name);
+}
 
 /*
  * Handle a volume definition.
@@ -1561,13 +1563,13 @@
 	vol->size = max(vol->size, PLEX[vol->plex[i]].length);
     vinum_conf.volumes_used++;				    /* one more in use */
     if (vol->dev == NULL)
-        vol->dev = make_dev(&vinum_cdevsw,
-            VINUMRMINOR(volno, VINUM_VOLUME_TYPE),
-            UID_ROOT,
-            GID_OPERATOR,
-            S_IRUSR | S_IWUSR | S_IRGRP,
-            "vinum/%s",
-            vol->name);
+	vol->dev = make_dev(&vinum_cdevsw,
+	    VINUMMINOR(volno, VINUM_VOLUME_TYPE),
+	    UID_ROOT,
+	    GID_OPERATOR,
+	    S_IRUSR | S_IWUSR | S_IRGRP,
+	    "vinum/%s",
+	    vol->name);
 }
 
 /*

==== //depot/projects/hammer/sys/dev/vinum/vinumext.h#4 (text+ko) ====

@@ -33,8 +33,8 @@
  * otherwise) arising in any way out of the use of this software, even if
  * advised of the possibility of such damage.
  *
- * $Id: vinumext.h,v 1.27 2001/05/22 04:07:22 grog Exp grog $
- * $FreeBSD: src/sys/dev/vinum/vinumext.h,v 1.36 2003/03/02 14:42:52 phk Exp $
+ * $Id: vinumext.h,v 1.31 2003/04/25 08:01:37 grog Exp $
+ * $FreeBSD: src/sys/dev/vinum/vinumext.h,v 1.37 2003/05/01 01:29:52 grog Exp $
  */
 
 /* vinumext.h: external definitions */
@@ -84,7 +84,7 @@
 int my_sd(int plexno, int sdno);
 int get_empty_drive(void);
 int find_drive(const char *name, int create);
-int find_drive_by_dev(const char *devname, int create);
+int find_drive_by_name(const char *devname, int create);
 int get_empty_sd(void);
 int find_subdisk(const char *name, int create);
 void return_drive_space(int driveno, int64_t offset, int length);
@@ -126,7 +126,6 @@
 /* void throw_rude_remark (int, struct _ioctl_reply *, char *, ...); XXX */
 void throw_rude_remark(int, char *,...);
 
-/* XXX die die */
 void format_config(char *config, int len);
 void checkkernel(char *op);
 void free_drive(struct drive *drive);
@@ -141,6 +140,7 @@
 d_strategy_t vinumstrategy;
 d_ioctl_t vinumioctl;
 
+int vinum_super_ioctl(dev_t, u_long, caddr_t);
 int vinumstart(struct buf *bp, int reviveok);
 int launch_requests(struct request *rq, int reviveok);
 void sdio(struct buf *bp);

==== //depot/projects/hammer/sys/dev/vinum/vinumio.c#5 (text+ko) ====

@@ -33,8 +33,8 @@
  * otherwise) arising in any way out of the use of this software, even if
  * advised of the possibility of such damage.
  *
- * $Id: vinumio.c,v 1.32 2001/05/23 23:03:45 grog Exp grog $
- * $FreeBSD: src/sys/dev/vinum/vinumio.c,v 1.81 2003/02/22 09:36:40 phk Exp $
+ * $Id: vinumio.c,v 1.36 2003/04/28 02:54:07 grog Exp $
+ * $FreeBSD: src/sys/dev/vinum/vinumio.c,v 1.82 2003/05/01 01:30:31 grog Exp $
  */
 
 #include <dev/vinum/vinumhdr.h>
@@ -44,8 +44,8 @@
 static int drivecmp(const void *va, const void *vb);
 
 /*
- * Open the device associated with the drive, and set drive's vp.
- * Return an error number
+ * Open the device associated with the drive, and
+ * set drive's vp.  Return an error number.
  */
 int
 open_drive(struct drive *drive, struct thread *td, int verbose)
@@ -81,8 +81,8 @@
 }
 
 /*
- * Set some variables in the drive struct
- * in more convenient form.  Return error indication
+ * Set some variables in the drive struct in more
+ * convenient form.  Return error indication.
  */
 int
 set_drive_parms(struct drive *drive)
@@ -93,8 +93,8 @@
 
     /* Now update the label part */
     bcopy(hostname, drive->label.sysname, VINUMHOSTNAMELEN); /* put in host name */
-    getmicrotime(&drive->label.date_of_birth);		    /* and current time */
-    drive->label.drive_size = drive->mediasize;
+    microtime(&drive->label.date_of_birth);		    /* and current time */
+    drive->label.drive_size = drive->mediasize;		    /* size of the drive in bytes */
 #ifdef VINUMDEBUG
     if (debug & DEBUG_BIGDRIVE)				    /* pretend we're 100 times as big */
 	drive->label.drive_size *= 100;
@@ -128,8 +128,8 @@
 }
 
 /*
- * Initialize a drive: open the device and add device
- * information
+ * Initialize a drive: open the device and add
+ * device information.
  */
 int
 init_drive(struct drive *drive, int verbose)
@@ -145,35 +145,20 @@
 	FREAD,
 	curthread);
     if (drive->lasterror == 0)
-	    drive->lasterror = (*devsw(drive->dev)->d_ioctl) (drive->dev,
-		DIOCGMEDIASIZE,
-		(caddr_t) & drive->mediasize,
-		FREAD,
-		curthread);
+	drive->lasterror = (*devsw(drive->dev)->d_ioctl) (drive->dev,
+	    DIOCGMEDIASIZE,
+	    (caddr_t) & drive->mediasize,
+	    FREAD,
+	    curthread);
     if (drive->lasterror) {
 	if (verbose)
-	    log(LOG_WARNING,
-		"vinum open_drive %s: Can't get partition information, drive->lasterror %d\n",
+	    log(LOG_ERR,
+		"vinum: Can't get partition information for %s: error %d\n",
 		drive->devicename,
 		drive->lasterror);
 	close_drive(drive);
 	return drive->lasterror;
     }
-#if 0
-    /*
-     * XXX: this check is bogus and needs to be rewitten, we cannot guarantee
-     * XXX: that there will be a label with a typefield on all platforms.
-     */
-    if (drive->partinfo.part->p_fstype != FS_VINUM) {	    /* not Vinum */
-	drive->lasterror = EFTYPE;
-	if (verbose)
-	    log(LOG_WARNING,
-		"vinum open_drive %s: Wrong partition type for vinum\n",
-		drive->devicename);
-	close_drive(drive);
-	return EFTYPE;
-    }
-#endif
     return set_drive_parms(drive);			    /* set various odds and ends */
 }
 
@@ -246,7 +231,7 @@
  * length and offset are in bytes, but must be multiples of sector
  * size.  The function *does not check* for this condition, and
  * truncates ruthlessly.
- * Return error number
+ * Return error number.
  */
 int
 driveio(struct drive *drive, char *buf, size_t length, off_t offset, int flag)
@@ -262,7 +247,7 @@
 	bp->b_flags = 0;
 	bp->b_iocmd = flag;
 	bp->b_dev = drive->dev;				    /* device */
-	bp->b_blkno = offset / drive->sectorsize;           /* block number */
+	bp->b_blkno = offset / drive->sectorsize;	    /* block number */
 	bp->b_saveaddr = bp->b_data;
 	bp->b_data = buf;
 	bp->b_bcount = len;
@@ -348,7 +333,7 @@
     int i;
     struct drive *drive;
 
-    driveno = find_drive_by_dev(devicename, 1);		    /* if entry doesn't exist, create it */
+    driveno = find_drive_by_name(devicename, 1);	    /* if entry doesn't exist, create it */
     drive = &vinum_conf.drive[driveno];			    /* and get a pointer */
 
     if (read_drive_label(drive, 0) == DL_OURS) {	    /* one of ours */
@@ -528,7 +513,7 @@
 
 /*
  * issue a save config request to the dæmon.  The actual work
- * is done in process context by daemon_save_config
+ * is done in process context by daemon_save_config.
  */
 void
 save_config(void)
@@ -538,7 +523,7 @@
 
 /*
  * Write the configuration to all vinum slices.  This
- * is performed by the dæmon only
+ * is performed by the daemon only.
  */
 void
 daemon_save_config(void)
@@ -573,7 +558,7 @@
 	    /*
 	     * First, do some drive consistency checks.  Some
 	     * of these are kludges, others require a process
-	     * context and couldn't be done before
+	     * context and couldn't be done before.
 	     */
 	    if ((drive->devicename[0] == '\0')
 		|| (drive->label.name[0] == '\0')) {
@@ -592,17 +577,26 @@
 		unlockdrive(drive);
 		close_drive(drive);			    /* close it */
 	    } else if (drive->state > drive_down) {
-		getmicrotime(&drive->label.last_update);    /* time of last update is now */
+		microtime(&drive->label.last_update);	    /* time of last update is now */
 		bcopy((char *) &drive->label,		    /* and the label info from the drive structure */
 		    (char *) &vhdr->label,
 		    sizeof(vhdr->label));
 		if ((drive->state != drive_unallocated)
 		    && (drive->state != drive_referenced)) { /* and it's a real drive */
-		    error = write_drive(drive, (char *) vhdr, VINUMHEADERLEN, VINUM_LABEL_OFFSET);
+		    error = write_drive(drive,
+			(char *) vhdr,
+			VINUMHEADERLEN,
+			VINUM_LABEL_OFFSET);
+		    if (error == 0)			    /* first config copy */
+			error = write_drive(drive,
+			    config,
+			    MAXCONFIG,
+			    VINUM_CONFIG_OFFSET);
 		    if (error == 0)
-			error = write_drive(drive, config, MAXCONFIG, VINUM_CONFIG_OFFSET); /* first config copy */
-		    if (error == 0)
-			error = write_drive(drive, config, MAXCONFIG, VINUM_CONFIG_OFFSET + MAXCONFIG);	/* second copy */
+			error = write_drive(drive,	    /* second copy */
+			    config,
+			    MAXCONFIG,
+			    VINUM_CONFIG_OFFSET + MAXCONFIG);
 		    unlockdrive(drive);
 		    if (error) {
 			log(LOG_ERR,
@@ -632,8 +626,8 @@
  */
 
 /*
- * get_volume_label returns a label structure to lp, which
- * is allocated by the caller
+ * get_volume_label returns a label structure to
+ * lp, which is allocated by the caller.
  */
 void
 get_volume_label(char *name, int plexes, u_int64_t size, struct disklabel *lp)
@@ -659,8 +653,7 @@
     lp->d_secperunit = size;				    /* data sectors per unit */
 
     lp->d_bbsize = BBSIZE;
-    lp->d_sbsize = 0;
-
+    lp->d_sbsize = 0;					    /* no longer used?  */
     lp->d_magic = DISKMAGIC;
     lp->d_magic2 = DISKMAGIC;
 
@@ -722,14 +715,6 @@
     *dlp = *lp;
     bp->b_flags &= ~B_INVAL;
     bp->b_iocmd = BIO_WRITE;
-
-    /*
-     * This should read:
-     *
-     *       vinumstrategy (bp);
-     *
-     * Negotiate with phk to get it fixed.
-     */
     DEV_STRATEGY(bp);
     error = bufwait(bp);
     bp->b_flags |= B_INVAL | B_AGE;
@@ -739,7 +724,7 @@
     return error;
 }
 
-/* Look at all disks on the system for vinum slices */
+/* Look at all disks on the system for vinum slices. */
 int
 vinum_scandisk(char *devicename[], int drives)
 {
@@ -836,10 +821,9 @@
 	return ENOENT;
     }
     /*
-     * We now have at least one drive
-     * open.  Sort them in order of config time
-     * and merge the config info with what we
-     * have already.
+     * We now have at least one drive open.  Sort
+     * them in order of config time and merge the
+     * config info with what we have already.
      */
     qsort(drivelist, gooddrives, sizeof(int), drivecmp);
     config_text = (char *) Malloc(MAXCONFIG * 2);	    /* allocate buffers */
@@ -887,10 +871,12 @@
 		    parse_status = parse_config(config_line, &keyword_set, 1); /* parse the config line */
 		    if (parse_status < 0) {		    /* error in config */
 			/*
-			   * This config should have been parsed in user
-			   * space.  If we run into problems here, something
-			   * serious is afoot.  Complain and let the user
-			   * snarf the config to see what's wrong.
+			   * This config should have been parsed
+			   * in user space.  If we run into
+			   * problems here, something serious is
+			   * afoot.  Complain and let the user
+			   * snarf the config to see what's
+			   * wrong.
 			 */
 			log(LOG_ERR,
 			    "vinum: Config error on %s, aborting integration\n",

==== //depot/projects/hammer/sys/dev/vinum/vinumioctl.c#5 (text+ko) ====

@@ -41,8 +41,8 @@
  * otherwise) arising in any way out of the use of this software, even if
  * advised of the possibility of such damage.
  *
- * $Id: vinumioctl.c,v 1.14 2000/10/27 03:07:53 grog Exp grog $
- * $FreeBSD: src/sys/dev/vinum/vinumioctl.c,v 1.41 2003/02/22 09:36:40 phk Exp $
+ * $Id: vinumioctl.c,v 1.20 2003/04/28 02:54:43 grog Exp $
+ * $FreeBSD: src/sys/dev/vinum/vinumioctl.c,v 1.42 2003/05/01 01:30:59 grog Exp $
  */
 
 #include <dev/vinum/vinumhdr.h>
@@ -69,345 +69,344 @@
     struct thread *td)
 {
     unsigned int objno;
-    int error = 0;
     struct sd *sd;
     struct plex *plex;
     struct volume *vol;
-    unsigned int index;					    /* for transferring config info */
-    unsigned int sdno;					    /* for transferring config info */
-    int fe;						    /* free list element number */
-    struct _ioctl_reply *ioctl_reply = (struct _ioctl_reply *) data; /* struct to return */
 
     /* First, decide what we're looking at */
-    switch (DEVTYPE(dev)) {
-    case VINUM_SUPERDEV_TYPE:				    /* ordinary super device */
-	ioctl_reply = (struct _ioctl_reply *) data;	    /* save the address to reply to */
-	switch (cmd) {
-#ifdef VINUMDEBUG
-	case VINUM_DEBUG:
-	    if (((struct debuginfo *) data)->changeit)	    /* change debug settings */
-		debug = (((struct debuginfo *) data)->param);
-	    else {
-		if (debug & DEBUG_REMOTEGDB)
-		    boothowto |= RB_GDB;		    /* serial debug line */
-		else
-		    boothowto &= ~RB_GDB;		    /* local ddb */
-		Debugger("vinum debug");
-	    }
-	    ioctl_reply = (struct _ioctl_reply *) data;	    /* reinstate the address to reply to */
-	    ioctl_reply->error = 0;
-	    return 0;
-#endif
+    if ((minor(dev) == VINUM_SUPERDEV_MINOR)
+	|| (minor(dev) == VINUM_DAEMON_MINOR))
+	return vinum_super_ioctl(dev, cmd, data);
+    else						    /* real device */
+	switch (DEVTYPE(dev)) {
+	case VINUM_SD_TYPE:
+	case VINUM_SD2_TYPE:				    /* second half of sd namespace */
+	    objno = Sdno(dev);
+
+	    sd = &SD[objno];
+
+	    switch (cmd) {
+	    case DIOCGDINFO:				    /* get disk label */
+		get_volume_label(sd->name, 1, sd->sectors, (struct disklabel *) data);
+		break;
+
+		/*
+		 * We don't have this stuff on hardware,
+		 * so just pretend to do it so that
+		 * utilities don't get upset.
+		 */
+	    case DIOCWDINFO:				    /* write partition info */
+	    case DIOCSDINFO:				    /* set partition info */
+		return 0;				    /* not a titty */
 
-	case VINUM_CREATE:				    /* create a vinum object */
-	    error = lock_config();			    /* get the config for us alone */
-	    if (error)					    /* can't do it, */
-		return error;				    /* give up */
-	    error = setjmp(command_fail);		    /* come back here on error */
-	    if (error == 0)				    /* first time, */
-		ioctl_reply->error = parse_user_config((char *) data, /* update the config */
-		    &keyword_set);
-	    else if (ioctl_reply->error == 0) {		    /* longjmp, but no error status */

>>> TRUNCATED FOR MAIL (1000 lines) <<<



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