From fdfcec3b7cc746c869691cdab546add23e836df3 Mon Sep 17 00:00:00 2001 From: Greg Lehey Date: Mon, 5 May 2003 05:32:52 +0000 Subject: vinum_scandisk: Make sure the config is locked before we mess around with it. Finally implement read policies. The previous "implementation" didn't work because it referred to plexes which were almost invariably when referred to. Instead, deprecate the "prefer" keyword for volumes (though it's still there for the moment) and add a keyword "preferred" to the plex definition. The relationship is like this: Old: vol foo ... prefer foo.p3 New: plex foo.p3 volume foo preferred print_config: Print "preferred" where appropriate. No longer print "prefer" on volume config entries. --- sys/dev/vinum/vinumio.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/vinum/vinumio.c b/sys/dev/vinum/vinumio.c index 3b31f6e26283a..9f4b01c813b3a 100644 --- a/sys/dev/vinum/vinumio.c +++ b/sys/dev/vinum/vinumio.c @@ -33,7 +33,7 @@ * 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.36 2003/04/28 02:54:07 grog Exp $ + * $Id: vinumio.c,v 1.37 2003/05/04 05:23:42 grog Exp grog $ * $FreeBSD$ */ @@ -408,13 +408,6 @@ format_config(char *config, int len) volume_state(vol->state)); while (*s) s++; /* find the end */ - if (vol->preferred_plex >= 0) /* preferences, */ - snprintf(s, - configend - s, - " readpol prefer %s", - vinum_conf.plex[vol->preferred_plex].name); - while (*s) - s++; /* find the end */ s = sappend("\n", s); } } @@ -422,6 +415,7 @@ format_config(char *config, int len) /* Then the plex configuration */ for (i = 0; i < vinum_conf.plexes_allocated; i++) { struct plex *plex; + struct volume *vol; plex = &vinum_conf.plex[i]; if ((plex->state > plex_referenced) @@ -442,13 +436,20 @@ format_config(char *config, int len) while (*s) s++; /* find the end */ } - if (plex->volno >= 0) /* we have a volume */ + if (plex->volno >= 0) { /* we have a volume */ + vol = &VOL[plex->volno]; snprintf(s, configend - s, "vol %s ", - vinum_conf.volume[plex->volno].name); - while (*s) - s++; /* find the end */ + vol->name); + while (*s) + s++; /* find the end */ + if ((vol->preferred_plex >= 0) /* has a preferred plex */ + &&vol->plex[vol->preferred_plex] == i) /* and it's us */ + snprintf(s, configend - s, "preferred "); + while (*s) + s++; /* find the end */ + } for (j = 0; j < plex->subdisks; j++) { snprintf(s, configend - s, @@ -776,12 +777,10 @@ vinum_scandisk(char *devicename) return ENOMEM; } else malloced = 1; - /* Now det the list of disks */ + /* Now get the list of disks */ kernel_sysctlbyname(&thread0, "kern.disks", devicename, &alloclen, NULL, 0, NULL); } - printf("vinum_scandisk: devicename is %s\n", devicename); /* XXX */ - status = 0; /* success indication */ vinum_conf.flags |= VF_READING_CONFIG; /* reading config from disk */ partname = Malloc(MAXPATHLEN); /* extract name of disk here */ @@ -797,6 +796,12 @@ vinum_scandisk(char *devicename) drives = 256; /* should be enough for most cases */ drivelist = (int *) Malloc(drives * sizeof(int)); CHECKALLOC(drivelist, "Can't allocate memory"); + error = lock_config(); /* make sure we're alone here */ + if (error) + return error; + error = setjmp(command_fail); /* come back here on error */ + if (error) /* longjmped out */ + return error; /* Open all drives and find which was modified most recently */ for (cp = devicename; *cp; cp = ep) { @@ -883,6 +888,7 @@ vinum_scandisk(char *devicename) log(LOG_INFO, "vinum: no additional drives found\n"); if (malloced) Free(devicename); + unlock_config(); return ENOENT; } /* @@ -966,6 +972,7 @@ vinum_scandisk(char *devicename) updateconfig(VF_READING_CONFIG); /* update from disk config */ if (malloced) Free(devicename); + unlock_config(); return status; } -- cgit v1.3