mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
rebase: update go-ceph to latest
updating go-ceph to latest 0.29.0 release. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
dbbca6ebf8
commit
fbb9687a80
111
vendor/github.com/ceph/go-ceph/rados/read_op_exec.go
generated
vendored
Normal file
111
vendor/github.com/ceph/go-ceph/rados/read_op_exec.go
generated
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
//go:build ceph_preview
|
||||
// +build ceph_preview
|
||||
|
||||
package rados
|
||||
|
||||
// #cgo LDFLAGS: -lrados
|
||||
// #include <stdlib.h>
|
||||
// #include <rados/librados.h>
|
||||
//
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// ReadOpExecStep - step for exec operation code.
|
||||
type ReadOpExecStep struct {
|
||||
withoutFree
|
||||
|
||||
inBuffPtr *C.char
|
||||
inBuffLen C.size_t
|
||||
outBuffPtr *C.char
|
||||
outBuffLen C.size_t
|
||||
prval C.int
|
||||
canReadOutput bool
|
||||
}
|
||||
|
||||
// newExecStepOp - init new *execStepOp.
|
||||
func newReadOpExecStep(in []byte) *ReadOpExecStep {
|
||||
es := &ReadOpExecStep{
|
||||
outBuffPtr: nil,
|
||||
outBuffLen: 0,
|
||||
prval: 0,
|
||||
}
|
||||
|
||||
if len(in) > 0 {
|
||||
es.inBuffPtr = (*C.char)(unsafe.Pointer(&in[0]))
|
||||
es.inBuffLen = C.size_t(len(in))
|
||||
}
|
||||
|
||||
runtime.SetFinalizer(es, func(es *ReadOpExecStep) {
|
||||
if es != nil {
|
||||
es.freeBuffer()
|
||||
es = nil
|
||||
}
|
||||
})
|
||||
return es
|
||||
}
|
||||
|
||||
// freeBuffer - releases C allocated buffer. It is separated from es.free() because lifespan of C allocated buffer is
|
||||
// longer than lifespan of read operation.
|
||||
func (es *ReadOpExecStep) freeBuffer() {
|
||||
if es.outBuffPtr != nil {
|
||||
C.free(unsafe.Pointer(es.outBuffPtr))
|
||||
es.outBuffPtr = nil
|
||||
es.canReadOutput = false
|
||||
}
|
||||
}
|
||||
|
||||
// update - update state operation.
|
||||
func (es *ReadOpExecStep) update() error {
|
||||
err := getError(es.prval)
|
||||
es.canReadOutput = err == nil
|
||||
return err
|
||||
}
|
||||
|
||||
// Bytes returns the result of the executed command as a byte slice.
|
||||
func (es *ReadOpExecStep) Bytes() ([]byte, error) {
|
||||
if !es.canReadOutput {
|
||||
return nil, ErrOperationIncomplete
|
||||
}
|
||||
|
||||
return C.GoBytes(unsafe.Pointer(es.outBuffPtr), C.int(es.outBuffLen)), nil
|
||||
}
|
||||
|
||||
// Exec executes an OSD class method on an object.
|
||||
// See rados_exec() in the RADOS C api documentation for a general description.
|
||||
//
|
||||
// Implements:
|
||||
//
|
||||
// void rados_read_op_exec(rados_read_op_t read_op,
|
||||
// const char *cls,
|
||||
// const char *method,
|
||||
// const char *in_buf,
|
||||
// size_t in_len,
|
||||
// char **out_buf,
|
||||
// size_t *out_len,
|
||||
// int *prval);
|
||||
func (r *ReadOp) Exec(clsName, method string, in []byte) *ReadOpExecStep {
|
||||
cClsName := C.CString(clsName)
|
||||
defer C.free(unsafe.Pointer(cClsName))
|
||||
|
||||
cMethod := C.CString(method)
|
||||
defer C.free(unsafe.Pointer(cMethod))
|
||||
|
||||
es := newReadOpExecStep(in)
|
||||
r.steps = append(r.steps, es)
|
||||
C.rados_read_op_exec(
|
||||
r.op,
|
||||
cClsName,
|
||||
cMethod,
|
||||
es.inBuffPtr,
|
||||
es.inBuffLen,
|
||||
&es.outBuffPtr,
|
||||
&es.outBuffLen,
|
||||
&es.prval,
|
||||
)
|
||||
|
||||
return es
|
||||
}
|
71
vendor/github.com/ceph/go-ceph/rados/write_op_exec.go
generated
vendored
Normal file
71
vendor/github.com/ceph/go-ceph/rados/write_op_exec.go
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
//go:build ceph_preview
|
||||
// +build ceph_preview
|
||||
|
||||
package rados
|
||||
|
||||
// #cgo LDFLAGS: -lrados
|
||||
// #include <stdlib.h>
|
||||
// #include <rados/librados.h>
|
||||
//
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// writeOpExecStep - exec step in write operation.
|
||||
type writeOpExecStep struct {
|
||||
withoutFree
|
||||
|
||||
inBuffPtr *C.char
|
||||
inBuffLen C.size_t
|
||||
prval C.int
|
||||
}
|
||||
|
||||
// newWriteOpExecStep - init new *writeOpExecStep.
|
||||
func newWriteOpExecStep(in []byte) *writeOpExecStep {
|
||||
es := &writeOpExecStep{
|
||||
prval: 0,
|
||||
}
|
||||
if len(in) > 0 {
|
||||
es.inBuffPtr = (*C.char)(unsafe.Pointer(&in[0]))
|
||||
es.inBuffLen = C.size_t(len(in))
|
||||
}
|
||||
|
||||
return es
|
||||
}
|
||||
|
||||
// update - update state operation.
|
||||
func (es *writeOpExecStep) update() error {
|
||||
return getError(es.prval)
|
||||
}
|
||||
|
||||
// Exec executes an OSD class method on an object.
|
||||
// See rados_exec() in the RADOS C api documentation for a general description.
|
||||
//
|
||||
// Implements:
|
||||
//
|
||||
// void rados_write_op_exec(rados_write_op_t write_op,
|
||||
// const char *cls,
|
||||
// const char *method,
|
||||
// const char *in_buf,
|
||||
// size_t in_len,
|
||||
// int *prval)
|
||||
func (w *WriteOp) Exec(clsName, method string, in []byte) {
|
||||
cClsName := C.CString(clsName)
|
||||
defer C.free(unsafe.Pointer(cClsName))
|
||||
|
||||
cMethod := C.CString(method)
|
||||
defer C.free(unsafe.Pointer(cMethod))
|
||||
|
||||
es := newWriteOpExecStep(in)
|
||||
w.steps = append(w.steps, es)
|
||||
C.rados_write_op_exec(
|
||||
w.op,
|
||||
cClsName,
|
||||
cMethod,
|
||||
es.inBuffPtr,
|
||||
es.inBuffLen,
|
||||
&es.prval,
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user