diff options
| author | Greg Lehey <grog@FreeBSD.org> | 1999-05-02 07:51:20 +0000 |
|---|---|---|
| committer | Greg Lehey <grog@FreeBSD.org> | 1999-05-02 07:51:20 +0000 |
| commit | a2d8e114f4ae89fb3398cada332fa22f0f493a32 (patch) | |
| tree | fd797a3bd75cb2307624e59456a91c64b9b8216e /sys | |
| parent | 3041dc10ba05a6f5299def544242aa3cbc623d5d (diff) | |
Notes
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/dev/vinum/vinumio.c | 75 |
1 files changed, 45 insertions, 30 deletions
diff --git a/sys/dev/vinum/vinumio.c b/sys/dev/vinum/vinumio.c index 43c7181f0fb0..e8c2556edaba 100644 --- a/sys/dev/vinum/vinumio.c +++ b/sys/dev/vinum/vinumio.c @@ -215,12 +215,26 @@ close_drive(struct drive *drive) { if (drive->vp) { LOCKDRIVE(drive); /* keep the daemon out */ + + /* + * If we can't access the drive, we can't flush + * the queues, which spec_close() will try to + * do. Get rid of them here first + */ + if (drive->state < drive_up) { /* we can't access the drive, */ + vn_lock(drive->vp, LK_EXCLUSIVE | LK_RETRY, drive->p); + vinvalbuf(drive->vp, 0, NOCRED, drive->p, 0, 0); + VOP_UNLOCK(drive->vp, 0, drive->p); + } vn_close(drive->vp, FREAD | FWRITE, NOCRED, drive->p); - if (drive->vp->v_usecount) /* XXX shouldn't happen */ +#ifdef VINUMDEBUG + if ((debug & DEBUG_WARNINGS) /* want to hear about them */ + &&(drive->vp->v_usecount)) /* XXX shouldn't happen */ log(LOG_WARNING, "close_drive %s: use count still %d\n", drive->devicename, drive->vp->v_usecount); +#endif drive->vp = NULL; unlockdrive(drive); } @@ -515,47 +529,48 @@ read_drive_label(struct drive *drive, int verbose) * Return drive number. */ struct drive * -check_drive(char *drivename) +check_drive(char *devicename) { int driveno; int i; struct drive *drive; - driveno = find_drive_by_dev(drivename, 1); /* entry doesn't exist, create it */ + driveno = find_drive_by_dev(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) { /* not ours */ - if (drive->lasterror == 0) - drive->lasterror = ENODEV; - set_drive_state(drive->driveno, drive_down, setstate_force); - } - for (i = 0; i < vinum_conf.drives_allocated; i++) { /* see if the name already exists */ - if ((i != driveno) /* not this drive */ + if (read_drive_label(drive, 0) == DL_OURS) { /* not ours */ + for (i = 0; i < vinum_conf.drives_allocated; i++) { /* see if the name already exists */ + if ((i != driveno) /* not this drive */ &&(DRIVE[i].state != drive_unallocated) /* and it's allocated */ - &&(strcmp(DRIVE[i].label.name, - DRIVE[driveno].label.name) == 0)) { /* and it has the same name */ - struct drive *mydrive = &DRIVE[i]; + &&(strcmp(DRIVE[i].label.name, + DRIVE[driveno].label.name) == 0)) { /* and it has the same name */ + struct drive *mydrive = &DRIVE[i]; - if (mydrive->devicename[0] == '/') { /* we know a device name for it */ - /* - * set an error, but don't take the drive down: - * that would cause unneeded error messages. - */ - drive->lasterror = EEXIST; - break; - } else { /* it's just a place holder, */ - int sdno; + if (mydrive->devicename[0] == '/') { /* we know a device name for it */ + /* + * set an error, but don't take the drive down: + * that would cause unneeded error messages. + */ + drive->lasterror = EEXIST; + break; + } else { /* it's just a place holder, */ + int sdno; - for (sdno = 0; sdno < vinum_conf.subdisks_allocated; sdno++) { /* look at each subdisk */ - if ((SD[sdno].driveno == driveno) /* it's pointing to this one, */ - &&(SD[sdno].state != sd_unallocated)) { /* and it's a real subdisk */ - SD[sdno].driveno = drive->driveno; /* point to the one we found */ - update_sd_state(sdno); /* and update its state */ + for (sdno = 0; sdno < vinum_conf.subdisks_allocated; sdno++) { /* look at each subdisk */ + if ((SD[sdno].driveno == i) /* it's pointing to this one, */ + &&(SD[sdno].state != sd_unallocated)) { /* and it's a real subdisk */ + SD[sdno].driveno = drive->driveno; /* point to the one we found */ + update_sd_state(sdno); /* and update its state */ + } } + bzero(mydrive, sizeof(struct drive)); /* don't deallocate it, just remove it */ } - free_drive(mydrive); } } + } else { + if (drive->lasterror == 0) + drive->lasterror = ENODEV; + set_drive_state(drive->driveno, drive_down, setstate_force); } return drive; } @@ -920,7 +935,7 @@ initsd(int sdno) /* Look at all disks on the system for vinum slices */ int -vinum_scandisk(char *drivename[], int drives) +vinum_scandisk(char *devicename[], int drives) { struct drive *volatile drive; volatile int driveno; @@ -959,7 +974,7 @@ vinum_scandisk(char *drivename[], int drives) snprintf(partname, /* /dev/sd0a */ DRIVENAMELEN, "%s%c", - drivename[driveno], + devicename[driveno], part); drive = check_drive(partname); /* try to open it */ if ((drive->lasterror != 0) /* didn't work, */ |
