mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
rebase: update go-ceph version to v0.11.0
Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
parent
87beaac25b
commit
56ac143450
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.16
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aws/aws-sdk-go v1.38.63
|
github.com/aws/aws-sdk-go v1.38.63
|
||||||
github.com/ceph/go-ceph v0.10.0
|
github.com/ceph/go-ceph v0.11.0
|
||||||
github.com/container-storage-interface/spec v1.5.0
|
github.com/container-storage-interface/spec v1.5.0
|
||||||
github.com/csi-addons/replication-lib-utils v0.2.0
|
github.com/csi-addons/replication-lib-utils v0.2.0
|
||||||
github.com/csi-addons/spec v0.1.0
|
github.com/csi-addons/spec v0.1.0
|
||||||
|
4
go.sum
4
go.sum
@ -158,8 +158,8 @@ github.com/briankassouf/jose v0.9.2-0.20180619214549-d2569464773f/go.mod h1:HQhV
|
|||||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
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/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f/go.mod h1:C0rtzmGXgN78pYR0tGJFhtHgkbAs0lIbHwkB81VxDQE=
|
||||||
github.com/ceph/go-ceph v0.10.0 h1:c9Bvqdt2ccv7aSyNBFtN9fm4dwMyfj8IX2or15tb4ag=
|
github.com/ceph/go-ceph v0.11.0 h1:A1pphV40LL8GQKDPpU4XqCa7gkmozsst7rhCC730/nk=
|
||||||
github.com/ceph/go-ceph v0.10.0/go.mod h1:mafFpf5Vg8Ai8Bd+FAMvKBHLmtdpTXdRP/TNq8XWegY=
|
github.com/ceph/go-ceph v0.11.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-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
|
||||||
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/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=
|
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||||
|
54
vendor/github.com/ceph/go-ceph/cephfs/admin/mgrmodule.go
generated
vendored
Normal file
54
vendor/github.com/ceph/go-ceph/cephfs/admin/mgrmodule.go
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ceph/go-ceph/internal/commands"
|
||||||
|
)
|
||||||
|
|
||||||
|
const mirroring = "mirroring"
|
||||||
|
|
||||||
|
// EnableModule will enable the specified manager module.
|
||||||
|
//
|
||||||
|
// Similar To:
|
||||||
|
// ceph mgr module enable <module> [--force]
|
||||||
|
func (fsa *FSAdmin) EnableModule(module string, force bool) error {
|
||||||
|
m := map[string]string{
|
||||||
|
"prefix": "mgr module enable",
|
||||||
|
"module": module,
|
||||||
|
"format": "json",
|
||||||
|
}
|
||||||
|
if force {
|
||||||
|
m["force"] = "--force"
|
||||||
|
}
|
||||||
|
// Why is this _only_ part of the mon command json? You'd think a mgr
|
||||||
|
// command would be available as a MgrCommand but I couldn't figure it out.
|
||||||
|
return commands.MarshalMonCommand(fsa.conn, m).NoData().End()
|
||||||
|
}
|
||||||
|
|
||||||
|
// DisableModule will disable the specified manager module.
|
||||||
|
//
|
||||||
|
// Similar To:
|
||||||
|
// ceph mgr module disable <module>
|
||||||
|
func (fsa *FSAdmin) DisableModule(module string) error {
|
||||||
|
m := map[string]string{
|
||||||
|
"prefix": "mgr module disable",
|
||||||
|
"module": module,
|
||||||
|
"format": "json",
|
||||||
|
}
|
||||||
|
return commands.MarshalMonCommand(fsa.conn, m).NoData().End()
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableMirroringModule will enable the mirroring module for cephfs.
|
||||||
|
//
|
||||||
|
// Similar To:
|
||||||
|
// ceph mgr module enable mirroring [--force]
|
||||||
|
func (fsa *FSAdmin) EnableMirroringModule(force bool) error {
|
||||||
|
return fsa.EnableModule(mirroring, force)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DisableMirroringModule will disable the mirroring module for cephfs.
|
||||||
|
//
|
||||||
|
// Similar To:
|
||||||
|
// ceph mgr module disable mirroring
|
||||||
|
func (fsa *FSAdmin) DisableMirroringModule() error {
|
||||||
|
return fsa.DisableModule(mirroring)
|
||||||
|
}
|
234
vendor/github.com/ceph/go-ceph/cephfs/admin/mirror.go
generated
vendored
Normal file
234
vendor/github.com/ceph/go-ceph/cephfs/admin/mirror.go
generated
vendored
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
ccom "github.com/ceph/go-ceph/common/commands"
|
||||||
|
"github.com/ceph/go-ceph/internal/commands"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SnapshotMirrorAdmin helps administer the snapshot mirroring features of
|
||||||
|
// cephfs. Snapshot mirroring is only available in ceph pacific and later.
|
||||||
|
type SnapshotMirrorAdmin struct {
|
||||||
|
conn ccom.MgrCommander
|
||||||
|
}
|
||||||
|
|
||||||
|
// SnapshotMirror returns a new SnapshotMirrorAdmin to be used for the
|
||||||
|
// administration of snapshot mirroring features.
|
||||||
|
func (fsa *FSAdmin) SnapshotMirror() *SnapshotMirrorAdmin {
|
||||||
|
return &SnapshotMirrorAdmin{conn: fsa.conn}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable snapshot mirroring for the given file system.
|
||||||
|
//
|
||||||
|
// Similar To:
|
||||||
|
// ceph fs snapshot mirror enable <fs_name>
|
||||||
|
func (sma *SnapshotMirrorAdmin) Enable(fsname string) error {
|
||||||
|
m := map[string]string{
|
||||||
|
"prefix": "fs snapshot mirror enable",
|
||||||
|
"fs_name": fsname,
|
||||||
|
"format": "json",
|
||||||
|
}
|
||||||
|
return commands.MarshalMgrCommand(sma.conn, m).NoStatus().EmptyBody().End()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable snapshot mirroring for the given file system.
|
||||||
|
//
|
||||||
|
// Similar To:
|
||||||
|
// ceph fs snapshot mirror disable <fs_name>
|
||||||
|
func (sma *SnapshotMirrorAdmin) Disable(fsname string) error {
|
||||||
|
m := map[string]string{
|
||||||
|
"prefix": "fs snapshot mirror disable",
|
||||||
|
"fs_name": fsname,
|
||||||
|
"format": "json",
|
||||||
|
}
|
||||||
|
return commands.MarshalMgrCommand(sma.conn, m).NoStatus().EmptyBody().End()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a path in the file system to be mirrored.
|
||||||
|
//
|
||||||
|
// Similar To:
|
||||||
|
// ceph fs snapshot mirror add <fs_name> <path>
|
||||||
|
func (sma *SnapshotMirrorAdmin) Add(fsname, path string) error {
|
||||||
|
m := map[string]string{
|
||||||
|
"prefix": "fs snapshot mirror add",
|
||||||
|
"fs_name": fsname,
|
||||||
|
"path": path,
|
||||||
|
"format": "json",
|
||||||
|
}
|
||||||
|
return commands.MarshalMgrCommand(sma.conn, m).NoStatus().EmptyBody().End()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove a path in the file system from mirroring.
|
||||||
|
//
|
||||||
|
// Similar To:
|
||||||
|
// ceph fs snapshot mirror remove <fs_name> <path>
|
||||||
|
func (sma *SnapshotMirrorAdmin) Remove(fsname, path string) error {
|
||||||
|
m := map[string]string{
|
||||||
|
"prefix": "fs snapshot mirror remove",
|
||||||
|
"fs_name": fsname,
|
||||||
|
"path": path,
|
||||||
|
"format": "json",
|
||||||
|
}
|
||||||
|
return commands.MarshalMgrCommand(sma.conn, m).NoStatus().EmptyBody().End()
|
||||||
|
}
|
||||||
|
|
||||||
|
type bootstrapTokenResponse struct {
|
||||||
|
Token string `json:"token"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatePeerBootstrapToken returns a token that can be used to create
|
||||||
|
// a peering association between this site an another site.
|
||||||
|
//
|
||||||
|
// Similar To:
|
||||||
|
// ceph fs snapshot mirror peer_bootstrap create <fs_name> <client_entity> <site-name>
|
||||||
|
func (sma *SnapshotMirrorAdmin) CreatePeerBootstrapToken(
|
||||||
|
fsname, client, site string) (string, error) {
|
||||||
|
m := map[string]string{
|
||||||
|
"prefix": "fs snapshot mirror peer_bootstrap create",
|
||||||
|
"fs_name": fsname,
|
||||||
|
"client_name": client,
|
||||||
|
"format": "json",
|
||||||
|
}
|
||||||
|
if site != "" {
|
||||||
|
m["site_name"] = site
|
||||||
|
}
|
||||||
|
var bt bootstrapTokenResponse
|
||||||
|
err := commands.MarshalMgrCommand(sma.conn, m).NoStatus().Unmarshal(&bt).End()
|
||||||
|
return bt.Token, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImportPeerBoostrapToken creates an association between another site, one
|
||||||
|
// that has provided a token, with the current site.
|
||||||
|
//
|
||||||
|
// Similar To:
|
||||||
|
// ceph fs snapshot mirror peer_bootstrap import <fs_name> <token>
|
||||||
|
func (sma *SnapshotMirrorAdmin) ImportPeerBoostrapToken(fsname, token string) error {
|
||||||
|
m := map[string]string{
|
||||||
|
"prefix": "fs snapshot mirror peer_bootstrap import",
|
||||||
|
"fs_name": fsname,
|
||||||
|
"token": token,
|
||||||
|
"format": "json",
|
||||||
|
}
|
||||||
|
return commands.MarshalMgrCommand(sma.conn, m).NoStatus().EmptyBody().End()
|
||||||
|
}
|
||||||
|
|
||||||
|
// DaemonID represents the ID of a cephfs mirroring daemon.
|
||||||
|
type DaemonID uint
|
||||||
|
|
||||||
|
// FileSystemID represents the ID of a cephfs file system.
|
||||||
|
type FileSystemID uint
|
||||||
|
|
||||||
|
// PeerUUID represents the UUID of a cephfs mirroring peer.
|
||||||
|
type PeerUUID string
|
||||||
|
|
||||||
|
// DaemonStatusPeer contains fields detailing a remote peer.
|
||||||
|
type DaemonStatusPeer struct {
|
||||||
|
ClientName string `json:"client_name"`
|
||||||
|
ClusterName string `json:"cluster_name"`
|
||||||
|
FSName string `json:"fs_name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DaemonStatusPeerStats contains fields detailing the a remote peer's stats.
|
||||||
|
type DaemonStatusPeerStats struct {
|
||||||
|
FailureCount uint64 `json:"failure_count"`
|
||||||
|
RecoveryCount uint64 `json:"recovery_count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DaemonStatusPeerInfo contains fields representing information about a remote peer.
|
||||||
|
type DaemonStatusPeerInfo struct {
|
||||||
|
UUID PeerUUID `json:"uuid"`
|
||||||
|
Remote DaemonStatusPeer `json:"remote"`
|
||||||
|
Stats DaemonStatusPeerStats `json:"stats"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DaemonStatusFileSystemInfo represents information about a mirrored file system.
|
||||||
|
type DaemonStatusFileSystemInfo struct {
|
||||||
|
FileSystemID FileSystemID `json:"filesystem_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
DirectoryCount int64 `json:"directory_count"`
|
||||||
|
Peers []DaemonStatusPeerInfo `json:"peers"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DaemonStatusInfo maps file system IDs to information about that file system.
|
||||||
|
type DaemonStatusInfo struct {
|
||||||
|
DaemonID DaemonID `json:"daemon_id"`
|
||||||
|
FileSystems []DaemonStatusFileSystemInfo `json:"filesystems"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DaemonStatusResults maps mirroring daemon IDs to information about that
|
||||||
|
// mirroring daemon.
|
||||||
|
type DaemonStatusResults []DaemonStatusInfo
|
||||||
|
|
||||||
|
func parseDaemonStatus(res response) (DaemonStatusResults, error) {
|
||||||
|
var dsr DaemonStatusResults
|
||||||
|
if err := res.NoStatus().Unmarshal(&dsr).End(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return dsr, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DaemonStatus returns information on the status of cephfs mirroring daemons
|
||||||
|
// associated with the given file system.
|
||||||
|
//
|
||||||
|
// Similar To:
|
||||||
|
// ceph fs snapshot mirror daemon status <fs_name>
|
||||||
|
func (sma *SnapshotMirrorAdmin) DaemonStatus(fsname string) (
|
||||||
|
DaemonStatusResults, error) {
|
||||||
|
// ---
|
||||||
|
m := map[string]string{
|
||||||
|
"prefix": "fs snapshot mirror daemon status",
|
||||||
|
"fs_name": fsname,
|
||||||
|
"format": "json",
|
||||||
|
}
|
||||||
|
return parseDaemonStatus(commands.MarshalMgrCommand(sma.conn, m))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PeerInfo includes information about a cephfs mirroring peer.
|
||||||
|
type PeerInfo struct {
|
||||||
|
ClientName string `json:"client_name"`
|
||||||
|
SiteName string `json:"site_name"`
|
||||||
|
FSName string `json:"fs_name"`
|
||||||
|
MonHost string `json:"mon_host"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PeerListResults maps a peer's UUID to information about that peer.
|
||||||
|
type PeerListResults map[PeerUUID]PeerInfo
|
||||||
|
|
||||||
|
func parsePeerList(res response) (PeerListResults, error) {
|
||||||
|
var plr PeerListResults
|
||||||
|
if err := res.NoStatus().Unmarshal(&plr).End(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return plr, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PeerList returns information about peers associated with the given file system.
|
||||||
|
//
|
||||||
|
// Similar To:
|
||||||
|
// ceph fs snapshot mirror peer_list <fs_name>
|
||||||
|
func (sma *SnapshotMirrorAdmin) PeerList(fsname string) (
|
||||||
|
PeerListResults, error) {
|
||||||
|
// ---
|
||||||
|
m := map[string]string{
|
||||||
|
"prefix": "fs snapshot mirror peer_list",
|
||||||
|
"fs_name": fsname,
|
||||||
|
"format": "json",
|
||||||
|
}
|
||||||
|
return parsePeerList(commands.MarshalMgrCommand(sma.conn, m))
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
DirMap - figure out what last_shuffled is supposed to mean and, if it is a time
|
||||||
|
like it seems to be, how best to represent in Go.
|
||||||
|
|
||||||
|
DirMap TODO
|
||||||
|
ceph fs snapshot mirror dirmap
|
||||||
|
func (sma *SnapshotMirrorAdmin) DirMap(fsname, path string) error {
|
||||||
|
m := map[string]string{
|
||||||
|
"prefix": "fs snapshot mirror dirmap",
|
||||||
|
"fs_name": fsname,
|
||||||
|
"path": path,
|
||||||
|
"format": "json",
|
||||||
|
}
|
||||||
|
return commands.MarshalMgrCommand(sma.conn, m).NoStatus().EmptyBody().End()
|
||||||
|
}
|
||||||
|
*/
|
17
vendor/github.com/ceph/go-ceph/internal/commands/response.go
generated
vendored
17
vendor/github.com/ceph/go-ceph/internal/commands/response.go
generated
vendored
@ -110,6 +110,23 @@ func (r Response) NoBody() Response {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EmptyBody is similar to NoBody but also accepts an empty JSON object.
|
||||||
|
func (r Response) EmptyBody() Response {
|
||||||
|
if !r.Ok() {
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
if len(r.body) != 0 {
|
||||||
|
d := map[string]interface{}{}
|
||||||
|
if err := json.Unmarshal(r.body, &d); err != nil {
|
||||||
|
return Response{r.body, r.status, err}
|
||||||
|
}
|
||||||
|
if len(d) != 0 {
|
||||||
|
return Response{r.body, r.status, ErrBodyNotEmpty}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
// NoData asserts that the input response has no status or body values.
|
// NoData asserts that the input response has no status or body values.
|
||||||
func (r Response) NoData() Response {
|
func (r Response) NoData() Response {
|
||||||
return r.NoStatus().NoBody()
|
return r.NoStatus().NoBody()
|
||||||
|
60
vendor/github.com/ceph/go-ceph/rados/conn.go
generated
vendored
60
vendor/github.com/ceph/go-ceph/rados/conn.go
generated
vendored
@ -38,13 +38,13 @@ func (c *Conn) Cluster() ClusterRef {
|
|||||||
|
|
||||||
// PingMonitor sends a ping to a monitor and returns the reply.
|
// PingMonitor sends a ping to a monitor and returns the reply.
|
||||||
func (c *Conn) PingMonitor(id string) (string, error) {
|
func (c *Conn) PingMonitor(id string) (string, error) {
|
||||||
c_id := C.CString(id)
|
cid := C.CString(id)
|
||||||
defer C.free(unsafe.Pointer(c_id))
|
defer C.free(unsafe.Pointer(cid))
|
||||||
|
|
||||||
var strlen C.size_t
|
var strlen C.size_t
|
||||||
var strout *C.char
|
var strout *C.char
|
||||||
|
|
||||||
ret := C.rados_ping_monitor(c.cluster, c_id, &strout, &strlen)
|
ret := C.rados_ping_monitor(c.cluster, cid, &strout, &strlen)
|
||||||
defer C.rados_buffer_free(strout)
|
defer C.rados_buffer_free(strout)
|
||||||
|
|
||||||
if ret == 0 {
|
if ret == 0 {
|
||||||
@ -75,9 +75,9 @@ func (c *Conn) Shutdown() {
|
|||||||
|
|
||||||
// ReadConfigFile configures the connection using a Ceph configuration file.
|
// ReadConfigFile configures the connection using a Ceph configuration file.
|
||||||
func (c *Conn) ReadConfigFile(path string) error {
|
func (c *Conn) ReadConfigFile(path string) error {
|
||||||
c_path := C.CString(path)
|
cPath := C.CString(path)
|
||||||
defer C.free(unsafe.Pointer(c_path))
|
defer C.free(unsafe.Pointer(cPath))
|
||||||
ret := C.rados_conf_read_file(c.cluster, c_path)
|
ret := C.rados_conf_read_file(c.cluster, cPath)
|
||||||
return getError(ret)
|
return getError(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,10 +94,10 @@ func (c *Conn) ReadDefaultConfigFile() error {
|
|||||||
// int rados_ioctx_create(rados_t cluster, const char *pool_name,
|
// int rados_ioctx_create(rados_t cluster, const char *pool_name,
|
||||||
// rados_ioctx_t *ioctx);
|
// rados_ioctx_t *ioctx);
|
||||||
func (c *Conn) OpenIOContext(pool string) (*IOContext, error) {
|
func (c *Conn) OpenIOContext(pool string) (*IOContext, error) {
|
||||||
c_pool := C.CString(pool)
|
cPool := C.CString(pool)
|
||||||
defer C.free(unsafe.Pointer(c_pool))
|
defer C.free(unsafe.Pointer(cPool))
|
||||||
ioctx := &IOContext{}
|
ioctx := &IOContext{}
|
||||||
ret := C.rados_ioctx_create(c.cluster, c_pool, &ioctx.ioctx)
|
ret := C.rados_ioctx_create(c.cluster, cPool, &ioctx.ioctx)
|
||||||
if ret == 0 {
|
if ret == 0 {
|
||||||
return ioctx, nil
|
return ioctx, nil
|
||||||
}
|
}
|
||||||
@ -127,10 +127,10 @@ func (c *Conn) ListPools() (names []string, err error) {
|
|||||||
// SetConfigOption sets the value of the configuration option identified by
|
// SetConfigOption sets the value of the configuration option identified by
|
||||||
// the given name.
|
// the given name.
|
||||||
func (c *Conn) SetConfigOption(option, value string) error {
|
func (c *Conn) SetConfigOption(option, value string) error {
|
||||||
c_opt, c_val := C.CString(option), C.CString(value)
|
cOpt, cVal := C.CString(option), C.CString(value)
|
||||||
defer C.free(unsafe.Pointer(c_opt))
|
defer C.free(unsafe.Pointer(cOpt))
|
||||||
defer C.free(unsafe.Pointer(c_val))
|
defer C.free(unsafe.Pointer(cVal))
|
||||||
ret := C.rados_conf_set(c.cluster, c_opt, c_val)
|
ret := C.rados_conf_set(c.cluster, cOpt, cVal)
|
||||||
return getError(ret)
|
return getError(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,16 +179,16 @@ func (c *Conn) GetClusterStats() (stat ClusterStat, err error) {
|
|||||||
if err := c.ensure_connected(); err != nil {
|
if err := c.ensure_connected(); err != nil {
|
||||||
return ClusterStat{}, err
|
return ClusterStat{}, err
|
||||||
}
|
}
|
||||||
c_stat := C.struct_rados_cluster_stat_t{}
|
cStat := C.struct_rados_cluster_stat_t{}
|
||||||
ret := C.rados_cluster_stat(c.cluster, &c_stat)
|
ret := C.rados_cluster_stat(c.cluster, &cStat)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return ClusterStat{}, getError(ret)
|
return ClusterStat{}, getError(ret)
|
||||||
}
|
}
|
||||||
return ClusterStat{
|
return ClusterStat{
|
||||||
Kb: uint64(c_stat.kb),
|
Kb: uint64(cStat.kb),
|
||||||
Kb_used: uint64(c_stat.kb_used),
|
Kb_used: uint64(cStat.kb_used),
|
||||||
Kb_avail: uint64(c_stat.kb_avail),
|
Kb_avail: uint64(cStat.kb_avail),
|
||||||
Num_objects: uint64(c_stat.num_objects),
|
Num_objects: uint64(cStat.num_objects),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,9 +261,9 @@ func (c *Conn) GetInstanceID() uint64 {
|
|||||||
|
|
||||||
// MakePool creates a new pool with default settings.
|
// MakePool creates a new pool with default settings.
|
||||||
func (c *Conn) MakePool(name string) error {
|
func (c *Conn) MakePool(name string) error {
|
||||||
c_name := C.CString(name)
|
cName := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
ret := C.rados_pool_create(c.cluster, c_name)
|
ret := C.rados_pool_create(c.cluster, cName)
|
||||||
return getError(ret)
|
return getError(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,9 +272,9 @@ func (c *Conn) DeletePool(name string) error {
|
|||||||
if err := c.ensure_connected(); err != nil {
|
if err := c.ensure_connected(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
c_name := C.CString(name)
|
cName := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
ret := C.rados_pool_delete(c.cluster, c_name)
|
ret := C.rados_pool_delete(c.cluster, cName)
|
||||||
return getError(ret)
|
return getError(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,9 +283,9 @@ func (c *Conn) GetPoolByName(name string) (int64, error) {
|
|||||||
if err := c.ensure_connected(); err != nil {
|
if err := c.ensure_connected(); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
c_name := C.CString(name)
|
cName := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
ret := int64(C.rados_pool_lookup(c.cluster, c_name))
|
ret := int64(C.rados_pool_lookup(c.cluster, cName))
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return 0, radosError(ret)
|
return 0, radosError(ret)
|
||||||
}
|
}
|
||||||
@ -298,8 +298,8 @@ func (c *Conn) GetPoolByID(id int64) (string, error) {
|
|||||||
if err := c.ensure_connected(); err != nil {
|
if err := c.ensure_connected(); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
c_id := C.int64_t(id)
|
cid := C.int64_t(id)
|
||||||
ret := int(C.rados_pool_reverse_lookup(c.cluster, c_id, (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf))))
|
ret := int(C.rados_pool_reverse_lookup(c.cluster, cid, (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf))))
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return "", radosError(ret)
|
return "", radosError(ret)
|
||||||
}
|
}
|
||||||
|
330
vendor/github.com/ceph/go-ceph/rados/ioctx.go
generated
vendored
330
vendor/github.com/ceph/go-ceph/rados/ioctx.go
generated
vendored
@ -114,12 +114,12 @@ func (ioctx *IOContext) Pointer() unsafe.Pointer {
|
|||||||
// void rados_ioctx_set_namespace(rados_ioctx_t io,
|
// void rados_ioctx_set_namespace(rados_ioctx_t io,
|
||||||
// const char *nspace);
|
// const char *nspace);
|
||||||
func (ioctx *IOContext) SetNamespace(namespace string) {
|
func (ioctx *IOContext) SetNamespace(namespace string) {
|
||||||
var c_ns *C.char
|
var cns *C.char
|
||||||
if len(namespace) > 0 {
|
if len(namespace) > 0 {
|
||||||
c_ns = C.CString(namespace)
|
cns = C.CString(namespace)
|
||||||
defer C.free(unsafe.Pointer(c_ns))
|
defer C.free(unsafe.Pointer(cns))
|
||||||
}
|
}
|
||||||
C.rados_ioctx_set_namespace(ioctx.ioctx, c_ns)
|
C.rados_ioctx_set_namespace(ioctx.ioctx, cns)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new object with key oid.
|
// Create a new object with key oid.
|
||||||
@ -137,15 +137,15 @@ func (ioctx *IOContext) Create(oid string, exclusive CreateOption) error {
|
|||||||
// Write writes len(data) bytes to the object with key oid starting at byte
|
// Write writes len(data) bytes to the object with key oid starting at byte
|
||||||
// offset offset. It returns an error, if any.
|
// offset offset. It returns an error, if any.
|
||||||
func (ioctx *IOContext) Write(oid string, data []byte, offset uint64) error {
|
func (ioctx *IOContext) Write(oid string, data []byte, offset uint64) error {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
|
|
||||||
dataPointer := unsafe.Pointer(nil)
|
dataPointer := unsafe.Pointer(nil)
|
||||||
if len(data) > 0 {
|
if len(data) > 0 {
|
||||||
dataPointer = unsafe.Pointer(&data[0])
|
dataPointer = unsafe.Pointer(&data[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := C.rados_write(ioctx.ioctx, c_oid,
|
ret := C.rados_write(ioctx.ioctx, coid,
|
||||||
(*C.char)(dataPointer),
|
(*C.char)(dataPointer),
|
||||||
(C.size_t)(len(data)),
|
(C.size_t)(len(data)),
|
||||||
(C.uint64_t)(offset))
|
(C.uint64_t)(offset))
|
||||||
@ -157,10 +157,10 @@ func (ioctx *IOContext) Write(oid string, data []byte, offset uint64) error {
|
|||||||
// The object is filled with the provided data. If the object exists,
|
// The object is filled with the provided data. If the object exists,
|
||||||
// it is atomically truncated and then written. It returns an error, if any.
|
// it is atomically truncated and then written. It returns an error, if any.
|
||||||
func (ioctx *IOContext) WriteFull(oid string, data []byte) error {
|
func (ioctx *IOContext) WriteFull(oid string, data []byte) error {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
|
|
||||||
ret := C.rados_write_full(ioctx.ioctx, c_oid,
|
ret := C.rados_write_full(ioctx.ioctx, coid,
|
||||||
(*C.char)(unsafe.Pointer(&data[0])),
|
(*C.char)(unsafe.Pointer(&data[0])),
|
||||||
(C.size_t)(len(data)))
|
(C.size_t)(len(data)))
|
||||||
return getError(ret)
|
return getError(ret)
|
||||||
@ -170,10 +170,10 @@ func (ioctx *IOContext) WriteFull(oid string, data []byte) error {
|
|||||||
// The object is appended with the provided data. If the object exists,
|
// The object is appended with the provided data. If the object exists,
|
||||||
// it is atomically appended to. It returns an error, if any.
|
// it is atomically appended to. It returns an error, if any.
|
||||||
func (ioctx *IOContext) Append(oid string, data []byte) error {
|
func (ioctx *IOContext) Append(oid string, data []byte) error {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
|
|
||||||
ret := C.rados_append(ioctx.ioctx, c_oid,
|
ret := C.rados_append(ioctx.ioctx, coid,
|
||||||
(*C.char)(unsafe.Pointer(&data[0])),
|
(*C.char)(unsafe.Pointer(&data[0])),
|
||||||
(C.size_t)(len(data)))
|
(C.size_t)(len(data)))
|
||||||
return getError(ret)
|
return getError(ret)
|
||||||
@ -182,8 +182,8 @@ func (ioctx *IOContext) Append(oid string, data []byte) error {
|
|||||||
// Read reads up to len(data) bytes from the object with key oid starting at byte
|
// Read reads up to len(data) bytes from the object with key oid starting at byte
|
||||||
// offset offset. It returns the number of bytes read and an error, if any.
|
// offset offset. It returns the number of bytes read and an error, if any.
|
||||||
func (ioctx *IOContext) Read(oid string, data []byte, offset uint64) (int, error) {
|
func (ioctx *IOContext) Read(oid string, data []byte, offset uint64) (int, error) {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
|
|
||||||
var buf *C.char
|
var buf *C.char
|
||||||
if len(data) > 0 {
|
if len(data) > 0 {
|
||||||
@ -192,7 +192,7 @@ func (ioctx *IOContext) Read(oid string, data []byte, offset uint64) (int, error
|
|||||||
|
|
||||||
ret := C.rados_read(
|
ret := C.rados_read(
|
||||||
ioctx.ioctx,
|
ioctx.ioctx,
|
||||||
c_oid,
|
coid,
|
||||||
buf,
|
buf,
|
||||||
(C.size_t)(len(data)),
|
(C.size_t)(len(data)),
|
||||||
(C.uint64_t)(offset))
|
(C.uint64_t)(offset))
|
||||||
@ -205,10 +205,10 @@ func (ioctx *IOContext) Read(oid string, data []byte, offset uint64) (int, error
|
|||||||
|
|
||||||
// Delete deletes the object with key oid. It returns an error, if any.
|
// Delete deletes the object with key oid. It returns an error, if any.
|
||||||
func (ioctx *IOContext) Delete(oid string) error {
|
func (ioctx *IOContext) Delete(oid string) error {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
|
|
||||||
return getError(C.rados_remove(ioctx.ioctx, c_oid))
|
return getError(C.rados_remove(ioctx.ioctx, coid))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Truncate resizes the object with key oid to size size. If the operation
|
// Truncate resizes the object with key oid to size size. If the operation
|
||||||
@ -216,10 +216,10 @@ func (ioctx *IOContext) Delete(oid string) error {
|
|||||||
// operation shrinks the object, the excess data is removed. It returns an
|
// operation shrinks the object, the excess data is removed. It returns an
|
||||||
// error, if any.
|
// error, if any.
|
||||||
func (ioctx *IOContext) Truncate(oid string, size uint64) error {
|
func (ioctx *IOContext) Truncate(oid string, size uint64) error {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
|
|
||||||
return getError(C.rados_trunc(ioctx.ioctx, c_oid, (C.uint64_t)(size)))
|
return getError(C.rados_trunc(ioctx.ioctx, coid, (C.uint64_t)(size)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy informs librados that the I/O context is no longer in use.
|
// Destroy informs librados that the I/O context is no longer in use.
|
||||||
@ -236,24 +236,24 @@ func (ioctx *IOContext) Destroy() {
|
|||||||
// int rados_ioctx_pool_stat(rados_ioctx_t io,
|
// int rados_ioctx_pool_stat(rados_ioctx_t io,
|
||||||
// struct rados_pool_stat_t *stats);
|
// struct rados_pool_stat_t *stats);
|
||||||
func (ioctx *IOContext) GetPoolStats() (stat PoolStat, err error) {
|
func (ioctx *IOContext) GetPoolStats() (stat PoolStat, err error) {
|
||||||
c_stat := C.struct_rados_pool_stat_t{}
|
cStat := C.struct_rados_pool_stat_t{}
|
||||||
ret := C.rados_ioctx_pool_stat(ioctx.ioctx, &c_stat)
|
ret := C.rados_ioctx_pool_stat(ioctx.ioctx, &cStat)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return PoolStat{}, getError(ret)
|
return PoolStat{}, getError(ret)
|
||||||
}
|
}
|
||||||
return PoolStat{
|
return PoolStat{
|
||||||
Num_bytes: uint64(c_stat.num_bytes),
|
Num_bytes: uint64(cStat.num_bytes),
|
||||||
Num_kb: uint64(c_stat.num_kb),
|
Num_kb: uint64(cStat.num_kb),
|
||||||
Num_objects: uint64(c_stat.num_objects),
|
Num_objects: uint64(cStat.num_objects),
|
||||||
Num_object_clones: uint64(c_stat.num_object_clones),
|
Num_object_clones: uint64(cStat.num_object_clones),
|
||||||
Num_object_copies: uint64(c_stat.num_object_copies),
|
Num_object_copies: uint64(cStat.num_object_copies),
|
||||||
Num_objects_missing_on_primary: uint64(c_stat.num_objects_missing_on_primary),
|
Num_objects_missing_on_primary: uint64(cStat.num_objects_missing_on_primary),
|
||||||
Num_objects_unfound: uint64(c_stat.num_objects_unfound),
|
Num_objects_unfound: uint64(cStat.num_objects_unfound),
|
||||||
Num_objects_degraded: uint64(c_stat.num_objects_degraded),
|
Num_objects_degraded: uint64(cStat.num_objects_degraded),
|
||||||
Num_rd: uint64(c_stat.num_rd),
|
Num_rd: uint64(cStat.num_rd),
|
||||||
Num_rd_kb: uint64(c_stat.num_rd_kb),
|
Num_rd_kb: uint64(cStat.num_rd_kb),
|
||||||
Num_wr: uint64(c_stat.num_wr),
|
Num_wr: uint64(cStat.num_wr),
|
||||||
Num_wr_kb: uint64(c_stat.num_wr_kb),
|
Num_wr_kb: uint64(cStat.num_wr_kb),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,51 +306,51 @@ func (ioctx *IOContext) ListObjects(listFn ObjectListFunc) error {
|
|||||||
defer func() { C.rados_nobjects_list_close(ctx) }()
|
defer func() { C.rados_nobjects_list_close(ctx) }()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
var c_entry *C.char
|
var cEntry *C.char
|
||||||
ret := C.rados_nobjects_list_next(ctx, &c_entry, nil, nil)
|
ret := C.rados_nobjects_list_next(ctx, &cEntry, nil, nil)
|
||||||
if ret == -C.ENOENT {
|
if ret == -C.ENOENT {
|
||||||
return nil
|
return nil
|
||||||
} else if ret < 0 {
|
} else if ret < 0 {
|
||||||
return getError(ret)
|
return getError(ret)
|
||||||
}
|
}
|
||||||
listFn(C.GoString(c_entry))
|
listFn(C.GoString(cEntry))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stat returns the size of the object and its last modification time
|
// Stat returns the size of the object and its last modification time
|
||||||
func (ioctx *IOContext) Stat(object string) (stat ObjectStat, err error) {
|
func (ioctx *IOContext) Stat(object string) (stat ObjectStat, err error) {
|
||||||
var c_psize C.uint64_t
|
var cPsize C.uint64_t
|
||||||
var c_pmtime C.time_t
|
var cPmtime C.time_t
|
||||||
c_object := C.CString(object)
|
cObject := C.CString(object)
|
||||||
defer C.free(unsafe.Pointer(c_object))
|
defer C.free(unsafe.Pointer(cObject))
|
||||||
|
|
||||||
ret := C.rados_stat(
|
ret := C.rados_stat(
|
||||||
ioctx.ioctx,
|
ioctx.ioctx,
|
||||||
c_object,
|
cObject,
|
||||||
&c_psize,
|
&cPsize,
|
||||||
&c_pmtime)
|
&cPmtime)
|
||||||
|
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return ObjectStat{}, getError(ret)
|
return ObjectStat{}, getError(ret)
|
||||||
}
|
}
|
||||||
return ObjectStat{
|
return ObjectStat{
|
||||||
Size: uint64(c_psize),
|
Size: uint64(cPsize),
|
||||||
ModTime: time.Unix(int64(c_pmtime), 0),
|
ModTime: time.Unix(int64(cPmtime), 0),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetXattr gets an xattr with key `name`, it returns the length of
|
// GetXattr gets an xattr with key `name`, it returns the length of
|
||||||
// the key read or an error if not successful
|
// the key read or an error if not successful
|
||||||
func (ioctx *IOContext) GetXattr(object string, name string, data []byte) (int, error) {
|
func (ioctx *IOContext) GetXattr(object string, name string, data []byte) (int, error) {
|
||||||
c_object := C.CString(object)
|
cObject := C.CString(object)
|
||||||
c_name := C.CString(name)
|
cName := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(c_object))
|
defer C.free(unsafe.Pointer(cObject))
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
|
|
||||||
ret := C.rados_getxattr(
|
ret := C.rados_getxattr(
|
||||||
ioctx.ioctx,
|
ioctx.ioctx,
|
||||||
c_object,
|
cObject,
|
||||||
c_name,
|
cName,
|
||||||
(*C.char)(unsafe.Pointer(&data[0])),
|
(*C.char)(unsafe.Pointer(&data[0])),
|
||||||
(C.size_t)(len(data)))
|
(C.size_t)(len(data)))
|
||||||
|
|
||||||
@ -362,15 +362,15 @@ func (ioctx *IOContext) GetXattr(object string, name string, data []byte) (int,
|
|||||||
|
|
||||||
// SetXattr sets an xattr for an object with key `name` with value as `data`
|
// SetXattr sets an xattr for an object with key `name` with value as `data`
|
||||||
func (ioctx *IOContext) SetXattr(object string, name string, data []byte) error {
|
func (ioctx *IOContext) SetXattr(object string, name string, data []byte) error {
|
||||||
c_object := C.CString(object)
|
cObject := C.CString(object)
|
||||||
c_name := C.CString(name)
|
cName := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(c_object))
|
defer C.free(unsafe.Pointer(cObject))
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
|
|
||||||
ret := C.rados_setxattr(
|
ret := C.rados_setxattr(
|
||||||
ioctx.ioctx,
|
ioctx.ioctx,
|
||||||
c_object,
|
cObject,
|
||||||
c_name,
|
cName,
|
||||||
(*C.char)(unsafe.Pointer(&data[0])),
|
(*C.char)(unsafe.Pointer(&data[0])),
|
||||||
(C.size_t)(len(data)))
|
(C.size_t)(len(data)))
|
||||||
|
|
||||||
@ -380,82 +380,82 @@ func (ioctx *IOContext) SetXattr(object string, name string, data []byte) error
|
|||||||
// ListXattrs lists all the xattrs for an object. The xattrs are returned as a
|
// ListXattrs lists all the xattrs for an object. The xattrs are returned as a
|
||||||
// mapping of string keys and byte-slice values.
|
// mapping of string keys and byte-slice values.
|
||||||
func (ioctx *IOContext) ListXattrs(oid string) (map[string][]byte, error) {
|
func (ioctx *IOContext) ListXattrs(oid string) (map[string][]byte, error) {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
|
|
||||||
var it C.rados_xattrs_iter_t
|
var it C.rados_xattrs_iter_t
|
||||||
|
|
||||||
ret := C.rados_getxattrs(ioctx.ioctx, c_oid, &it)
|
ret := C.rados_getxattrs(ioctx.ioctx, coid, &it)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return nil, getError(ret)
|
return nil, getError(ret)
|
||||||
}
|
}
|
||||||
defer func() { C.rados_getxattrs_end(it) }()
|
defer func() { C.rados_getxattrs_end(it) }()
|
||||||
m := make(map[string][]byte)
|
m := make(map[string][]byte)
|
||||||
for {
|
for {
|
||||||
var c_name, c_val *C.char
|
var cName, cVal *C.char
|
||||||
var c_len C.size_t
|
var cLen C.size_t
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
defer C.free(unsafe.Pointer(c_val))
|
defer C.free(unsafe.Pointer(cVal))
|
||||||
|
|
||||||
ret := C.rados_getxattrs_next(it, &c_name, &c_val, &c_len)
|
ret := C.rados_getxattrs_next(it, &cName, &cVal, &cLen)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return nil, getError(ret)
|
return nil, getError(ret)
|
||||||
}
|
}
|
||||||
// rados api returns a null name,val & 0-length upon
|
// rados api returns a null name,val & 0-length upon
|
||||||
// end of iteration
|
// end of iteration
|
||||||
if c_name == nil {
|
if cName == nil {
|
||||||
return m, nil // stop iteration
|
return m, nil // stop iteration
|
||||||
}
|
}
|
||||||
m[C.GoString(c_name)] = C.GoBytes(unsafe.Pointer(c_val), (C.int)(c_len))
|
m[C.GoString(cName)] = C.GoBytes(unsafe.Pointer(cVal), (C.int)(cLen))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RmXattr removes an xattr with key `name` from object `oid`
|
// RmXattr removes an xattr with key `name` from object `oid`
|
||||||
func (ioctx *IOContext) RmXattr(oid string, name string) error {
|
func (ioctx *IOContext) RmXattr(oid string, name string) error {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
c_name := C.CString(name)
|
cName := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
|
|
||||||
ret := C.rados_rmxattr(
|
ret := C.rados_rmxattr(
|
||||||
ioctx.ioctx,
|
ioctx.ioctx,
|
||||||
c_oid,
|
coid,
|
||||||
c_name)
|
cName)
|
||||||
|
|
||||||
return getError(ret)
|
return getError(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LockExclusive takes an exclusive lock on an object.
|
// LockExclusive takes an exclusive lock on an object.
|
||||||
func (ioctx *IOContext) LockExclusive(oid, name, cookie, desc string, duration time.Duration, flags *byte) (int, error) {
|
func (ioctx *IOContext) LockExclusive(oid, name, cookie, desc string, duration time.Duration, flags *byte) (int, error) {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
c_name := C.CString(name)
|
cName := C.CString(name)
|
||||||
c_cookie := C.CString(cookie)
|
cCookie := C.CString(cookie)
|
||||||
c_desc := C.CString(desc)
|
cDesc := C.CString(desc)
|
||||||
|
|
||||||
var c_duration C.struct_timeval
|
var cDuration C.struct_timeval
|
||||||
if duration != 0 {
|
if duration != 0 {
|
||||||
tv := syscall.NsecToTimeval(duration.Nanoseconds())
|
tv := syscall.NsecToTimeval(duration.Nanoseconds())
|
||||||
c_duration = C.struct_timeval{tv_sec: C.ceph_time_t(tv.Sec), tv_usec: C.ceph_suseconds_t(tv.Usec)}
|
cDuration = C.struct_timeval{tv_sec: C.ceph_time_t(tv.Sec), tv_usec: C.ceph_suseconds_t(tv.Usec)}
|
||||||
}
|
}
|
||||||
|
|
||||||
var c_flags C.uint8_t
|
var cFlags C.uint8_t
|
||||||
if flags != nil {
|
if flags != nil {
|
||||||
c_flags = C.uint8_t(*flags)
|
cFlags = C.uint8_t(*flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
defer C.free(unsafe.Pointer(c_cookie))
|
defer C.free(unsafe.Pointer(cCookie))
|
||||||
defer C.free(unsafe.Pointer(c_desc))
|
defer C.free(unsafe.Pointer(cDesc))
|
||||||
|
|
||||||
ret := C.rados_lock_exclusive(
|
ret := C.rados_lock_exclusive(
|
||||||
ioctx.ioctx,
|
ioctx.ioctx,
|
||||||
c_oid,
|
coid,
|
||||||
c_name,
|
cName,
|
||||||
c_cookie,
|
cCookie,
|
||||||
c_desc,
|
cDesc,
|
||||||
&c_duration,
|
&cDuration,
|
||||||
c_flags)
|
cFlags)
|
||||||
|
|
||||||
// 0 on success, negative error code on failure
|
// 0 on success, negative error code on failure
|
||||||
// -EBUSY if the lock is already held by another (client, cookie) pair
|
// -EBUSY if the lock is already held by another (client, cookie) pair
|
||||||
@ -475,38 +475,38 @@ func (ioctx *IOContext) LockExclusive(oid, name, cookie, desc string, duration t
|
|||||||
|
|
||||||
// LockShared takes a shared lock on an object.
|
// LockShared takes a shared lock on an object.
|
||||||
func (ioctx *IOContext) LockShared(oid, name, cookie, tag, desc string, duration time.Duration, flags *byte) (int, error) {
|
func (ioctx *IOContext) LockShared(oid, name, cookie, tag, desc string, duration time.Duration, flags *byte) (int, error) {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
c_name := C.CString(name)
|
cName := C.CString(name)
|
||||||
c_cookie := C.CString(cookie)
|
cCookie := C.CString(cookie)
|
||||||
c_tag := C.CString(tag)
|
cTag := C.CString(tag)
|
||||||
c_desc := C.CString(desc)
|
cDesc := C.CString(desc)
|
||||||
|
|
||||||
var c_duration C.struct_timeval
|
var cDuration C.struct_timeval
|
||||||
if duration != 0 {
|
if duration != 0 {
|
||||||
tv := syscall.NsecToTimeval(duration.Nanoseconds())
|
tv := syscall.NsecToTimeval(duration.Nanoseconds())
|
||||||
c_duration = C.struct_timeval{tv_sec: C.ceph_time_t(tv.Sec), tv_usec: C.ceph_suseconds_t(tv.Usec)}
|
cDuration = C.struct_timeval{tv_sec: C.ceph_time_t(tv.Sec), tv_usec: C.ceph_suseconds_t(tv.Usec)}
|
||||||
}
|
}
|
||||||
|
|
||||||
var c_flags C.uint8_t
|
var cFlags C.uint8_t
|
||||||
if flags != nil {
|
if flags != nil {
|
||||||
c_flags = C.uint8_t(*flags)
|
cFlags = C.uint8_t(*flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
defer C.free(unsafe.Pointer(c_cookie))
|
defer C.free(unsafe.Pointer(cCookie))
|
||||||
defer C.free(unsafe.Pointer(c_tag))
|
defer C.free(unsafe.Pointer(cTag))
|
||||||
defer C.free(unsafe.Pointer(c_desc))
|
defer C.free(unsafe.Pointer(cDesc))
|
||||||
|
|
||||||
ret := C.rados_lock_shared(
|
ret := C.rados_lock_shared(
|
||||||
ioctx.ioctx,
|
ioctx.ioctx,
|
||||||
c_oid,
|
coid,
|
||||||
c_name,
|
cName,
|
||||||
c_cookie,
|
cCookie,
|
||||||
c_tag,
|
cTag,
|
||||||
c_desc,
|
cDesc,
|
||||||
&c_duration,
|
&cDuration,
|
||||||
c_flags)
|
cFlags)
|
||||||
|
|
||||||
// 0 on success, negative error code on failure
|
// 0 on success, negative error code on failure
|
||||||
// -EBUSY if the lock is already held by another (client, cookie) pair
|
// -EBUSY if the lock is already held by another (client, cookie) pair
|
||||||
@ -526,22 +526,22 @@ func (ioctx *IOContext) LockShared(oid, name, cookie, tag, desc string, duration
|
|||||||
|
|
||||||
// Unlock releases a shared or exclusive lock on an object.
|
// Unlock releases a shared or exclusive lock on an object.
|
||||||
func (ioctx *IOContext) Unlock(oid, name, cookie string) (int, error) {
|
func (ioctx *IOContext) Unlock(oid, name, cookie string) (int, error) {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
c_name := C.CString(name)
|
cName := C.CString(name)
|
||||||
c_cookie := C.CString(cookie)
|
cCookie := C.CString(cookie)
|
||||||
|
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
defer C.free(unsafe.Pointer(c_cookie))
|
defer C.free(unsafe.Pointer(cCookie))
|
||||||
|
|
||||||
// 0 on success, negative error code on failure
|
// 0 on success, negative error code on failure
|
||||||
// -ENOENT if the lock is not held by the specified (client, cookie) pair
|
// -ENOENT if the lock is not held by the specified (client, cookie) pair
|
||||||
|
|
||||||
ret := C.rados_unlock(
|
ret := C.rados_unlock(
|
||||||
ioctx.ioctx,
|
ioctx.ioctx,
|
||||||
c_oid,
|
coid,
|
||||||
c_name,
|
cName,
|
||||||
c_cookie)
|
cCookie)
|
||||||
|
|
||||||
switch ret {
|
switch ret {
|
||||||
case 0:
|
case 0:
|
||||||
@ -559,40 +559,40 @@ func (ioctx *IOContext) Unlock(oid, name, cookie string) (int, error) {
|
|||||||
// out parameter. If any of the provided buffers are too short, -ERANGE is
|
// out parameter. If any of the provided buffers are too short, -ERANGE is
|
||||||
// returned after these sizes are filled in.
|
// returned after these sizes are filled in.
|
||||||
func (ioctx *IOContext) ListLockers(oid, name string) (*LockInfo, error) {
|
func (ioctx *IOContext) ListLockers(oid, name string) (*LockInfo, error) {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
c_name := C.CString(name)
|
cName := C.CString(name)
|
||||||
|
|
||||||
c_tag := (*C.char)(C.malloc(C.size_t(1024)))
|
cTag := (*C.char)(C.malloc(C.size_t(1024)))
|
||||||
c_clients := (*C.char)(C.malloc(C.size_t(1024)))
|
cClients := (*C.char)(C.malloc(C.size_t(1024)))
|
||||||
c_cookies := (*C.char)(C.malloc(C.size_t(1024)))
|
cCookies := (*C.char)(C.malloc(C.size_t(1024)))
|
||||||
c_addrs := (*C.char)(C.malloc(C.size_t(1024)))
|
cAddrs := (*C.char)(C.malloc(C.size_t(1024)))
|
||||||
|
|
||||||
var c_exclusive C.int
|
var cExclusive C.int
|
||||||
c_tag_len := C.size_t(1024)
|
cTagLen := C.size_t(1024)
|
||||||
c_clients_len := C.size_t(1024)
|
cClientsLen := C.size_t(1024)
|
||||||
c_cookies_len := C.size_t(1024)
|
cCookiesLen := C.size_t(1024)
|
||||||
c_addrs_len := C.size_t(1024)
|
cAddrsLen := C.size_t(1024)
|
||||||
|
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
defer C.free(unsafe.Pointer(c_tag))
|
defer C.free(unsafe.Pointer(cTag))
|
||||||
defer C.free(unsafe.Pointer(c_clients))
|
defer C.free(unsafe.Pointer(cClients))
|
||||||
defer C.free(unsafe.Pointer(c_cookies))
|
defer C.free(unsafe.Pointer(cCookies))
|
||||||
defer C.free(unsafe.Pointer(c_addrs))
|
defer C.free(unsafe.Pointer(cAddrs))
|
||||||
|
|
||||||
ret := C.rados_list_lockers(
|
ret := C.rados_list_lockers(
|
||||||
ioctx.ioctx,
|
ioctx.ioctx,
|
||||||
c_oid,
|
coid,
|
||||||
c_name,
|
cName,
|
||||||
&c_exclusive,
|
&cExclusive,
|
||||||
c_tag,
|
cTag,
|
||||||
&c_tag_len,
|
&cTagLen,
|
||||||
c_clients,
|
cClients,
|
||||||
&c_clients_len,
|
&cClientsLen,
|
||||||
c_cookies,
|
cCookies,
|
||||||
&c_cookies_len,
|
&cCookiesLen,
|
||||||
c_addrs,
|
cAddrs,
|
||||||
&c_addrs_len)
|
&cAddrsLen)
|
||||||
|
|
||||||
splitCString := func(items *C.char, itemsLen C.size_t) []string {
|
splitCString := func(items *C.char, itemsLen C.size_t) []string {
|
||||||
currLen := 0
|
currLen := 0
|
||||||
@ -608,20 +608,20 @@ func (ioctx *IOContext) ListLockers(oid, name string) (*LockInfo, error) {
|
|||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return nil, radosError(ret)
|
return nil, radosError(ret)
|
||||||
}
|
}
|
||||||
return &LockInfo{int(ret), c_exclusive == 1, C.GoString(c_tag), splitCString(c_clients, c_clients_len), splitCString(c_cookies, c_cookies_len), splitCString(c_addrs, c_addrs_len)}, nil
|
return &LockInfo{int(ret), cExclusive == 1, C.GoString(cTag), splitCString(cClients, cClientsLen), splitCString(cCookies, cCookiesLen), splitCString(cAddrs, cAddrsLen)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// BreakLock releases a shared or exclusive lock on an object, which was taken by the specified client.
|
// BreakLock releases a shared or exclusive lock on an object, which was taken by the specified client.
|
||||||
func (ioctx *IOContext) BreakLock(oid, name, client, cookie string) (int, error) {
|
func (ioctx *IOContext) BreakLock(oid, name, client, cookie string) (int, error) {
|
||||||
c_oid := C.CString(oid)
|
coid := C.CString(oid)
|
||||||
c_name := C.CString(name)
|
cName := C.CString(name)
|
||||||
c_client := C.CString(client)
|
cClient := C.CString(client)
|
||||||
c_cookie := C.CString(cookie)
|
cCookie := C.CString(cookie)
|
||||||
|
|
||||||
defer C.free(unsafe.Pointer(c_oid))
|
defer C.free(unsafe.Pointer(coid))
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
defer C.free(unsafe.Pointer(c_client))
|
defer C.free(unsafe.Pointer(cClient))
|
||||||
defer C.free(unsafe.Pointer(c_cookie))
|
defer C.free(unsafe.Pointer(cCookie))
|
||||||
|
|
||||||
// 0 on success, negative error code on failure
|
// 0 on success, negative error code on failure
|
||||||
// -ENOENT if the lock is not held by the specified (client, cookie) pair
|
// -ENOENT if the lock is not held by the specified (client, cookie) pair
|
||||||
@ -629,10 +629,10 @@ func (ioctx *IOContext) BreakLock(oid, name, client, cookie string) (int, error)
|
|||||||
|
|
||||||
ret := C.rados_break_lock(
|
ret := C.rados_break_lock(
|
||||||
ioctx.ioctx,
|
ioctx.ioctx,
|
||||||
c_oid,
|
coid,
|
||||||
c_name,
|
cName,
|
||||||
c_client,
|
cClient,
|
||||||
c_cookie)
|
cCookie)
|
||||||
|
|
||||||
switch ret {
|
switch ret {
|
||||||
case 0:
|
case 0:
|
||||||
|
10
vendor/github.com/ceph/go-ceph/rados/object_iter.go
generated
vendored
10
vendor/github.com/ceph/go-ceph/rados/object_iter.go
generated
vendored
@ -50,14 +50,14 @@ func (iter *Iter) Seek(token IterToken) {
|
|||||||
// return iter.Err()
|
// return iter.Err()
|
||||||
//
|
//
|
||||||
func (iter *Iter) Next() bool {
|
func (iter *Iter) Next() bool {
|
||||||
var c_entry *C.char
|
var cEntry *C.char
|
||||||
var c_namespace *C.char
|
var cNamespace *C.char
|
||||||
if cerr := C.rados_nobjects_list_next(iter.ctx, &c_entry, nil, &c_namespace); cerr < 0 {
|
if cerr := C.rados_nobjects_list_next(iter.ctx, &cEntry, nil, &cNamespace); cerr < 0 {
|
||||||
iter.err = getError(cerr)
|
iter.err = getError(cerr)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
iter.entry = C.GoString(c_entry)
|
iter.entry = C.GoString(cEntry)
|
||||||
iter.namespace = C.GoString(c_namespace)
|
iter.namespace = C.GoString(cNamespace)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
vendor/github.com/ceph/go-ceph/rados/rados.go
generated
vendored
22
vendor/github.com/ceph/go-ceph/rados/rados.go
generated
vendored
@ -55,9 +55,9 @@ const (
|
|||||||
// Version returns the major, minor, and patch components of the version of
|
// Version returns the major, minor, and patch components of the version of
|
||||||
// the RADOS library linked against.
|
// the RADOS library linked against.
|
||||||
func Version() (int, int, int) {
|
func Version() (int, int, int) {
|
||||||
var c_major, c_minor, c_patch C.int
|
var cMajor, cMinor, cPatch C.int
|
||||||
C.rados_version(&c_major, &c_minor, &c_patch)
|
C.rados_version(&cMajor, &cMinor, &cPatch)
|
||||||
return int(c_major), int(c_minor), int(c_patch)
|
return int(cMajor), int(cMinor), int(cPatch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeConn() *Conn {
|
func makeConn() *Conn {
|
||||||
@ -85,22 +85,22 @@ func NewConn() (*Conn, error) {
|
|||||||
// NewConnWithUser creates a new connection object with a custom username.
|
// NewConnWithUser creates a new connection object with a custom username.
|
||||||
// It returns the connection and an error, if any.
|
// It returns the connection and an error, if any.
|
||||||
func NewConnWithUser(user string) (*Conn, error) {
|
func NewConnWithUser(user string) (*Conn, error) {
|
||||||
c_user := C.CString(user)
|
cUser := C.CString(user)
|
||||||
defer C.free(unsafe.Pointer(c_user))
|
defer C.free(unsafe.Pointer(cUser))
|
||||||
return newConn(c_user)
|
return newConn(cUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConnWithClusterAndUser creates a new connection object for a specific cluster and username.
|
// NewConnWithClusterAndUser creates a new connection object for a specific cluster and username.
|
||||||
// It returns the connection and an error, if any.
|
// It returns the connection and an error, if any.
|
||||||
func NewConnWithClusterAndUser(clusterName string, userName string) (*Conn, error) {
|
func NewConnWithClusterAndUser(clusterName string, userName string) (*Conn, error) {
|
||||||
c_cluster_name := C.CString(clusterName)
|
cClusterName := C.CString(clusterName)
|
||||||
defer C.free(unsafe.Pointer(c_cluster_name))
|
defer C.free(unsafe.Pointer(cClusterName))
|
||||||
|
|
||||||
c_name := C.CString(userName)
|
cName := C.CString(userName)
|
||||||
defer C.free(unsafe.Pointer(c_name))
|
defer C.free(unsafe.Pointer(cName))
|
||||||
|
|
||||||
conn := makeConn()
|
conn := makeConn()
|
||||||
ret := C.rados_create2(&conn.cluster, c_cluster_name, c_name, 0)
|
ret := C.rados_create2(&conn.cluster, cClusterName, cName, 0)
|
||||||
if ret != 0 {
|
if ret != 0 {
|
||||||
return nil, getError(ret)
|
return nil, getError(ret)
|
||||||
}
|
}
|
||||||
|
139
vendor/github.com/ceph/go-ceph/rbd/encryption.go
generated
vendored
Normal file
139
vendor/github.com/ceph/go-ceph/rbd/encryption.go
generated
vendored
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
// +build !octopus,!nautilus
|
||||||
|
|
||||||
|
package rbd
|
||||||
|
|
||||||
|
// #cgo LDFLAGS: -lrbd
|
||||||
|
// /* force XSI-complaint strerror_r() */
|
||||||
|
// #define _POSIX_C_SOURCE 200112L
|
||||||
|
// #undef _GNU_SOURCE
|
||||||
|
// #include <errno.h>
|
||||||
|
// #include <stdlib.h>
|
||||||
|
// #include <rados/librados.h>
|
||||||
|
// #include <rbd/librbd.h>
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// cEncryptionData contains the data needed by the encryption functions
|
||||||
|
type cEncryptionData struct {
|
||||||
|
format C.rbd_encryption_format_t
|
||||||
|
opts C.rbd_encryption_options_t
|
||||||
|
optsSize C.size_t
|
||||||
|
free func()
|
||||||
|
}
|
||||||
|
|
||||||
|
// EncryptionAlgorithm is the encryption algorithm
|
||||||
|
type EncryptionAlgorithm C.rbd_encryption_algorithm_t
|
||||||
|
|
||||||
|
// Possible values for EncryptionAlgorithm:
|
||||||
|
// EncryptionAlgorithmAES128: AES 128bits
|
||||||
|
// EncryptionAlgorithmAES256: AES 256bits
|
||||||
|
const (
|
||||||
|
EncryptionAlgorithmAES128 = EncryptionAlgorithm(C.RBD_ENCRYPTION_ALGORITHM_AES128)
|
||||||
|
EncryptionAlgorithmAES256 = EncryptionAlgorithm(C.RBD_ENCRYPTION_ALGORITHM_AES256)
|
||||||
|
)
|
||||||
|
|
||||||
|
// EncryptionOptionsLUKS1 and EncryptionOptionsLUKS2 are identical
|
||||||
|
// structures at the moment, just as they are in the librbd api.
|
||||||
|
// The purpose behind creating different identical structures, is to facilitate
|
||||||
|
// future modifications of one of the formats, while maintaining backwards
|
||||||
|
// compatibility with the other.
|
||||||
|
|
||||||
|
// EncryptionOptionsLUKS1 options required for LUKS v1
|
||||||
|
type EncryptionOptionsLUKS1 struct {
|
||||||
|
Alg EncryptionAlgorithm
|
||||||
|
Passphrase []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// EncryptionOptionsLUKS2 options required for LUKS v2
|
||||||
|
type EncryptionOptionsLUKS2 struct {
|
||||||
|
Alg EncryptionAlgorithm
|
||||||
|
Passphrase []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// EncryptionOptions interface is used to encapsulate the different encryption
|
||||||
|
// formats options and enable converting them from go to C structures.
|
||||||
|
type EncryptionOptions interface {
|
||||||
|
allocateEncryptionOptions() cEncryptionData
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
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_luks1_format_options_t)
|
||||||
|
retData.free = func() { C.free(unsafe.Pointer(cOpts.passphrase)) }
|
||||||
|
retData.format = C.RBD_ENCRYPTION_FORMAT_LUKS1
|
||||||
|
return retData
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
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_luks2_format_options_t)
|
||||||
|
retData.free = func() { C.free(unsafe.Pointer(cOpts.passphrase)) }
|
||||||
|
retData.format = C.RBD_ENCRYPTION_FORMAT_LUKS2
|
||||||
|
return retData
|
||||||
|
}
|
||||||
|
|
||||||
|
// EncryptionFormat creates an encryption format header
|
||||||
|
//
|
||||||
|
// Implements:
|
||||||
|
// int rbd_encryption_format(rbd_image_t image,
|
||||||
|
// rbd_encryption_format_t format,
|
||||||
|
// rbd_encryption_options_t opts,
|
||||||
|
// size_t opts_size);
|
||||||
|
//
|
||||||
|
// To issue an IO against the image, you need to mount the image
|
||||||
|
// with libvirt/qemu using the LUKS format, or make a call to
|
||||||
|
// rbd_encryption_load().
|
||||||
|
func (image *Image) EncryptionFormat(opts EncryptionOptions) error {
|
||||||
|
if image.image == nil {
|
||||||
|
return ErrImageNotOpen
|
||||||
|
}
|
||||||
|
|
||||||
|
encryptionOpts := opts.allocateEncryptionOptions()
|
||||||
|
defer encryptionOpts.free()
|
||||||
|
|
||||||
|
ret := C.rbd_encryption_format(
|
||||||
|
image.image,
|
||||||
|
encryptionOpts.format,
|
||||||
|
encryptionOpts.opts,
|
||||||
|
encryptionOpts.optsSize)
|
||||||
|
|
||||||
|
return getError(ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EncryptionLoad enables IO on an open encrypted image
|
||||||
|
//
|
||||||
|
// Implements:
|
||||||
|
// int rbd_encryption_load(rbd_image_t image,
|
||||||
|
// rbd_encryption_format_t format,
|
||||||
|
// rbd_encryption_options_t opts,
|
||||||
|
// size_t opts_size);
|
||||||
|
func (image *Image) EncryptionLoad(opts EncryptionOptions) error {
|
||||||
|
if image.image == nil {
|
||||||
|
return ErrImageNotOpen
|
||||||
|
}
|
||||||
|
|
||||||
|
encryptionOpts := opts.allocateEncryptionOptions()
|
||||||
|
defer encryptionOpts.free()
|
||||||
|
|
||||||
|
ret := C.rbd_encryption_load(
|
||||||
|
image.image,
|
||||||
|
encryptionOpts.format,
|
||||||
|
encryptionOpts.opts,
|
||||||
|
encryptionOpts.optsSize)
|
||||||
|
return getError(ret)
|
||||||
|
}
|
9
vendor/github.com/ceph/go-ceph/rbd/features.go
generated
vendored
9
vendor/github.com/ceph/go-ceph/rbd/features.go
generated
vendored
@ -39,6 +39,10 @@ const (
|
|||||||
// librbd
|
// librbd
|
||||||
FeatureDataPool = uint64(C.RBD_FEATURE_DATA_POOL)
|
FeatureDataPool = uint64(C.RBD_FEATURE_DATA_POOL)
|
||||||
|
|
||||||
|
// FeatureOperations is the representation of RBD_FEATURE_OPERATIONS
|
||||||
|
// from librbd
|
||||||
|
FeatureOperations = uint64(C.RBD_FEATURE_OPERATIONS)
|
||||||
|
|
||||||
// RBD features, strings
|
// RBD features, strings
|
||||||
|
|
||||||
// FeatureNameLayering is the representation of
|
// FeatureNameLayering is the representation of
|
||||||
@ -73,6 +77,10 @@ const (
|
|||||||
// RBD_FEATURE_NAME_DATA_POOL from librbd
|
// RBD_FEATURE_NAME_DATA_POOL from librbd
|
||||||
FeatureNameDataPool = C.RBD_FEATURE_NAME_DATA_POOL
|
FeatureNameDataPool = C.RBD_FEATURE_NAME_DATA_POOL
|
||||||
|
|
||||||
|
// FeatureNameOperations is the representation of
|
||||||
|
// RBD_FEATURE_NAME_OPERATIONS from librbd
|
||||||
|
FeatureNameOperations = C.RBD_FEATURE_NAME_OPERATIONS
|
||||||
|
|
||||||
// old names for backwards compatibility (unused?)
|
// old names for backwards compatibility (unused?)
|
||||||
|
|
||||||
// RbdFeatureLayering deprecated alias for FeatureLayering
|
// RbdFeatureLayering deprecated alias for FeatureLayering
|
||||||
@ -115,6 +123,7 @@ var (
|
|||||||
FeatureNameDeepFlatten: FeatureDeepFlatten,
|
FeatureNameDeepFlatten: FeatureDeepFlatten,
|
||||||
FeatureNameJournaling: FeatureJournaling,
|
FeatureNameJournaling: FeatureJournaling,
|
||||||
FeatureNameDataPool: FeatureDataPool,
|
FeatureNameDataPool: FeatureDataPool,
|
||||||
|
FeatureNameOperations: FeatureOperations,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
20
vendor/github.com/ceph/go-ceph/rbd/features_mimic.go
generated
vendored
20
vendor/github.com/ceph/go-ceph/rbd/features_mimic.go
generated
vendored
@ -1,20 +0,0 @@
|
|||||||
// +build !luminous
|
|
||||||
|
|
||||||
package rbd
|
|
||||||
|
|
||||||
// #include <rbd/librbd.h>
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
const (
|
|
||||||
// FeatureOperations is the representation of RBD_FEATURE_OPERATIONS
|
|
||||||
// from librbd
|
|
||||||
FeatureOperations = uint64(C.RBD_FEATURE_OPERATIONS)
|
|
||||||
|
|
||||||
// FeatureNameOperations is the representation of
|
|
||||||
// RBD_FEATURE_NAME_OPERATIONS from librbd
|
|
||||||
FeatureNameOperations = C.RBD_FEATURE_NAME_OPERATIONS
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
featureNameToBit[FeatureNameOperations] = FeatureOperations
|
|
||||||
}
|
|
226
vendor/github.com/ceph/go-ceph/rbd/mirror.go
generated
vendored
226
vendor/github.com/ceph/go-ceph/rbd/mirror.go
generated
vendored
@ -50,6 +50,16 @@ func (m MirrorMode) String() string {
|
|||||||
// ImageMirrorMode is used to indicate the mirroring approach for an RBD image.
|
// ImageMirrorMode is used to indicate the mirroring approach for an RBD image.
|
||||||
type ImageMirrorMode int64
|
type ImageMirrorMode int64
|
||||||
|
|
||||||
|
// ImageMirrorModeFilter is a ImageMirrorMode or nil for no filtering
|
||||||
|
type ImageMirrorModeFilter interface {
|
||||||
|
mode() ImageMirrorMode
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mode returns the ImageMirrorMode
|
||||||
|
func (imm ImageMirrorMode) mode() ImageMirrorMode {
|
||||||
|
return imm
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// ImageMirrorModeJournal uses journaling to propagate RBD images between
|
// ImageMirrorModeJournal uses journaling to propagate RBD images between
|
||||||
// ceph clusters.
|
// ceph clusters.
|
||||||
@ -71,12 +81,12 @@ func (imm ImageMirrorMode) String() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMirrorUUID returns a string naming the mirroring uuid for the pool
|
// GetMirrorUUID returns a string naming the mirroring uuid for the pool
|
||||||
// associated with the ioctx.
|
// associated with the ioctx.
|
||||||
//
|
//
|
||||||
// Implements:
|
// Implements:
|
||||||
// int rbd_mirror_uuid_get(rados_ioctx_t io_ctx,
|
// int rbd_mirror_uuid_get(rados_ioctx_t io_ctx, char *uuid, size_t
|
||||||
// char *uuid, size_t *max_len);
|
// *max_len);
|
||||||
func GetMirrorUUID(ioctx *rados.IOContext) (string, error) {
|
func GetMirrorUUID(ioctx *rados.IOContext) (string, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
@ -626,6 +636,45 @@ type GlobalMirrorImageIDAndStatus struct {
|
|||||||
Status GlobalMirrorImageStatus
|
Status GlobalMirrorImageStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// iterBufSize is intentionally not a constant. The unit tests alter
|
||||||
|
// this value in order to get more code coverage w/o needing to create
|
||||||
|
// very many images.
|
||||||
|
var iterBufSize = 64
|
||||||
|
|
||||||
|
// MirrorImageGlobalStatusList returns a slice of GlobalMirrorImageIDAndStatus.
|
||||||
|
// 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_status_list(rados_ioctx_t p,
|
||||||
|
// 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) {
|
||||||
|
var (
|
||||||
|
result []GlobalMirrorImageIDAndStatus
|
||||||
|
fetchAll bool
|
||||||
|
)
|
||||||
|
if max <= 0 {
|
||||||
|
max = iterBufSize
|
||||||
|
fetchAll = true
|
||||||
|
}
|
||||||
|
chunk := make([]GlobalMirrorImageIDAndStatus, max)
|
||||||
|
for {
|
||||||
|
length, err := mirrorImageGlobalStatusList(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 mirrorImageGlobalStatusList(
|
func mirrorImageGlobalStatusList(
|
||||||
ioctx *rados.IOContext, start string,
|
ioctx *rados.IOContext, start string,
|
||||||
results []GlobalMirrorImageIDAndStatus) (int, error) {
|
results []GlobalMirrorImageIDAndStatus) (int, error) {
|
||||||
@ -645,26 +694,23 @@ func mirrorImageGlobalStatusList(
|
|||||||
cephIoctx(ioctx),
|
cephIoctx(ioctx),
|
||||||
cStart,
|
cStart,
|
||||||
max,
|
max,
|
||||||
(**C.char)(unsafe.Pointer(&ids[0])),
|
&ids[0],
|
||||||
(*C.rbd_mirror_image_global_status_t)(unsafe.Pointer(&images[0])),
|
&images[0],
|
||||||
&length)
|
&length)
|
||||||
|
if err := getError(ret); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
for i := 0; i < int(length); i++ {
|
for i := 0; i < int(length); i++ {
|
||||||
results[i].ID = C.GoString(ids[i])
|
results[i].ID = C.GoString(ids[i])
|
||||||
results[i].Status = newGlobalMirrorImageStatus(&images[0])
|
results[i].Status = newGlobalMirrorImageStatus(&images[0])
|
||||||
}
|
}
|
||||||
C.rbd_mirror_image_global_status_list_cleanup(
|
C.rbd_mirror_image_global_status_list_cleanup(
|
||||||
(**C.char)(unsafe.Pointer(&ids[0])),
|
&ids[0],
|
||||||
(*C.rbd_mirror_image_global_status_t)(unsafe.Pointer(&images[0])),
|
&images[0],
|
||||||
length)
|
length)
|
||||||
return int(length), getError(ret)
|
return int(length), getError(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
// statusIterBufSize is intentionally not a constant. The unit tests alter
|
|
||||||
// this value in order to get more code coverage w/o needing to create
|
|
||||||
// very many images.
|
|
||||||
var statusIterBufSize = 64
|
|
||||||
|
|
||||||
// MirrorImageGlobalStatusIter provide methods for iterating over all
|
// MirrorImageGlobalStatusIter provide methods for iterating over all
|
||||||
// the GlobalMirrorImageIdAndStatus values in a pool.
|
// the GlobalMirrorImageIdAndStatus values in a pool.
|
||||||
type MirrorImageGlobalStatusIter struct {
|
type MirrorImageGlobalStatusIter struct {
|
||||||
@ -700,16 +746,14 @@ func (iter *MirrorImageGlobalStatusIter) Next() (*GlobalMirrorImageIDAndStatus,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Close terminates iteration regardless if iteration was completed and
|
// Close terminates iteration regardless if iteration was completed and
|
||||||
// frees any associated resources.
|
// frees any associated resources. (DEPRECATED)
|
||||||
func (iter *MirrorImageGlobalStatusIter) Close() error {
|
func (*MirrorImageGlobalStatusIter) Close() error {
|
||||||
iter.buf = nil
|
|
||||||
iter.lastID = ""
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (iter *MirrorImageGlobalStatusIter) fetch() error {
|
func (iter *MirrorImageGlobalStatusIter) fetch() error {
|
||||||
iter.buf = nil
|
iter.buf = nil
|
||||||
items := make([]GlobalMirrorImageIDAndStatus, statusIterBufSize)
|
items := make([]GlobalMirrorImageIDAndStatus, iterBufSize)
|
||||||
n, err := mirrorImageGlobalStatusList(
|
n, err := mirrorImageGlobalStatusList(
|
||||||
iter.ioctx,
|
iter.ioctx,
|
||||||
iter.lastID,
|
iter.lastID,
|
||||||
@ -722,3 +766,145 @@ func (iter *MirrorImageGlobalStatusIter) fetch() error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MirrorImageInfoItem contains an ID string for a RBD image and that image's
|
||||||
|
// ImageMirrorMode and MirrorImageInfo.
|
||||||
|
type MirrorImageInfoItem struct {
|
||||||
|
ID string
|
||||||
|
Mode ImageMirrorMode
|
||||||
|
Info MirrorImageInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
// MirrorImageInfoList returns a slice of MirrorImageInfoItem. 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. The returned
|
||||||
|
// items are filtered by the mirror mode specified with modeFilter. If max is 0
|
||||||
|
// a slice of all items is returned.
|
||||||
|
//
|
||||||
|
// Implements:
|
||||||
|
// int rbd_mirror_image_info_list(
|
||||||
|
// rados_ioctx_t p, rbd_mirror_image_mode_t *mode_filter,
|
||||||
|
// const char *start_id, size_t max, char **image_ids,
|
||||||
|
// rbd_mirror_image_mode_t *mode_entries,
|
||||||
|
// rbd_mirror_image_info_t *info_entries, size_t *num_entries)
|
||||||
|
func MirrorImageInfoList(
|
||||||
|
ioctx *rados.IOContext, modeFilter ImageMirrorModeFilter, start string,
|
||||||
|
max int) ([]MirrorImageInfoItem, error) {
|
||||||
|
var (
|
||||||
|
result []MirrorImageInfoItem
|
||||||
|
fetchAll bool
|
||||||
|
)
|
||||||
|
if max <= 0 {
|
||||||
|
max = iterBufSize
|
||||||
|
fetchAll = true
|
||||||
|
}
|
||||||
|
chunk := make([]MirrorImageInfoItem, max)
|
||||||
|
for {
|
||||||
|
length, err := mirrorImageInfoList(ioctx, start, modeFilter, 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 mirrorImageInfoList(ioctx *rados.IOContext, start string,
|
||||||
|
modeFilter ImageMirrorModeFilter, results []MirrorImageInfoItem) (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))
|
||||||
|
modes = make([]C.rbd_mirror_image_mode_t, len(results))
|
||||||
|
infos = make([]C.rbd_mirror_image_info_t, len(results))
|
||||||
|
modeFilterPtr *C.rbd_mirror_image_mode_t
|
||||||
|
)
|
||||||
|
if modeFilter != nil {
|
||||||
|
cMode := C.rbd_mirror_image_mode_t(modeFilter.mode())
|
||||||
|
modeFilterPtr = &cMode
|
||||||
|
}
|
||||||
|
ret := C.rbd_mirror_image_info_list(
|
||||||
|
cephIoctx(ioctx),
|
||||||
|
modeFilterPtr,
|
||||||
|
cStart,
|
||||||
|
max,
|
||||||
|
&ids[0],
|
||||||
|
&modes[0],
|
||||||
|
&infos[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].Mode = ImageMirrorMode(modes[i])
|
||||||
|
results[i].Info = convertMirrorImageInfo(&infos[i])
|
||||||
|
}
|
||||||
|
C.rbd_mirror_image_info_list_cleanup(
|
||||||
|
&ids[0],
|
||||||
|
&infos[0],
|
||||||
|
length)
|
||||||
|
return int(length), getError(ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MirrorImageInfoIter provide methods for iterating over all
|
||||||
|
// the MirrorImageInfoItem values in a pool.
|
||||||
|
type MirrorImageInfoIter struct {
|
||||||
|
ioctx *rados.IOContext
|
||||||
|
|
||||||
|
modeFilter ImageMirrorModeFilter
|
||||||
|
buf []MirrorImageInfoItem
|
||||||
|
lastID string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMirrorImageInfoIter creates a new iterator ready for use.
|
||||||
|
func NewMirrorImageInfoIter(ioctx *rados.IOContext, modeFilter ImageMirrorModeFilter) *MirrorImageInfoIter {
|
||||||
|
return &MirrorImageInfoIter{
|
||||||
|
ioctx: ioctx,
|
||||||
|
modeFilter: modeFilter,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next fetches one MirrorImageInfoItem 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 *MirrorImageInfoIter) Next() (*MirrorImageInfoItem, 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 *MirrorImageInfoIter) fetch() error {
|
||||||
|
iter.buf = nil
|
||||||
|
items := make([]MirrorImageInfoItem, iterBufSize)
|
||||||
|
n, err := mirrorImageInfoList(
|
||||||
|
iter.ioctx,
|
||||||
|
iter.lastID,
|
||||||
|
iter.modeFilter,
|
||||||
|
items)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if n > 0 {
|
||||||
|
iter.buf = items[:n]
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
6
vendor/github.com/ceph/go-ceph/rbd/options.go
generated
vendored
6
vendor/github.com/ceph/go-ceph/rbd/options.go
generated
vendored
@ -46,6 +46,12 @@ const (
|
|||||||
// ImageOptionDataPool is the representation of RBD_IMAGE_OPTION_DATA_POOL
|
// ImageOptionDataPool is the representation of RBD_IMAGE_OPTION_DATA_POOL
|
||||||
// from librbd
|
// from librbd
|
||||||
ImageOptionDataPool = C.RBD_IMAGE_OPTION_DATA_POOL
|
ImageOptionDataPool = C.RBD_IMAGE_OPTION_DATA_POOL
|
||||||
|
// ImageOptionFlatten is the representation of RBD_IMAGE_OPTION_FLATTEN
|
||||||
|
// from librbd
|
||||||
|
ImageOptionFlatten = C.RBD_IMAGE_OPTION_FLATTEN
|
||||||
|
// ImageOptionCloneFormat is the representation of
|
||||||
|
// RBD_IMAGE_OPTION_CLONE_FORMAT from librbd
|
||||||
|
ImageOptionCloneFormat = C.RBD_IMAGE_OPTION_CLONE_FORMAT
|
||||||
|
|
||||||
// RbdImageOptionFormat deprecated alias for ImageOptionFormat
|
// RbdImageOptionFormat deprecated alias for ImageOptionFormat
|
||||||
RbdImageOptionFormat = ImageOptionFormat
|
RbdImageOptionFormat = ImageOptionFormat
|
||||||
|
16
vendor/github.com/ceph/go-ceph/rbd/options_mimic.go
generated
vendored
16
vendor/github.com/ceph/go-ceph/rbd/options_mimic.go
generated
vendored
@ -1,16 +0,0 @@
|
|||||||
// +build !luminous
|
|
||||||
|
|
||||||
package rbd
|
|
||||||
|
|
||||||
// #include <rbd/librbd.h>
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
const (
|
|
||||||
// ImageOptionFlatten is the representation of RBD_IMAGE_OPTION_FLATTEN
|
|
||||||
// from librbd
|
|
||||||
ImageOptionFlatten = C.RBD_IMAGE_OPTION_FLATTEN
|
|
||||||
|
|
||||||
// ImageOptionCloneFormat is the representation of
|
|
||||||
// RBD_IMAGE_OPTION_CLONE_FORMAT from librbd
|
|
||||||
ImageOptionCloneFormat = C.RBD_IMAGE_OPTION_CLONE_FORMAT
|
|
||||||
)
|
|
2
vendor/github.com/ceph/go-ceph/rbd/options_octopus.go
generated
vendored
2
vendor/github.com/ceph/go-ceph/rbd/options_octopus.go
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// +build !luminous,!mimic,!nautilus
|
// +build !nautilus
|
||||||
|
|
||||||
package rbd
|
package rbd
|
||||||
|
|
||||||
|
42
vendor/github.com/ceph/go-ceph/rbd/rbd_mimic.go
generated
vendored
42
vendor/github.com/ceph/go-ceph/rbd/rbd_mimic.go
generated
vendored
@ -1,42 +0,0 @@
|
|||||||
// +build luminous mimic
|
|
||||||
// +build !nautilus
|
|
||||||
//
|
|
||||||
// Ceph Nautilus includes rbd_list2() and marked rbd_list() deprecated.
|
|
||||||
|
|
||||||
package rbd
|
|
||||||
|
|
||||||
// #cgo LDFLAGS: -lrbd
|
|
||||||
// #include <rados/librados.h>
|
|
||||||
// #include <rbd/librbd.h>
|
|
||||||
// #include <errno.h>
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
import (
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"github.com/ceph/go-ceph/internal/cutil"
|
|
||||||
"github.com/ceph/go-ceph/internal/retry"
|
|
||||||
"github.com/ceph/go-ceph/rados"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetImageNames returns the list of current RBD images.
|
|
||||||
func GetImageNames(ioctx *rados.IOContext) (names []string, err error) {
|
|
||||||
var (
|
|
||||||
buf []byte
|
|
||||||
csize C.size_t
|
|
||||||
)
|
|
||||||
// from 4KiB to 32KiB
|
|
||||||
retry.WithSizes(4096, 1<<15, func(size int) retry.Hint {
|
|
||||||
csize = C.size_t(size)
|
|
||||||
buf = make([]byte, csize)
|
|
||||||
ret := C.rbd_list(cephIoctx(ioctx),
|
|
||||||
(*C.char)(unsafe.Pointer(&buf[0])), &csize)
|
|
||||||
err = getErrorIfNegative(ret)
|
|
||||||
return retry.Size(int(csize)).If(err == errRange)
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
names = cutil.SplitSparseBuffer(buf[:csize])
|
|
||||||
return names, nil
|
|
||||||
}
|
|
88
vendor/github.com/ceph/go-ceph/rbd/snapshot_mimic.go
generated
vendored
88
vendor/github.com/ceph/go-ceph/rbd/snapshot_mimic.go
generated
vendored
@ -1,88 +0,0 @@
|
|||||||
// +build luminous mimic
|
|
||||||
// +build !nautilus
|
|
||||||
//
|
|
||||||
// Ceph Nautilus introduced rbd_get_parent() and deprecated rbd_get_parent_info().
|
|
||||||
// Ceph Nautilus introduced rbd_list_children3() and deprecated rbd_list_children().
|
|
||||||
|
|
||||||
package rbd
|
|
||||||
|
|
||||||
// #cgo LDFLAGS: -lrbd
|
|
||||||
// #include <rbd/librbd.h>
|
|
||||||
// #include <errno.h>
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
import (
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"github.com/ceph/go-ceph/internal/cutil"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetParentInfo looks for the parent of the image and stores the pool, name
|
|
||||||
// and snapshot-name in the byte-arrays that are passed as arguments.
|
|
||||||
//
|
|
||||||
// Implements:
|
|
||||||
// int rbd_get_parent_info(rbd_image_t image, char *parent_pool_name,
|
|
||||||
// size_t ppool_namelen, char *parent_name,
|
|
||||||
// size_t pnamelen, char *parent_snap_name,
|
|
||||||
// size_t psnap_namelen)
|
|
||||||
func (image *Image) GetParentInfo(p_pool, p_name, p_snapname []byte) error {
|
|
||||||
if err := image.validate(imageIsOpen); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
ret := C.rbd_get_parent_info(
|
|
||||||
image.image,
|
|
||||||
(*C.char)(unsafe.Pointer(&p_pool[0])),
|
|
||||||
(C.size_t)(len(p_pool)),
|
|
||||||
(*C.char)(unsafe.Pointer(&p_name[0])),
|
|
||||||
(C.size_t)(len(p_name)),
|
|
||||||
(*C.char)(unsafe.Pointer(&p_snapname[0])),
|
|
||||||
(C.size_t)(len(p_snapname)))
|
|
||||||
if ret == 0 {
|
|
||||||
return nil
|
|
||||||
} else {
|
|
||||||
return rbdError(ret)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListChildren returns arrays with the pools and names of the images that are
|
|
||||||
// children of the given image. The index of the pools and images arrays can be
|
|
||||||
// used to link the two items together.
|
|
||||||
//
|
|
||||||
// Implements:
|
|
||||||
// ssize_t rbd_list_children(rbd_image_t image, char *pools,
|
|
||||||
// size_t *pools_len,
|
|
||||||
// char *images, size_t *images_len);
|
|
||||||
func (image *Image) ListChildren() (pools []string, images []string, err error) {
|
|
||||||
if err := image.validate(imageIsOpen); err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var c_pools_len, c_images_len C.size_t
|
|
||||||
|
|
||||||
ret := C.rbd_list_children(image.image,
|
|
||||||
nil, &c_pools_len,
|
|
||||||
nil, &c_images_len)
|
|
||||||
if ret == 0 {
|
|
||||||
return nil, nil, nil
|
|
||||||
}
|
|
||||||
if ret < 0 && ret != -C.ERANGE {
|
|
||||||
return nil, nil, rbdError(ret)
|
|
||||||
}
|
|
||||||
|
|
||||||
pools_buf := make([]byte, c_pools_len)
|
|
||||||
images_buf := make([]byte, c_images_len)
|
|
||||||
|
|
||||||
ret = C.rbd_list_children(image.image,
|
|
||||||
(*C.char)(unsafe.Pointer(&pools_buf[0])),
|
|
||||||
&c_pools_len,
|
|
||||||
(*C.char)(unsafe.Pointer(&images_buf[0])),
|
|
||||||
&c_images_len)
|
|
||||||
if ret < 0 {
|
|
||||||
return nil, nil, rbdError(ret)
|
|
||||||
}
|
|
||||||
|
|
||||||
pools = cutil.SplitSparseBuffer(pools_buf[:c_pools_len])
|
|
||||||
images = cutil.SplitSparseBuffer(images_buf[:c_images_len])
|
|
||||||
return pools, images, nil
|
|
||||||
}
|
|
@ -1,7 +1,3 @@
|
|||||||
// +build !luminous
|
|
||||||
//
|
|
||||||
// Ceph Mimic is the first version that supports watchers through librbd.
|
|
||||||
|
|
||||||
package rbd
|
package rbd
|
||||||
|
|
||||||
/*
|
/*
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -47,7 +47,7 @@ github.com/aws/aws-sdk-go/service/sts/stsiface
|
|||||||
github.com/beorn7/perks/quantile
|
github.com/beorn7/perks/quantile
|
||||||
# github.com/blang/semver v3.5.1+incompatible
|
# github.com/blang/semver v3.5.1+incompatible
|
||||||
github.com/blang/semver
|
github.com/blang/semver
|
||||||
# github.com/ceph/go-ceph v0.10.0
|
# github.com/ceph/go-ceph v0.11.0
|
||||||
## explicit
|
## explicit
|
||||||
github.com/ceph/go-ceph/cephfs/admin
|
github.com/ceph/go-ceph/cephfs/admin
|
||||||
github.com/ceph/go-ceph/common/commands
|
github.com/ceph/go-ceph/common/commands
|
||||||
|
Loading…
Reference in New Issue
Block a user