aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorAlfred Perlstein <alfred@FreeBSD.org>2001-02-20 11:37:04 +0000
committerAlfred Perlstein <alfred@FreeBSD.org>2001-02-20 11:37:04 +0000
commitd9ca06d2a31855195a60862dfc4ccf4924d15252 (patch)
tree9566888454b6caf61eb967d3cb5cd61d49706ef2 /sys/dev
parent2cf5d587a943a31fd825caa26718f52b364cffa4 (diff)
Notes
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/vinum/vinum.c35
-rw-r--r--sys/dev/vinum/vinumconfig.c33
-rw-r--r--sys/dev/vinum/vinumhdr.h1
-rw-r--r--sys/dev/vinum/vinumvar.h7
4 files changed, 57 insertions, 19 deletions
diff --git a/sys/dev/vinum/vinum.c b/sys/dev/vinum/vinum.c
index b98aabe85ccb..ea4f7d2ab1b2 100644
--- a/sys/dev/vinum/vinum.c
+++ b/sys/dev/vinum/vinum.c
@@ -53,7 +53,7 @@ extern struct mc malloced[];
#endif
#include <dev/vinum/request.h>
-STATIC struct cdevsw vinum_cdevsw =
+struct cdevsw vinum_cdevsw =
{
vinumopen, vinumclose, physread, physwrite,
vinumioctl, seltrue, nommap, vinumstrategy,
@@ -68,6 +68,9 @@ STATIC int vinum_modevent(module_t mod, modeventtype_t type, void *unused);
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 @@ vinumattach(void *dummy)
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 @@ free_vinum(int cleardrive)
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 @@ vinum_modevent(module_t mod, modeventtype_t type, void *unused)
}
}
#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;
diff --git a/sys/dev/vinum/vinumconfig.c b/sys/dev/vinum/vinumconfig.c
index b32607dc1d3a..60fdbe78a983 100644
--- a/sys/dev/vinum/vinumconfig.c
+++ b/sys/dev/vinum/vinumconfig.c
@@ -734,6 +734,7 @@ free_sd(int sdno)
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(int plexno)
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 @@ free_volume(int volno)
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 @@ config_subdisk(int update)
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 @@ config_plex(int update)
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 @@ config_volume(int update)
/* 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 @@ remove_sd_entry(int sdno, int force, int recurse)
||(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 @@ remove_sd_entry(int sdno, int force, int recurse)
*/
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 */
diff --git a/sys/dev/vinum/vinumhdr.h b/sys/dev/vinum/vinumhdr.h
index 2b7d290c1d58..d6f65179c0d1 100644
--- a/sys/dev/vinum/vinumhdr.h
+++ b/sys/dev/vinum/vinumhdr.h
@@ -96,3 +96,4 @@ void FFree (void *mem, char *, int);
#define Free(x) free ((x)) /* just the address */
#endif
+extern struct cdevsw vinum_cdevsw;
diff --git a/sys/dev/vinum/vinumvar.h b/sys/dev/vinum/vinumvar.h
index d6620771890d..9e61128d19ea 100644
--- a/sys/dev/vinum/vinumvar.h
+++ b/sys/dev/vinum/vinumvar.h
@@ -37,7 +37,7 @@
* 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 $
+ * $Id: vinumvar.h,v 1.36 2001/01/14 06:34:57 grog Exp $
* $FreeBSD$
*/
@@ -216,7 +216,7 @@ struct devcode {
unsigned signbit:1; /* to make 32 bits */
};
-#define VINUM_DIR "/dev/vinum"
+#define VINUM_DIR "vinum"
/*
* These definitions help catch
@@ -451,6 +451,7 @@ struct sd {
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 @@ struct plex {
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 @@ struct volume {
int plex[MAXPLEX]; /* index of plexes */
char name[MAXVOLNAME]; /* name of volume */
struct disklabel label; /* for DIOCGPART */
+ dev_t dev;
};
/*