Documentation ¶
Overview ¶
Package rbd contains a set of wrappers around Ceph's librbd API.
Index ¶
- Constants
- Variables
- func CloneFromImage(parent *Image, snapName string, destctx *rados.IOContext, name string, ...) error
- func CloneImage(ioctx *rados.IOContext, parentName, snapName string, destctx *rados.IOContext, ...) error
- func CreateImage(ioctx *rados.IOContext, name string, size uint64, rio *RbdImageOptions) error
- func GetImageNames(ioctx *rados.IOContext) ([]string, error)
- func RemoveImage(ioctx *rados.IOContext, name string) error
- func TrashRemove(ioctx *rados.IOContext, id string, force bool) error
- func TrashRestore(ioctx *rados.IOContext, id, name string) error
- func Version() (int, int, int)
- type Image
- func Create(ioctx *rados.IOContext, name string, size uint64, order int, args ...uint64) (image *Image, err error)
- func Create2(ioctx *rados.IOContext, name string, size uint64, features uint64, order int) (image *Image, err error)
- func Create3(ioctx *rados.IOContext, name string, size uint64, features uint64, order int, ...) (image *Image, err error)
- func GetImage(ioctx *rados.IOContext, name string) *Image
- func OpenImage(ioctx *rados.IOContext, name, snapName string) (*Image, error)
- func OpenImageById(ioctx *rados.IOContext, id, snapName string) (*Image, error)
- func OpenImageByIdReadOnly(ioctx *rados.IOContext, id, snapName string) (*Image, error)
- func OpenImageReadOnly(ioctx *rados.IOContext, name, snapName string) (*Image, error)
- func (image *Image) BreakLock(client string, cookie string) error
- func (image *Image) Clone(snapname string, c_ioctx *rados.IOContext, c_name string, features uint64, ...) (*Image, error)
- func (image *Image) Close() error
- func (image *Image) Copy(ioctx *rados.IOContext, destname string) error
- func (image *Image) Copy2(dest *Image) error
- func (image *Image) CreateSnapshot(snapname string) (*Snapshot, error)
- func (image *Image) Discard(ofs uint64, length uint64) (int, error)
- func (image *Image) Flatten() error
- func (image *Image) Flush() error
- func (image *Image) GetFeatures() (features uint64, err error)
- func (image *Image) GetId() (string, error)
- func (image *Image) GetMetadata(key string) (string, error)
- func (image *Image) GetOverlap() (overlap uint64, err error)
- func (image *Image) GetParentInfo(pool, name, snapname []byte) error
- func (image *Image) GetSize() (size uint64, err error)
- func (image *Image) GetSnapshot(snapname string) *Snapshot
- func (image *Image) GetSnapshotNames() (snaps []SnapInfo, err error)
- func (image *Image) GetStripeCount() (stripe_count uint64, err error)
- func (image *Image) GetStripeUnit() (stripe_unit uint64, err error)
- func (image *Image) IsOldFormat() (old_format bool, err error)
- func (image *Image) ListChildren() (pools []string, images []string, err error)
- func (image *Image) ListLockers() (tag string, lockers []Locker, err error)
- func (image *Image) LockExclusive(cookie string) error
- func (image *Image) LockShared(cookie string, tag string) error
- func (image *Image) Open(args ...interface{}) errordeprecated
- func (image *Image) Read(data []byte) (int, error)
- func (image *Image) ReadAt(data []byte, off int64) (int, error)
- func (image *Image) Remove() error
- func (image *Image) RemoveMetadata(key string) error
- func (image *Image) Rename(destname string) error
- func (image *Image) Resize(size uint64) error
- func (image *Image) Seek(offset int64, whence int) (int64, error)
- func (image *Image) SetMetadata(key string, value string) error
- func (image *Image) Stat() (info *ImageInfo, err error)
- func (image *Image) Trash(delay time.Duration) error
- func (image *Image) Unlock(cookie string) error
- func (image *Image) Write(data []byte) (n int, err error)
- func (image *Image) WriteAt(data []byte, off int64) (n int, err error)
- type ImageInfo
- type Locker
- type RBDError
- type RbdImageOption
- type RbdImageOptions
- func (rio *RbdImageOptions) Clear()
- func (rio *RbdImageOptions) Destroy()
- func (rio *RbdImageOptions) GetString(option RbdImageOption) (string, error)
- func (rio *RbdImageOptions) GetUint64(option RbdImageOption) (uint64, error)
- func (rio *RbdImageOptions) IsEmpty() bool
- func (rio *RbdImageOptions) IsSet(option RbdImageOption) (bool, error)
- func (rio *RbdImageOptions) SetString(option RbdImageOption, value string) error
- func (rio *RbdImageOptions) SetUint64(option RbdImageOption, value uint64) error
- func (rio *RbdImageOptions) Unset(option RbdImageOption) error
- type SnapInfo
- type Snapshot
- type TrashInfo
Constants ¶
const ( // RBD image options. RbdImageOptionFormat = C.RBD_IMAGE_OPTION_FORMAT RbdImageOptionFeatures = C.RBD_IMAGE_OPTION_FEATURES RbdImageOptionOrder = C.RBD_IMAGE_OPTION_ORDER RbdImageOptionStripeUnit = C.RBD_IMAGE_OPTION_STRIPE_UNIT RbdImageOptionStripeCount = C.RBD_IMAGE_OPTION_STRIPE_COUNT RbdImageOptionJournalOrder = C.RBD_IMAGE_OPTION_JOURNAL_ORDER RbdImageOptionJournalSplayWidth = C.RBD_IMAGE_OPTION_JOURNAL_SPLAY_WIDTH RbdImageOptionJournalPool = C.RBD_IMAGE_OPTION_JOURNAL_POOL RbdImageOptionFeaturesSet = C.RBD_IMAGE_OPTION_FEATURES_SET RbdImageOptionFeaturesClear = C.RBD_IMAGE_OPTION_FEATURES_CLEAR RbdImageOptionDataPool = C.RBD_IMAGE_OPTION_DATA_POOL )
const ( // RBD features. RbdFeatureLayering = uint64(C.RBD_FEATURE_LAYERING) RbdFeatureStripingV2 = uint64(C.RBD_FEATURE_STRIPINGV2) RbdFeatureExclusiveLock = uint64(C.RBD_FEATURE_EXCLUSIVE_LOCK) RbdFeatureObjectMap = uint64(C.RBD_FEATURE_OBJECT_MAP) RbdFeatureFastDiff = uint64(C.RBD_FEATURE_FAST_DIFF) RbdFeatureDeepFlatten = uint64(C.RBD_FEATURE_DEEP_FLATTEN) RbdFeatureJournaling = uint64(C.RBD_FEATURE_JOURNALING) RbdFeatureDataPool = uint64(C.RBD_FEATURE_DATA_POOL) RbdFeaturesDefault = uint64(C.RBD_FEATURES_DEFAULT) // Features that make an image inaccessible for read or write by clients that don't understand // them. RbdFeaturesIncompatible = uint64(C.RBD_FEATURES_INCOMPATIBLE) // Features that make an image unwritable by clients that don't understand them. RbdFeaturesRwIncompatible = uint64(C.RBD_FEATURES_RW_INCOMPATIBLE) // Features that may be dynamically enabled or disabled. RbdFeaturesMutable = uint64(C.RBD_FEATURES_MUTABLE) // Features that only work when used with a single client using the image for writes. RbdFeaturesSingleClient = uint64(C.RBD_FEATURES_SINGLE_CLIENT) // Image.Seek() constants SeekSet = int(C.SEEK_SET) SeekCur = int(C.SEEK_CUR) SeekEnd = int(C.SEEK_END) )
const (
// NoSnapshot indicates that no snapshot name is in use (see OpenImage)
NoSnapshot = ""
)
bits for Image.validate() and Snapshot.validate()
Variables ¶
var ( ErrNoIOContext = errors.New("RBD image does not have an IOContext") ErrNoName = errors.New("RBD image does not have a name") ErrSnapshotNoName = errors.New("RBD snapshot does not have a name") ErrImageNotOpen = errors.New("RBD image not open") ErrNotFound = errors.New("RBD image not found") // retained for compatibility with old versions RbdErrorImageNotOpen = ErrImageNotOpen RbdErrorNotFound = ErrNotFound )
Functions ¶
func CloneFromImage ¶
func CloneFromImage(parent *Image, snapName string, destctx *rados.IOContext, name string, rio *RbdImageOptions) error
CloneFromImage creates a clone of the image from the named snapshot in the provided io-context with the given name and image options. This function is a convenience wrapper around CloneImage to support cloning from an existing Image.
func CloneImage ¶
func CloneImage(ioctx *rados.IOContext, parentName, snapName string, destctx *rados.IOContext, name string, rio *RbdImageOptions) error
CloneImage creates a clone of the image from the named snapshot in the provided io-context with the given name and image options.
Implements:
int rbd_clone3(rados_ioctx_t p_ioctx, const char *p_name, const char *p_snapname, rados_ioctx_t c_ioctx, const char *c_name, rbd_image_options_t c_opts);
func CreateImage ¶
CreateImage creates a new rbd image using provided image options.
Implements:
int rbd_create4(rados_ioctx_t io, const char *name, uint64_t size, rbd_image_options_t opts);
func GetImageNames ¶
GetImageNames returns the list of current RBD images.
func RemoveImage ¶
RemoveImage removes the specified rbd image.
Implements:
int rbd_remove(rados_ioctx_t io, const char *name);
func TrashRemove ¶
TrashRemove permanently deletes the trashed RBD with the specified id.
func TrashRestore ¶
TrashRestore restores the trashed RBD with the specified id back to the pool from whence it came, with the specified new name.
Types ¶
type Image ¶
type Image struct { io.Reader io.Writer io.Seeker io.ReaderAt io.WriterAt // contains filtered or unexported fields }
func Create ¶
func Create(ioctx *rados.IOContext, name string, size uint64, order int, args ...uint64) (image *Image, err error)
Create a new rbd image.
Implements:
int rbd_create(rados_ioctx_t io, const char *name, uint64_t size, int *order);
Also implements (for backward compatibility):
int rbd_create2(rados_ioctx_t io, const char *name, uint64_t size, uint64_t features, int *order); int rbd_create3(rados_ioctx_t io, const char *name, uint64_t size, uint64_t features, int *order, uint64_t stripe_unit, uint64_t stripe_count);
func Create2 ¶
func Create2(ioctx *rados.IOContext, name string, size uint64, features uint64, order int) (image *Image, err error)
Create2 creates a new rbd image using provided features.
Implements:
int rbd_create2(rados_ioctx_t io, const char *name, uint64_t size, uint64_t features, int *order);
func Create3 ¶
func Create3(ioctx *rados.IOContext, name string, size uint64, features uint64, order int, stripe_unit uint64, stripe_count uint64) (image *Image, err error)
Create3 creates a new rbd image using provided features and stripe parameters.
Implements:
int rbd_create3(rados_ioctx_t io, const char *name, uint64_t size, uint64_t features, int *order, uint64_t stripe_unit, uint64_t stripe_count);
func OpenImage ¶
OpenImage will open an existing rbd image by name and snapshot name, returning a new opened image. Pass the NoSnapshot sentinel value as the snapName to explicitly indicate that no snapshot name is being provided.
Implements:
int rbd_open(rados_ioctx_t io, const char *name, rbd_image_t *image, const char *snap_name);
func OpenImageById ¶
OpenImageById will open an existing rbd image by ID and snapshot name, returning a new opened image. Pass the NoSnapshot sentinel value as the snapName to explicitly indicate that no snapshot name is being provided. Error handling will fail & segfault unless compiled with a version of ceph that fixes https://tracker.ceph.com/issues/43178
Implements:
int rbd_open_by_id(rados_ioctx_t io, const char *id, rbd_image_t *image, const char *snap_name);
func OpenImageByIdReadOnly ¶
OpenImageByIdReadOnly will open an existing rbd image by ID and snapshot name, returning a new opened-for-read image. Pass the NoSnapshot sentinel value as the snapName to explicitly indicate that no snapshot name is being provided. Error handling will fail & segfault unless compiled with a version of ceph that fixes https://tracker.ceph.com/issues/43178
Implements:
int rbd_open_by_id_read_only(rados_ioctx_t io, const char *id, rbd_image_t *image, const char *snap_name);
func OpenImageReadOnly ¶
OpenImageReadOnly will open an existing rbd image by name and snapshot name, returning a new opened-for-read image. Pass the NoSnapshot sentinel value as the snapName to explicitly indicate that no snapshot name is being provided.
Implements:
int rbd_open_read_only(rados_ioctx_t io, const char *name, rbd_image_t *image, const char *snap_name);
func (*Image) BreakLock ¶
BreakLock forces the release of a lock held by another client.
Implements:
int rbd_break_lock(rbd_image_t image, const char *client, const char *cookie);
func (*Image) Clone ¶
func (image *Image) Clone(snapname string, c_ioctx *rados.IOContext, c_name string, features uint64, order int) (*Image, error)
Clone a new rbd image from a snapshot.
Implements:
int rbd_clone(rados_ioctx_t p_ioctx, const char *p_name, const char *p_snapname, rados_ioctx_t c_ioctx, const char *c_name, uint64_t features, int *c_order);
func (*Image) Copy ¶
Copy one rbd image to another.
Implements:
int rbd_copy(rbd_image_t image, rados_ioctx_t dest_io_ctx, const char *destname);
func (*Image) Copy2 ¶
Copy one rbd image to another, using an image handle.
Implements:
int rbd_copy2(rbd_image_t src, rbd_image_t dest);
func (*Image) CreateSnapshot ¶
int rbd_snap_create(rbd_image_t image, const char *snapname);
func (*Image) Flatten ¶
Flatten removes snapshot references from the image.
Implements:
int rbd_flatten(rbd_image_t image);
func (*Image) GetFeatures ¶
GetFeatures returns the features bitmask for the rbd image.
Implements:
int rbd_get_features(rbd_image_t image, uint64_t *features);
func (*Image) GetId ¶
GetId returns the internal image ID string.
Implements:
int rbd_get_id(rbd_image_t image, char *id, size_t id_len);
func (*Image) GetMetadata ¶
int rbd_metadata_get(rbd_image_t image, const char *key, char *value, size_t *vallen)
func (*Image) GetOverlap ¶
GetOverlap returns the overlapping bytes between the rbd image and its parent.
Implements:
int rbd_get_overlap(rbd_image_t image, uint64_t *overlap);
func (*Image) GetParentInfo ¶
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(rbd_image_t image, rbd_linked_image_spec_t *parent_image, rbd_snap_spec_t *parent_snap)
func (*Image) GetSize ¶
GetSize returns the size of the rbd image.
Implements:
int rbd_size(rbd_image_t image, uint64_t *size);
func (*Image) GetSnapshot ¶
func (*Image) GetSnapshotNames ¶
int rbd_snap_list(rbd_image_t image, rbd_snap_info_t *snaps, int *max_snaps); void rbd_snap_list_end(rbd_snap_info_t *snaps);
func (*Image) GetStripeCount ¶
GetStripeCount returns the stripe-count value for the rbd image.
Implements:
int rbd_get_stripe_count(rbd_image_t image, uint64_t *stripe_count);
func (*Image) GetStripeUnit ¶
GetStripeUnit returns the stripe-unit value for the rbd image.
Implements:
int rbd_get_stripe_unit(rbd_image_t image, uint64_t *stripe_unit);
func (*Image) IsOldFormat ¶
IsOldFormat returns true if the rbd image uses the old format.
Implements:
int rbd_get_old_format(rbd_image_t image, uint8_t *old);
func (*Image) ListChildren ¶
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:
int rbd_list_children3(rbd_image_t image, rbd_linked_image_spec_t *images, size_t *max_images);
func (*Image) ListLockers ¶
ListLockers returns a list of clients that have locks on the image.
Impelemnts:
ssize_t rbd_list_lockers(rbd_image_t image, int *exclusive, char *tag, size_t *tag_len, char *clients, size_t *clients_len, char *cookies, size_t *cookies_len, char *addrs, size_t *addrs_len);
func (*Image) LockExclusive ¶
LockExclusive acquires an exclusive lock on the rbd image.
Implements:
int rbd_lock_exclusive(rbd_image_t image, const char *cookie);
func (*Image) LockShared ¶
LockShared acquires a shared lock on the rbd image.
Implements:
int rbd_lock_shared(rbd_image_t image, const char *cookie, const char *tag);
func (*Image) Read ¶
ssize_t rbd_read(rbd_image_t image, uint64_t ofs, size_t len, char *buf); TODO: int64_t rbd_read_iterate(rbd_image_t image, uint64_t ofs, size_t len,
int (*cb)(uint64_t, size_t, const char *, void *), void *arg);
TODO: int rbd_read_iterate2(rbd_image_t image, uint64_t ofs, uint64_t len,
int (*cb)(uint64_t, size_t, const char *, void *), void *arg);
TODO: int rbd_diff_iterate(rbd_image_t image,
const char *fromsnapname, uint64_t ofs, uint64_t len, int (*cb)(uint64_t, size_t, int, void *), void *arg);
func (*Image) Remove ¶
Remove the specified rbd image.
Implements:
int rbd_remove(rados_ioctx_t io, const char *name);
func (*Image) RemoveMetadata ¶
int rbd_metadata_remove(rbd_image_t image, const char *key)
func (*Image) Rename ¶
Rename an rbd image.
Implements:
int rbd_rename(rados_ioctx_t src_io_ctx, const char *srcname, const char *destname);
func (*Image) Resize ¶
Resize an rbd image.
Implements:
int rbd_resize(rbd_image_t image, uint64_t size);
func (*Image) SetMetadata ¶
int rbd_metadata_set(rbd_image_t image, const char *key, const char *value)
func (*Image) Stat ¶
Stat an rbd image.
Implements:
int rbd_stat(rbd_image_t image, rbd_image_info_t *info, size_t infosize);
func (*Image) Trash ¶
Trash will move an image into the RBD trash, where it will be protected (i.e., salvageable) for at least the specified delay.
func (*Image) Unlock ¶
Unlock releases a lock on the image.
Implements:
int rbd_lock_shared(rbd_image_t image, const char *cookie, const char *tag);
type RbdImageOption ¶
type RbdImageOptions ¶
type RbdImageOptions struct {
// contains filtered or unexported fields
}
func NewRbdImageOptions ¶
func NewRbdImageOptions() *RbdImageOptions
NewRbdImageOptions creates a new RbdImageOptions struct. Call RbdImageOptions.Destroy() to free the resources.
Implements:
void rbd_image_options_create(rbd_image_options_t* opts)
func (*RbdImageOptions) Clear ¶
func (rio *RbdImageOptions) Clear()
Clear all options in the RbdImageOptions.
Implements:
void rbd_image_options_clear(rbd_image_options_t opts)
func (*RbdImageOptions) Destroy ¶
func (rio *RbdImageOptions) Destroy()
Destroy a RbdImageOptions struct and free the associated resources.
Implements:
void rbd_image_options_destroy(rbd_image_options_t opts);
func (*RbdImageOptions) GetString ¶
func (rio *RbdImageOptions) GetString(option RbdImageOption) (string, error)
GetString returns the string value of the RbdImageOption.
Implements:
int rbd_image_options_get_string(rbd_image_options_t opts, int optname, char* optval, size_t maxlen);
func (*RbdImageOptions) GetUint64 ¶
func (rio *RbdImageOptions) GetUint64(option RbdImageOption) (uint64, error)
GetUint64 returns the uint64 value of the RbdImageOption.
Implements:
int rbd_image_options_get_uint64(rbd_image_options_t opts, int optname, uint64_t* optval);
func (*RbdImageOptions) IsEmpty ¶
func (rio *RbdImageOptions) IsEmpty() bool
IsEmpty returns true if there are no options set in the RbdImageOptions, false otherwise.
Implements:
int rbd_image_options_is_empty(rbd_image_options_t opts)
func (*RbdImageOptions) IsSet ¶
func (rio *RbdImageOptions) IsSet(option RbdImageOption) (bool, error)
IsSet returns a true if the RbdImageOption is set, false otherwise.
Implements:
int rbd_image_options_is_set(rbd_image_options_t opts, int optname, bool* is_set);
func (*RbdImageOptions) SetString ¶
func (rio *RbdImageOptions) SetString(option RbdImageOption, value string) error
SetString sets the value of the RbdImageOption to the given string.
Implements:
int rbd_image_options_set_string(rbd_image_options_t opts, int optname, const char* optval);
func (*RbdImageOptions) SetUint64 ¶
func (rio *RbdImageOptions) SetUint64(option RbdImageOption, value uint64) error
SetUint64 sets the value of the RbdImageOption to the given uint64.
Implements:
int rbd_image_options_set_uint64(rbd_image_options_t opts, int optname, const uint64_t optval);
func (*RbdImageOptions) Unset ¶
func (rio *RbdImageOptions) Unset(option RbdImageOption) error
Unset a given RbdImageOption.
Implements:
int rbd_image_options_unset(rbd_image_options_t opts, int optname)
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
func (*Snapshot) IsProtected ¶
int rbd_snap_is_protected(rbd_image_t image, const char *snap_name,
int *is_protected);
func (*Snapshot) Rollback ¶
int rbd_snap_rollback(rbd_image_t image, const char *snapname); int rbd_snap_rollback_with_progress(rbd_image_t image, const char *snapname,
librbd_progress_fn_t cb, void *cbdata);
type TrashInfo ¶
type TrashInfo struct { Id string // Id string, required to remove / restore trashed RBDs. Name string // Original name of trashed RBD. DeletionTime time.Time // Date / time at which the RBD was moved to the trash. DefermentEndTime time.Time // Date / time after which the trashed RBD may be permanently deleted. }
TrashInfo contains information about trashed RBDs.