kernels/linux-2.4.0/drivers/md/lvm.c
/*
 * character device support function lock/unlock physical extend
 */
character device support function lock/unlock physical extend
character device support function lock / unlock physical extend
static int lvm_do_pe_lock_unlock(vg_t *vg_ptr, void *arg)
{
	uint p;
	if (vg_ptr == NULL) return -ENXIO;
	if (copy_from_user(&pe_lock_req, arg,
			   sizeof(pe_lock_req_t)) != 0) return -EFAULT;
	switch (pe_lock_req.lock) {
	case LOCK_PE:
		for (p = 0; p < vg_ptr->pv_max; p++) {
			if (vg_ptr->pv[p] != NULL &&
			    pe_lock_req.data.pv_dev ==
			    vg_ptr->pv[p]->pv_dev)
				break;
		}
		if (p == vg_ptr->pv_max) return -ENXIO;
		pe_lock_req.lock = UNLOCK_PE;
		fsync_dev(pe_lock_req.data.lv_dev);
		pe_lock_req.lock = LOCK_PE;
		break;
	case UNLOCK_PE:
		pe_lock_req.lock = UNLOCK_PE;
		pe_lock_req.data.lv_dev = \
		pe_lock_req.data.pv_dev = \
		pe_lock_req.data.pv_offset = 0;
		wake_up(&lvm_map_wait);
		break;
	default:
		return -EINVAL;
	}
	return 0;
}
static int lvm_do_pe_lock_unlock ( vg_t * vg_ptr , void * arg ) { uint p ; if ( vg_ptr == NULL ) return - ENXIO ; if ( copy_from_user ( & pe_lock_req , arg , sizeof ( pe_lock_req_t ) ) != 0 ) return - EFAULT ; switch ( pe_lock_req . lock ) { case LOCK_PE : for ( p = 0 ; p < vg_ptr -> pv_max ; p ++ ) { if ( vg_ptr -> pv [ p ] != NULL && pe_lock_req . data . pv_dev == vg_ptr -> pv [ p ] -> pv_dev ) break ; } if ( p == vg_ptr -> pv_max ) return - ENXIO ; pe_lock_req . lock = UNLOCK_PE ; fsync_dev ( pe_lock_req . data . lv_dev ) ; pe_lock_req . lock = LOCK_PE ; break ; case UNLOCK_PE : pe_lock_req . lock = UNLOCK_PE ; pe_lock_req . data . lv_dev = pe_lock_req . data . pv_dev = pe_lock_req . data . pv_offset = 0 ; wake_up ( & lvm_map_wait ) ; break ; default : return - EINVAL ; } return 0 ; }
character device support function lock/unlock physical extend
character device support function lock / unlock physical extend