FreeBSD/sys/dev/xen/blkback/blkback.c
/*--------------------------- Backend Configuration --------------------------*/
/**
 * Close and cleanup any backend device/file specific state for this
 * block back instance. 
 *
 * \param xbb  Per-instance xbb configuration structure.
 */
Backend Configuration
Close and cleanup any backend device/file specific state for this
block back instance.

\param xbb  Per-instance xbb configuration structure.
Backend Configuration Close and cleanup any backend device / file specific state for this block back instance . \ param xbb Per - instance xbb configuration structure .
static void
xbb_close_backend(struct xbb_softc *xbb)
{
	DROP_GIANT();
	DPRINTF("closing dev=%s\n", xbb->dev_name);
	if (xbb->vn) {
		int flags = FREAD;
		if ((xbb->flags & XBBF_READ_ONLY) == 0)
			flags |= FWRITE;
		switch (xbb->device_type) {
		case XBB_TYPE_DISK:
			if (xbb->backend.dev.csw) {
				dev_relthread(xbb->backend.dev.cdev,
					      xbb->backend.dev.dev_ref);
				xbb->backend.dev.csw  = NULL;
				xbb->backend.dev.cdev = NULL;
			}
			break;
		case XBB_TYPE_FILE:
			break;
		case XBB_TYPE_NONE:
		default:
			panic("Unexpected backend type.");
			break;
		}
		(void)vn_close(xbb->vn, flags, NOCRED, curthread);
		xbb->vn = NULL;
		switch (xbb->device_type) {
		case XBB_TYPE_DISK:
			break;
		case XBB_TYPE_FILE:
			if (xbb->backend.file.cred != NULL) {
				crfree(xbb->backend.file.cred);
				xbb->backend.file.cred = NULL;
			}
			break;
		case XBB_TYPE_NONE:
		default:
			panic("Unexpected backend type.");
			break;
		}
	}
	PICKUP_GIANT();
}
static void xbb_close_backend ( struct xbb_softc * xbb ) { DROP_GIANT ( ) ; DPRINTF ( " \n " , xbb -> dev_name ) ; if ( xbb -> vn ) { int flags = FREAD ; if ( ( xbb -> flags & XBBF_READ_ONLY ) == 0 ) flags |= FWRITE ; switch ( xbb -> device_type ) { case XBB_TYPE_DISK : if ( xbb -> backend . dev . csw ) { dev_relthread ( xbb -> backend . dev . cdev , xbb -> backend . dev . dev_ref ) ; xbb -> backend . dev . csw = NULL ; xbb -> backend . dev . cdev = NULL ; } break ; case XBB_TYPE_FILE : break ; case XBB_TYPE_NONE : default : panic ( " " ) ; break ; } ( void ) vn_close ( xbb -> vn , flags , NOCRED , curthread ) ; xbb -> vn = NULL ; switch ( xbb -> device_type ) { case XBB_TYPE_DISK : break ; case XBB_TYPE_FILE : if ( xbb -> backend . file . cred != NULL ) { crfree ( xbb -> backend . file . cred ) ; xbb -> backend . file . cred = NULL ; } break ; case XBB_TYPE_NONE : default : panic ( " " ) ; break ; } } PICKUP_GIANT ( ) ; }
Backend Configuration
 Close and cleanup any backend device/file specific state for this
 block back instance.
Backend Configuration Close and cleanup any backend device / file specific state for this block back instance .