mirror of
https://github.com/ceph/go-ceph
synced 2024-12-22 06:10:09 +00:00
rados: add support for retrieving the alignment (stripe size) for EC pools
Add support for getting the alignment (stripe size) in bytes for pools that require/support it. Fixes #739 This commit adds two new API calls to IOContext, one to know if the pool requires alignment and the second one to get the stripe size in bytes: RequiresAlignment() (bool, error) Alignment() (uint64, error) Signed-off-by: Daniel M. Lambea <dmlambea@tenerife.es>
This commit is contained in:
parent
fdd9853f0f
commit
f06baa43e5
27
rados/ioctx_pool_alignment.go
Normal file
27
rados/ioctx_pool_alignment.go
Normal file
@ -0,0 +1,27 @@
|
||||
//go:build ceph_preview
|
||||
// +build ceph_preview
|
||||
|
||||
package rados
|
||||
|
||||
// #cgo LDFLAGS: -lrados
|
||||
// #include <rados/librados.h>
|
||||
// #include <stdlib.h>
|
||||
//
|
||||
import "C"
|
||||
|
||||
// Alignment returns the required stripe size in bytes for pools supporting/requiring it, or an error if unsuccessful.
|
||||
// For an EC pool, a buffer size multiple of its stripe size is required to call Append. To know if the pool requires
|
||||
// alignment or not, use RequiresAlignment.
|
||||
//
|
||||
// Implements:
|
||||
// int rados_ioctx_pool_required_alignment2(rados_ioctx_t io, uint64_t *alignment)
|
||||
func (ioctx *IOContext) Alignment() (uint64, error) {
|
||||
var alignSizeBytes C.uint64_t
|
||||
ret := C.rados_ioctx_pool_required_alignment2(
|
||||
ioctx.ioctx,
|
||||
&alignSizeBytes)
|
||||
if ret != 0 {
|
||||
return 0, getError(ret)
|
||||
}
|
||||
return uint64(alignSizeBytes), nil
|
||||
}
|
15
rados/ioctx_pool_alignment_test.go
Normal file
15
rados/ioctx_pool_alignment_test.go
Normal file
@ -0,0 +1,15 @@
|
||||
//go:build ceph_preview
|
||||
// +build ceph_preview
|
||||
|
||||
package rados
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func (suite *RadosTestSuite) TestAlignment() {
|
||||
suite.SetupConnection()
|
||||
|
||||
_, err := suite.ioctx.Alignment()
|
||||
assert.NoError(suite.T(), err)
|
||||
}
|
27
rados/ioctx_pool_requires_alignment.go
Normal file
27
rados/ioctx_pool_requires_alignment.go
Normal file
@ -0,0 +1,27 @@
|
||||
//go:build ceph_preview
|
||||
// +build ceph_preview
|
||||
|
||||
package rados
|
||||
|
||||
// #cgo LDFLAGS: -lrados
|
||||
// #include <rados/librados.h>
|
||||
// #include <stdlib.h>
|
||||
//
|
||||
import "C"
|
||||
|
||||
// RequiresAlignment returns true if the pool supports/requires alignment or an error if not successful.
|
||||
// For an EC pool, a buffer size multiple of its stripe size is required to call Append. See
|
||||
// Alignment to know how to get the stripe size for pools requiring it.
|
||||
//
|
||||
// Implements:
|
||||
// int rados_ioctx_pool_requires_alignment2(rados_ioctx_t io, int *req)
|
||||
func (ioctx *IOContext) RequiresAlignment() (bool, error) {
|
||||
var alignRequired C.int
|
||||
ret := C.rados_ioctx_pool_requires_alignment2(
|
||||
ioctx.ioctx,
|
||||
&alignRequired)
|
||||
if ret != 0 {
|
||||
return false, getError(ret)
|
||||
}
|
||||
return (alignRequired != 0), nil
|
||||
}
|
15
rados/ioctx_pool_requires_alignment_test.go
Normal file
15
rados/ioctx_pool_requires_alignment_test.go
Normal file
@ -0,0 +1,15 @@
|
||||
//go:build ceph_preview
|
||||
// +build ceph_preview
|
||||
|
||||
package rados
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func (suite *RadosTestSuite) TestRequiresAlignment() {
|
||||
suite.SetupConnection()
|
||||
|
||||
_, err := suite.ioctx.RequiresAlignment()
|
||||
assert.NoError(suite.T(), err)
|
||||
}
|
Loading…
Reference in New Issue
Block a user