From owner-freebsd-current Mon Feb 19 2: 6: 5 2001 Delivered-To: freebsd-current@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 7E33E37B401; Mon, 19 Feb 2001 02:05:56 -0800 (PST) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id f1JA5uH06662; Mon, 19 Feb 2001 02:05:56 -0800 (PST) Date: Mon, 19 Feb 2001 02:05:56 -0800 From: Alfred Perlstein To: grog@freebsd.org Cc: current@freebsd.org Subject: please test, vinum + devfs Message-ID: <20010219020556.K6641@fw.wintelcom.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i X-all-your-base: are belong to us. Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This gets my vinum config working enough such that I can mount my pre-devfs configuration, if anyone wants to test/comment please try this: (you'll need to recompile src/sbin/vinum as well) Index: vinum.c =================================================================== RCS file: /home/ncvs/src/sys/dev/vinum/vinum.c,v retrieving revision 1.39 diff -u -r1.39 vinum.c --- vinum.c 2000/10/23 08:35:36 1.39 +++ vinum.c 2001/02/19 09:54:39 @@ -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.28 1999/10/12 09:41:20 grog Exp grog $ - * $FreeBSD: src/sys/dev/vinum/vinum.c,v 1.39 2000/10/23 08:35:36 phk Exp $ + * $Id: vinum.c,v 1.39 2000/10/23 08:35:36 phk Exp $ + * $FreeBSD: src/sys/dev/vinum/vinum.c,v 1.38 2000/02/29 06:07:39 grog Exp $ */ #define STATIC static /* nothing while we're testing XXX */ @@ -53,7 +53,7 @@ #endif #include -STATIC struct cdevsw vinum_cdevsw = +struct cdevsw vinum_cdevsw = { vinumopen, vinumclose, physread, physwrite, vinumioctl, seltrue, nommap, vinumstrategy, @@ -68,6 +68,9 @@ struct _vinum_conf vinum_conf; /* configuration information */ +dev_t vinum_daemon_dev; +dev_t vinum_super_dev; + /* * Called by main() during pseudo-device attachment. All we need * to do is allocate enough space for devices to be configured later, and @@ -88,6 +91,10 @@ dqend = NULL; cdevsw_add(&vinum_cdevsw); /* add the cdevsw entry */ + vinum_daemon_dev = make_dev(&vinum_cdevsw, VINUM_DAEMON_DEV, + UID_ROOT, GID_WHEEL, S_IRUSR|S_IWUSR, VINUM_DAEMON_DEV_NAME); /* daemon device */ + vinum_super_dev = make_dev(&vinum_cdevsw, VINUM_SUPERDEV, + UID_ROOT, GID_WHEEL, S_IRUSR|S_IWUSR, VINUM_SUPERDEV_NAME); /* daemon device */ /* allocate space: drives... */ DRIVE = (struct drive *) Malloc(sizeof(struct drive) * INITIAL_DRIVES); @@ -174,21 +181,33 @@ queue_daemon_request(daemonrq_return, (union daemoninfo) 0); /* stop the daemon */ tsleep(&vinumclose, PUSER, "vstop", 1); /* and wait for it */ } - if (SD != NULL) + if (SD != NULL) { + for (i = 0; i < vinum_conf.subdisks_allocated; i++) { + struct sd *sd = &vinum_conf.sd[i]; + + if (sd->state != sd_unallocated) + free_sd(i); + } Free(SD); + } if (PLEX != NULL) { for (i = 0; i < vinum_conf.plexes_allocated; i++) { struct plex *plex = &vinum_conf.plex[i]; - if (plex->state != plex_unallocated) { /* we have real data there */ - if (plex->sdnos) - Free(plex->sdnos); - } + if (plex->state != plex_unallocated) /* we have real data there */ + free_plex(i); } Free(PLEX); } - if (VOL != NULL) + if (VOL != NULL) { + for (i = 0; i < vinum_conf.volumes_allocated; i++) { + struct volume *volume = &vinum_conf.volume[i]; + + if (volume->state != volume_unallocated) + free_volume(i); + } Free(VOL); + } bzero(&vinum_conf, sizeof(vinum_conf)); } @@ -236,6 +255,8 @@ } } #endif + destroy_dev(vinum_daemon_dev); /* daemon device */ + destroy_dev(vinum_super_dev); cdevsw_remove(&vinum_cdevsw); log(LOG_INFO, "vinum: unloaded\n"); /* tell the world */ return 0; Index: vinumconfig.c =================================================================== RCS file: /home/ncvs/src/sys/dev/vinum/vinumconfig.c,v retrieving revision 1.38 diff -u -r1.38 vinumconfig.c --- vinumconfig.c 2001/02/02 07:14:13 1.38 +++ vinumconfig.c 2001/02/19 10:05:10 @@ -734,6 +734,7 @@ sd->sectors); if (sd->plexno >= 0) PLEX[sd->plexno].subdisks--; /* one less subdisk */ + destroy_dev(sd->dev); bzero(sd, sizeof(struct sd)); /* and clear it out */ sd->state = sd_unallocated; vinum_conf.subdisks_used--; /* one less sd */ @@ -811,6 +812,7 @@ Free(plex->sdnos); if (plex->lock) Free(plex->lock); + destroy_dev(plex->dev); bzero(plex, sizeof(struct plex)); /* and clear it out */ plex->state = plex_unallocated; } @@ -881,6 +883,7 @@ struct volume *vol; vol = &VOL[volno]; + destroy_dev(vol->dev); bzero(vol, sizeof(struct volume)); /* and clear it out */ vol->state = volume_unallocated; } @@ -1220,6 +1223,8 @@ if (sd->sectors < 0) throw_rude_remark(EINVAL, "sd %s has no length spec", sd->name); + sd->dev = make_dev(&vinum_cdevsw, VINUMRMINOR(VINUM_SD_TYPE, sdno), + UID_ROOT, GID_WHEEL, S_IRUSR|S_IWUSR, "vinum/sd/%s", sd->name); if (state != sd_unallocated) /* we had a specific state to set */ sd->state = state; /* do it now */ else if (sd->state == sd_unallocated) /* no, nothing set yet, */ @@ -1377,6 +1382,9 @@ if (plex->organization == plex_disorg) throw_rude_remark(EINVAL, "No plex organization specified"); + plex->dev = make_dev(&vinum_cdevsw, VINUMRMINOR(VINUM_PLEX_TYPE, plexno), + UID_ROOT, GID_WHEEL, S_IRUSR|S_IWUSR, "vinum/plex/%s", plex->name); + if ((plex->volno < 0) /* we don't have a volume */ &&(!detached)) /* and we wouldn't object */ plex->volno = current_volume; @@ -1534,7 +1542,10 @@ /* Find out how big our volume is */ for (i = 0; i < vol->plexes; i++) vol->size = max(vol->size, PLEX[vol->plex[i]].length); + vinum_conf.volumes_used++; /* one more in use */ + vol->dev = make_dev(&vinum_cdevsw, VINUMRMINOR(VINUM_VOLUME_TYPE, volno), + UID_ROOT, GID_WHEEL, S_IRUSR|S_IWUSR, "vinum/vol/%s", vol->name); } /* @@ -1686,23 +1697,29 @@ ||(sd->state == sd_unallocated)) { /* or nothing there */ ioctl_reply->error = EINVAL; strcpy(ioctl_reply->msg, "No such subdisk"); + return; } else if (sd->flags & VF_OPEN) { /* we're open */ ioctl_reply->error = EBUSY; /* no getting around that */ return; } else if (sd->plexno >= 0) { /* we have a plex */ - if (force) { /* do it at any cost */ + if (!force) { /* do it at any cost */ + ioctl_reply->error = EBUSY; /* can't do that */ + return; + } else { struct plex *plex = &PLEX[sd->plexno]; /* point to our plex */ int mysdno; for (mysdno = 0; /* look for ourselves */ mysdno < plex->subdisks && &SD[plex->sdnos[mysdno]] != sd; mysdno++); - if (mysdno == plex->subdisks) /* didn't find it */ + if (mysdno == plex->subdisks) { /* didn't find it */ log(LOG_ERR, "Error removing subdisk %s: not found in plex %s\n", SD[mysdno].name, plex->name); - else { /* remove the subdisk from plex */ + ioctl_reply->error = EINVAL; + return; + } else { /* remove the subdisk from plex */ if (mysdno < (plex->subdisks - 1)) /* not the last subdisk */ bcopy(&plex->sdnos[mysdno + 1], &plex->sdnos[mysdno], @@ -1719,14 +1736,10 @@ */ if (plex->organization != plex_concat) /* not concatenated, */ set_plex_state(plex->plexno, plex_faulty, setstate_force); /* need to reinitialize */ - log(LOG_INFO, "vinum: removing %s\n", sd->name); - free_sd(sdno); - } else - ioctl_reply->error = EBUSY; /* can't do that */ - } else { - log(LOG_INFO, "vinum: removing %s\n", sd->name); - free_sd(sdno); + } } + log(LOG_INFO, "vinum: removing %s\n", sd->name); + free_sd(sdno); } /* remove a plex */ Index: vinumhdr.h =================================================================== RCS file: /home/ncvs/src/sys/dev/vinum/vinumhdr.h,v retrieving revision 1.22 diff -u -r1.22 vinumhdr.h --- vinumhdr.h 2001/01/21 19:25:04 1.22 +++ vinumhdr.h 2001/02/18 23:49:36 @@ -36,8 +36,8 @@ /* Header files used by all modules */ /* - * $Id: vinumhdr.h,v 1.18 2001/01/04 00:14:14 grog Exp grog $ - * $FreeBSD: src/sys/dev/vinum/vinumhdr.h,v 1.22 2001/01/21 19:25:04 jake Exp $ + * $Id: vinumhdr.h,v 1.22 2001/01/21 19:25:04 jake Exp $ + * $FreeBSD: src/sys/dev/vinum/vinumhdr.h,v 1.21 2001/01/10 21:42:06 grog Exp $ */ #include @@ -96,3 +96,4 @@ #define Free(x) free ((x)) /* just the address */ #endif +extern struct cdevsw vinum_cdevsw; Index: vinumvar.h =================================================================== RCS file: /home/ncvs/src/sys/dev/vinum/vinumvar.h,v retrieving revision 1.36 diff -u -r1.36 vinumvar.h --- vinumvar.h 2001/01/14 06:34:57 1.36 +++ vinumvar.h 2001/02/19 09:43:58 @@ -37,8 +37,8 @@ * otherwise) arising in any way out of the use of this software, even if * advised of the possibility of such damage. * - * $Id: vinumvar.h,v 1.24 2000/03/01 02:34:57 grog Exp grog $ - * $FreeBSD: src/sys/dev/vinum/vinumvar.h,v 1.36 2001/01/14 06:34:57 grog Exp $ + * $Id: vinumvar.h,v 1.36 2001/01/14 06:34:57 grog Exp $ + * $FreeBSD$ */ #include @@ -216,7 +216,7 @@ unsigned signbit:1; /* to make 32 bits */ }; -#define VINUM_DIR "/dev/vinum" +#define VINUM_DIR "vinum" /* * These definitions help catch @@ -451,6 +451,7 @@ int init_blocksize; /* init block size (bytes) */ int init_interval; /* and time to wait between transfers */ char name[MAXSDNAME]; /* name of subdisk */ + dev_t dev; }; /*** Plex definitions ***/ @@ -498,6 +499,7 @@ u_int64_t multistripe; /* requests that needed more than one stripe */ int sddowncount; /* number of subdisks down */ char name[MAXPLEXNAME]; /* name of plex */ + dev_t dev; }; /*** Volume definitions ***/ @@ -537,6 +539,7 @@ int plex[MAXPLEX]; /* index of plexes */ char name[MAXVOLNAME]; /* name of volume */ struct disklabel label; /* for DIOCGPART */ + dev_t dev; }; /* -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message