diff --git a/go.mod b/go.mod index 144b93c90..2a022ddf8 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/aws/aws-sdk-go v1.55.6 github.com/aws/aws-sdk-go-v2/service/sts v1.33.14 github.com/ceph/ceph-csi/api v0.0.0-00010101000000-000000000000 - github.com/ceph/go-ceph v0.31.0 + github.com/ceph/go-ceph v0.32.0 github.com/container-storage-interface/spec v1.11.0 github.com/csi-addons/spec v0.2.1-0.20241104111131-27825f744db5 github.com/gemalto/kmip-go v0.0.10 diff --git a/go.sum b/go.sum index 0327bf9ba..390ee48f4 100644 --- a/go.sum +++ b/go.sum @@ -1451,8 +1451,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.31.0 h1:3yqMVsRN89VyMhJ+qiF91mQHw4RBjbWVVERGX7bYxkk= -github.com/ceph/go-ceph v0.31.0/go.mod h1:VnMYp08oE2o2of29p/oGkxnM8VNF/+LJyVQ5pZSj3Wg= +github.com/ceph/go-ceph v0.32.0 h1:iXRUGdPmH7h9Vf/WA1Dg3Wo1tgL7gcUbylfpbxrlGLs= +github.com/ceph/go-ceph v0.32.0/go.mod h1:42eoJzyLS3VREzqrg2ot44NtuluQZi55hFRSoLF36GQ= 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= diff --git a/vendor/github.com/ceph/go-ceph/internal/retry/sizer.go b/vendor/github.com/ceph/go-ceph/internal/retry/sizer.go index 5b27e5103..df427cf03 100644 --- a/vendor/github.com/ceph/go-ceph/internal/retry/sizer.go +++ b/vendor/github.com/ceph/go-ceph/internal/retry/sizer.go @@ -43,13 +43,13 @@ type SizeFunc func(size int) (hint Hint) // DoubleSize or indicating a size not greater than the current size, the size // is doubled. If the hint or next size is greater than the max size, the max // size is used for a last retry. -func WithSizes(size int, max int, f SizeFunc) { - if size > max { +func WithSizes(size int, maxSize int, f SizeFunc) { + if size > maxSize { return } for { hint := f(size) - if hint == nil || size == max { + if hint == nil || size == maxSize { break } if hint.size() > size { @@ -57,8 +57,8 @@ func WithSizes(size int, max int, f SizeFunc) { } else { size *= 2 } - if size > max { - size = max + if size > maxSize { + size = maxSize } } } diff --git a/vendor/github.com/ceph/go-ceph/rbd/encryption.go b/vendor/github.com/ceph/go-ceph/rbd/encryption.go index a0ddfea9d..1fede749d 100644 --- a/vendor/github.com/ceph/go-ceph/rbd/encryption.go +++ b/vendor/github.com/ceph/go-ceph/rbd/encryption.go @@ -64,7 +64,7 @@ func (opts EncryptionOptionsLUKS1) allocateEncryptionOptions() cEncryptionData { var cOpts C.rbd_encryption_luks1_format_options_t var retData cEncryptionData cOpts.alg = C.rbd_encryption_algorithm_t(opts.Alg) - //CBytes allocates memory which we'll free by calling cOptsFree() + // CBytes allocates memory. it will be freed when cEncryptionData.free is called cOpts.passphrase = (*C.char)(C.CBytes(opts.Passphrase)) cOpts.passphrase_size = C.size_t(len(opts.Passphrase)) retData.opts = C.rbd_encryption_options_t(&cOpts) @@ -78,7 +78,7 @@ func (opts EncryptionOptionsLUKS2) allocateEncryptionOptions() cEncryptionData { var cOpts C.rbd_encryption_luks2_format_options_t var retData cEncryptionData cOpts.alg = C.rbd_encryption_algorithm_t(opts.Alg) - //CBytes allocates memory which we'll free by calling cOptsFree() + // CBytes allocates memory. it will be freed when cEncryptionData.free is called cOpts.passphrase = (*C.char)(C.CBytes(opts.Passphrase)) cOpts.passphrase_size = C.size_t(len(opts.Passphrase)) retData.opts = C.rbd_encryption_options_t(&cOpts) diff --git a/vendor/github.com/ceph/go-ceph/rbd/encryption_load2.go b/vendor/github.com/ceph/go-ceph/rbd/encryption_load2.go new file mode 100644 index 000000000..81f6f3e4f --- /dev/null +++ b/vendor/github.com/ceph/go-ceph/rbd/encryption_load2.go @@ -0,0 +1,105 @@ +//go:build !octopus && !pacific && !quincy && ceph_preview + +package rbd + +// #cgo LDFLAGS: -lrbd +// /* force XSI-complaint strerror_r() */ +// #define _POSIX_C_SOURCE 200112L +// #undef _GNU_SOURCE +// #include +// #include +// #include +import "C" + +import ( + "unsafe" +) + +type encryptionOptions2 interface { + EncryptionOptions + writeEncryptionSpec(spec *C.rbd_encryption_spec_t) func() +} + +func (opts EncryptionOptionsLUKS1) writeEncryptionSpec(spec *C.rbd_encryption_spec_t) func() { + /* only C memory should be attached to spec */ + cPassphrase := (*C.char)(C.CBytes(opts.Passphrase)) + cOptsSize := C.size_t(C.sizeof_rbd_encryption_luks1_format_options_t) + cOpts := (*C.rbd_encryption_luks1_format_options_t)(C.malloc(cOptsSize)) + cOpts.alg = C.rbd_encryption_algorithm_t(opts.Alg) + cOpts.passphrase = cPassphrase + cOpts.passphrase_size = C.size_t(len(opts.Passphrase)) + + spec.format = C.RBD_ENCRYPTION_FORMAT_LUKS1 + spec.opts = C.rbd_encryption_options_t(cOpts) + spec.opts_size = cOptsSize + return func() { + C.free(unsafe.Pointer(cOpts.passphrase)) + C.free(unsafe.Pointer(cOpts)) + } +} + +func (opts EncryptionOptionsLUKS2) writeEncryptionSpec(spec *C.rbd_encryption_spec_t) func() { + /* only C memory should be attached to spec */ + cPassphrase := (*C.char)(C.CBytes(opts.Passphrase)) + cOptsSize := C.size_t(C.sizeof_rbd_encryption_luks2_format_options_t) + cOpts := (*C.rbd_encryption_luks2_format_options_t)(C.malloc(cOptsSize)) + cOpts.alg = C.rbd_encryption_algorithm_t(opts.Alg) + cOpts.passphrase = cPassphrase + cOpts.passphrase_size = C.size_t(len(opts.Passphrase)) + + spec.format = C.RBD_ENCRYPTION_FORMAT_LUKS2 + spec.opts = C.rbd_encryption_options_t(cOpts) + spec.opts_size = cOptsSize + return func() { + C.free(unsafe.Pointer(cOpts.passphrase)) + C.free(unsafe.Pointer(cOpts)) + } +} + +// EncryptionLoad2 enables IO on an open encrypted image. Multiple encryption +// option values can be passed to this call in a slice. For more information +// about how items in the slice are applied to images, and possibly ancestor +// images refer to the documentation in the C api for rbd_encryption_load2. +// +// Implements: +// +// int rbd_encryption_load2(rbd_image_t image, +// const rbd_encryption_spec_t *specs, +// size_t spec_count); +func (image *Image) EncryptionLoad2(opts []EncryptionOptions) error { + if image.image == nil { + return ErrImageNotOpen + } + for _, o := range opts { + if _, ok := o.(encryptionOptions2); !ok { + // this should not happen unless someone adds a new type + // implementing EncryptionOptions but fails to add a + // writeEncryptionSpec such that the type is not also implementing + // encryptionOptions2. + return getError(C.EINVAL) + } + } + + length := len(opts) + cspecs := (*C.rbd_encryption_spec_t)(C.malloc( + C.size_t(C.sizeof_rbd_encryption_spec_t * length))) + specs := unsafe.Slice(cspecs, length) + freeFuncs := make([]func(), length) + + for idx, option := range opts { + f := option.(encryptionOptions2).writeEncryptionSpec(&specs[idx]) + freeFuncs[idx] = f + } + defer func() { + for _, f := range freeFuncs { + f() + } + C.free(unsafe.Pointer(cspecs)) + }() + + ret := C.rbd_encryption_load2( + image.image, + cspecs, + C.size_t(length)) + return getError(ret) +} diff --git a/vendor/github.com/ceph/go-ceph/rbd/encryption_opt_luks.go b/vendor/github.com/ceph/go-ceph/rbd/encryption_opt_luks.go new file mode 100644 index 000000000..bfacdde54 --- /dev/null +++ b/vendor/github.com/ceph/go-ceph/rbd/encryption_opt_luks.go @@ -0,0 +1,51 @@ +//go:build !octopus && !pacific && !quincy && ceph_preview + +package rbd + +// #cgo LDFLAGS: -lrbd +// /* force XSI-complaint strerror_r() */ +// #define _POSIX_C_SOURCE 200112L +// #undef _GNU_SOURCE +// #include +// #include +import "C" + +import ( + "unsafe" +) + +// EncryptionOptionsLUKS generic options for either LUKS v1 or v2. May only be +// used for opening existing images - not valid for the EncryptionFormat call. +type EncryptionOptionsLUKS struct { + Passphrase []byte +} + +func (opts EncryptionOptionsLUKS) allocateEncryptionOptions() cEncryptionData { + var cOpts C.rbd_encryption_luks_format_options_t + var retData cEncryptionData + // CBytes allocates memory. it will be freed when cEncryptionData.free is called + cOpts.passphrase = (*C.char)(C.CBytes(opts.Passphrase)) + cOpts.passphrase_size = C.size_t(len(opts.Passphrase)) + retData.opts = C.rbd_encryption_options_t(&cOpts) + retData.optsSize = C.size_t(C.sizeof_rbd_encryption_luks_format_options_t) + retData.free = func() { C.free(unsafe.Pointer(cOpts.passphrase)) } + retData.format = C.RBD_ENCRYPTION_FORMAT_LUKS + return retData +} + +func (opts EncryptionOptionsLUKS) writeEncryptionSpec(spec *C.rbd_encryption_spec_t) func() { + /* only C memory should be attached to spec */ + cPassphrase := (*C.char)(C.CBytes(opts.Passphrase)) + cOptsSize := C.size_t(C.sizeof_rbd_encryption_luks_format_options_t) + cOpts := (*C.rbd_encryption_luks_format_options_t)(C.malloc(cOptsSize)) + cOpts.passphrase = cPassphrase + cOpts.passphrase_size = C.size_t(len(opts.Passphrase)) + + spec.format = C.RBD_ENCRYPTION_FORMAT_LUKS + spec.opts = C.rbd_encryption_options_t(cOpts) + spec.opts_size = cOptsSize + return func() { + C.free(unsafe.Pointer(cOpts.passphrase)) + C.free(unsafe.Pointer(cOpts)) + } +} diff --git a/vendor/github.com/ceph/go-ceph/rbd/group_snap.go b/vendor/github.com/ceph/go-ceph/rbd/group_snap.go index a9994b9d9..ce21499a1 100644 --- a/vendor/github.com/ceph/go-ceph/rbd/group_snap.go +++ b/vendor/github.com/ceph/go-ceph/rbd/group_snap.go @@ -217,7 +217,7 @@ func GroupSnapRollbackWithProgress( data: data, } cbIndex := groupSnapRollbackCallbacks.Add(ctx) - defer diffIterateCallbacks.Remove(cbIndex) + defer groupSnapRollbackCallbacks.Remove(cbIndex) ret := C.wrap_rbd_group_snap_rollback_with_progress( cephIoctx(ioctx), diff --git a/vendor/github.com/ceph/go-ceph/rbd/group_snap_info.go b/vendor/github.com/ceph/go-ceph/rbd/group_snap_info.go index de9c58e23..f8a3b9c6e 100644 --- a/vendor/github.com/ceph/go-ceph/rbd/group_snap_info.go +++ b/vendor/github.com/ceph/go-ceph/rbd/group_snap_info.go @@ -1,5 +1,3 @@ -//go:build ceph_preview - package rbd /* diff --git a/vendor/github.com/ceph/go-ceph/rbd/mirror.go b/vendor/github.com/ceph/go-ceph/rbd/mirror.go index bd85536b0..ce279506c 100644 --- a/vendor/github.com/ceph/go-ceph/rbd/mirror.go +++ b/vendor/github.com/ceph/go-ceph/rbd/mirror.go @@ -666,23 +666,23 @@ var iterBufSize = 64 // const char *start_id, size_t max, char **image_ids, // rbd_mirror_image_status_t *images, size_t *len) func MirrorImageGlobalStatusList( - ioctx *rados.IOContext, start string, max int) ([]GlobalMirrorImageIDAndStatus, error) { + ioctx *rados.IOContext, start string, maxItems int) ([]GlobalMirrorImageIDAndStatus, error) { var ( result []GlobalMirrorImageIDAndStatus fetchAll bool ) - if max <= 0 { - max = iterBufSize + if maxItems <= 0 { + maxItems = iterBufSize fetchAll = true } - chunk := make([]GlobalMirrorImageIDAndStatus, max) + chunk := make([]GlobalMirrorImageIDAndStatus, maxItems) for { length, err := mirrorImageGlobalStatusList(ioctx, start, chunk) if err != nil { return nil, err } result = append(result, chunk[:length]...) - if !fetchAll || length < max { + if !fetchAll || length < maxItems { break } start = chunk[length-1].ID @@ -700,15 +700,15 @@ func mirrorImageGlobalStatusList( defer C.free(unsafe.Pointer(cStart)) var ( - max = C.size_t(len(results)) - length = C.size_t(0) - ids = make([]*C.char, len(results)) - images = make([]C.rbd_mirror_image_global_status_t, len(results)) + maxItems = C.size_t(len(results)) + length = C.size_t(0) + ids = make([]*C.char, len(results)) + images = make([]C.rbd_mirror_image_global_status_t, len(results)) ) ret := C.rbd_mirror_image_global_status_list( cephIoctx(ioctx), cStart, - max, + maxItems, &ids[0], &images[0], &length) @@ -807,23 +807,23 @@ type MirrorImageInfoItem struct { // rbd_mirror_image_info_t *info_entries, size_t *num_entries) func MirrorImageInfoList( ioctx *rados.IOContext, modeFilter ImageMirrorModeFilter, start string, - max int) ([]MirrorImageInfoItem, error) { + maxItems int) ([]MirrorImageInfoItem, error) { var ( result []MirrorImageInfoItem fetchAll bool ) - if max <= 0 { - max = iterBufSize + if maxItems <= 0 { + maxItems = iterBufSize fetchAll = true } - chunk := make([]MirrorImageInfoItem, max) + chunk := make([]MirrorImageInfoItem, maxItems) for { length, err := mirrorImageInfoList(ioctx, start, modeFilter, chunk) if err != nil { return nil, err } result = append(result, chunk[:length]...) - if !fetchAll || length < max { + if !fetchAll || length < maxItems { break } start = chunk[length-1].ID @@ -838,7 +838,7 @@ func mirrorImageInfoList(ioctx *rados.IOContext, start string, defer C.free(unsafe.Pointer(cStart)) var ( - max = C.size_t(len(results)) + maxItems = C.size_t(len(results)) length = C.size_t(0) ids = make([]*C.char, len(results)) modes = make([]C.rbd_mirror_image_mode_t, len(results)) @@ -853,7 +853,7 @@ func mirrorImageInfoList(ioctx *rados.IOContext, start string, cephIoctx(ioctx), modeFilterPtr, cStart, - max, + maxItems, &ids[0], &modes[0], &infos[0], @@ -949,23 +949,23 @@ type MirrorImageInstanceIDItem struct { // size_t *len) func MirrorImageInstanceIDList( ioctx *rados.IOContext, start string, - max int) ([]MirrorImageInstanceIDItem, error) { + maxItems int) ([]MirrorImageInstanceIDItem, error) { var ( result []MirrorImageInstanceIDItem fetchAll bool ) - if max <= 0 { - max = iterBufSize + if maxItems <= 0 { + maxItems = iterBufSize fetchAll = true } - chunk := make([]MirrorImageInstanceIDItem, max) + chunk := make([]MirrorImageInstanceIDItem, maxItems) for { length, err := mirrorImageInstanceIDList(ioctx, start, chunk) if err != nil { return nil, err } result = append(result, chunk[:length]...) - if !fetchAll || length < max { + if !fetchAll || length < maxItems { break } start = chunk[length-1].ID @@ -980,7 +980,7 @@ func mirrorImageInstanceIDList(ioctx *rados.IOContext, start string, defer C.free(unsafe.Pointer(cStart)) var ( - max = C.size_t(len(results)) + maxItems = C.size_t(len(results)) length = C.size_t(0) ids = make([]*C.char, len(results)) instanceIDs = make([]*C.char, len(results)) @@ -988,7 +988,7 @@ func mirrorImageInstanceIDList(ioctx *rados.IOContext, start string, ret := C.rbd_mirror_image_instance_id_list( cephIoctx(ioctx), cStart, - max, + maxItems, &ids[0], &instanceIDs[0], &length, diff --git a/vendor/github.com/ceph/go-ceph/rbd/sparsify.go b/vendor/github.com/ceph/go-ceph/rbd/sparsify.go index 7435a1571..13a9dd948 100644 --- a/vendor/github.com/ceph/go-ceph/rbd/sparsify.go +++ b/vendor/github.com/ceph/go-ceph/rbd/sparsify.go @@ -72,7 +72,7 @@ func (image *Image) SparsifyWithProgress( data: data, } cbIndex := sparsifyCallbacks.Add(ctx) - defer diffIterateCallbacks.Remove(cbIndex) + defer sparsifyCallbacks.Remove(cbIndex) ret := C.wrap_rbd_sparsify_with_progress(image.image, C.size_t(sparseSize), C.uintptr_t(cbIndex)) diff --git a/vendor/modules.txt b/vendor/modules.txt index ad01271e3..ede1b41bb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -217,8 +217,8 @@ 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.31.0 -## explicit; go 1.19 +# github.com/ceph/go-ceph v0.32.0 +## explicit; go 1.21 github.com/ceph/go-ceph/cephfs github.com/ceph/go-ceph/cephfs/admin github.com/ceph/go-ceph/common/admin/manager