Properly count references of our dev_t to avoid triggering a KASSERT in

dev_strategy().

Submitted by:   dwmalone
Approved by:    grog (mentor)
This commit is contained in:
le 2004-03-11 14:11:08 +00:00
parent 7ad97e57ad
commit b4f24d5013
2 changed files with 4 additions and 0 deletions

View File

@ -476,6 +476,7 @@ get_empty_drive(void)
bzero(drive, sizeof(struct drive));
drive->driveno = driveno; /* put number in structure */
drive->flags |= VF_NEWBORN; /* newly born drive */
drive->dev = NODEV;
strcpy(drive->devicename, "unknown"); /* and make the name ``unknown'' */
return driveno; /* return the index */
}
@ -594,6 +595,8 @@ free_drive(struct drive *drive)
close_locked_drive(drive); /* close it */
if (drive->freelist)
Free(drive->freelist);
if (drive->dev != NODEV)
dev_rel(drive->dev);
bzero(drive, sizeof(struct drive)); /* this also sets drive_unallocated */
unlockdrive(drive);
}

View File

@ -58,6 +58,7 @@ open_drive(struct drive *drive, struct thread *td, int verbose)
drive->dev = getdiskbyname(drive->devicename);
if (drive->dev == NODEV) /* didn't find anything */
return ENOENT;
dev_ref(drive->dev);
drive->dev->si_iosize_max = DFLTPHYS;
dsw = devsw(drive->dev);