mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-21 22:00:19 +00:00
rebase: bump github.com/ceph/go-ceph
Bumps [github.com/ceph/go-ceph](https://github.com/ceph/go-ceph) from 0.29.1-0.20240925141413-065319c78733 to 0.30.0. - [Release notes](https://github.com/ceph/go-ceph/releases) - [Changelog](https://github.com/ceph/go-ceph/blob/master/docs/release-process.md) - [Commits](https://github.com/ceph/go-ceph/commits/v0.30.0) --- updated-dependencies: - dependency-name: github.com/ceph/go-ceph dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
3bcf6afe30
commit
9152b4c2c7
2
go.mod
2
go.mod
@ -7,7 +7,7 @@ require (
|
||||
github.com/aws/aws-sdk-go v1.55.5
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.32.2
|
||||
github.com/ceph/ceph-csi/api v0.0.0-00010101000000-000000000000
|
||||
github.com/ceph/go-ceph v0.29.1-0.20240925141413-065319c78733
|
||||
github.com/ceph/go-ceph v0.30.0
|
||||
github.com/container-storage-interface/spec v1.10.0
|
||||
github.com/csi-addons/spec v0.2.1-0.20240730084235-3958a5b17d24
|
||||
github.com/gemalto/kmip-go v0.0.10
|
||||
|
4
go.sum
4
go.sum
@ -1445,8 +1445,8 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
|
||||
github.com/ceph/go-ceph v0.29.1-0.20240925141413-065319c78733 h1:vX8mfbKwE24CbO5t1Xc02u53pjWAsyvjgAMJk7o7nsQ=
|
||||
github.com/ceph/go-ceph v0.29.1-0.20240925141413-065319c78733/go.mod h1:OJFju/Xmtb7ihHo/aXOayw6RhVOUGNke5EwTipwaf6A=
|
||||
github.com/ceph/go-ceph v0.30.0 h1:p/+rNnn9dUByrDhXfBFilVriRZKJghMJcts8N2wQ+ws=
|
||||
github.com/ceph/go-ceph v0.30.0/go.mod h1:OJFju/Xmtb7ihHo/aXOayw6RhVOUGNke5EwTipwaf6A=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
|
35
vendor/github.com/ceph/go-ceph/cephfs/errors.go
generated
vendored
35
vendor/github.com/ceph/go-ceph/cephfs/errors.go
generated
vendored
@ -11,23 +11,8 @@ import (
|
||||
"github.com/ceph/go-ceph/internal/errutil"
|
||||
)
|
||||
|
||||
// cephFSError represents an error condition returned from the CephFS APIs.
|
||||
type cephFSError int
|
||||
|
||||
// Error returns the error string for the cephFSError type.
|
||||
func (e cephFSError) Error() string {
|
||||
return errutil.FormatErrorCode("cephfs", int(e))
|
||||
}
|
||||
|
||||
func (e cephFSError) ErrorCode() int {
|
||||
return int(e)
|
||||
}
|
||||
|
||||
func getError(e C.int) error {
|
||||
if e == 0 {
|
||||
return nil
|
||||
}
|
||||
return cephFSError(e)
|
||||
return errutil.GetError("cephfs", int(e))
|
||||
}
|
||||
|
||||
// getErrorIfNegative converts a ceph return code to error if negative.
|
||||
@ -46,22 +31,16 @@ var (
|
||||
// ErrEmptyArgument may be returned if a function argument is passed
|
||||
// a zero-length slice or map.
|
||||
ErrEmptyArgument = errors.New("Argument must contain at least one item")
|
||||
)
|
||||
|
||||
// Public CephFSErrors:
|
||||
|
||||
const (
|
||||
// ErrNotConnected may be returned when client is not connected
|
||||
// to a cluster.
|
||||
ErrNotConnected = cephFSError(-C.ENOTCONN)
|
||||
ErrNotConnected = getError(-C.ENOTCONN)
|
||||
// ErrNotExist indicates a non-specific missing resource.
|
||||
ErrNotExist = cephFSError(-C.ENOENT)
|
||||
)
|
||||
ErrNotExist = getError(-C.ENOENT)
|
||||
|
||||
// Private errors:
|
||||
// Private errors:
|
||||
|
||||
const (
|
||||
errInvalid = cephFSError(-C.EINVAL)
|
||||
errNameTooLong = cephFSError(-C.ENAMETOOLONG)
|
||||
errRange = cephFSError(-C.ERANGE)
|
||||
errInvalid = getError(-C.EINVAL)
|
||||
errNameTooLong = getError(-C.ENAMETOOLONG)
|
||||
errRange = getError(-C.ERANGE)
|
||||
)
|
||||
|
57
vendor/github.com/ceph/go-ceph/internal/errutil/error.go
generated
vendored
Normal file
57
vendor/github.com/ceph/go-ceph/internal/errutil/error.go
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
package errutil
|
||||
|
||||
type cephErrno int
|
||||
|
||||
// Error returns the error string for the errno.
|
||||
func (e cephErrno) Error() string {
|
||||
_, strerror := FormatErrno(int(e))
|
||||
return strerror
|
||||
}
|
||||
|
||||
// cephError combines the source/component that generated the error and its
|
||||
// related errno.
|
||||
type cephError struct {
|
||||
source string
|
||||
errno cephErrno
|
||||
}
|
||||
|
||||
// Error returns the error string with the source and errno.
|
||||
func (e cephError) Error() string {
|
||||
return FormatErrorCode(e.source, int(e.errno))
|
||||
}
|
||||
|
||||
// Unwrap returns an error without the source.
|
||||
func (e cephError) Unwrap() error {
|
||||
if e.errno == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return e.errno
|
||||
}
|
||||
|
||||
// Is checks if both errors have the same errno.
|
||||
func (e cephError) Is(err error) bool {
|
||||
ce, ok := err.(cephError)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
return e.errno == ce.errno
|
||||
}
|
||||
|
||||
// ErrorCode returns the errno of the error.
|
||||
func (e cephError) ErrorCode() int {
|
||||
return int(e.errno)
|
||||
}
|
||||
|
||||
// GetError returns a new error that can be compared with errors.Is(),
|
||||
// independently of the source/component of the error.
|
||||
func GetError(source string, e int) error {
|
||||
if e == 0 {
|
||||
return nil
|
||||
}
|
||||
return cephError{
|
||||
source: source,
|
||||
errno: cephErrno(int(e)),
|
||||
}
|
||||
}
|
10
vendor/github.com/ceph/go-ceph/rados/conn.go
generated
vendored
10
vendor/github.com/ceph/go-ceph/rados/conn.go
generated
vendored
@ -291,11 +291,11 @@ func (c *Conn) GetPoolByName(name string) (int64, error) {
|
||||
}
|
||||
cName := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cName))
|
||||
ret := int64(C.rados_pool_lookup(c.cluster, cName))
|
||||
ret := C.rados_pool_lookup(c.cluster, cName)
|
||||
if ret < 0 {
|
||||
return 0, radosError(ret)
|
||||
return 0, getError(C.int(ret))
|
||||
}
|
||||
return ret, nil
|
||||
return int64(ret), nil
|
||||
}
|
||||
|
||||
// GetPoolByID returns the name of a pool by a given ID.
|
||||
@ -305,9 +305,9 @@ func (c *Conn) GetPoolByID(id int64) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
cid := C.int64_t(id)
|
||||
ret := int(C.rados_pool_reverse_lookup(c.cluster, cid, (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf))))
|
||||
ret := C.rados_pool_reverse_lookup(c.cluster, cid, (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))
|
||||
if ret < 0 {
|
||||
return "", radosError(ret)
|
||||
return "", getError(ret)
|
||||
}
|
||||
return C.GoString((*C.char)(unsafe.Pointer(&buf[0]))), nil
|
||||
}
|
||||
|
96
vendor/github.com/ceph/go-ceph/rados/errors.go
generated
vendored
96
vendor/github.com/ceph/go-ceph/rados/errors.go
generated
vendored
@ -11,23 +11,46 @@ import (
|
||||
"github.com/ceph/go-ceph/internal/errutil"
|
||||
)
|
||||
|
||||
// radosError represents an error condition returned from the Ceph RADOS APIs.
|
||||
type radosError int
|
||||
// Public go errors:
|
||||
|
||||
// Error returns the error string for the radosError type.
|
||||
func (e radosError) Error() string {
|
||||
return errutil.FormatErrorCode("rados", int(e))
|
||||
}
|
||||
var (
|
||||
// ErrNotConnected is returned when functions are called
|
||||
// without a RADOS connection.
|
||||
ErrNotConnected = getError(-C.ENOTCONN)
|
||||
// ErrEmptyArgument may be returned if a function argument is passed
|
||||
// a zero-length slice or map.
|
||||
ErrEmptyArgument = errors.New("Argument must contain at least one item")
|
||||
// ErrInvalidIOContext may be returned if an api call requires an IOContext
|
||||
// but IOContext is not ready for use.
|
||||
ErrInvalidIOContext = errors.New("IOContext is not ready for use")
|
||||
// ErrOperationIncomplete is returned from write op or read op steps for
|
||||
// which the operation has not been performed yet.
|
||||
ErrOperationIncomplete = errors.New("Operation has not been performed yet")
|
||||
|
||||
func (e radosError) ErrorCode() int {
|
||||
return int(e)
|
||||
}
|
||||
// ErrNotFound indicates a missing resource.
|
||||
ErrNotFound = getError(-C.ENOENT)
|
||||
// ErrPermissionDenied indicates a permissions issue.
|
||||
ErrPermissionDenied = getError(-C.EPERM)
|
||||
// ErrObjectExists indicates that an exclusive object creation failed.
|
||||
ErrObjectExists = getError(-C.EEXIST)
|
||||
|
||||
func getError(e C.int) error {
|
||||
if e == 0 {
|
||||
return nil
|
||||
}
|
||||
return radosError(e)
|
||||
// RadosErrorNotFound indicates a missing resource.
|
||||
//
|
||||
// Deprecated: use ErrNotFound instead
|
||||
RadosErrorNotFound = ErrNotFound
|
||||
// RadosErrorPermissionDenied indicates a permissions issue.
|
||||
//
|
||||
// Deprecated: use ErrPermissionDenied instead
|
||||
RadosErrorPermissionDenied = ErrPermissionDenied
|
||||
|
||||
// Private errors:
|
||||
|
||||
errNameTooLong = getError(-C.ENAMETOOLONG)
|
||||
errRange = getError(-C.ERANGE)
|
||||
)
|
||||
|
||||
func getError(errno C.int) error {
|
||||
return errutil.GetError("rados", int(errno))
|
||||
}
|
||||
|
||||
// getErrorIfNegative converts a ceph return code to error if negative.
|
||||
@ -39,48 +62,3 @@ func getErrorIfNegative(ret C.int) error {
|
||||
}
|
||||
return getError(ret)
|
||||
}
|
||||
|
||||
// Public go errors:
|
||||
|
||||
var (
|
||||
// ErrNotConnected is returned when functions are called
|
||||
// without a RADOS connection.
|
||||
ErrNotConnected = errors.New("RADOS not connected")
|
||||
// ErrEmptyArgument may be returned if a function argument is passed
|
||||
// a zero-length slice or map.
|
||||
ErrEmptyArgument = errors.New("Argument must contain at least one item")
|
||||
// ErrInvalidIOContext may be returned if an api call requires an IOContext
|
||||
// but IOContext is not ready for use.
|
||||
ErrInvalidIOContext = errors.New("IOContext is not ready for use")
|
||||
// ErrOperationIncomplete is returned from write op or read op steps for
|
||||
// which the operation has not been performed yet.
|
||||
ErrOperationIncomplete = errors.New("Operation has not been performed yet")
|
||||
)
|
||||
|
||||
// Public radosErrors:
|
||||
|
||||
const (
|
||||
// ErrNotFound indicates a missing resource.
|
||||
ErrNotFound = radosError(-C.ENOENT)
|
||||
// ErrPermissionDenied indicates a permissions issue.
|
||||
ErrPermissionDenied = radosError(-C.EPERM)
|
||||
// ErrObjectExists indicates that an exclusive object creation failed.
|
||||
ErrObjectExists = radosError(-C.EEXIST)
|
||||
|
||||
// RadosErrorNotFound indicates a missing resource.
|
||||
//
|
||||
// Deprecated: use ErrNotFound instead
|
||||
RadosErrorNotFound = ErrNotFound
|
||||
// RadosErrorPermissionDenied indicates a permissions issue.
|
||||
//
|
||||
// Deprecated: use ErrPermissionDenied instead
|
||||
RadosErrorPermissionDenied = ErrPermissionDenied
|
||||
)
|
||||
|
||||
// Private errors:
|
||||
|
||||
const (
|
||||
errNameTooLong = radosError(-C.ENAMETOOLONG)
|
||||
|
||||
errRange = radosError(-C.ERANGE)
|
||||
)
|
||||
|
2
vendor/github.com/ceph/go-ceph/rados/ioctx.go
generated
vendored
2
vendor/github.com/ceph/go-ceph/rados/ioctx.go
generated
vendored
@ -640,7 +640,7 @@ func (ioctx *IOContext) ListLockers(oid, name string) (*LockInfo, error) {
|
||||
}
|
||||
|
||||
if ret < 0 {
|
||||
return nil, radosError(ret)
|
||||
return nil, getError(C.int(ret))
|
||||
}
|
||||
return &LockInfo{int(ret), cExclusive == 1, C.GoString(cTag), splitCString(cClients, cClientsLen), splitCString(cCookies, cCookiesLen), splitCString(cAddrs, cAddrsLen)}, nil
|
||||
}
|
||||
|
2
vendor/github.com/ceph/go-ceph/rbd/clone_image_by_id.go
generated
vendored
2
vendor/github.com/ceph/go-ceph/rbd/clone_image_by_id.go
generated
vendored
@ -52,7 +52,7 @@ var (
|
||||
func CloneImageByID(ioctx *rados.IOContext, parentName string, snapID uint64,
|
||||
destctx *rados.IOContext, name string, rio *ImageOptions) error {
|
||||
if rio == nil {
|
||||
return rbdError(C.EINVAL)
|
||||
return getError(C.EINVAL)
|
||||
}
|
||||
|
||||
rbdClone4Once.Do(func() {
|
||||
|
2
vendor/github.com/ceph/go-ceph/rbd/diff_iterate.go
generated
vendored
2
vendor/github.com/ceph/go-ceph/rbd/diff_iterate.go
generated
vendored
@ -96,7 +96,7 @@ func (image *Image) DiffIterate(config DiffIterateConfig) error {
|
||||
return err
|
||||
}
|
||||
if config.Callback == nil {
|
||||
return rbdError(C.EINVAL)
|
||||
return getError(C.EINVAL)
|
||||
}
|
||||
|
||||
var cSnapName *C.char
|
||||
|
31
vendor/github.com/ceph/go-ceph/rbd/errors.go
generated
vendored
31
vendor/github.com/ceph/go-ceph/rbd/errors.go
generated
vendored
@ -7,27 +7,17 @@ import "C"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/ceph/go-ceph/internal/errutil"
|
||||
)
|
||||
|
||||
// rbdError represents an error condition returned from the librbd APIs.
|
||||
type rbdError int
|
||||
|
||||
func (e rbdError) Error() string {
|
||||
return errutil.FormatErrorCode("rbd", int(e))
|
||||
}
|
||||
|
||||
func (e rbdError) ErrorCode() int {
|
||||
return int(e)
|
||||
}
|
||||
|
||||
func getError(err C.int) error {
|
||||
if err != 0 {
|
||||
if err == -C.ENOENT {
|
||||
return ErrNotFound
|
||||
}
|
||||
return rbdError(err)
|
||||
return errutil.GetError("rbd", int(err))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -60,7 +50,7 @@ var (
|
||||
ErrImageIsOpen = errors.New("RBD image is open")
|
||||
// ErrNotFound may be returned from an api call when the requested item is
|
||||
// missing.
|
||||
ErrNotFound = errors.New("RBD image not found")
|
||||
ErrNotFound = fmt.Errorf("RBD image not found: %w", errutil.GetError("rbd", -C.ENOENT))
|
||||
// ErrNoNamespaceName maye be returned if an api call requires a namespace
|
||||
// name and it is not provided.
|
||||
ErrNoNamespaceName = errors.New("Namespace value is missing")
|
||||
@ -69,20 +59,15 @@ var (
|
||||
RbdErrorImageNotOpen = ErrImageNotOpen
|
||||
RbdErrorNotFound = ErrNotFound
|
||||
// revive:enable:exported
|
||||
)
|
||||
|
||||
// Public general error
|
||||
const (
|
||||
// ErrExist indicates a non-specific already existing resource.
|
||||
ErrExist = rbdError(-C.EEXIST)
|
||||
ErrExist = getError(-C.EEXIST)
|
||||
// ErrNotExist indicates a non-specific missing resource.
|
||||
ErrNotExist = rbdError(-C.ENOENT)
|
||||
ErrNotExist = getError(-C.ENOENT)
|
||||
// ErrNotImplemented indicates a function is not implemented in by librbd.
|
||||
ErrNotImplemented = rbdError(-C.ENOSYS)
|
||||
)
|
||||
ErrNotImplemented = getError(-C.ENOSYS)
|
||||
|
||||
// Private errors:
|
||||
// Private errors:
|
||||
|
||||
const (
|
||||
errRange = rbdError(-C.ERANGE)
|
||||
errRange = getError(-C.ERANGE)
|
||||
)
|
||||
|
2
vendor/github.com/ceph/go-ceph/rbd/features.go
generated
vendored
2
vendor/github.com/ceph/go-ceph/rbd/features.go
generated
vendored
@ -171,7 +171,7 @@ func (image *Image) GetFeatures() (features uint64, err error) {
|
||||
}
|
||||
|
||||
if ret := C.rbd_get_features(image.image, (*C.uint64_t)(&features)); ret < 0 {
|
||||
return 0, rbdError(ret)
|
||||
return 0, getError(ret)
|
||||
}
|
||||
|
||||
return features, nil
|
||||
|
20
vendor/github.com/ceph/go-ceph/rbd/group_snap.go
generated
vendored
20
vendor/github.com/ceph/go-ceph/rbd/group_snap.go
generated
vendored
@ -91,11 +91,25 @@ const (
|
||||
GroupSnapStateComplete = GroupSnapState(C.RBD_GROUP_SNAP_STATE_COMPLETE)
|
||||
)
|
||||
|
||||
// GroupSnapInfo values are returned by GroupSnapList, representing the
|
||||
// snapshots that are part of an rbd group.
|
||||
// GroupSnap contains the information of a single snapshot that is part of a
|
||||
// group snapshot.
|
||||
type GroupSnap struct {
|
||||
Name string
|
||||
PoolID uint64
|
||||
SnapID uint64
|
||||
}
|
||||
|
||||
// GroupSnapInfo values are returned by GroupSnapList and GroupSnapGetInfo,
|
||||
// representing the group snapshots that are created of an rbd group.
|
||||
// SnapName, ID and Snapshots are only set by the GroupSnapGetInfo function.
|
||||
type GroupSnapInfo struct {
|
||||
Name string
|
||||
State GroupSnapState
|
||||
|
||||
SnapName string
|
||||
ID string
|
||||
|
||||
Snapshots []GroupSnap
|
||||
}
|
||||
|
||||
// GroupSnapList returns a slice of snapshots in a group.
|
||||
@ -190,7 +204,7 @@ func GroupSnapRollbackWithProgress(
|
||||
cb GroupSnapRollbackCallback, data interface{}) error {
|
||||
// the provided callback must be a real function
|
||||
if cb == nil {
|
||||
return rbdError(C.EINVAL)
|
||||
return getError(C.EINVAL)
|
||||
}
|
||||
|
||||
cGroupName := C.CString(group)
|
||||
|
154
vendor/github.com/ceph/go-ceph/rbd/group_snap_info.go
generated
vendored
Normal file
154
vendor/github.com/ceph/go-ceph/rbd/group_snap_info.go
generated
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
//go:build ceph_preview
|
||||
|
||||
package rbd
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -lrbd
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <rbd/librbd.h>
|
||||
|
||||
// Types and constants are copied from librbd.h with added "_" as prefix. This
|
||||
// prevents redefinition of the types on librbd versions that have them
|
||||
// already.
|
||||
|
||||
typedef enum {
|
||||
_RBD_GROUP_SNAP_NAMESPACE_TYPE_USER = 0
|
||||
} _rbd_group_snap_namespace_type_t;
|
||||
|
||||
typedef struct {
|
||||
char *image_name;
|
||||
int64_t pool_id;
|
||||
uint64_t snap_id;
|
||||
} _rbd_group_image_snap_info_t;
|
||||
|
||||
typedef struct {
|
||||
char *id;
|
||||
char *name;
|
||||
char *image_snap_name;
|
||||
rbd_group_snap_state_t state;
|
||||
_rbd_group_snap_namespace_type_t namespace_type;
|
||||
size_t image_snaps_count;
|
||||
_rbd_group_image_snap_info_t *image_snaps;
|
||||
} _rbd_group_snap_info2_t;
|
||||
|
||||
// rbd_group_snap_get_info_fn matches the rbd_group_snap_get_info function signature.
|
||||
typedef int(*rbd_group_snap_get_info_fn)(rados_ioctx_t group_p,
|
||||
const char *group_name,
|
||||
const char *snap_name,
|
||||
_rbd_group_snap_info2_t *snaps);
|
||||
|
||||
// rbd_group_snap_get_info_dlsym take *fn as rbd_group_snap_get_info_fn and
|
||||
// calls the dynamically loaded rbd_group_snap_get_info function passed as 1st
|
||||
// argument.
|
||||
static inline int rbd_group_snap_get_info_dlsym(void *fn,
|
||||
rados_ioctx_t group_p,
|
||||
const char *group_name,
|
||||
const char *snap_name,
|
||||
_rbd_group_snap_info2_t *snaps) {
|
||||
// cast function pointer fn to rbd_group_snap_get_info and call the function
|
||||
return ((rbd_group_snap_get_info_fn) fn)(group_p, group_name, snap_name, snaps);
|
||||
}
|
||||
|
||||
// rbd_group_snap_get_info_cleanup_fn matches the rbd_group_snap_get_info_cleanup function signature.
|
||||
typedef int(*rbd_group_snap_get_info_cleanup_fn)(_rbd_group_snap_info2_t *snaps);
|
||||
|
||||
// rbd_group_snap_get_info_cleanup_dlsym take *fn as rbd_group_snap_get_info_cleanup_fn and
|
||||
// calls the dynamically loaded rbd_group_snap_get_info_cleanup function passed as 1st
|
||||
// argument.
|
||||
static inline int rbd_group_snap_get_info_cleanup_dlsym(void *fn,
|
||||
_rbd_group_snap_info2_t *snaps) {
|
||||
// cast function pointer fn to rbd_group_snap_get_info_cleanup and call the function
|
||||
return ((rbd_group_snap_get_info_cleanup_fn) fn)(snaps);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"unsafe"
|
||||
|
||||
"github.com/ceph/go-ceph/internal/cutil"
|
||||
"github.com/ceph/go-ceph/internal/dlsym"
|
||||
"github.com/ceph/go-ceph/rados"
|
||||
)
|
||||
|
||||
type imgSnapInfoArray [cutil.MaxIdx]C._rbd_group_image_snap_info_t
|
||||
|
||||
var (
|
||||
rbdGroupGetSnapInfoOnce sync.Once
|
||||
rbdGroupGetSnapInfo unsafe.Pointer
|
||||
rbdGroupGetSnapInfoErr error
|
||||
|
||||
rbdGroupSnapGetInfoCleanupOnce sync.Once
|
||||
rbdGroupSnapGetInfoCleanup unsafe.Pointer
|
||||
rbdGroupSnapGetInfoCleanupErr error
|
||||
)
|
||||
|
||||
// GroupSnapGetInfo returns a slice of RBD image snapshots that are part of a
|
||||
// group snapshot.
|
||||
//
|
||||
// Implements:
|
||||
//
|
||||
// int rbd_group_snap_get_info(rados_ioctx_t group_p,
|
||||
// const char *group_name,
|
||||
// const char *snap_name,
|
||||
// rbd_group_snap_info2_t *snaps);
|
||||
func GroupSnapGetInfo(ioctx *rados.IOContext, group, snap string) (GroupSnapInfo, error) {
|
||||
rbdGroupGetSnapInfoOnce.Do(func() {
|
||||
rbdGroupGetSnapInfo, rbdGroupGetSnapInfoErr = dlsym.LookupSymbol("rbd_group_snap_get_info")
|
||||
})
|
||||
|
||||
if rbdGroupGetSnapInfoErr != nil {
|
||||
return GroupSnapInfo{}, fmt.Errorf("%w: %w", ErrNotImplemented, rbdGroupGetSnapInfoErr)
|
||||
}
|
||||
|
||||
rbdGroupSnapGetInfoCleanupOnce.Do(func() {
|
||||
rbdGroupSnapGetInfoCleanup, rbdGroupSnapGetInfoCleanupErr = dlsym.LookupSymbol("rbd_group_snap_get_info_cleanup")
|
||||
})
|
||||
|
||||
if rbdGroupSnapGetInfoCleanupErr != nil {
|
||||
return GroupSnapInfo{}, fmt.Errorf("%w: %w", ErrNotImplemented, rbdGroupSnapGetInfoCleanupErr)
|
||||
}
|
||||
|
||||
cGroupName := C.CString(group)
|
||||
defer C.free(unsafe.Pointer(cGroupName))
|
||||
cSnapName := C.CString(snap)
|
||||
defer C.free(unsafe.Pointer(cSnapName))
|
||||
|
||||
cSnapInfo := C._rbd_group_snap_info2_t{}
|
||||
|
||||
ret := C.rbd_group_snap_get_info_dlsym(
|
||||
rbdGroupGetSnapInfo,
|
||||
cephIoctx(ioctx),
|
||||
cGroupName,
|
||||
cSnapName,
|
||||
&cSnapInfo)
|
||||
err := getErrorIfNegative(ret)
|
||||
if err != nil {
|
||||
return GroupSnapInfo{}, err
|
||||
}
|
||||
|
||||
snapCount := uint64(cSnapInfo.image_snaps_count)
|
||||
|
||||
snapInfo := GroupSnapInfo{
|
||||
ID: C.GoString(cSnapInfo.id),
|
||||
Name: C.GoString(cSnapInfo.name),
|
||||
SnapName: C.GoString(cSnapInfo.image_snap_name),
|
||||
State: GroupSnapState(cSnapInfo.state),
|
||||
Snapshots: make([]GroupSnap, snapCount),
|
||||
}
|
||||
|
||||
imgSnaps := (*imgSnapInfoArray)(unsafe.Pointer(cSnapInfo.image_snaps))[0:snapCount]
|
||||
|
||||
for i, imgSnap := range imgSnaps {
|
||||
snapInfo.Snapshots[i].Name = C.GoString(imgSnap.image_name)
|
||||
snapInfo.Snapshots[i].PoolID = uint64(imgSnap.pool_id)
|
||||
snapInfo.Snapshots[i].SnapID = uint64(imgSnap.snap_id)
|
||||
}
|
||||
|
||||
// free C memory allocated by C.rbd_group_snap_get_info call
|
||||
C.rbd_group_snap_get_info_cleanup_dlsym(rbdGroupSnapGetInfoCleanup, &cSnapInfo)
|
||||
return snapInfo, nil
|
||||
}
|
4
vendor/github.com/ceph/go-ceph/rbd/metadata.go
generated
vendored
4
vendor/github.com/ceph/go-ceph/rbd/metadata.go
generated
vendored
@ -62,7 +62,7 @@ func (image *Image) SetMetadata(key string, value string) error {
|
||||
|
||||
ret := C.rbd_metadata_set(image.image, cKey, cValue)
|
||||
if ret < 0 {
|
||||
return rbdError(ret)
|
||||
return getError(ret)
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -83,7 +83,7 @@ func (image *Image) RemoveMetadata(key string) error {
|
||||
|
||||
ret := C.rbd_metadata_remove(image.image, cKey)
|
||||
if ret < 0 {
|
||||
return rbdError(ret)
|
||||
return getError(ret)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
50
vendor/github.com/ceph/go-ceph/rbd/rbd.go
generated
vendored
50
vendor/github.com/ceph/go-ceph/rbd/rbd.go
generated
vendored
@ -178,7 +178,7 @@ func Create(ioctx *rados.IOContext, name string, size uint64, order int,
|
||||
}
|
||||
|
||||
if ret < 0 {
|
||||
return nil, rbdError(ret)
|
||||
return nil, getError(ret)
|
||||
}
|
||||
|
||||
return &Image{
|
||||
@ -205,7 +205,7 @@ func Create2(ioctx *rados.IOContext, name string, size uint64, features uint64,
|
||||
ret = C.rbd_create2(cephIoctx(ioctx), cName,
|
||||
C.uint64_t(size), C.uint64_t(features), &cOrder)
|
||||
if ret < 0 {
|
||||
return nil, rbdError(ret)
|
||||
return nil, getError(ret)
|
||||
}
|
||||
|
||||
return &Image{
|
||||
@ -235,7 +235,7 @@ func Create3(ioctx *rados.IOContext, name string, size uint64, features uint64,
|
||||
C.uint64_t(size), C.uint64_t(features), &cOrder,
|
||||
C.uint64_t(stripeUnit), C.uint64_t(stripeCount))
|
||||
if ret < 0 {
|
||||
return nil, rbdError(ret)
|
||||
return nil, getError(ret)
|
||||
}
|
||||
|
||||
return &Image{
|
||||
@ -274,7 +274,7 @@ func (image *Image) Clone(snapname string, cIoctx *rados.IOContext, cName string
|
||||
C.uint64_t(features),
|
||||
&cOrder)
|
||||
if ret < 0 {
|
||||
return nil, rbdError(ret)
|
||||
return nil, getError(ret)
|
||||
}
|
||||
|
||||
return &Image{
|
||||
@ -325,9 +325,9 @@ func (image *Image) Rename(destname string) error {
|
||||
defer C.free(unsafe.Pointer(cSrcName))
|
||||
defer C.free(unsafe.Pointer(cDestName))
|
||||
|
||||
err := rbdError(C.rbd_rename(cephIoctx(image.ioctx),
|
||||
err := getError(C.rbd_rename(cephIoctx(image.ioctx),
|
||||
cSrcName, cDestName))
|
||||
if err == 0 {
|
||||
if err == nil {
|
||||
image.name = destname
|
||||
return nil
|
||||
}
|
||||
@ -385,7 +385,7 @@ func (image *Image) Close() error {
|
||||
}
|
||||
|
||||
if ret := C.rbd_close(image.image); ret != 0 {
|
||||
return rbdError(ret)
|
||||
return getError(ret)
|
||||
}
|
||||
|
||||
image.image = nil
|
||||
@ -418,7 +418,7 @@ func (image *Image) Stat() (info *ImageInfo, err error) {
|
||||
var cStat C.rbd_image_info_t
|
||||
|
||||
if ret := C.rbd_stat(image.image, &cStat, C.size_t(unsafe.Sizeof(info))); ret < 0 {
|
||||
return info, rbdError(ret)
|
||||
return info, getError(ret)
|
||||
}
|
||||
|
||||
return &ImageInfo{
|
||||
@ -443,7 +443,7 @@ func (image *Image) IsOldFormat() (bool, error) {
|
||||
ret := C.rbd_get_old_format(image.image,
|
||||
&cOldFormat)
|
||||
if ret < 0 {
|
||||
return false, rbdError(ret)
|
||||
return false, getError(ret)
|
||||
}
|
||||
|
||||
return cOldFormat != 0, nil
|
||||
@ -460,7 +460,7 @@ func (image *Image) GetSize() (size uint64, err error) {
|
||||
}
|
||||
|
||||
if ret := C.rbd_get_size(image.image, (*C.uint64_t)(&size)); ret < 0 {
|
||||
return 0, rbdError(ret)
|
||||
return 0, getError(ret)
|
||||
}
|
||||
|
||||
return size, nil
|
||||
@ -478,7 +478,7 @@ func (image *Image) GetStripeUnit() (uint64, error) {
|
||||
|
||||
var stripeUnit uint64
|
||||
if ret := C.rbd_get_stripe_unit(image.image, (*C.uint64_t)(&stripeUnit)); ret < 0 {
|
||||
return 0, rbdError(ret)
|
||||
return 0, getError(ret)
|
||||
}
|
||||
|
||||
return stripeUnit, nil
|
||||
@ -496,7 +496,7 @@ func (image *Image) GetStripeCount() (uint64, error) {
|
||||
|
||||
var stripeCount uint64
|
||||
if ret := C.rbd_get_stripe_count(image.image, (*C.uint64_t)(&stripeCount)); ret < 0 {
|
||||
return 0, rbdError(ret)
|
||||
return 0, getError(ret)
|
||||
}
|
||||
|
||||
return stripeCount, nil
|
||||
@ -514,7 +514,7 @@ func (image *Image) GetOverlap() (overlap uint64, err error) {
|
||||
}
|
||||
|
||||
if ret := C.rbd_get_overlap(image.image, (*C.uint64_t)(&overlap)); ret < 0 {
|
||||
return overlap, rbdError(ret)
|
||||
return overlap, getError(ret)
|
||||
}
|
||||
|
||||
return overlap, nil
|
||||
@ -573,7 +573,7 @@ func (image *Image) DeepCopy(ioctx *rados.IOContext, destname string, rio *Image
|
||||
return ErrNoName
|
||||
}
|
||||
if rio == nil {
|
||||
return rbdError(C.EINVAL)
|
||||
return getError(C.EINVAL)
|
||||
}
|
||||
|
||||
cDestname := C.CString(destname)
|
||||
@ -644,8 +644,8 @@ func (image *Image) ListLockers() (tag string, lockers []Locker, err error) {
|
||||
// and *0* means no locker held on rbd image.
|
||||
// but *0* is unexpected here because first rbd_list_lockers already
|
||||
// dealt with no locker case
|
||||
if int(cLockerCount) <= 0 {
|
||||
return "", nil, rbdError(cLockerCount)
|
||||
if cLockerCount <= 0 {
|
||||
return "", nil, getError(C.int(cLockerCount))
|
||||
}
|
||||
|
||||
clients := cutil.SplitSparseBuffer(clientsBuf)
|
||||
@ -754,7 +754,7 @@ func (image *Image) Read(data []byte) (int, error) {
|
||||
(*C.char)(unsafe.Pointer(&data[0]))))
|
||||
|
||||
if ret < 0 {
|
||||
return 0, rbdError(ret)
|
||||
return 0, getError(C.int(ret))
|
||||
}
|
||||
|
||||
image.offset += int64(ret)
|
||||
@ -786,7 +786,7 @@ func (image *Image) Write(data []byte) (n int, err error) {
|
||||
}
|
||||
|
||||
if ret != len(data) {
|
||||
err = rbdError(-C.EPERM)
|
||||
err = getError(-C.EPERM)
|
||||
}
|
||||
|
||||
return ret, err
|
||||
@ -825,7 +825,7 @@ func (image *Image) Discard(ofs uint64, length uint64) (int, error) {
|
||||
|
||||
ret := C.rbd_discard(image.image, C.uint64_t(ofs), C.uint64_t(length))
|
||||
if ret < 0 {
|
||||
return 0, rbdError(ret)
|
||||
return 0, getError(ret)
|
||||
}
|
||||
|
||||
return int(ret), nil
|
||||
@ -848,7 +848,7 @@ func (image *Image) ReadAt(data []byte, off int64) (int, error) {
|
||||
(*C.char)(unsafe.Pointer(&data[0]))))
|
||||
|
||||
if ret < 0 {
|
||||
return 0, rbdError(ret)
|
||||
return 0, getError(C.int(ret))
|
||||
}
|
||||
|
||||
if ret < len(data) {
|
||||
@ -872,7 +872,7 @@ func (image *Image) WriteAt(data []byte, off int64) (n int, err error) {
|
||||
C.size_t(len(data)), (*C.char)(unsafe.Pointer(&data[0]))))
|
||||
|
||||
if ret != len(data) {
|
||||
err = rbdError(-C.EPERM)
|
||||
err = getError(-C.EPERM)
|
||||
}
|
||||
|
||||
return ret, err
|
||||
@ -938,7 +938,7 @@ func (image *Image) GetSnapshotNames() (snaps []SnapInfo, err error) {
|
||||
ret := C.rbd_snap_list(image.image, nil, &cMaxSnaps)
|
||||
// bugfix index out of range(&cSnaps[0])
|
||||
if cMaxSnaps < 1 {
|
||||
return nil, rbdError(ret)
|
||||
return nil, getError(ret)
|
||||
}
|
||||
cSnaps := make([]C.rbd_snap_info_t, cMaxSnaps)
|
||||
snaps = make([]SnapInfo, cMaxSnaps)
|
||||
@ -946,7 +946,7 @@ func (image *Image) GetSnapshotNames() (snaps []SnapInfo, err error) {
|
||||
ret = C.rbd_snap_list(image.image,
|
||||
&cSnaps[0], &cMaxSnaps)
|
||||
if ret < 0 {
|
||||
return nil, rbdError(ret)
|
||||
return nil, getError(ret)
|
||||
}
|
||||
|
||||
for i, s := range cSnaps {
|
||||
@ -1253,7 +1253,7 @@ func CreateImage(ioctx *rados.IOContext, name string, size uint64, rio *ImageOpt
|
||||
return ErrNoName
|
||||
}
|
||||
if rio == nil {
|
||||
return rbdError(C.EINVAL)
|
||||
return getError(C.EINVAL)
|
||||
}
|
||||
|
||||
cName := C.CString(name)
|
||||
@ -1294,7 +1294,7 @@ func CloneImage(ioctx *rados.IOContext, parentName, snapName string,
|
||||
destctx *rados.IOContext, name string, rio *ImageOptions) error {
|
||||
|
||||
if rio == nil {
|
||||
return rbdError(C.EINVAL)
|
||||
return getError(C.EINVAL)
|
||||
}
|
||||
|
||||
cParentName := C.CString(parentName)
|
||||
|
2
vendor/github.com/ceph/go-ceph/rbd/resize.go
generated
vendored
2
vendor/github.com/ceph/go-ceph/rbd/resize.go
generated
vendored
@ -57,7 +57,7 @@ func resize2Callback(
|
||||
func (image *Image) Resize2(size uint64, allowShrink bool, cb Resize2ProgressCallback, data interface{}) error {
|
||||
// the provided callback must be a real function
|
||||
if cb == nil {
|
||||
return rbdError(C.EINVAL)
|
||||
return getError(C.EINVAL)
|
||||
}
|
||||
|
||||
if err := image.validate(imageIsOpen); err != nil {
|
||||
|
4
vendor/github.com/ceph/go-ceph/rbd/snapshot.go
generated
vendored
4
vendor/github.com/ceph/go-ceph/rbd/snapshot.go
generated
vendored
@ -33,7 +33,7 @@ func (image *Image) CreateSnapshot(snapname string) (*Snapshot, error) {
|
||||
|
||||
ret := C.rbd_snap_create(image.image, cSnapName)
|
||||
if ret < 0 {
|
||||
return nil, rbdError(ret)
|
||||
return nil, getError(ret)
|
||||
}
|
||||
|
||||
return &Snapshot{
|
||||
@ -147,7 +147,7 @@ func (snapshot *Snapshot) IsProtected() (bool, error) {
|
||||
ret := C.rbd_snap_is_protected(snapshot.image.image, cSnapName,
|
||||
&cIsProtected)
|
||||
if ret < 0 {
|
||||
return false, rbdError(ret)
|
||||
return false, getError(ret)
|
||||
}
|
||||
|
||||
return cIsProtected != 0, nil
|
||||
|
14
vendor/github.com/ceph/go-ceph/rbd/snapshot_nautilus.go
generated
vendored
14
vendor/github.com/ceph/go-ceph/rbd/snapshot_nautilus.go
generated
vendored
@ -32,7 +32,7 @@ func (image *Image) GetParentInfo(pool, name, snapname []byte) error {
|
||||
parentSnap := C.rbd_snap_spec_t{}
|
||||
ret := C.rbd_get_parent(image.image, &parentImage, &parentSnap)
|
||||
if ret != 0 {
|
||||
return rbdError(ret)
|
||||
return getError(ret)
|
||||
}
|
||||
|
||||
defer C.rbd_linked_image_spec_cleanup(&parentImage)
|
||||
@ -40,26 +40,26 @@ func (image *Image) GetParentInfo(pool, name, snapname []byte) error {
|
||||
|
||||
strlen := int(C.strlen(parentImage.pool_name))
|
||||
if len(pool) < strlen {
|
||||
return rbdError(C.ERANGE)
|
||||
return getError(C.ERANGE)
|
||||
}
|
||||
if copy(pool, C.GoString(parentImage.pool_name)) != strlen {
|
||||
return rbdError(C.ERANGE)
|
||||
return getError(C.ERANGE)
|
||||
}
|
||||
|
||||
strlen = int(C.strlen(parentImage.image_name))
|
||||
if len(name) < strlen {
|
||||
return rbdError(C.ERANGE)
|
||||
return getError(C.ERANGE)
|
||||
}
|
||||
if copy(name, C.GoString(parentImage.image_name)) != strlen {
|
||||
return rbdError(C.ERANGE)
|
||||
return getError(C.ERANGE)
|
||||
}
|
||||
|
||||
strlen = int(C.strlen(parentSnap.name))
|
||||
if len(snapname) < strlen {
|
||||
return rbdError(C.ERANGE)
|
||||
return getError(C.ERANGE)
|
||||
}
|
||||
if copy(snapname, C.GoString(parentSnap.name)) != strlen {
|
||||
return rbdError(C.ERANGE)
|
||||
return getError(C.ERANGE)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
2
vendor/github.com/ceph/go-ceph/rbd/sparsify.go
generated
vendored
2
vendor/github.com/ceph/go-ceph/rbd/sparsify.go
generated
vendored
@ -60,7 +60,7 @@ func (image *Image) SparsifyWithProgress(
|
||||
) error {
|
||||
// the provided callback must be a real function
|
||||
if cb == nil {
|
||||
return rbdError(C.EINVAL)
|
||||
return getError(C.EINVAL)
|
||||
}
|
||||
|
||||
if err := image.validate(imageIsOpen); err != nil {
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -204,7 +204,7 @@ github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs
|
||||
github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs
|
||||
github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd
|
||||
github.com/ceph/ceph-csi/api/deploy/ocp
|
||||
# github.com/ceph/go-ceph v0.29.1-0.20240925141413-065319c78733
|
||||
# github.com/ceph/go-ceph v0.30.0
|
||||
## explicit; go 1.19
|
||||
github.com/ceph/go-ceph/cephfs
|
||||
github.com/ceph/go-ceph/cephfs/admin
|
||||
|
Loading…
Reference in New Issue
Block a user