Ejemplo n.º 1
0
//Unlocks the segment for the StorageProvider to give to other consumers
//Implies a flush
func (seg *CephSegment) Unlock() {
	seg.flushWrite()
	_, err := C.handle_close(seg.h)
	if err != nil {
		log.Panic("CGO ERROR: %v", err)
	}
	seg.warrs = nil
	if (seg.naddr & OFFSET_MASK) < WORTH_CACHING {
		seg.sp.segcachelock.Lock()
		seg.sp.pruneSegCache()
		seg.sp.segaddrcache[seg.uid] = seg.naddr
		seg.sp.segcachelock.Unlock()
	}

}
Ejemplo n.º 2
0
//Called to create the database for the first time
func (sp *CephStorageProvider) CreateDatabase(opts map[string]string) error {
	cephconf := C.CString(opts["cephconf"])
	cephpool := C.CString(opts["cephpool"])
	_, err := C.initialize_provider(cephconf, cephpool)
	if err != nil {
		log.Panic("CGO ERROR: %v", err)
	}
	C.free(unsafe.Pointer(cephconf))
	C.free(unsafe.Pointer(cephpool))
	h, err := C.handle_create()
	if err != nil {
		log.Panic("CGO ERROR: %v", err)
	}
	C.handle_init_allocator(h)
	_, err = C.handle_close(h)
	if err != nil {
		log.Panic("CGO ERROR: %v", err)
	}
	return nil
}