Fix unload of the fdc.ko:

Wakeup the thread doing the fdc_detach() when the fdc worker thread exits [1].
Write access to the write-protected floppy shall call device_unbusy() to
pair the device_busy() in the fd_access() [2].

PR:	116537 [1], 116539 [2]
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2008-01-11 11:53:04 +00:00
parent 73b2958b94
commit fc9f8bcf4f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=175226

View file

@ -1205,6 +1205,7 @@ fdc_thread(void *arg)
mtx_lock(&fdc->fdc_mtx);
}
fdc->flags &= ~(FDC_KTHREAD_EXIT | FDC_KTHREAD_ALIVE);
wakeup(&fdc->fdc_thread);
mtx_unlock(&fdc->fdc_mtx);
kproc_exit(0);
@ -1383,6 +1384,7 @@ fd_access(struct g_provider *pp, int r, int w, int e)
struct fd_data *fd;
struct fdc_data *fdc;
int ar, aw, ae;
int busy;
fd = pp->geom->softc;
fdc = fd->fdc;
@ -1403,6 +1405,7 @@ fd_access(struct g_provider *pp, int r, int w, int e)
return (0);
}
busy = 0;
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) {
if (fdmisccmd(fd, BIO_PROBE, NULL))
return (ENXIO);
@ -1415,10 +1418,14 @@ fd_access(struct g_provider *pp, int r, int w, int e)
mtx_unlock(&fdc->fdc_mtx);
}
device_busy(fd->dev);
busy = 1;
}
if (w > 0 && (fd->flags & FD_WP))
if (w > 0 && (fd->flags & FD_WP)) {
if (busy)
device_unbusy(fd->dev);
return (EROFS);
}
pp->sectorsize = fd->sectorsize;
pp->stripesize = fd->ft->heads * fd->ft->sectrac * fd->sectorsize;