mirror of
https://github.com/ceph/go-ceph
synced 2025-01-17 11:40:43 +00:00
rbd: don't cap the buffer size used in GetImageNames
This removes the limit on the max buffer size GetImageNames is willing to pass to rbd_list2, which is somewhat arbitrary and is too small for large clusters. GetImageNames will continue to start with a small buffer size and retry with a larger buffer if rbd_list2 returns ERANGE (just without a cap on the max buffer size it's willing to go to). Signed-off-by: Sanford Miller <smiller@digitalocean.com>
This commit is contained in:
parent
863d71caa5
commit
36d5c4498e
@ -13,28 +13,14 @@ import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/ceph/go-ceph/internal/retry"
|
||||
ts "github.com/ceph/go-ceph/internal/timespec"
|
||||
"github.com/ceph/go-ceph/rados"
|
||||
)
|
||||
|
||||
// GetImageNames returns the list of current RBD images.
|
||||
func GetImageNames(ioctx *rados.IOContext) ([]string, error) {
|
||||
var (
|
||||
err error
|
||||
images []C.rbd_image_spec_t
|
||||
size C.size_t
|
||||
)
|
||||
retry.WithSizes(32, 4096, func(s int) retry.Hint {
|
||||
size = C.size_t(s)
|
||||
images = make([]C.rbd_image_spec_t, size)
|
||||
ret := C.rbd_list2(
|
||||
cephIoctx(ioctx),
|
||||
(*C.rbd_image_spec_t)(unsafe.Pointer(&images[0])),
|
||||
&size)
|
||||
err = getErrorIfNegative(ret)
|
||||
return retry.Size(int(size)).If(err == errRange)
|
||||
})
|
||||
size := C.size_t(4096)
|
||||
images, err := getImageNames(ioctx, &size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -47,6 +33,22 @@ func GetImageNames(ioctx *rados.IOContext) ([]string, error) {
|
||||
return names, nil
|
||||
}
|
||||
|
||||
func getImageNames(ioctx *rados.IOContext, size *C.size_t) ([]C.rbd_image_spec_t, error) {
|
||||
images := make([]C.rbd_image_spec_t, *size)
|
||||
ret := C.rbd_list2(
|
||||
cephIoctx(ioctx),
|
||||
(*C.rbd_image_spec_t)(unsafe.Pointer(&images[0])),
|
||||
size)
|
||||
err := getErrorIfNegative(ret)
|
||||
if err != nil {
|
||||
if err == errRange {
|
||||
return getImageNames(ioctx, size)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return images, nil
|
||||
}
|
||||
|
||||
// GetCreateTimestamp returns the time the rbd image was created.
|
||||
//
|
||||
// Implements:
|
||||
|
Loading…
Reference in New Issue
Block a user