static int mfi_syspd_detach(device_t dev) { struct mfi_system_pd *sc; sc = device_get_softc(dev); device_printf(dev, "Detaching syspd\n"); mtx_lock(&sc->pd_controller->mfi_io_lock); if (((sc->pd_disk->d_flags & DISKFLAG_OPEN) || (sc->pd_flags & MFI_DISK_FLAGS_OPEN)) && (sc->pd_controller->mfi_keep_deleted_volumes || sc->pd_controller->mfi_detaching)) { mtx_unlock(&sc->pd_controller->mfi_io_lock); device_printf(dev, "Cant detach syspd\n"); return (EBUSY); } mtx_unlock(&sc->pd_controller->mfi_io_lock); disk_destroy(sc->pd_disk); mtx_lock(&sc->pd_controller->mfi_io_lock); TAILQ_REMOVE(&sc->pd_controller->mfi_syspd_tqh, sc, pd_link); mtx_unlock(&sc->pd_controller->mfi_io_lock); free(sc->pd_info, M_MFIBUF); return (0); }
static int ad_detach(device_t dev) { struct ad_softc *adp = device_get_ivars(dev); struct ata_device *atadev = device_get_softc(dev); /* check that we have a valid disk to detach */ if (!device_get_ivars(dev)) return ENXIO; /* destroy the power timeout */ callout_drain(&atadev->spindown_timer); /* detach & delete all children */ device_delete_children(dev); /* destroy disk from the system so we don't get any further requests */ disk_destroy(adp->disk); /* fail requests on the queue and any that's "in flight" for this device */ ata_fail_requests(dev); /* don't leave anything behind */ device_set_ivars(dev, NULL); free(adp, M_AD); return 0; }
static int mambodisk_detach(device_t dev) { struct mambodisk_softc *sc = device_get_softc(dev); /* kill thread */ MBODISK_LOCK(sc); sc->running = 0; wakeup(sc); MBODISK_UNLOCK(sc); /* wait for thread to finish. XXX probably want timeout. -sorbo */ MBODISK_LOCK(sc); while (sc->running != -1) msleep(sc, &sc->sc_mtx, PRIBIO, "detach", 0); MBODISK_UNLOCK(sc); /* kill disk */ disk_destroy(sc->disk); /* XXX destroy anything in queue */ MBODISK_LOCK_DESTROY(sc); return (0); }
static int vtblk_detach(device_t dev) { struct vtblk_softc *sc; sc = device_get_softc(dev); VTBLK_LOCK(sc); sc->vtblk_flags |= VTBLK_FLAG_DETACH; if (device_is_attached(dev)) vtblk_stop(sc); VTBLK_UNLOCK(sc); if (sc->vtblk_tq != NULL) { taskqueue_drain(sc->vtblk_tq, &sc->vtblk_intr_task); taskqueue_free(sc->vtblk_tq); sc->vtblk_tq = NULL; } vtblk_drain(sc); if (sc->vtblk_disk != NULL) { disk_destroy(sc->vtblk_disk); sc->vtblk_disk = NULL; } if (sc->vtblk_sglist != NULL) { sglist_free(sc->vtblk_sglist); sc->vtblk_sglist = NULL; } VTBLK_LOCK_DESTROY(sc); return (0); }
static void destroy_geom_disk(struct nvd_disk *ndisk) { struct bio *bp; struct disk *disk; uint32_t unit; int cnt = 0; disk = ndisk->disk; unit = disk->d_unit; taskqueue_free(ndisk->tq); disk_destroy(ndisk->disk); mtx_lock(&ndisk->bioqlock); for (;;) { bp = bioq_takefirst(&ndisk->bioq); if (bp == NULL) break; bp->bio_error = EIO; bp->bio_flags |= BIO_ERROR; bp->bio_resid = bp->bio_bcount; cnt++; biodone(bp); } printf(NVD_STR"%u: lost device - %d outstanding\n", unit, cnt); printf(NVD_STR"%u: removing device entry\n", unit); mtx_unlock(&ndisk->bioqlock); mtx_destroy(&ndisk->bioqlock); }
/* * dm_detach: * * Autoconfiguration detach function for pseudo-device glue. * This routine is called by dm_ioctl::dm_dev_remove_ioctl and by autoconf to * remove devices created in device-mapper. */ static int dm_detach(device_t self, int flags) { dm_dev_t *dmv; /* Detach device from global device list */ if ((dmv = dm_dev_detach(self)) == NULL) return ENOENT; /* Destroy active table first. */ dm_table_destroy(&dmv->table_head, DM_TABLE_ACTIVE); /* Destroy inactive table if exits, too. */ dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE); dm_table_head_destroy(&dmv->table_head); /* Destroy disk device structure */ disk_detach(dmv->diskp); disk_destroy(dmv->diskp); /* Destroy device */ (void)dm_dev_free(dmv); /* Decrement device counter After removing device */ atomic_dec_32(&dm_dev_counter); return 0; }
static int vtblk_detach(device_t dev) { struct vtblk_softc *sc; sc = device_get_softc(dev); lwkt_serialize_enter(&sc->vtblk_slz); sc->vtblk_flags |= VTBLK_FLAG_DETACH; if (device_is_attached(dev)) vtblk_stop(sc); lwkt_serialize_exit(&sc->vtblk_slz); vtblk_drain(sc); if (sc->cdev != NULL) { disk_destroy(&sc->vtblk_disk); sc->cdev = NULL; } if (sc->vtblk_sglist != NULL) { sglist_free(sc->vtblk_sglist); sc->vtblk_sglist = NULL; } return (0); }
static int idad_detach(device_t dev) { struct idad_softc *drv; drv = (struct idad_softc *)device_get_softc(dev); devstat_remove_entry(&drv->stats); disk_destroy(&drv->disk); return (0); }
static int mlxd_detach(device_t dev) { struct mlxd_softc *sc = (struct mlxd_softc *)device_get_softc(dev); debug_called(1); disk_destroy(sc->mlxd_disk); return(0); }
static int ipsd_detach(device_t dev) { ipsdisk_softc_t *dsc; DEVICE_PRINTF(2, dev,"in detach\n"); dsc = (ipsdisk_softc_t *)device_get_softc(dev); if(dsc->state & IPS_DEV_OPEN) return (EBUSY); disk_destroy(dsc->ipsd_disk); return 0; }
static int cfi_disk_detach(device_t dev) { struct cfi_disk_softc *sc = device_get_softc(dev); if (sc->flags & CFI_DISK_OPEN) return EBUSY; taskqueue_free(sc->tq); /* XXX drain bioq */ disk_destroy(sc->disk); mtx_destroy(&sc->qlock); return 0; }
void destroy_geom_disk(struct nand_chip *chip) { struct bio *bp; taskqueue_free(chip->tq); disk_destroy(chip->ndisk); disk_destroy(chip->rdisk); mtx_lock(&chip->qlock); for (;;) { bp = bioq_takefirst(&chip->bioq); if (bp == NULL) break; bp->bio_error = EIO; bp->bio_flags |= BIO_ERROR; bp->bio_resid = bp->bio_bcount; biodone(bp); } mtx_unlock(&chip->qlock); mtx_destroy(&chip->qlock); }
static int vnd_detach(device_t self, int flags) { int error; struct vnd_softc *sc = device_private(self); if (sc->sc_flags & VNF_INITED) { error = vnddoclear(sc, 0, -1, (flags & DETACH_FORCE) != 0); if (error != 0) return error; } pmf_device_deregister(self); bufq_free(sc->sc_tab); disk_destroy(&sc->sc_dkdev); return 0; }
void afddetach(struct ata_device *atadev) { struct afd_softc *fdp = atadev->driver; struct bio *bp; while ((bp = bioq_first(&fdp->queue))) { bioq_remove(&fdp->queue, bp); biofinish(bp, NULL, ENXIO); } disk_invalidate(&fdp->disk); disk_destroy(fdp->dev); devstat_remove_entry(&fdp->stats); ata_free_name(atadev); ata_free_lun(&afd_lun_map, fdp->lun); free(fdp, M_AFD); atadev->driver = NULL; }
static int afd_detach(device_t dev) { struct afd_softc *fdp = device_get_ivars(dev); /* check that we have a valid device to detach */ if (!device_get_ivars(dev)) return ENXIO; /* detroy disk from the system so we dont get any further requests */ disk_destroy(fdp->disk); /* fail requests on the queue and any thats "in flight" for this device */ ata_fail_requests(dev); /* dont leave anything behind */ device_set_ivars(dev, NULL); free(fdp, M_AFD); return 0; }
void afddetach(struct ata_device *atadev) { struct afd_softc *fdp = atadev->driver; struct buf *bp; while ((bp = bufq_first(&fdp->queue))) { bufq_remove(&fdp->queue, bp); bp->b_flags |= B_ERROR; bp->b_error = ENXIO; biodone(bp); } disk_invalidate(&fdp->disk); disk_destroy(fdp->dev); devstat_remove_entry(&fdp->stats); ata_free_name(atadev); ata_free_lun(&afd_lun_map, fdp->lun); free(fdp, M_AFD); atadev->driver = NULL; }
static int cgd_detach(device_t self, int flags) { int ret; const int pmask = 1 << RAW_PART; struct cgd_softc *sc = device_private(self); struct dk_softc *dksc = &sc->sc_dksc; if (DK_BUSY(dksc, pmask)) return EBUSY; if (DK_ATTACHED(dksc) && (ret = cgd_ioctl_clr(sc, curlwp)) != 0) return ret; disk_destroy(&dksc->sc_dkdev); mutex_destroy(&sc->sc_lock); return 0; }
static int fddetach(device_t self, int flags) { struct fd_softc *fd = device_private(self); int bmaj, cmaj, i, mn; fd_motor_off(fd); /* locate the major number */ bmaj = bdevsw_lookup_major(&fd_bdevsw); cmaj = cdevsw_lookup_major(&fd_cdevsw); /* Nuke the vnodes for any open instances. */ for (i = 0; i < MAXPARTITIONS; i++) { mn = DISKMINOR(device_unit(self), i); vdevgone(bmaj, mn, mn, VBLK); vdevgone(cmaj, mn, mn, VCHR); } pmf_device_deregister(self); #if 0 /* XXX need to undo at detach? */ fd_set_properties(fd); #endif #if NRND > 0 rnd_detach_source(&fd->rnd_source); #endif disk_detach(&fd->sc_dk); disk_destroy(&fd->sc_dk); /* Kill off any queued buffers. */ bufq_drain(fd->sc_q); bufq_free(fd->sc_q); callout_destroy(&fd->sc_motoroff_ch); callout_destroy(&fd->sc_motoron_ch); return 0; }
static int vnclose(struct dev_close_args *ap) { cdev_t dev = ap->a_head.a_dev; struct vn_softc *vn; vn = dev->si_drv1; KKASSERT(vn != NULL); vn->sc_flags &= ~VNF_OPENED; /* The disk has been detached and can now be safely destroyed */ if (vn->sc_flags & VNF_DESTROY) { KKASSERT(disk_getopencount(&vn->sc_disk) == 0); disk_destroy(&vn->sc_disk); devfs_clone_bitmap_put(&DEVFS_CLONE_BITMAP(vn), dkunit(dev)); SLIST_REMOVE(&vn_list, vn, vn_softc, sc_list); kfree(vn, M_VN); } return (0); }
static int ad_detach(device_t dev) { struct ad_softc *adp = device_get_ivars(dev); device_t *children; int nchildren, i; /* check that we have a valid disk to detach */ if (!adp) return ENXIO; #if 0 /* XXX TGEN Probably useless, we fail the queue below. */ /* check that the disk is closed */ if (adp->ad_flags & AD_DISK_OPEN) return EBUSY; #endif /* 0 */ /* detach & delete all children */ if (!device_get_children(dev, &children, &nchildren)) { for (i = 0; i < nchildren; i++) if (children[i]) device_delete_child(dev, children[i]); kfree(children, M_TEMP); } /* detroy disk from the system so we dont get any further requests */ disk_invalidate(&adp->disk); disk_destroy(&adp->disk); /* fail requests on the queue and any thats "in flight" for this device */ ata_fail_requests(dev); /* dont leave anything behind */ /* disk_destroy() already took care of the dev_ops */ devstat_remove_entry(&adp->stats); device_set_ivars(dev, NULL); kfree(adp, M_AD); return 0; }
static int mfi_syspd_detach(device_t dev) { struct mfi_system_pd *sc; sc = device_get_softc(dev); lockmgr(&sc->pd_controller->mfi_io_lock, LK_EXCLUSIVE); if ((sc->pd_flags & MFI_DISK_FLAGS_OPEN) && (sc->pd_controller->mfi_keep_deleted_volumes || sc->pd_controller->mfi_detaching)) { lockmgr(&sc->pd_controller->mfi_io_lock, LK_RELEASE); return (EBUSY); } lockmgr(&sc->pd_controller->mfi_io_lock, LK_RELEASE); disk_destroy(&sc->pd_disk); devstat_remove_entry(&sc->pd_devstat); lockmgr(&sc->pd_controller->mfi_io_lock, LK_EXCLUSIVE); TAILQ_REMOVE(&sc->pd_controller->mfi_syspd_tqh, sc, pd_link); lockmgr(&sc->pd_controller->mfi_io_lock, LK_RELEASE); kfree(sc->pd_info, M_MFIBUF); return (0); }
static void isf_disk_remove(struct isf_softc *sc) { struct disk *disk; ISF_LOCK_ASSERT(sc); KASSERT(sc->isf_disk != NULL, ("%s: isf_disk NULL", __func__)); sc->isf_doomed = 1; ISF_WAKEUP(sc); ISF_SLEEP(sc, sc->isf_proc, 0); /* * XXXRW: Is it OK to call disk_destroy() under the mutex, or should * we be deferring that to the calling context once it is released? */ disk = sc->isf_disk; disk_gone(disk); disk_destroy(disk); sc->isf_disk = NULL; free(sc->isf_bstate, M_ISF); device_printf(sc->isf_dev, "flash device removed\n"); }
static int afd_detach(device_t dev) { struct afd_softc *fdp = device_get_ivars(dev); /* check that we have a valid device to detach */ if (!device_get_ivars(dev)) return ENXIO; /* detroy disk from the system so we dont get any further requests */ disk_invalidate(&fdp->disk); disk_destroy(&fdp->disk); /* fail requests on the queue and any thats "in flight" for this device */ ata_fail_requests(dev); /* dont leave anything behind */ /* disk_destroy() already took care of the dev_ops */ devstat_remove_entry(&fdp->stats); device_set_ivars(dev, NULL); kfree(fdp, M_AFD); return 0; }
static int fss_detach(device_t self, int flags) { struct fss_softc *sc = device_private(self); if (sc->sc_flags & FSS_ACTIVE) return EBUSY; if (--fss_num_attached == 0) vfs_hooks_detach(&fss_vfs_hooks); pmf_device_deregister(self); mutex_destroy(&sc->sc_slock); mutex_destroy(&sc->sc_lock); cv_destroy(&sc->sc_work_cv); cv_destroy(&sc->sc_cache_cv); bufq_drain(sc->sc_bufq); bufq_free(sc->sc_bufq); disk_destroy(sc->sc_dkdev); free(sc->sc_dkdev, M_DEVBUF); return 0; }
static void destroy_geom_disk(struct nvd_disk *ndisk) { struct bio *bp; taskqueue_free(ndisk->tq); disk_destroy(ndisk->disk); mtx_lock(&ndisk->bioqlock); for (;;) { bp = bioq_takefirst(&ndisk->bioq); if (bp == NULL) break; bp->bio_error = EIO; bp->bio_flags |= BIO_ERROR; bp->bio_resid = bp->bio_bcount; biodone(bp); } mtx_unlock(&ndisk->bioqlock); mtx_destroy(&ndisk->bioqlock); }