mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
rebase: bump github.com/ceph/go-ceph from 0.11.0 to 0.12.0
Bumps [github.com/ceph/go-ceph](https://github.com/ceph/go-ceph) from 0.11.0 to 0.12.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/compare/v0.11.0...v0.12.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
fedbb01ec3
commit
a66012a5d4
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.16
|
||||
require (
|
||||
github.com/aws/aws-sdk-go v1.41.0
|
||||
github.com/ceph/ceph-csi/api v0.0.0-00010101000000-000000000000
|
||||
github.com/ceph/go-ceph v0.11.0
|
||||
github.com/ceph/go-ceph v0.12.0
|
||||
github.com/container-storage-interface/spec v1.5.0
|
||||
github.com/csi-addons/replication-lib-utils v0.2.0
|
||||
github.com/csi-addons/spec v0.1.1
|
||||
|
4
go.sum
4
go.sum
@ -161,8 +161,8 @@ github.com/cenkalti/backoff/v3 v3.0.0 h1:ske+9nBpD9qZsTBoF41nW5L+AIuFBKMeze18XQ3
|
||||
github.com/cenkalti/backoff/v3 v3.0.0/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f/go.mod h1:C0rtzmGXgN78pYR0tGJFhtHgkbAs0lIbHwkB81VxDQE=
|
||||
github.com/ceph/go-ceph v0.11.0 h1:A1pphV40LL8GQKDPpU4XqCa7gkmozsst7rhCC730/nk=
|
||||
github.com/ceph/go-ceph v0.11.0/go.mod h1:mafFpf5Vg8Ai8Bd+FAMvKBHLmtdpTXdRP/TNq8XWegY=
|
||||
github.com/ceph/go-ceph v0.12.0 h1:nlFgKQZXOFR4oMnzXsKwTr79Y6EYDwqTrpigICGy/Tw=
|
||||
github.com/ceph/go-ceph v0.12.0/go.mod h1:mafFpf5Vg8Ai8Bd+FAMvKBHLmtdpTXdRP/TNq8XWegY=
|
||||
github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
|
||||
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
|
||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
|
1
vendor/github.com/ceph/go-ceph/cephfs/admin/bytecount.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/cephfs/admin/bytecount.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
package admin
|
||||
|
1
vendor/github.com/ceph/go-ceph/cephfs/admin/clone.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/cephfs/admin/clone.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
package admin
|
||||
|
1
vendor/github.com/ceph/go-ceph/cephfs/admin/flags.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/cephfs/admin/flags.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
package admin
|
||||
|
1
vendor/github.com/ceph/go-ceph/cephfs/admin/fsadmin.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/cephfs/admin/fsadmin.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
package admin
|
||||
|
1
vendor/github.com/ceph/go-ceph/cephfs/admin/response.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/cephfs/admin/response.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
package admin
|
||||
|
1
vendor/github.com/ceph/go-ceph/cephfs/admin/subvolume.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/cephfs/admin/subvolume.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
package admin
|
||||
|
1
vendor/github.com/ceph/go-ceph/cephfs/admin/subvolumegroup.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/cephfs/admin/subvolumegroup.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
package admin
|
||||
|
1
vendor/github.com/ceph/go-ceph/cephfs/admin/timestamp.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/cephfs/admin/timestamp.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
package admin
|
||||
|
1
vendor/github.com/ceph/go-ceph/cephfs/admin/volume.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/cephfs/admin/volume.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
package admin
|
||||
|
8
vendor/github.com/ceph/go-ceph/internal/cutil/ptrguard.go
generated
vendored
8
vendor/github.com/ceph/go-ceph/internal/cutil/ptrguard.go
generated
vendored
@ -60,10 +60,10 @@ func (v *PtrGuard) Release() {
|
||||
// The uintptrPtr() helper function below assumes that uintptr has the same size
|
||||
// as a pointer, although in theory it could be larger. Therefore we use this
|
||||
// constant expression to assert size equality as a safeguard at compile time.
|
||||
// How it works: the difference of both sizes is converted into an 8 bit value
|
||||
// and left-bit-shifted by 8. This always creates an overflow error at compile
|
||||
// time, if the difference of the sizes is not 0.
|
||||
const _ = uint8(unsafe.Sizeof(uintptr(0))-PtrSize) << 8 // size assert
|
||||
// How it works: if sizes are different, either the inner or outer expression is
|
||||
// negative, which always fails with "constant ... overflows uintptr", because
|
||||
// unsafe.Sizeof() is a uintptr typed constant.
|
||||
const _ = -(unsafe.Sizeof(uintptr(0)) - PtrSize) // size assert
|
||||
func uintptrPtr(p *CPtr) *uintptr {
|
||||
return (*uintptr)(unsafe.Pointer(p))
|
||||
}
|
||||
|
1
vendor/github.com/ceph/go-ceph/internal/cutil/sync_buffer.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/internal/cutil/sync_buffer.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build ptrguard
|
||||
// +build ptrguard
|
||||
|
||||
package cutil
|
||||
|
1
vendor/github.com/ceph/go-ceph/internal/cutil/sync_buffer_memcpy.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/internal/cutil/sync_buffer_memcpy.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !ptrguard
|
||||
// +build !ptrguard
|
||||
|
||||
package cutil
|
||||
|
16
vendor/github.com/ceph/go-ceph/rados/conn.go
generated
vendored
16
vendor/github.com/ceph/go-ceph/rados/conn.go
generated
vendored
@ -14,6 +14,8 @@ import (
|
||||
|
||||
var argvPlaceholder = "placeholder"
|
||||
|
||||
//revive:disable:var-naming old-yet-exported public api
|
||||
|
||||
// ClusterStat represents Ceph cluster statistics.
|
||||
type ClusterStat struct {
|
||||
Kb uint64
|
||||
@ -22,6 +24,8 @@ type ClusterStat struct {
|
||||
Num_objects uint64
|
||||
}
|
||||
|
||||
//revive:enable:var-naming
|
||||
|
||||
// Conn is a connection handle to a Ceph cluster.
|
||||
type Conn struct {
|
||||
cluster C.rados_t
|
||||
@ -67,7 +71,7 @@ func (c *Conn) Connect() error {
|
||||
|
||||
// Shutdown disconnects from the cluster.
|
||||
func (c *Conn) Shutdown() {
|
||||
if err := c.ensure_connected(); err != nil {
|
||||
if err := c.ensureConnected(); err != nil {
|
||||
return
|
||||
}
|
||||
freeConn(c)
|
||||
@ -166,7 +170,7 @@ func (c *Conn) WaitForLatestOSDMap() error {
|
||||
return getError(ret)
|
||||
}
|
||||
|
||||
func (c *Conn) ensure_connected() error {
|
||||
func (c *Conn) ensureConnected() error {
|
||||
if c.connected {
|
||||
return nil
|
||||
}
|
||||
@ -176,7 +180,7 @@ func (c *Conn) ensure_connected() error {
|
||||
// GetClusterStats returns statistics about the cluster associated with the
|
||||
// connection.
|
||||
func (c *Conn) GetClusterStats() (stat ClusterStat, err error) {
|
||||
if err := c.ensure_connected(); err != nil {
|
||||
if err := c.ensureConnected(); err != nil {
|
||||
return ClusterStat{}, err
|
||||
}
|
||||
cStat := C.struct_rados_cluster_stat_t{}
|
||||
@ -269,7 +273,7 @@ func (c *Conn) MakePool(name string) error {
|
||||
|
||||
// DeletePool deletes a pool and all the data inside the pool.
|
||||
func (c *Conn) DeletePool(name string) error {
|
||||
if err := c.ensure_connected(); err != nil {
|
||||
if err := c.ensureConnected(); err != nil {
|
||||
return err
|
||||
}
|
||||
cName := C.CString(name)
|
||||
@ -280,7 +284,7 @@ func (c *Conn) DeletePool(name string) error {
|
||||
|
||||
// GetPoolByName returns the ID of the pool with a given name.
|
||||
func (c *Conn) GetPoolByName(name string) (int64, error) {
|
||||
if err := c.ensure_connected(); err != nil {
|
||||
if err := c.ensureConnected(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
cName := C.CString(name)
|
||||
@ -295,7 +299,7 @@ func (c *Conn) GetPoolByName(name string) (int64, error) {
|
||||
// GetPoolByID returns the name of a pool by a given ID.
|
||||
func (c *Conn) GetPoolByID(id int64) (string, error) {
|
||||
buf := make([]byte, 4096)
|
||||
if err := c.ensure_connected(); err != nil {
|
||||
if err := c.ensureConnected(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
cid := C.int64_t(id)
|
||||
|
4
vendor/github.com/ceph/go-ceph/rados/ioctx.go
generated
vendored
4
vendor/github.com/ceph/go-ceph/rados/ioctx.go
generated
vendored
@ -45,6 +45,8 @@ const (
|
||||
CreateIdempotent = C.LIBRADOS_CREATE_IDEMPOTENT
|
||||
)
|
||||
|
||||
//revive:disable:var-naming old-yet-exported public api
|
||||
|
||||
// PoolStat represents Ceph pool statistics.
|
||||
type PoolStat struct {
|
||||
// space used in bytes
|
||||
@ -69,6 +71,8 @@ type PoolStat struct {
|
||||
Num_wr_kb uint64
|
||||
}
|
||||
|
||||
//revive:enable:var-naming
|
||||
|
||||
// ObjectStat represents an object stat information
|
||||
type ObjectStat struct {
|
||||
// current length in bytes
|
||||
|
1
vendor/github.com/ceph/go-ceph/rados/ioctx_nautilus.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/rados/ioctx_nautilus.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build nautilus
|
||||
// +build nautilus
|
||||
|
||||
package rados
|
||||
|
1
vendor/github.com/ceph/go-ceph/rados/ioctx_octopus.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/rados/ioctx_octopus.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !nautilus
|
||||
// +build !nautilus
|
||||
|
||||
package rados
|
||||
|
1
vendor/github.com/ceph/go-ceph/rados/rados_nautilus.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/rados/rados_nautilus.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !mimic
|
||||
// +build !mimic
|
||||
|
||||
package rados
|
||||
|
1
vendor/github.com/ceph/go-ceph/rbd/admin/admin.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/rbd/admin/admin.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !nautilus
|
||||
// +build !nautilus
|
||||
|
||||
package admin
|
||||
|
46
vendor/github.com/ceph/go-ceph/rbd/admin/imagespec.go
generated
vendored
Normal file
46
vendor/github.com/ceph/go-ceph/rbd/admin/imagespec.go
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
//go:build !nautilus && ceph_preview
|
||||
// +build !nautilus,ceph_preview
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ImageSpec values are used to identify an RBD image wherever Ceph APIs
|
||||
// require an image_spec/image_id_spec using image name/id and optional
|
||||
// pool and namespace.
|
||||
// PREVIEW
|
||||
type ImageSpec struct {
|
||||
spec string
|
||||
}
|
||||
|
||||
// NewImageSpec is used to construct an ImageSpec given an image name/id
|
||||
// and optional namespace and pool names.
|
||||
// PREVIEW
|
||||
//
|
||||
// NewImageSpec constructs an ImageSpec to identify an RBD image and thus
|
||||
// requires image name/id, whereas NewLevelSpec constructs LevelSpec to
|
||||
// identify entire pool, pool namespace or single RBD image, all of which
|
||||
// requires pool name.
|
||||
func NewImageSpec(pool, namespace, image string) ImageSpec {
|
||||
var s string
|
||||
if pool != "" && namespace != "" {
|
||||
s = fmt.Sprintf("%s/%s/%s", pool, namespace, image)
|
||||
} else if pool != "" {
|
||||
s = fmt.Sprintf("%s/%s", pool, image)
|
||||
} else {
|
||||
s = image
|
||||
}
|
||||
return ImageSpec{s}
|
||||
}
|
||||
|
||||
// NewRawImageSpec returns a ImageSpec directly based on the spec string
|
||||
// argument without constructing it from component values.
|
||||
// PREVIEW
|
||||
//
|
||||
// This should only be used if NewImageSpec can not create the imagespec value
|
||||
// you want to pass to ceph.
|
||||
func NewRawImageSpec(spec string) ImageSpec {
|
||||
return ImageSpec{spec}
|
||||
}
|
1
vendor/github.com/ceph/go-ceph/rbd/admin/msschedule.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/rbd/admin/msschedule.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !nautilus
|
||||
// +build !nautilus
|
||||
|
||||
package admin
|
||||
|
143
vendor/github.com/ceph/go-ceph/rbd/admin/task.go
generated
vendored
Normal file
143
vendor/github.com/ceph/go-ceph/rbd/admin/task.go
generated
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
//go:build !nautilus && ceph_preview
|
||||
// +build !nautilus,ceph_preview
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
ccom "github.com/ceph/go-ceph/common/commands"
|
||||
"github.com/ceph/go-ceph/internal/commands"
|
||||
)
|
||||
|
||||
// TaskAdmin encapsulates management functions for ceph rbd task operations.
|
||||
// PREVIEW
|
||||
type TaskAdmin struct {
|
||||
conn ccom.MgrCommander
|
||||
}
|
||||
|
||||
// Task returns a TaskAdmin type for managing ceph rbd task operations.
|
||||
// PREVIEW
|
||||
func (ra *RBDAdmin) Task() *TaskAdmin {
|
||||
return &TaskAdmin{conn: ra.conn}
|
||||
}
|
||||
|
||||
// TaskRefs contains the action name and information about the image.
|
||||
// PREVIEW
|
||||
type TaskRefs struct {
|
||||
Action string `json:"action"`
|
||||
PoolName string `json:"pool_name"`
|
||||
PoolNamespace string `json:"pool_namespace"`
|
||||
ImageName string `json:"image_name"`
|
||||
ImageID string `json:"image_id"`
|
||||
}
|
||||
|
||||
// TaskResponse contains the information about the task added on an image.
|
||||
// PREVIEW
|
||||
type TaskResponse struct {
|
||||
Sequence int `json:"sequence"`
|
||||
ID string `json:"id"`
|
||||
Message string `json:"message"`
|
||||
Refs TaskRefs `json:"refs"`
|
||||
InProgress bool `json:"in_progress"`
|
||||
Progress float64 `json:"progress"`
|
||||
RetryAttempts int `json:"retry_attempts"`
|
||||
RetryTime string `json:"retry_time"`
|
||||
RetryMessage string `json:"retry_message"`
|
||||
}
|
||||
|
||||
func parseTaskResponse(res commands.Response) (TaskResponse, error) {
|
||||
var taskResponse TaskResponse
|
||||
err := res.NoStatus().Unmarshal(&taskResponse).End()
|
||||
return taskResponse, err
|
||||
}
|
||||
|
||||
func parseTaskResponseList(res commands.Response) ([]TaskResponse, error) {
|
||||
var taskResponseList []TaskResponse
|
||||
err := res.NoStatus().Unmarshal(&taskResponseList).End()
|
||||
return taskResponseList, err
|
||||
}
|
||||
|
||||
// AddFlatten adds a background task to flatten a cloned image based on the
|
||||
// supplied image spec.
|
||||
// PREVIEW
|
||||
//
|
||||
// Similar To:
|
||||
// rbd task add flatten <image_spec>
|
||||
func (ta *TaskAdmin) AddFlatten(img ImageSpec) (TaskResponse, error) {
|
||||
m := map[string]string{
|
||||
"prefix": "rbd task add flatten",
|
||||
"image_spec": img.spec,
|
||||
"format": "json",
|
||||
}
|
||||
return parseTaskResponse(commands.MarshalMgrCommand(ta.conn, m))
|
||||
}
|
||||
|
||||
// AddRemove adds a background task to remove an image based on the supplied
|
||||
// image spec.
|
||||
// PREVIEW
|
||||
//
|
||||
// Similar To:
|
||||
// rbd task add remove <image_spec>
|
||||
func (ta *TaskAdmin) AddRemove(img ImageSpec) (TaskResponse, error) {
|
||||
m := map[string]string{
|
||||
"prefix": "rbd task add remove",
|
||||
"image_spec": img.spec,
|
||||
"format": "json",
|
||||
}
|
||||
return parseTaskResponse(commands.MarshalMgrCommand(ta.conn, m))
|
||||
}
|
||||
|
||||
// AddTrashRemove adds a background task to remove an image from the trash based
|
||||
// on the supplied image id spec.
|
||||
// PREVIEW
|
||||
//
|
||||
// Similar To:
|
||||
// rbd task add trash remove <image_id_spec>
|
||||
func (ta *TaskAdmin) AddTrashRemove(img ImageSpec) (TaskResponse, error) {
|
||||
m := map[string]string{
|
||||
"prefix": "rbd task add trash remove",
|
||||
"image_id_spec": img.spec,
|
||||
"format": "json",
|
||||
}
|
||||
return parseTaskResponse(commands.MarshalMgrCommand(ta.conn, m))
|
||||
}
|
||||
|
||||
// List pending or running asynchronous tasks.
|
||||
// PREVIEW
|
||||
//
|
||||
// Similar To:
|
||||
// rbd task list
|
||||
func (ta *TaskAdmin) List() ([]TaskResponse, error) {
|
||||
m := map[string]string{
|
||||
"prefix": "rbd task list",
|
||||
"format": "json",
|
||||
}
|
||||
return parseTaskResponseList(commands.MarshalMgrCommand(ta.conn, m))
|
||||
}
|
||||
|
||||
// GetTaskByID returns pending or running asynchronous task using id.
|
||||
// PREVIEW
|
||||
//
|
||||
// Similar To:
|
||||
// rbd task list <task_id>
|
||||
func (ta *TaskAdmin) GetTaskByID(taskID string) (TaskResponse, error) {
|
||||
m := map[string]string{
|
||||
"prefix": "rbd task list",
|
||||
"task_id": taskID,
|
||||
"format": "json",
|
||||
}
|
||||
return parseTaskResponse(commands.MarshalMgrCommand(ta.conn, m))
|
||||
}
|
||||
|
||||
// Cancel a pending or running asynchronous task.
|
||||
// PREVIEW
|
||||
//
|
||||
// Similar To:
|
||||
// rbd task cancel <task_id>
|
||||
func (ta *TaskAdmin) Cancel(taskID string) (TaskResponse, error) {
|
||||
m := map[string]string{
|
||||
"prefix": "rbd task cancel",
|
||||
"task_id": taskID,
|
||||
"format": "json",
|
||||
}
|
||||
return parseTaskResponse(commands.MarshalMgrCommand(ta.conn, m))
|
||||
}
|
1
vendor/github.com/ceph/go-ceph/rbd/encryption.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/rbd/encryption.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !octopus && !nautilus
|
||||
// +build !octopus,!nautilus
|
||||
|
||||
package rbd
|
||||
|
1
vendor/github.com/ceph/go-ceph/rbd/features_nautilus.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/rbd/features_nautilus.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
package rbd
|
||||
|
22
vendor/github.com/ceph/go-ceph/rbd/metadata.go
generated
vendored
22
vendor/github.com/ceph/go-ceph/rbd/metadata.go
generated
vendored
@ -21,8 +21,8 @@ func (image *Image) GetMetadata(key string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
c_key := C.CString(key)
|
||||
defer C.free(unsafe.Pointer(c_key))
|
||||
cKey := C.CString(key)
|
||||
defer C.free(unsafe.Pointer(cKey))
|
||||
|
||||
var (
|
||||
buf []byte
|
||||
@ -34,7 +34,7 @@ func (image *Image) GetMetadata(key string) (string, error) {
|
||||
// rbd_metadata_get is a bit quirky and *does not* update the size
|
||||
// value if the size passed in >= the needed size.
|
||||
ret := C.rbd_metadata_get(
|
||||
image.image, c_key, (*C.char)(unsafe.Pointer(&buf[0])), &csize)
|
||||
image.image, cKey, (*C.char)(unsafe.Pointer(&buf[0])), &csize)
|
||||
err = getError(ret)
|
||||
return retry.Size(int(csize)).If(err == errRange)
|
||||
})
|
||||
@ -53,12 +53,12 @@ func (image *Image) SetMetadata(key string, value string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_key := C.CString(key)
|
||||
c_value := C.CString(value)
|
||||
defer C.free(unsafe.Pointer(c_key))
|
||||
defer C.free(unsafe.Pointer(c_value))
|
||||
cKey := C.CString(key)
|
||||
cValue := C.CString(value)
|
||||
defer C.free(unsafe.Pointer(cKey))
|
||||
defer C.free(unsafe.Pointer(cValue))
|
||||
|
||||
ret := C.rbd_metadata_set(image.image, c_key, c_value)
|
||||
ret := C.rbd_metadata_set(image.image, cKey, cValue)
|
||||
if ret < 0 {
|
||||
return rbdError(ret)
|
||||
}
|
||||
@ -75,10 +75,10 @@ func (image *Image) RemoveMetadata(key string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_key := C.CString(key)
|
||||
defer C.free(unsafe.Pointer(c_key))
|
||||
cKey := C.CString(key)
|
||||
defer C.free(unsafe.Pointer(cKey))
|
||||
|
||||
ret := C.rbd_metadata_remove(image.image, c_key)
|
||||
ret := C.rbd_metadata_remove(image.image, cKey)
|
||||
if ret < 0 {
|
||||
return rbdError(ret)
|
||||
}
|
||||
|
134
vendor/github.com/ceph/go-ceph/rbd/mirror.go
generated
vendored
134
vendor/github.com/ceph/go-ceph/rbd/mirror.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !nautilus
|
||||
// +build !nautilus
|
||||
|
||||
// Initially, we're only providing mirroring related functions for octopus as
|
||||
@ -746,7 +747,9 @@ func (iter *MirrorImageGlobalStatusIter) Next() (*GlobalMirrorImageIDAndStatus,
|
||||
}
|
||||
|
||||
// Close terminates iteration regardless if iteration was completed and
|
||||
// frees any associated resources. (DEPRECATED)
|
||||
// frees any associated resources.
|
||||
//
|
||||
// Deprecated: not required
|
||||
func (*MirrorImageGlobalStatusIter) Close() error {
|
||||
return nil
|
||||
}
|
||||
@ -908,3 +911,132 @@ func (iter *MirrorImageInfoIter) fetch() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MirrorImageInstanceIDItem contains an ID string for a RBD image and
|
||||
// its corresponding mirrored image's Instance ID.
|
||||
type MirrorImageInstanceIDItem struct {
|
||||
ID string
|
||||
InstanceID string
|
||||
}
|
||||
|
||||
// MirrorImageInstanceIDList returns a slice of MirrorImageInstanceIDItem. If
|
||||
// the length of the returned slice equals max, the next chunk of the list can
|
||||
// be obtained by setting start to the ID of the last item of the returned slice.
|
||||
// If max is 0 a slice of all items is returned.
|
||||
//
|
||||
// Implements:
|
||||
// int rbd_mirror_image_instance_id_list(
|
||||
// rados_ioctx_t io_ctx,
|
||||
// const char *start_id,
|
||||
// size_t max, char **image_ids,
|
||||
// char **instance_ids,
|
||||
// size_t *len)
|
||||
func MirrorImageInstanceIDList(
|
||||
ioctx *rados.IOContext, start string,
|
||||
max int) ([]MirrorImageInstanceIDItem, error) {
|
||||
var (
|
||||
result []MirrorImageInstanceIDItem
|
||||
fetchAll bool
|
||||
)
|
||||
if max <= 0 {
|
||||
max = iterBufSize
|
||||
fetchAll = true
|
||||
}
|
||||
chunk := make([]MirrorImageInstanceIDItem, max)
|
||||
for {
|
||||
length, err := mirrorImageInstanceIDList(ioctx, start, chunk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, chunk[:length]...)
|
||||
if !fetchAll || length < max {
|
||||
break
|
||||
}
|
||||
start = chunk[length-1].ID
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func mirrorImageInstanceIDList(ioctx *rados.IOContext, start string,
|
||||
results []MirrorImageInstanceIDItem) (int, error) {
|
||||
|
||||
cStart := C.CString(start)
|
||||
defer C.free(unsafe.Pointer(cStart))
|
||||
|
||||
var (
|
||||
max = C.size_t(len(results))
|
||||
length = C.size_t(0)
|
||||
ids = make([]*C.char, len(results))
|
||||
instanceIDs = make([]*C.char, len(results))
|
||||
)
|
||||
ret := C.rbd_mirror_image_instance_id_list(
|
||||
cephIoctx(ioctx),
|
||||
cStart,
|
||||
max,
|
||||
&ids[0],
|
||||
&instanceIDs[0],
|
||||
&length,
|
||||
)
|
||||
if err := getError(ret); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
for i := 0; i < int(length); i++ {
|
||||
results[i].ID = C.GoString(ids[i])
|
||||
results[i].InstanceID = C.GoString(instanceIDs[i])
|
||||
}
|
||||
C.rbd_mirror_image_instance_id_list_cleanup(
|
||||
&ids[0],
|
||||
&instanceIDs[0],
|
||||
length)
|
||||
return int(length), getError(ret)
|
||||
}
|
||||
|
||||
// MirrorImageInstanceIDIter provide methods for iterating over all
|
||||
// the MirrorImageInstanceIDItem values in a pool.
|
||||
type MirrorImageInstanceIDIter struct {
|
||||
ioctx *rados.IOContext
|
||||
|
||||
buf []MirrorImageInstanceIDItem
|
||||
lastID string
|
||||
}
|
||||
|
||||
// NewMirrorImageInstanceIDIter creates a new iterator ready for use.
|
||||
func NewMirrorImageInstanceIDIter(ioctx *rados.IOContext) *MirrorImageInstanceIDIter {
|
||||
return &MirrorImageInstanceIDIter{
|
||||
ioctx: ioctx,
|
||||
}
|
||||
}
|
||||
|
||||
// Next fetches one MirrorImageInstanceIDItem value or a nil value if iteration is
|
||||
// exhausted. The error return will be non-nil if an underlying error fetching
|
||||
// more values occurred.
|
||||
func (iter *MirrorImageInstanceIDIter) Next() (*MirrorImageInstanceIDItem, error) {
|
||||
if len(iter.buf) == 0 {
|
||||
if err := iter.fetch(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(iter.buf) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
iter.lastID = iter.buf[len(iter.buf)-1].ID
|
||||
}
|
||||
item := iter.buf[0]
|
||||
iter.buf = iter.buf[1:]
|
||||
return &item, nil
|
||||
}
|
||||
|
||||
func (iter *MirrorImageInstanceIDIter) fetch() error {
|
||||
iter.buf = nil
|
||||
items := make([]MirrorImageInstanceIDItem, iterBufSize)
|
||||
n, err := mirrorImageInstanceIDList(
|
||||
iter.ioctx,
|
||||
iter.lastID,
|
||||
items)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if n > 0 {
|
||||
iter.buf = items[:n]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
2
vendor/github.com/ceph/go-ceph/rbd/namespace_nautilus.go
generated
vendored
2
vendor/github.com/ceph/go-ceph/rbd/namespace_nautilus.go
generated
vendored
@ -1,4 +1,6 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
//
|
||||
// Ceph Nautilus is the first release that includes rbd_namespace_create(),
|
||||
// rbd_namespace_remove(), rbd_namespace_exists() and rbd_namespace_list().
|
||||
|
22
vendor/github.com/ceph/go-ceph/rbd/options.go
generated
vendored
22
vendor/github.com/ceph/go-ceph/rbd/options.go
generated
vendored
@ -120,10 +120,10 @@ func (rio *ImageOptions) Destroy() {
|
||||
// int rbd_image_options_set_string(rbd_image_options_t opts, int optname,
|
||||
// const char* optval);
|
||||
func (rio *ImageOptions) SetString(option ImageOption, value string) error {
|
||||
c_value := C.CString(value)
|
||||
defer C.free(unsafe.Pointer(c_value))
|
||||
cValue := C.CString(value)
|
||||
defer C.free(unsafe.Pointer(cValue))
|
||||
|
||||
ret := C.rbd_image_options_set_string(rio.options, C.int(option), c_value)
|
||||
ret := C.rbd_image_options_set_string(rio.options, C.int(option), cValue)
|
||||
if ret != 0 {
|
||||
return fmt.Errorf("%v, could not set option %v to \"%v\"",
|
||||
getError(ret), option, value)
|
||||
@ -156,9 +156,9 @@ func (rio *ImageOptions) GetString(option ImageOption) (string, error) {
|
||||
// int rbd_image_options_set_uint64(rbd_image_options_t opts, int optname,
|
||||
// const uint64_t optval);
|
||||
func (rio *ImageOptions) SetUint64(option ImageOption, value uint64) error {
|
||||
c_value := C.uint64_t(value)
|
||||
cValue := C.uint64_t(value)
|
||||
|
||||
ret := C.rbd_image_options_set_uint64(rio.options, C.int(option), c_value)
|
||||
ret := C.rbd_image_options_set_uint64(rio.options, C.int(option), cValue)
|
||||
if ret != 0 {
|
||||
return fmt.Errorf("%v, could not set option %v to \"%v\"",
|
||||
getError(ret), option, value)
|
||||
@ -173,14 +173,14 @@ func (rio *ImageOptions) SetUint64(option ImageOption, value uint64) error {
|
||||
// int rbd_image_options_get_uint64(rbd_image_options_t opts, int optname,
|
||||
// uint64_t* optval);
|
||||
func (rio *ImageOptions) GetUint64(option ImageOption) (uint64, error) {
|
||||
var c_value C.uint64_t
|
||||
var cValue C.uint64_t
|
||||
|
||||
ret := C.rbd_image_options_get_uint64(rio.options, C.int(option), &c_value)
|
||||
ret := C.rbd_image_options_get_uint64(rio.options, C.int(option), &cValue)
|
||||
if ret != 0 {
|
||||
return 0, fmt.Errorf("%v, could not get option %v", getError(ret), option)
|
||||
}
|
||||
|
||||
return uint64(c_value), nil
|
||||
return uint64(cValue), nil
|
||||
}
|
||||
|
||||
// IsSet returns a true if the RbdImageOption is set, false otherwise.
|
||||
@ -189,14 +189,14 @@ func (rio *ImageOptions) GetUint64(option ImageOption) (uint64, error) {
|
||||
// int rbd_image_options_is_set(rbd_image_options_t opts, int optname,
|
||||
// bool* is_set);
|
||||
func (rio *ImageOptions) IsSet(option ImageOption) (bool, error) {
|
||||
var c_set C.bool
|
||||
var cSet C.bool
|
||||
|
||||
ret := C.rbd_image_options_is_set(rio.options, C.int(option), &c_set)
|
||||
ret := C.rbd_image_options_is_set(rio.options, C.int(option), &cSet)
|
||||
if ret != 0 {
|
||||
return false, fmt.Errorf("%v, could not check option %v", getError(ret), option)
|
||||
}
|
||||
|
||||
return bool(c_set), nil
|
||||
return bool(cSet), nil
|
||||
}
|
||||
|
||||
// Unset a given RbdImageOption.
|
||||
|
1
vendor/github.com/ceph/go-ceph/rbd/options_octopus.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/rbd/options_octopus.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !nautilus
|
||||
// +build !nautilus
|
||||
|
||||
package rbd
|
||||
|
2
vendor/github.com/ceph/go-ceph/rbd/pool_nautilus.go
generated
vendored
2
vendor/github.com/ceph/go-ceph/rbd/pool_nautilus.go
generated
vendored
@ -1,4 +1,6 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
//
|
||||
// Ceph Nautilus is the first release that includes rbd_pool_metadata_get(),
|
||||
// rbd_pool_metadata_set() and rbd_pool_metadata_remove().
|
||||
|
270
vendor/github.com/ceph/go-ceph/rbd/rbd.go
generated
vendored
270
vendor/github.com/ceph/go-ceph/rbd/rbd.go
generated
vendored
@ -49,6 +49,8 @@ const (
|
||||
// Timespec is a public type for the internal C 'struct timespec'
|
||||
type Timespec ts.Timespec
|
||||
|
||||
// revive:disable:var-naming old-yet-exported public api
|
||||
|
||||
// ImageInfo represents the status information for an image.
|
||||
type ImageInfo struct {
|
||||
Size uint64
|
||||
@ -58,6 +60,8 @@ type ImageInfo struct {
|
||||
Block_name_prefix string
|
||||
}
|
||||
|
||||
// revive:enable:var-naming
|
||||
|
||||
// SnapInfo represents the status information for a snapshot.
|
||||
type SnapInfo struct {
|
||||
Id uint64
|
||||
@ -125,9 +129,9 @@ func (image *Image) validate(req uint32) error {
|
||||
|
||||
// Version returns the major, minor, and patch level of the librbd library.
|
||||
func Version() (int, int, int) {
|
||||
var c_major, c_minor, c_patch C.int
|
||||
C.rbd_version(&c_major, &c_minor, &c_patch)
|
||||
return int(c_major), int(c_minor), int(c_patch)
|
||||
var cMajor, cMinor, cPatch C.int
|
||||
C.rbd_version(&cMajor, &cMinor, &cPatch)
|
||||
return int(cMajor), int(cMinor), int(cPatch)
|
||||
}
|
||||
|
||||
// GetImage gets a reference to a previously created rbd image.
|
||||
@ -160,13 +164,13 @@ func Create(ioctx *rados.IOContext, name string, size uint64, order int,
|
||||
case 1:
|
||||
return Create2(ioctx, name, size, args[0], order)
|
||||
case 0:
|
||||
c_order := C.int(order)
|
||||
c_name := C.CString(name)
|
||||
cOrder := C.int(order)
|
||||
cName := C.CString(name)
|
||||
|
||||
defer C.free(unsafe.Pointer(c_name))
|
||||
defer C.free(unsafe.Pointer(cName))
|
||||
|
||||
ret = C.rbd_create(cephIoctx(ioctx),
|
||||
c_name, C.uint64_t(size), &c_order)
|
||||
cName, C.uint64_t(size), &cOrder)
|
||||
default:
|
||||
return nil, errors.New("Wrong number of argument")
|
||||
}
|
||||
@ -190,13 +194,13 @@ func Create2(ioctx *rados.IOContext, name string, size uint64, features uint64,
|
||||
order int) (image *Image, err error) {
|
||||
var ret C.int
|
||||
|
||||
c_order := C.int(order)
|
||||
c_name := C.CString(name)
|
||||
cOrder := C.int(order)
|
||||
cName := C.CString(name)
|
||||
|
||||
defer C.free(unsafe.Pointer(c_name))
|
||||
defer C.free(unsafe.Pointer(cName))
|
||||
|
||||
ret = C.rbd_create2(cephIoctx(ioctx), c_name,
|
||||
C.uint64_t(size), C.uint64_t(features), &c_order)
|
||||
ret = C.rbd_create2(cephIoctx(ioctx), cName,
|
||||
C.uint64_t(size), C.uint64_t(features), &cOrder)
|
||||
if ret < 0 {
|
||||
return nil, rbdError(ret)
|
||||
}
|
||||
@ -215,17 +219,17 @@ func Create2(ioctx *rados.IOContext, name string, size uint64, features uint64,
|
||||
// uint64_t features, int *order,
|
||||
// uint64_t stripe_unit, uint64_t stripe_count);
|
||||
func Create3(ioctx *rados.IOContext, name string, size uint64, features uint64,
|
||||
order int, stripe_unit uint64, stripe_count uint64) (image *Image, err error) {
|
||||
order int, stripeUnit uint64, stripeCount uint64) (image *Image, err error) {
|
||||
var ret C.int
|
||||
|
||||
c_order := C.int(order)
|
||||
c_name := C.CString(name)
|
||||
cOrder := C.int(order)
|
||||
cName := C.CString(name)
|
||||
|
||||
defer C.free(unsafe.Pointer(c_name))
|
||||
defer C.free(unsafe.Pointer(cName))
|
||||
|
||||
ret = C.rbd_create3(cephIoctx(ioctx), c_name,
|
||||
C.uint64_t(size), C.uint64_t(features), &c_order,
|
||||
C.uint64_t(stripe_unit), C.uint64_t(stripe_count))
|
||||
ret = C.rbd_create3(cephIoctx(ioctx), cName,
|
||||
C.uint64_t(size), C.uint64_t(features), &cOrder,
|
||||
C.uint64_t(stripeUnit), C.uint64_t(stripeCount))
|
||||
if ret < 0 {
|
||||
return nil, rbdError(ret)
|
||||
}
|
||||
@ -242,31 +246,35 @@ func Create3(ioctx *rados.IOContext, name string, size uint64, features uint64,
|
||||
// int rbd_clone(rados_ioctx_t p_ioctx, const char *p_name,
|
||||
// const char *p_snapname, rados_ioctx_t c_ioctx,
|
||||
// const char *c_name, uint64_t features, int *c_order);
|
||||
func (image *Image) Clone(snapname string, c_ioctx *rados.IOContext, c_name string, features uint64, order int) (*Image, error) {
|
||||
func (image *Image) Clone(snapname string, cIoctx *rados.IOContext, cName string, features uint64, order int) (*Image, error) {
|
||||
if err := image.validate(imageNeedsIOContext); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c_order := C.int(order)
|
||||
c_p_name := C.CString(image.name)
|
||||
c_p_snapname := C.CString(snapname)
|
||||
c_c_name := C.CString(c_name)
|
||||
cOrder := C.int(order)
|
||||
cParentName := C.CString(image.name)
|
||||
cParentSnapName := C.CString(snapname)
|
||||
cCloneName := C.CString(cName)
|
||||
|
||||
defer C.free(unsafe.Pointer(c_p_name))
|
||||
defer C.free(unsafe.Pointer(c_p_snapname))
|
||||
defer C.free(unsafe.Pointer(c_c_name))
|
||||
defer C.free(unsafe.Pointer(cParentName))
|
||||
defer C.free(unsafe.Pointer(cParentSnapName))
|
||||
defer C.free(unsafe.Pointer(cCloneName))
|
||||
|
||||
ret := C.rbd_clone(cephIoctx(image.ioctx),
|
||||
c_p_name, c_p_snapname,
|
||||
cephIoctx(c_ioctx),
|
||||
c_c_name, C.uint64_t(features), &c_order)
|
||||
ret := C.rbd_clone(
|
||||
cephIoctx(image.ioctx),
|
||||
cParentName,
|
||||
cParentSnapName,
|
||||
cephIoctx(cIoctx),
|
||||
cCloneName,
|
||||
C.uint64_t(features),
|
||||
&cOrder)
|
||||
if ret < 0 {
|
||||
return nil, rbdError(ret)
|
||||
}
|
||||
|
||||
return &Image{
|
||||
ioctx: c_ioctx,
|
||||
name: c_name,
|
||||
ioctx: cIoctx,
|
||||
name: cName,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -288,10 +296,10 @@ func (image *Image) Trash(delay time.Duration) error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_name := C.CString(image.name)
|
||||
defer C.free(unsafe.Pointer(c_name))
|
||||
cName := C.CString(image.name)
|
||||
defer C.free(unsafe.Pointer(cName))
|
||||
|
||||
return getError(C.rbd_trash_move(cephIoctx(image.ioctx), c_name,
|
||||
return getError(C.rbd_trash_move(cephIoctx(image.ioctx), cName,
|
||||
C.uint64_t(delay.Seconds())))
|
||||
}
|
||||
|
||||
@ -304,14 +312,14 @@ func (image *Image) Rename(destname string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_srcname := C.CString(image.name)
|
||||
c_destname := C.CString(destname)
|
||||
cSrcName := C.CString(image.name)
|
||||
cDestName := C.CString(destname)
|
||||
|
||||
defer C.free(unsafe.Pointer(c_srcname))
|
||||
defer C.free(unsafe.Pointer(c_destname))
|
||||
defer C.free(unsafe.Pointer(cSrcName))
|
||||
defer C.free(unsafe.Pointer(cDestName))
|
||||
|
||||
err := rbdError(C.rbd_rename(cephIoctx(image.ioctx),
|
||||
c_srcname, c_destname))
|
||||
cSrcName, cDestName))
|
||||
if err == 0 {
|
||||
image.name = destname
|
||||
return nil
|
||||
@ -321,9 +329,7 @@ func (image *Image) Rename(destname string) error {
|
||||
|
||||
// Open the rbd image.
|
||||
//
|
||||
// Deprecated: The Open function was provided in earlier versions of the API
|
||||
// and now exists to support older code. The use of OpenImage and
|
||||
// OpenImageReadOnly is preferred.
|
||||
// Deprecated: use OpenImage and OpenImageReadOnly instead
|
||||
func (image *Image) Open(args ...interface{}) error {
|
||||
if err := image.validate(imageNeedsIOContext | imageNeedsName); err != nil {
|
||||
return err
|
||||
@ -399,37 +405,37 @@ func (image *Image) Stat() (info *ImageInfo, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var c_stat C.rbd_image_info_t
|
||||
var cStat C.rbd_image_info_t
|
||||
|
||||
if ret := C.rbd_stat(image.image, &c_stat, C.size_t(unsafe.Sizeof(info))); ret < 0 {
|
||||
if ret := C.rbd_stat(image.image, &cStat, C.size_t(unsafe.Sizeof(info))); ret < 0 {
|
||||
return info, rbdError(ret)
|
||||
}
|
||||
|
||||
return &ImageInfo{
|
||||
Size: uint64(c_stat.size),
|
||||
Obj_size: uint64(c_stat.obj_size),
|
||||
Num_objs: uint64(c_stat.num_objs),
|
||||
Order: int(c_stat.order),
|
||||
Block_name_prefix: C.GoString((*C.char)(&c_stat.block_name_prefix[0]))}, nil
|
||||
Size: uint64(cStat.size),
|
||||
Obj_size: uint64(cStat.obj_size),
|
||||
Num_objs: uint64(cStat.num_objs),
|
||||
Order: int(cStat.order),
|
||||
Block_name_prefix: C.GoString((*C.char)(&cStat.block_name_prefix[0]))}, nil
|
||||
}
|
||||
|
||||
// IsOldFormat returns true if the rbd image uses the old format.
|
||||
//
|
||||
// Implements:
|
||||
// int rbd_get_old_format(rbd_image_t image, uint8_t *old);
|
||||
func (image *Image) IsOldFormat() (old_format bool, err error) {
|
||||
func (image *Image) IsOldFormat() (bool, error) {
|
||||
if err := image.validate(imageIsOpen); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
var c_old_format C.uint8_t
|
||||
var cOldFormat C.uint8_t
|
||||
ret := C.rbd_get_old_format(image.image,
|
||||
&c_old_format)
|
||||
&cOldFormat)
|
||||
if ret < 0 {
|
||||
return false, rbdError(ret)
|
||||
}
|
||||
|
||||
return c_old_format != 0, nil
|
||||
return cOldFormat != 0, nil
|
||||
}
|
||||
|
||||
// GetSize returns the size of the rbd image.
|
||||
@ -452,32 +458,34 @@ func (image *Image) GetSize() (size uint64, err error) {
|
||||
//
|
||||
// Implements:
|
||||
// int rbd_get_stripe_unit(rbd_image_t image, uint64_t *stripe_unit);
|
||||
func (image *Image) GetStripeUnit() (stripe_unit uint64, err error) {
|
||||
func (image *Image) GetStripeUnit() (uint64, error) {
|
||||
if err := image.validate(imageIsOpen); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if ret := C.rbd_get_stripe_unit(image.image, (*C.uint64_t)(&stripe_unit)); ret < 0 {
|
||||
var stripeUnit uint64
|
||||
if ret := C.rbd_get_stripe_unit(image.image, (*C.uint64_t)(&stripeUnit)); ret < 0 {
|
||||
return 0, rbdError(ret)
|
||||
}
|
||||
|
||||
return stripe_unit, nil
|
||||
return stripeUnit, nil
|
||||
}
|
||||
|
||||
// GetStripeCount returns the stripe-count value for the rbd image.
|
||||
//
|
||||
// Implements:
|
||||
// int rbd_get_stripe_count(rbd_image_t image, uint64_t *stripe_count);
|
||||
func (image *Image) GetStripeCount() (stripe_count uint64, err error) {
|
||||
func (image *Image) GetStripeCount() (uint64, error) {
|
||||
if err := image.validate(imageIsOpen); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if ret := C.rbd_get_stripe_count(image.image, (*C.uint64_t)(&stripe_count)); ret < 0 {
|
||||
var stripeCount uint64
|
||||
if ret := C.rbd_get_stripe_count(image.image, (*C.uint64_t)(&stripeCount)); ret < 0 {
|
||||
return 0, rbdError(ret)
|
||||
}
|
||||
|
||||
return stripe_count, nil
|
||||
return stripeCount, nil
|
||||
}
|
||||
|
||||
// GetOverlap returns the overlapping bytes between the rbd image and its
|
||||
@ -510,11 +518,11 @@ func (image *Image) Copy(ioctx *rados.IOContext, destname string) error {
|
||||
return ErrNoName
|
||||
}
|
||||
|
||||
c_destname := C.CString(destname)
|
||||
defer C.free(unsafe.Pointer(c_destname))
|
||||
cDestName := C.CString(destname)
|
||||
defer C.free(unsafe.Pointer(cDestName))
|
||||
|
||||
return getError(C.rbd_copy(image.image,
|
||||
cephIoctx(ioctx), c_destname))
|
||||
cephIoctx(ioctx), cDestName))
|
||||
}
|
||||
|
||||
// Copy2 copies one rbd image to another, using an image handle.
|
||||
@ -583,55 +591,55 @@ func (image *Image) ListLockers() (tag string, lockers []Locker, err error) {
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
var c_exclusive C.int
|
||||
var c_tag_len, c_clients_len, c_cookies_len, c_addrs_len C.size_t
|
||||
var c_locker_cnt C.ssize_t
|
||||
var cExclusive C.int
|
||||
var cTagLen, cClientsLen, cCookiesLen, cAddrsLen C.size_t
|
||||
var cLockerCount C.ssize_t
|
||||
|
||||
C.rbd_list_lockers(image.image, &c_exclusive,
|
||||
nil, (*C.size_t)(&c_tag_len),
|
||||
nil, (*C.size_t)(&c_clients_len),
|
||||
nil, (*C.size_t)(&c_cookies_len),
|
||||
nil, (*C.size_t)(&c_addrs_len))
|
||||
C.rbd_list_lockers(image.image, &cExclusive,
|
||||
nil, (*C.size_t)(&cTagLen),
|
||||
nil, (*C.size_t)(&cClientsLen),
|
||||
nil, (*C.size_t)(&cCookiesLen),
|
||||
nil, (*C.size_t)(&cAddrsLen))
|
||||
|
||||
// no locker held on rbd image when either c_clients_len,
|
||||
// c_cookies_len or c_addrs_len is *0*, so just quickly returned
|
||||
if int(c_clients_len) == 0 || int(c_cookies_len) == 0 ||
|
||||
int(c_addrs_len) == 0 {
|
||||
if int(cClientsLen) == 0 || int(cCookiesLen) == 0 ||
|
||||
int(cAddrsLen) == 0 {
|
||||
lockers = make([]Locker, 0)
|
||||
return "", lockers, nil
|
||||
}
|
||||
|
||||
tag_buf := make([]byte, c_tag_len)
|
||||
clients_buf := make([]byte, c_clients_len)
|
||||
cookies_buf := make([]byte, c_cookies_len)
|
||||
addrs_buf := make([]byte, c_addrs_len)
|
||||
tagBuf := make([]byte, cTagLen)
|
||||
clientsBuf := make([]byte, cClientsLen)
|
||||
cookiesBuf := make([]byte, cCookiesLen)
|
||||
addrsBuf := make([]byte, cAddrsLen)
|
||||
|
||||
c_locker_cnt = C.rbd_list_lockers(image.image, &c_exclusive,
|
||||
(*C.char)(unsafe.Pointer(&tag_buf[0])), (*C.size_t)(&c_tag_len),
|
||||
(*C.char)(unsafe.Pointer(&clients_buf[0])), (*C.size_t)(&c_clients_len),
|
||||
(*C.char)(unsafe.Pointer(&cookies_buf[0])), (*C.size_t)(&c_cookies_len),
|
||||
(*C.char)(unsafe.Pointer(&addrs_buf[0])), (*C.size_t)(&c_addrs_len))
|
||||
cLockerCount = C.rbd_list_lockers(image.image, &cExclusive,
|
||||
(*C.char)(unsafe.Pointer(&tagBuf[0])), (*C.size_t)(&cTagLen),
|
||||
(*C.char)(unsafe.Pointer(&clientsBuf[0])), (*C.size_t)(&cClientsLen),
|
||||
(*C.char)(unsafe.Pointer(&cookiesBuf[0])), (*C.size_t)(&cCookiesLen),
|
||||
(*C.char)(unsafe.Pointer(&addrsBuf[0])), (*C.size_t)(&cAddrsLen))
|
||||
|
||||
// rbd_list_lockers returns negative value for errors
|
||||
// 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(c_locker_cnt) <= 0 {
|
||||
return "", nil, rbdError(c_locker_cnt)
|
||||
if int(cLockerCount) <= 0 {
|
||||
return "", nil, rbdError(cLockerCount)
|
||||
}
|
||||
|
||||
clients := cutil.SplitSparseBuffer(clients_buf)
|
||||
cookies := cutil.SplitSparseBuffer(cookies_buf)
|
||||
addrs := cutil.SplitSparseBuffer(addrs_buf)
|
||||
clients := cutil.SplitSparseBuffer(clientsBuf)
|
||||
cookies := cutil.SplitSparseBuffer(cookiesBuf)
|
||||
addrs := cutil.SplitSparseBuffer(addrsBuf)
|
||||
|
||||
lockers = make([]Locker, c_locker_cnt)
|
||||
for i := 0; i < int(c_locker_cnt); i++ {
|
||||
lockers = make([]Locker, cLockerCount)
|
||||
for i := 0; i < int(cLockerCount); i++ {
|
||||
lockers[i] = Locker{Client: clients[i],
|
||||
Cookie: cookies[i],
|
||||
Addr: addrs[i]}
|
||||
}
|
||||
|
||||
return string(tag_buf), lockers, nil
|
||||
return string(tagBuf), lockers, nil
|
||||
}
|
||||
|
||||
// LockExclusive acquires an exclusive lock on the rbd image.
|
||||
@ -643,10 +651,10 @@ func (image *Image) LockExclusive(cookie string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_cookie := C.CString(cookie)
|
||||
defer C.free(unsafe.Pointer(c_cookie))
|
||||
cCookie := C.CString(cookie)
|
||||
defer C.free(unsafe.Pointer(cCookie))
|
||||
|
||||
return getError(C.rbd_lock_exclusive(image.image, c_cookie))
|
||||
return getError(C.rbd_lock_exclusive(image.image, cCookie))
|
||||
}
|
||||
|
||||
// LockShared acquires a shared lock on the rbd image.
|
||||
@ -658,12 +666,12 @@ func (image *Image) LockShared(cookie string, tag string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_cookie := C.CString(cookie)
|
||||
c_tag := C.CString(tag)
|
||||
defer C.free(unsafe.Pointer(c_cookie))
|
||||
defer C.free(unsafe.Pointer(c_tag))
|
||||
cCookie := C.CString(cookie)
|
||||
cTag := C.CString(tag)
|
||||
defer C.free(unsafe.Pointer(cCookie))
|
||||
defer C.free(unsafe.Pointer(cTag))
|
||||
|
||||
return getError(C.rbd_lock_shared(image.image, c_cookie, c_tag))
|
||||
return getError(C.rbd_lock_shared(image.image, cCookie, cTag))
|
||||
}
|
||||
|
||||
// Unlock releases a lock on the image.
|
||||
@ -675,10 +683,10 @@ func (image *Image) Unlock(cookie string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_cookie := C.CString(cookie)
|
||||
defer C.free(unsafe.Pointer(c_cookie))
|
||||
cCookie := C.CString(cookie)
|
||||
defer C.free(unsafe.Pointer(cCookie))
|
||||
|
||||
return getError(C.rbd_unlock(image.image, c_cookie))
|
||||
return getError(C.rbd_unlock(image.image, cCookie))
|
||||
}
|
||||
|
||||
// BreakLock forces the release of a lock held by another client.
|
||||
@ -690,12 +698,12 @@ func (image *Image) BreakLock(client string, cookie string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_client := C.CString(client)
|
||||
c_cookie := C.CString(cookie)
|
||||
defer C.free(unsafe.Pointer(c_client))
|
||||
defer C.free(unsafe.Pointer(c_cookie))
|
||||
cClient := C.CString(client)
|
||||
cCookie := C.CString(cookie)
|
||||
defer C.free(unsafe.Pointer(cClient))
|
||||
defer C.free(unsafe.Pointer(cCookie))
|
||||
|
||||
return getError(C.rbd_break_lock(image.image, c_client, c_cookie))
|
||||
return getError(C.rbd_break_lock(image.image, cClient, cCookie))
|
||||
}
|
||||
|
||||
// ssize_t rbd_read(rbd_image_t image, uint64_t ofs, size_t len, char *buf);
|
||||
@ -891,26 +899,26 @@ func (image *Image) GetSnapshotNames() (snaps []SnapInfo, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var c_max_snaps C.int
|
||||
var cMaxSnaps C.int
|
||||
|
||||
ret := C.rbd_snap_list(image.image, nil, &c_max_snaps)
|
||||
ret := C.rbd_snap_list(image.image, nil, &cMaxSnaps)
|
||||
|
||||
c_snaps := make([]C.rbd_snap_info_t, c_max_snaps)
|
||||
snaps = make([]SnapInfo, c_max_snaps)
|
||||
cSnaps := make([]C.rbd_snap_info_t, cMaxSnaps)
|
||||
snaps = make([]SnapInfo, cMaxSnaps)
|
||||
|
||||
ret = C.rbd_snap_list(image.image,
|
||||
&c_snaps[0], &c_max_snaps)
|
||||
&cSnaps[0], &cMaxSnaps)
|
||||
if ret < 0 {
|
||||
return nil, rbdError(ret)
|
||||
}
|
||||
|
||||
for i, s := range c_snaps {
|
||||
for i, s := range cSnaps {
|
||||
snaps[i] = SnapInfo{Id: uint64(s.id),
|
||||
Size: uint64(s.size),
|
||||
Name: C.GoString(s.name)}
|
||||
}
|
||||
|
||||
C.rbd_snap_list_end(&c_snaps[0])
|
||||
C.rbd_snap_list_end(&cSnaps[0])
|
||||
return snaps[:len(snaps)-1], nil
|
||||
}
|
||||
|
||||
@ -953,10 +961,10 @@ func (image *Image) SetSnapshot(snapname string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_snapname := C.CString(snapname)
|
||||
defer C.free(unsafe.Pointer(c_snapname))
|
||||
cSnapName := C.CString(snapname)
|
||||
defer C.free(unsafe.Pointer(cSnapName))
|
||||
|
||||
return getError(C.rbd_snap_set(image.image, c_snapname))
|
||||
return getError(C.rbd_snap_set(image.image, cSnapName))
|
||||
}
|
||||
|
||||
// GetTrashList returns a slice of TrashInfo structs, containing information about all RBD images
|
||||
@ -994,21 +1002,21 @@ func GetTrashList(ioctx *rados.IOContext) ([]TrashInfo, error) {
|
||||
|
||||
// TrashRemove permanently deletes the trashed RBD with the specified id.
|
||||
func TrashRemove(ioctx *rados.IOContext, id string, force bool) error {
|
||||
c_id := C.CString(id)
|
||||
defer C.free(unsafe.Pointer(c_id))
|
||||
cid := C.CString(id)
|
||||
defer C.free(unsafe.Pointer(cid))
|
||||
|
||||
return getError(C.rbd_trash_remove(cephIoctx(ioctx), c_id, C.bool(force)))
|
||||
return getError(C.rbd_trash_remove(cephIoctx(ioctx), cid, C.bool(force)))
|
||||
}
|
||||
|
||||
// TrashRestore restores the trashed RBD with the specified id back to the pool from whence it
|
||||
// came, with the specified new name.
|
||||
func TrashRestore(ioctx *rados.IOContext, id, name string) error {
|
||||
c_id := C.CString(id)
|
||||
c_name := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(c_id))
|
||||
defer C.free(unsafe.Pointer(c_name))
|
||||
cid := C.CString(id)
|
||||
cName := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cid))
|
||||
defer C.free(unsafe.Pointer(cName))
|
||||
|
||||
return getError(C.rbd_trash_restore(cephIoctx(ioctx), c_id, c_name))
|
||||
return getError(C.rbd_trash_restore(cephIoctx(ioctx), cid, cName))
|
||||
}
|
||||
|
||||
// OpenImage will open an existing rbd image by name and snapshot name,
|
||||
@ -1199,10 +1207,10 @@ func CreateImage(ioctx *rados.IOContext, name string, size uint64, rio *ImageOpt
|
||||
return rbdError(C.EINVAL)
|
||||
}
|
||||
|
||||
c_name := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(c_name))
|
||||
cName := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cName))
|
||||
|
||||
ret := C.rbd_create4(cephIoctx(ioctx), c_name,
|
||||
ret := C.rbd_create4(cephIoctx(ioctx), cName,
|
||||
C.uint64_t(size), C.rbd_image_options_t(rio.options))
|
||||
return getError(ret)
|
||||
}
|
||||
@ -1219,9 +1227,9 @@ func RemoveImage(ioctx *rados.IOContext, name string) error {
|
||||
return ErrNoName
|
||||
}
|
||||
|
||||
c_name := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(c_name))
|
||||
return getError(C.rbd_remove(cephIoctx(ioctx), c_name))
|
||||
cName := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cName))
|
||||
return getError(C.rbd_remove(cephIoctx(ioctx), cName))
|
||||
}
|
||||
|
||||
// CloneImage creates a clone of the image from the named snapshot in the
|
||||
|
2
vendor/github.com/ceph/go-ceph/rbd/rbd_nautilus.go
generated
vendored
2
vendor/github.com/ceph/go-ceph/rbd/rbd_nautilus.go
generated
vendored
@ -1,4 +1,6 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
//
|
||||
// Ceph Nautilus is the first release that includes rbd_list2() and
|
||||
// rbd_get_create_timestamp().
|
||||
|
49
vendor/github.com/ceph/go-ceph/rbd/snapshot.go
generated
vendored
49
vendor/github.com/ceph/go-ceph/rbd/snapshot.go
generated
vendored
@ -27,10 +27,10 @@ func (image *Image) CreateSnapshot(snapname string) (*Snapshot, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c_snapname := C.CString(snapname)
|
||||
defer C.free(unsafe.Pointer(c_snapname))
|
||||
cSnapName := C.CString(snapname)
|
||||
defer C.free(unsafe.Pointer(cSnapName))
|
||||
|
||||
ret := C.rbd_snap_create(image.image, c_snapname)
|
||||
ret := C.rbd_snap_create(image.image, cSnapName)
|
||||
if ret < 0 {
|
||||
return nil, rbdError(ret)
|
||||
}
|
||||
@ -72,10 +72,10 @@ func (snapshot *Snapshot) Remove() error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_snapname := C.CString(snapshot.name)
|
||||
defer C.free(unsafe.Pointer(c_snapname))
|
||||
cSnapName := C.CString(snapshot.name)
|
||||
defer C.free(unsafe.Pointer(cSnapName))
|
||||
|
||||
return getError(C.rbd_snap_remove(snapshot.image.image, c_snapname))
|
||||
return getError(C.rbd_snap_remove(snapshot.image.image, cSnapName))
|
||||
}
|
||||
|
||||
// Rollback the image to the snapshot.
|
||||
@ -87,10 +87,10 @@ func (snapshot *Snapshot) Rollback() error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_snapname := C.CString(snapshot.name)
|
||||
defer C.free(unsafe.Pointer(c_snapname))
|
||||
cSnapName := C.CString(snapshot.name)
|
||||
defer C.free(unsafe.Pointer(cSnapName))
|
||||
|
||||
return getError(C.rbd_snap_rollback(snapshot.image.image, c_snapname))
|
||||
return getError(C.rbd_snap_rollback(snapshot.image.image, cSnapName))
|
||||
}
|
||||
|
||||
// Protect a snapshot from unwanted deletion.
|
||||
@ -102,10 +102,10 @@ func (snapshot *Snapshot) Protect() error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_snapname := C.CString(snapshot.name)
|
||||
defer C.free(unsafe.Pointer(c_snapname))
|
||||
cSnapName := C.CString(snapshot.name)
|
||||
defer C.free(unsafe.Pointer(cSnapName))
|
||||
|
||||
return getError(C.rbd_snap_protect(snapshot.image.image, c_snapname))
|
||||
return getError(C.rbd_snap_protect(snapshot.image.image, cSnapName))
|
||||
}
|
||||
|
||||
// Unprotect stops protecting the snapshot.
|
||||
@ -117,10 +117,10 @@ func (snapshot *Snapshot) Unprotect() error {
|
||||
return err
|
||||
}
|
||||
|
||||
c_snapname := C.CString(snapshot.name)
|
||||
defer C.free(unsafe.Pointer(c_snapname))
|
||||
cSnapName := C.CString(snapshot.name)
|
||||
defer C.free(unsafe.Pointer(cSnapName))
|
||||
|
||||
return getError(C.rbd_snap_unprotect(snapshot.image.image, c_snapname))
|
||||
return getError(C.rbd_snap_unprotect(snapshot.image.image, cSnapName))
|
||||
}
|
||||
|
||||
// IsProtected returns true if the snapshot is currently protected.
|
||||
@ -133,23 +133,24 @@ func (snapshot *Snapshot) IsProtected() (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
var c_is_protected C.int
|
||||
var cIsProtected C.int
|
||||
|
||||
c_snapname := C.CString(snapshot.name)
|
||||
defer C.free(unsafe.Pointer(c_snapname))
|
||||
cSnapName := C.CString(snapshot.name)
|
||||
defer C.free(unsafe.Pointer(cSnapName))
|
||||
|
||||
ret := C.rbd_snap_is_protected(snapshot.image.image, c_snapname,
|
||||
&c_is_protected)
|
||||
ret := C.rbd_snap_is_protected(snapshot.image.image, cSnapName,
|
||||
&cIsProtected)
|
||||
if ret < 0 {
|
||||
return false, rbdError(ret)
|
||||
}
|
||||
|
||||
return c_is_protected != 0, nil
|
||||
return cIsProtected != 0, nil
|
||||
}
|
||||
|
||||
// Set updates the rbd image (not the Snapshot) such that the snapshot
|
||||
// is the source of readable data.
|
||||
// This method is deprecated. Refer the SetSnapshot method of the Image type instead.
|
||||
// Set updates the rbd image (not the Snapshot) such that the snapshot is the
|
||||
// source of readable data.
|
||||
//
|
||||
// Deprecated: use the SetSnapshot method of the Image type instead
|
||||
//
|
||||
// Implements:
|
||||
// int rbd_snap_set(rbd_image_t image, const char *snapname);
|
||||
|
2
vendor/github.com/ceph/go-ceph/rbd/snapshot_namespace.go
generated
vendored
2
vendor/github.com/ceph/go-ceph/rbd/snapshot_namespace.go
generated
vendored
@ -1,4 +1,6 @@
|
||||
//go:build !luminous
|
||||
// +build !luminous
|
||||
|
||||
//
|
||||
// Ceph Mimic introduced rbd_snap_get_namespace_type().
|
||||
|
||||
|
2
vendor/github.com/ceph/go-ceph/rbd/snapshot_nautilus.go
generated
vendored
2
vendor/github.com/ceph/go-ceph/rbd/snapshot_nautilus.go
generated
vendored
@ -1,4 +1,6 @@
|
||||
//go:build !luminous && !mimic
|
||||
// +build !luminous,!mimic
|
||||
|
||||
//
|
||||
// Ceph Nautilus introduced rbd_get_parent() and deprecated rbd_get_parent_info().
|
||||
// Ceph Nautilus introduced rbd_list_children3() and deprecated rbd_list_children().
|
||||
|
1
vendor/github.com/ceph/go-ceph/rbd/snapshot_octopus.go
generated
vendored
1
vendor/github.com/ceph/go-ceph/rbd/snapshot_octopus.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !nautilus
|
||||
// +build !nautilus
|
||||
|
||||
package rbd
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -53,7 +53,7 @@ github.com/cenkalti/backoff/v3
|
||||
## explicit
|
||||
github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd
|
||||
github.com/ceph/ceph-csi/api/deploy/ocp
|
||||
# github.com/ceph/go-ceph v0.11.0
|
||||
# github.com/ceph/go-ceph v0.12.0
|
||||
## explicit
|
||||
github.com/ceph/go-ceph/cephfs/admin
|
||||
github.com/ceph/go-ceph/common/commands
|
||||
|
Loading…
Reference in New Issue
Block a user