1 // -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2011 New Dream Network
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
22 #include <netinet/in.h>
23 #if defined(__linux__)
24 #include <linux/types.h>
25 #elif defined(__FreeBSD__)
26 #include <sys/types.h>
31 #include "../rados/librados.h"
34 #define LIBRBD_VER_MAJOR 1
35 #define LIBRBD_VER_MINOR 12
36 #define LIBRBD_VER_EXTRA 0
38 #define LIBRBD_VERSION(maj, min, extra) ((maj << 16) + (min << 8) + extra)
40 #define LIBRBD_VERSION_CODE LIBRBD_VERSION(LIBRBD_VER_MAJOR, LIBRBD_VER_MINOR, LIBRBD_VER_EXTRA)
42 #define LIBRBD_SUPPORTS_AIO_FLUSH 1
43 #define LIBRBD_SUPPORTS_AIO_OPEN 1
44 #define LIBRBD_SUPPORTS_COMPARE_AND_WRITE 1
45 #define LIBRBD_SUPPORTS_LOCKING 1
46 #define LIBRBD_SUPPORTS_INVALIDATE 1
47 #define LIBRBD_SUPPORTS_IOVEC 1
48 #define LIBRBD_SUPPORTS_WATCH 0
49 #define LIBRBD_SUPPORTS_WRITESAME 1
52 #define CEPH_RBD_API __attribute__ ((visibility ("default")))
57 #define RBD_FLAG_OBJECT_MAP_INVALID (1<<0)
58 #define RBD_FLAG_FAST_DIFF_INVALID (1<<1)
60 typedef void *rbd_image_t
;
61 typedef void *rbd_image_options_t
;
62 typedef void *rbd_pool_stats_t
;
64 typedef void *rbd_completion_t
;
65 typedef void (*rbd_callback_t
)(rbd_completion_t cb
, void *arg
);
67 typedef int (*librbd_progress_fn_t
)(uint64_t offset
, uint64_t total
, void *ptr
);
69 typedef void (*rbd_update_callback_t
)(void *arg
);
72 RBD_SNAP_NAMESPACE_TYPE_USER
= 0,
73 RBD_SNAP_NAMESPACE_TYPE_GROUP
= 1,
74 RBD_SNAP_NAMESPACE_TYPE_TRASH
= 2
75 } rbd_snap_namespace_type_t
;
89 } rbd_linked_image_spec_t
;
93 rbd_snap_namespace_type_t namespace_type
;
104 const char *pool_name
;
105 const char *image_name
;
106 const char *image_id
;
110 #define RBD_MAX_IMAGE_NAME_SIZE 96
111 #define RBD_MAX_BLOCK_NAME_SIZE 24
113 #define RBD_SNAP_REMOVE_UNPROTECT 1 << 0
114 #define RBD_SNAP_REMOVE_FLATTEN 1 << 1
115 #define RBD_SNAP_REMOVE_FORCE (RBD_SNAP_REMOVE_UNPROTECT | RBD_SNAP_REMOVE_FLATTEN)
118 * These types used to in set_image_notification to indicate the type of event
123 EVENT_TYPE_EVENTFD
= 2
131 char block_name_prefix
[RBD_MAX_BLOCK_NAME_SIZE
]; /* deprecated */
132 int64_t parent_pool
; /* deprecated */
133 char parent_name
[RBD_MAX_IMAGE_NAME_SIZE
]; /* deprecated */
137 RBD_MIRROR_MODE_DISABLED
, /* mirroring is disabled */
138 RBD_MIRROR_MODE_IMAGE
, /* mirroring enabled on a per-image basis */
139 RBD_MIRROR_MODE_POOL
/* mirroring enabled on all journaled images */
148 #define RBD_MIRROR_PEER_ATTRIBUTE_NAME_MON_HOST "mon_host"
149 #define RBD_MIRROR_PEER_ATTRIBUTE_NAME_KEY "key"
152 RBD_MIRROR_IMAGE_DISABLING
= 0,
153 RBD_MIRROR_IMAGE_ENABLED
= 1,
154 RBD_MIRROR_IMAGE_DISABLED
= 2
155 } rbd_mirror_image_state_t
;
159 rbd_mirror_image_state_t state
;
161 } rbd_mirror_image_info_t
;
164 MIRROR_IMAGE_STATUS_STATE_UNKNOWN
= 0,
165 MIRROR_IMAGE_STATUS_STATE_ERROR
= 1,
166 MIRROR_IMAGE_STATUS_STATE_SYNCING
= 2,
167 MIRROR_IMAGE_STATUS_STATE_STARTING_REPLAY
= 3,
168 MIRROR_IMAGE_STATUS_STATE_REPLAYING
= 4,
169 MIRROR_IMAGE_STATUS_STATE_STOPPING_REPLAY
= 5,
170 MIRROR_IMAGE_STATUS_STATE_STOPPED
= 6,
171 } rbd_mirror_image_status_state_t
;
175 rbd_mirror_image_info_t info
;
176 rbd_mirror_image_status_state_t state
;
180 } rbd_mirror_image_status_t
;
183 RBD_GROUP_IMAGE_STATE_ATTACHED
,
184 RBD_GROUP_IMAGE_STATE_INCOMPLETE
185 } rbd_group_image_state_t
;
190 rbd_group_image_state_t state
;
191 } rbd_group_image_info_t
;
199 RBD_GROUP_SNAP_STATE_INCOMPLETE
,
200 RBD_GROUP_SNAP_STATE_COMPLETE
201 } rbd_group_snap_state_t
;
205 rbd_group_snap_state_t state
;
206 } rbd_group_snap_info_t
;
211 char *group_snap_name
;
212 } rbd_snap_group_namespace_t
;
215 RBD_LOCK_MODE_EXCLUSIVE
= 0,
216 RBD_LOCK_MODE_SHARED
= 1,
219 CEPH_RBD_API
void rbd_version(int *major
, int *minor
, int *extra
);
223 RBD_IMAGE_OPTION_FORMAT
= 0,
224 RBD_IMAGE_OPTION_FEATURES
= 1,
225 RBD_IMAGE_OPTION_ORDER
= 2,
226 RBD_IMAGE_OPTION_STRIPE_UNIT
= 3,
227 RBD_IMAGE_OPTION_STRIPE_COUNT
= 4,
228 RBD_IMAGE_OPTION_JOURNAL_ORDER
= 5,
229 RBD_IMAGE_OPTION_JOURNAL_SPLAY_WIDTH
= 6,
230 RBD_IMAGE_OPTION_JOURNAL_POOL
= 7,
231 RBD_IMAGE_OPTION_FEATURES_SET
= 8,
232 RBD_IMAGE_OPTION_FEATURES_CLEAR
= 9,
233 RBD_IMAGE_OPTION_DATA_POOL
= 10,
234 RBD_IMAGE_OPTION_FLATTEN
= 11,
238 RBD_TRASH_IMAGE_SOURCE_USER
= 0,
239 RBD_TRASH_IMAGE_SOURCE_MIRRORING
= 1,
240 RBD_TRASH_IMAGE_SOURCE_MIGRATION
= 2,
241 RBD_TRASH_IMAGE_SOURCE_REMOVING
= 3
242 } rbd_trash_image_source_t
;
247 rbd_trash_image_source_t source
;
248 time_t deletion_time
;
249 time_t deferment_end_time
;
250 } rbd_trash_image_info_t
;
256 } rbd_image_watcher_t
;
259 RBD_IMAGE_MIGRATION_STATE_UNKNOWN
= -1,
260 RBD_IMAGE_MIGRATION_STATE_ERROR
= 0,
261 RBD_IMAGE_MIGRATION_STATE_PREPARING
= 1,
262 RBD_IMAGE_MIGRATION_STATE_PREPARED
= 2,
263 RBD_IMAGE_MIGRATION_STATE_EXECUTING
= 3,
264 RBD_IMAGE_MIGRATION_STATE_EXECUTED
= 4,
265 } rbd_image_migration_state_t
;
268 int64_t source_pool_id
;
269 char *source_pool_namespace
;
270 char *source_image_name
;
271 char *source_image_id
;
272 int64_t dest_pool_id
;
273 char *dest_pool_namespace
;
274 char *dest_image_name
;
276 rbd_image_migration_state_t state
;
277 char *state_description
;
278 } rbd_image_migration_status_t
;
281 RBD_CONFIG_SOURCE_CONFIG
= 0,
282 RBD_CONFIG_SOURCE_POOL
= 1,
283 RBD_CONFIG_SOURCE_IMAGE
= 2,
284 } rbd_config_source_t
;
289 rbd_config_source_t source
;
290 } rbd_config_option_t
;
293 RBD_POOL_STAT_OPTION_IMAGES
,
294 RBD_POOL_STAT_OPTION_IMAGE_PROVISIONED_BYTES
,
295 RBD_POOL_STAT_OPTION_IMAGE_MAX_PROVISIONED_BYTES
,
296 RBD_POOL_STAT_OPTION_IMAGE_SNAPSHOTS
,
297 RBD_POOL_STAT_OPTION_TRASH_IMAGES
,
298 RBD_POOL_STAT_OPTION_TRASH_PROVISIONED_BYTES
,
299 RBD_POOL_STAT_OPTION_TRASH_MAX_PROVISIONED_BYTES
,
300 RBD_POOL_STAT_OPTION_TRASH_SNAPSHOTS
301 } rbd_pool_stat_option_t
;
303 CEPH_RBD_API
void rbd_image_options_create(rbd_image_options_t
* opts
);
304 CEPH_RBD_API
void rbd_image_options_destroy(rbd_image_options_t opts
);
305 CEPH_RBD_API
int rbd_image_options_set_string(rbd_image_options_t opts
,
306 int optname
, const char* optval
);
307 CEPH_RBD_API
int rbd_image_options_set_uint64(rbd_image_options_t opts
,
308 int optname
, uint64_t optval
);
309 CEPH_RBD_API
int rbd_image_options_get_string(rbd_image_options_t opts
,
310 int optname
, char* optval
,
312 CEPH_RBD_API
int rbd_image_options_get_uint64(rbd_image_options_t opts
,
313 int optname
, uint64_t* optval
);
314 CEPH_RBD_API
int rbd_image_options_is_set(rbd_image_options_t opts
,
315 int optname
, bool* is_set
);
316 CEPH_RBD_API
int rbd_image_options_unset(rbd_image_options_t opts
, int optname
);
317 CEPH_RBD_API
void rbd_image_options_clear(rbd_image_options_t opts
);
318 CEPH_RBD_API
int rbd_image_options_is_empty(rbd_image_options_t opts
);
321 CEPH_RBD_API
void rbd_image_spec_cleanup(rbd_image_spec_t
*image
);
322 CEPH_RBD_API
void rbd_image_spec_list_cleanup(rbd_image_spec_t
*images
,
324 CEPH_RBD_API
void rbd_linked_image_spec_cleanup(rbd_linked_image_spec_t
*image
);
325 CEPH_RBD_API
void rbd_linked_image_spec_list_cleanup(
326 rbd_linked_image_spec_t
*images
, size_t num_images
);
327 CEPH_RBD_API
void rbd_snap_spec_cleanup(rbd_snap_spec_t
*snap
);
330 CEPH_RBD_API
int rbd_list(rados_ioctx_t io
, char *names
, size_t *size
)
331 __attribute__((deprecated
));
332 CEPH_RBD_API
int rbd_list2(rados_ioctx_t io
, rbd_image_spec_t
* images
,
335 CEPH_RBD_API
int rbd_create(rados_ioctx_t io
, const char *name
, uint64_t size
,
337 CEPH_RBD_API
int rbd_create2(rados_ioctx_t io
, const char *name
, uint64_t size
,
338 uint64_t features
, int *order
);
340 * create new rbd image
342 * The stripe_unit must be a factor of the object size (1 << order).
343 * The stripe_count can be one (no intra-object striping) or greater
344 * than one. The RBD_FEATURE_STRIPINGV2 must be specified if the
345 * stripe_unit != the object size and the stripe_count is != 1.
348 * @param name image name
349 * @param size image size in bytes
350 * @param features initial feature bits
351 * @param order object/block size, as a power of two (object size == 1 << order)
352 * @param stripe_unit stripe unit size, in bytes.
353 * @param stripe_count number of objects to stripe over before looping
354 * @return 0 on success, or negative error code
356 CEPH_RBD_API
int rbd_create3(rados_ioctx_t io
, const char *name
, uint64_t size
,
357 uint64_t features
, int *order
,
358 uint64_t stripe_unit
, uint64_t stripe_count
);
359 CEPH_RBD_API
int rbd_create4(rados_ioctx_t io
, const char *name
, uint64_t size
,
360 rbd_image_options_t opts
);
361 CEPH_RBD_API
int rbd_clone(rados_ioctx_t p_ioctx
, const char *p_name
,
362 const char *p_snapname
, rados_ioctx_t c_ioctx
,
363 const char *c_name
, uint64_t features
, int *c_order
);
364 CEPH_RBD_API
int rbd_clone2(rados_ioctx_t p_ioctx
, const char *p_name
,
365 const char *p_snapname
, rados_ioctx_t c_ioctx
,
366 const char *c_name
, uint64_t features
, int *c_order
,
367 uint64_t stripe_unit
, int stripe_count
);
368 CEPH_RBD_API
int rbd_clone3(rados_ioctx_t p_ioctx
, const char *p_name
,
369 const char *p_snapname
, rados_ioctx_t c_ioctx
,
370 const char *c_name
, rbd_image_options_t c_opts
);
371 CEPH_RBD_API
int rbd_remove(rados_ioctx_t io
, const char *name
);
372 CEPH_RBD_API
int rbd_remove_with_progress(rados_ioctx_t io
, const char *name
,
373 librbd_progress_fn_t cb
,
375 CEPH_RBD_API
int rbd_rename(rados_ioctx_t src_io_ctx
, const char *srcname
,
376 const char *destname
);
378 CEPH_RBD_API
int rbd_trash_move(rados_ioctx_t io
, const char *name
,
380 CEPH_RBD_API
int rbd_trash_get(rados_ioctx_t io
, const char *id
,
381 rbd_trash_image_info_t
*info
);
382 CEPH_RBD_API
void rbd_trash_get_cleanup(rbd_trash_image_info_t
*info
);
383 CEPH_RBD_API
int rbd_trash_list(rados_ioctx_t io
,
384 rbd_trash_image_info_t
*trash_entries
,
385 size_t *num_entries
);
386 CEPH_RBD_API
void rbd_trash_list_cleanup(rbd_trash_image_info_t
*trash_entries
,
388 CEPH_RBD_API
int rbd_trash_purge(rados_ioctx_t io
, time_t expire_ts
, float threshold
);
389 CEPH_RBD_API
int rbd_trash_purge_with_progress(rados_ioctx_t io
, time_t expire_ts
,
390 float threshold
, librbd_progress_fn_t cb
,
392 CEPH_RBD_API
int rbd_trash_remove(rados_ioctx_t io
, const char *id
, bool force
);
393 CEPH_RBD_API
int rbd_trash_remove_with_progress(rados_ioctx_t io
,
396 librbd_progress_fn_t cb
,
398 CEPH_RBD_API
int rbd_trash_restore(rados_ioctx_t io
, const char *id
,
402 CEPH_RBD_API
int rbd_migration_prepare(rados_ioctx_t ioctx
,
403 const char *image_name
,
404 rados_ioctx_t dest_ioctx
,
405 const char *dest_image_name
,
406 rbd_image_options_t opts
);
407 CEPH_RBD_API
int rbd_migration_execute(rados_ioctx_t ioctx
,
408 const char *image_name
);
409 CEPH_RBD_API
int rbd_migration_execute_with_progress(rados_ioctx_t ioctx
,
410 const char *image_name
,
411 librbd_progress_fn_t cb
,
413 CEPH_RBD_API
int rbd_migration_abort(rados_ioctx_t ioctx
,
414 const char *image_name
);
415 CEPH_RBD_API
int rbd_migration_abort_with_progress(rados_ioctx_t ioctx
,
416 const char *image_name
,
417 librbd_progress_fn_t cb
,
419 CEPH_RBD_API
int rbd_migration_commit(rados_ioctx_t ioctx
,
420 const char *image_name
);
421 CEPH_RBD_API
int rbd_migration_commit_with_progress(rados_ioctx_t ioctx
,
422 const char *image_name
,
423 librbd_progress_fn_t cb
,
425 CEPH_RBD_API
int rbd_migration_status(rados_ioctx_t ioctx
,
426 const char *image_name
,
427 rbd_image_migration_status_t
*status
,
429 CEPH_RBD_API
void rbd_migration_status_cleanup(
430 rbd_image_migration_status_t
*status
);
433 CEPH_RBD_API
int rbd_mirror_mode_get(rados_ioctx_t io_ctx
,
434 rbd_mirror_mode_t
*mirror_mode
);
435 CEPH_RBD_API
int rbd_mirror_mode_set(rados_ioctx_t io_ctx
,
436 rbd_mirror_mode_t mirror_mode
);
437 CEPH_RBD_API
int rbd_mirror_peer_add(rados_ioctx_t io_ctx
,
438 char *uuid
, size_t uuid_max_length
,
439 const char *cluster_name
,
440 const char *client_name
);
441 CEPH_RBD_API
int rbd_mirror_peer_remove(rados_ioctx_t io_ctx
,
443 CEPH_RBD_API
int rbd_mirror_peer_list(rados_ioctx_t io_ctx
,
444 rbd_mirror_peer_t
*peers
, int *max_peers
);
445 CEPH_RBD_API
void rbd_mirror_peer_list_cleanup(rbd_mirror_peer_t
*peers
,
447 CEPH_RBD_API
int rbd_mirror_peer_set_client(rados_ioctx_t io_ctx
,
449 const char *client_name
);
450 CEPH_RBD_API
int rbd_mirror_peer_set_cluster(rados_ioctx_t io_ctx
,
452 const char *cluster_name
);
453 CEPH_RBD_API
int rbd_mirror_peer_get_attributes(
454 rados_ioctx_t p
, const char *uuid
, char *keys
, size_t *max_key_len
,
455 char *values
, size_t *max_value_len
, size_t *key_value_count
);
456 CEPH_RBD_API
int rbd_mirror_peer_set_attributes(
457 rados_ioctx_t p
, const char *uuid
, const char *keys
, const char *values
,
458 size_t key_value_count
);
460 CEPH_RBD_API
int rbd_mirror_image_status_list(rados_ioctx_t io_ctx
,
461 const char *start_id
, size_t max
,
463 rbd_mirror_image_status_t
*images
,
465 CEPH_RBD_API
void rbd_mirror_image_status_list_cleanup(char **image_ids
,
466 rbd_mirror_image_status_t
*images
, size_t len
);
467 CEPH_RBD_API
int rbd_mirror_image_status_summary(rados_ioctx_t io_ctx
,
468 rbd_mirror_image_status_state_t
*states
, int *counts
, size_t *maxlen
);
470 CEPH_RBD_API
int rbd_mirror_image_instance_id_list(rados_ioctx_t io_ctx
,
471 const char *start_id
,
472 size_t max
, char **image_ids
,
475 CEPH_RBD_API
void rbd_mirror_image_instance_id_list_cleanup(char **image_ids
,
480 CEPH_RBD_API
int rbd_pool_metadata_get(rados_ioctx_t io_ctx
, const char *key
,
481 char *value
, size_t *val_len
);
482 CEPH_RBD_API
int rbd_pool_metadata_set(rados_ioctx_t io_ctx
, const char *key
,
484 CEPH_RBD_API
int rbd_pool_metadata_remove(rados_ioctx_t io_ctx
,
486 CEPH_RBD_API
int rbd_pool_metadata_list(rados_ioctx_t io_ctx
, const char *start
,
487 uint64_t max
, char *keys
,
488 size_t *key_len
, char *values
,
491 CEPH_RBD_API
int rbd_config_pool_list(rados_ioctx_t io_ctx
,
492 rbd_config_option_t
*options
,
494 CEPH_RBD_API
void rbd_config_pool_list_cleanup(rbd_config_option_t
*options
,
497 CEPH_RBD_API
int rbd_open(rados_ioctx_t io
, const char *name
,
498 rbd_image_t
*image
, const char *snap_name
);
499 CEPH_RBD_API
int rbd_open_by_id(rados_ioctx_t io
, const char *id
,
500 rbd_image_t
*image
, const char *snap_name
);
502 CEPH_RBD_API
int rbd_aio_open(rados_ioctx_t io
, const char *name
,
503 rbd_image_t
*image
, const char *snap_name
,
505 CEPH_RBD_API
int rbd_aio_open_by_id(rados_ioctx_t io
, const char *id
,
506 rbd_image_t
*image
, const char *snap_name
,
510 * Open an image in read-only mode.
512 * This is intended for use by clients that cannot write to a block
513 * device due to cephx restrictions. There will be no watch
514 * established on the header object, since a watch is a write. This
515 * means the metadata reported about this image (parents, snapshots,
516 * size, etc.) may become stale. This should not be used for
517 * long-running operations, unless you can be sure that one of these
518 * properties changing is safe.
520 * Attempting to write to a read-only image will return -EROFS.
522 * @param io ioctx to determine the pool the image is in
523 * @param name image name
524 * @param image where to store newly opened image handle
525 * @param snap_name name of snapshot to open at, or NULL for no snapshot
526 * @returns 0 on success, negative error code on failure
528 CEPH_RBD_API
int rbd_open_read_only(rados_ioctx_t io
, const char *name
,
529 rbd_image_t
*image
, const char *snap_name
);
530 CEPH_RBD_API
int rbd_open_by_id_read_only(rados_ioctx_t io
, const char *id
,
531 rbd_image_t
*image
, const char *snap_name
);
532 CEPH_RBD_API
int rbd_aio_open_read_only(rados_ioctx_t io
, const char *name
,
533 rbd_image_t
*image
, const char *snap_name
,
535 CEPH_RBD_API
int rbd_aio_open_by_id_read_only(rados_ioctx_t io
, const char *id
,
536 rbd_image_t
*image
, const char *snap_name
,
538 CEPH_RBD_API
int rbd_close(rbd_image_t image
);
539 CEPH_RBD_API
int rbd_aio_close(rbd_image_t image
, rbd_completion_t c
);
540 CEPH_RBD_API
int rbd_resize(rbd_image_t image
, uint64_t size
);
541 CEPH_RBD_API
int rbd_resize2(rbd_image_t image
, uint64_t size
, bool allow_shrink
,
542 librbd_progress_fn_t cb
, void *cbdata
);
543 CEPH_RBD_API
int rbd_resize_with_progress(rbd_image_t image
, uint64_t size
,
544 librbd_progress_fn_t cb
, void *cbdata
);
545 CEPH_RBD_API
int rbd_stat(rbd_image_t image
, rbd_image_info_t
*info
,
547 CEPH_RBD_API
int rbd_get_old_format(rbd_image_t image
, uint8_t *old
);
548 CEPH_RBD_API
int rbd_get_size(rbd_image_t image
, uint64_t *size
);
549 CEPH_RBD_API
int rbd_get_features(rbd_image_t image
, uint64_t *features
);
550 CEPH_RBD_API
int rbd_update_features(rbd_image_t image
, uint64_t features
,
552 CEPH_RBD_API
int rbd_get_op_features(rbd_image_t image
, uint64_t *op_features
);
553 CEPH_RBD_API
int rbd_get_stripe_unit(rbd_image_t image
, uint64_t *stripe_unit
);
554 CEPH_RBD_API
int rbd_get_stripe_count(rbd_image_t image
,
555 uint64_t *stripe_count
);
557 CEPH_RBD_API
int rbd_get_create_timestamp(rbd_image_t image
,
558 struct timespec
*timestamp
);
559 CEPH_RBD_API
int rbd_get_access_timestamp(rbd_image_t image
,
560 struct timespec
*timestamp
);
561 CEPH_RBD_API
int rbd_get_modify_timestamp(rbd_image_t image
,
562 struct timespec
*timestamp
);
564 CEPH_RBD_API
int rbd_get_overlap(rbd_image_t image
, uint64_t *overlap
);
565 CEPH_RBD_API
int rbd_get_name(rbd_image_t image
, char *name
, size_t *name_len
);
566 CEPH_RBD_API
int rbd_get_id(rbd_image_t image
, char *id
, size_t id_len
);
567 CEPH_RBD_API
int rbd_get_block_name_prefix(rbd_image_t image
,
568 char *prefix
, size_t prefix_len
);
569 CEPH_RBD_API
int64_t rbd_get_data_pool_id(rbd_image_t image
);
571 CEPH_RBD_API
int rbd_get_parent_info(rbd_image_t image
,
572 char *parent_poolname
, size_t ppoolnamelen
,
573 char *parent_name
, size_t pnamelen
,
574 char *parent_snapname
,
576 __attribute__((deprecated
));
577 CEPH_RBD_API
int rbd_get_parent_info2(rbd_image_t image
,
578 char *parent_poolname
,
580 char *parent_name
, size_t pnamelen
,
581 char *parent_id
, size_t pidlen
,
582 char *parent_snapname
,
584 __attribute__((deprecated
));
585 CEPH_RBD_API
int rbd_get_parent(rbd_image_t image
,
586 rbd_linked_image_spec_t
*parent_image
,
587 rbd_snap_spec_t
*parent_snap
);
589 CEPH_RBD_API
int rbd_get_flags(rbd_image_t image
, uint64_t *flags
);
590 CEPH_RBD_API
int rbd_get_group(rbd_image_t image
, rbd_group_info_t
*group_info
,
591 size_t group_info_size
);
592 CEPH_RBD_API
int rbd_set_image_notification(rbd_image_t image
, int fd
, int type
);
594 /* exclusive lock feature */
595 CEPH_RBD_API
int rbd_is_exclusive_lock_owner(rbd_image_t image
, int *is_owner
);
596 CEPH_RBD_API
int rbd_lock_acquire(rbd_image_t image
, rbd_lock_mode_t lock_mode
);
597 CEPH_RBD_API
int rbd_lock_release(rbd_image_t image
);
598 CEPH_RBD_API
int rbd_lock_get_owners(rbd_image_t image
,
599 rbd_lock_mode_t
*lock_mode
,
601 size_t *max_lock_owners
);
602 CEPH_RBD_API
void rbd_lock_get_owners_cleanup(char **lock_owners
,
603 size_t lock_owner_count
);
604 CEPH_RBD_API
int rbd_lock_break(rbd_image_t image
, rbd_lock_mode_t lock_mode
,
605 const char *lock_owner
);
607 /* object map feature */
608 CEPH_RBD_API
int rbd_rebuild_object_map(rbd_image_t image
,
609 librbd_progress_fn_t cb
, void *cbdata
);
611 CEPH_RBD_API
int rbd_copy(rbd_image_t image
, rados_ioctx_t dest_io_ctx
,
612 const char *destname
);
613 CEPH_RBD_API
int rbd_copy2(rbd_image_t src
, rbd_image_t dest
);
614 CEPH_RBD_API
int rbd_copy3(rbd_image_t src
, rados_ioctx_t dest_io_ctx
,
615 const char *destname
, rbd_image_options_t dest_opts
);
616 CEPH_RBD_API
int rbd_copy4(rbd_image_t src
, rados_ioctx_t dest_io_ctx
,
617 const char *destname
, rbd_image_options_t dest_opts
,
619 CEPH_RBD_API
int rbd_copy_with_progress(rbd_image_t image
, rados_ioctx_t dest_p
,
620 const char *destname
,
621 librbd_progress_fn_t cb
, void *cbdata
);
622 CEPH_RBD_API
int rbd_copy_with_progress2(rbd_image_t src
, rbd_image_t dest
,
623 librbd_progress_fn_t cb
, void *cbdata
);
624 CEPH_RBD_API
int rbd_copy_with_progress3(rbd_image_t image
,
625 rados_ioctx_t dest_p
,
626 const char *destname
,
627 rbd_image_options_t dest_opts
,
628 librbd_progress_fn_t cb
, void *cbdata
);
629 CEPH_RBD_API
int rbd_copy_with_progress4(rbd_image_t image
,
630 rados_ioctx_t dest_p
,
631 const char *destname
,
632 rbd_image_options_t dest_opts
,
633 librbd_progress_fn_t cb
, void *cbdata
,
637 CEPH_RBD_API
int rbd_deep_copy(rbd_image_t src
, rados_ioctx_t dest_io_ctx
,
638 const char *destname
,
639 rbd_image_options_t dest_opts
);
640 CEPH_RBD_API
int rbd_deep_copy_with_progress(rbd_image_t image
,
641 rados_ioctx_t dest_io_ctx
,
642 const char *destname
,
643 rbd_image_options_t dest_opts
,
644 librbd_progress_fn_t cb
,
648 CEPH_RBD_API
int rbd_snap_list(rbd_image_t image
, rbd_snap_info_t
*snaps
,
650 CEPH_RBD_API
void rbd_snap_list_end(rbd_snap_info_t
*snaps
);
651 CEPH_RBD_API
int rbd_snap_create(rbd_image_t image
, const char *snapname
);
652 CEPH_RBD_API
int rbd_snap_remove(rbd_image_t image
, const char *snapname
);
653 CEPH_RBD_API
int rbd_snap_remove2(rbd_image_t image
, const char *snap_name
,
654 uint32_t flags
, librbd_progress_fn_t cb
,
656 CEPH_RBD_API
int rbd_snap_remove_by_id(rbd_image_t image
, uint64_t snap_id
);
657 CEPH_RBD_API
int rbd_snap_rollback(rbd_image_t image
, const char *snapname
);
658 CEPH_RBD_API
int rbd_snap_rollback_with_progress(rbd_image_t image
,
659 const char *snapname
,
660 librbd_progress_fn_t cb
,
662 CEPH_RBD_API
int rbd_snap_rename(rbd_image_t image
, const char *snapname
,
663 const char* dstsnapsname
);
665 * Prevent a snapshot from being deleted until it is unprotected.
667 * @param snap_name which snapshot to protect
668 * @returns 0 on success, negative error code on failure
669 * @returns -EBUSY if snap is already protected
671 CEPH_RBD_API
int rbd_snap_protect(rbd_image_t image
, const char *snap_name
);
673 * Allow a snaphshot to be deleted.
675 * @param snap_name which snapshot to unprotect
676 * @returns 0 on success, negative error code on failure
677 * @returns -EINVAL if snap is not protected
679 CEPH_RBD_API
int rbd_snap_unprotect(rbd_image_t image
, const char *snap_name
);
681 * Determine whether a snapshot is protected.
683 * @param snap_name which snapshot query
684 * @param is_protected where to store the result (0 or 1)
685 * @returns 0 on success, negative error code on failure
687 CEPH_RBD_API
int rbd_snap_is_protected(rbd_image_t image
, const char *snap_name
,
690 * Get the current snapshot limit for an image. If no limit is set,
691 * UINT64_MAX is returned.
693 * @param limit pointer where the limit will be stored on success
694 * @returns 0 on success, negative error code on failure
696 CEPH_RBD_API
int rbd_snap_get_limit(rbd_image_t image
, uint64_t *limit
);
699 * Set a limit for the number of snapshots that may be taken of an image.
701 * @param limit the maximum number of snapshots allowed in the future.
702 * @returns 0 on success, negative error code on failure
704 CEPH_RBD_API
int rbd_snap_set_limit(rbd_image_t image
, uint64_t limit
);
707 * Get the timestamp of a snapshot for an image.
709 * @param snap_id the snap id of a snapshot of input image.
710 * @param timestamp the timestamp of input snapshot.
711 * @returns 0 on success, negative error code on failure
713 CEPH_RBD_API
int rbd_snap_get_timestamp(rbd_image_t image
, uint64_t snap_id
, struct timespec
*timestamp
);
715 CEPH_RBD_API
int rbd_snap_set(rbd_image_t image
, const char *snapname
);
716 CEPH_RBD_API
int rbd_snap_set_by_id(rbd_image_t image
, uint64_t snap_id
);
718 CEPH_RBD_API
int rbd_snap_get_namespace_type(rbd_image_t image
,
720 rbd_snap_namespace_type_t
*namespace_type
);
721 CEPH_RBD_API
int rbd_snap_get_group_namespace(rbd_image_t image
,
723 rbd_snap_group_namespace_t
*group_snap
,
724 size_t group_snap_size
);
725 CEPH_RBD_API
int rbd_snap_group_namespace_cleanup(rbd_snap_group_namespace_t
*group_snap
,
726 size_t group_snap_size
);
727 CEPH_RBD_API
int rbd_snap_get_trash_namespace(rbd_image_t image
,
732 CEPH_RBD_API
int rbd_flatten(rbd_image_t image
);
734 CEPH_RBD_API
int rbd_flatten_with_progress(rbd_image_t image
,
735 librbd_progress_fn_t cb
,
738 CEPH_RBD_API
int rbd_sparsify(rbd_image_t image
, size_t sparse_size
);
740 CEPH_RBD_API
int rbd_sparsify_with_progress(rbd_image_t image
,
742 librbd_progress_fn_t cb
,
746 * List all images that are cloned from the image at the
747 * snapshot that is set via rbd_snap_set().
749 * This iterates over all pools, so it should be run by a user with
750 * read access to all of them. pools_len and images_len are filled in
751 * with the number of bytes put into the pools and images buffers.
753 * If the provided buffers are too short, the required lengths are
754 * still filled in, but the data is not and -ERANGE is returned.
755 * Otherwise, the buffers are filled with the pool and image names
756 * of the children, with a '\0' after each.
758 * @param image which image (and implicitly snapshot) to list clones of
759 * @param pools buffer in which to store pool names
760 * @param pools_len number of bytes in pools buffer
761 * @param images buffer in which to store image names
762 * @param images_len number of bytes in images buffer
763 * @returns number of children on success, negative error code on failure
764 * @returns -ERANGE if either buffer is too short
766 CEPH_RBD_API ssize_t
rbd_list_children(rbd_image_t image
, char *pools
,
767 size_t *pools_len
, char *images
,
769 __attribute__((deprecated
));
770 CEPH_RBD_API
int rbd_list_children2(rbd_image_t image
,
771 rbd_child_info_t
*children
,
773 __attribute__((deprecated
));
774 CEPH_RBD_API
void rbd_list_child_cleanup(rbd_child_info_t
*child
)
775 __attribute__((deprecated
));
776 CEPH_RBD_API
void rbd_list_children_cleanup(rbd_child_info_t
*children
,
778 __attribute__((deprecated
));
780 CEPH_RBD_API
int rbd_list_children3(rbd_image_t image
,
781 rbd_linked_image_spec_t
*images
,
784 CEPH_RBD_API
int rbd_list_descendants(rbd_image_t image
,
785 rbd_linked_image_spec_t
*images
,
789 * @defgroup librbd_h_locking Advisory Locking
791 * An rbd image may be locking exclusively, or shared, to facilitate
792 * e.g. live migration where the image may be open in two places at once.
793 * These locks are intended to guard against more than one client
794 * writing to an image without coordination. They don't need to
795 * be used for snapshots, since snapshots are read-only.
797 * Currently locks only guard against locks being acquired.
798 * They do not prevent anything else.
800 * A locker is identified by the internal rados client id of the
801 * holder and a user-defined cookie. This (client id, cookie) pair
802 * must be unique for each locker.
804 * A shared lock also has a user-defined tag associated with it. Each
805 * additional shared lock must specify the same tag or lock
806 * acquisition will fail. This can be used by e.g. groups of hosts
807 * using a clustered filesystem on top of an rbd image to make sure
808 * they're accessing the correct image.
813 * List clients that have locked the image and information about the lock.
815 * The number of bytes required in each buffer is put in the
816 * corresponding size out parameter. If any of the provided buffers
817 * are too short, -ERANGE is returned after these sizes are filled in.
819 * @param exclusive where to store whether the lock is exclusive (1) or shared (0)
820 * @param tag where to store the tag associated with the image
821 * @param tag_len number of bytes in tag buffer
822 * @param clients buffer in which locker clients are stored, separated by '\0'
823 * @param clients_len number of bytes in the clients buffer
824 * @param cookies buffer in which locker cookies are stored, separated by '\0'
825 * @param cookies_len number of bytes in the cookies buffer
826 * @param addrs buffer in which locker addresses are stored, separated by '\0'
827 * @param addrs_len number of bytes in the clients buffer
828 * @returns number of lockers on success, negative error code on failure
829 * @returns -ERANGE if any of the buffers are too short
831 CEPH_RBD_API ssize_t
rbd_list_lockers(rbd_image_t image
, int *exclusive
,
832 char *tag
, size_t *tag_len
,
833 char *clients
, size_t *clients_len
,
834 char *cookies
, size_t *cookies_len
,
835 char *addrs
, size_t *addrs_len
);
838 * Take an exclusive lock on the image.
840 * @param image the image to lock
841 * @param cookie user-defined identifier for this instance of the lock
842 * @returns 0 on success, negative error code on failure
843 * @returns -EBUSY if the lock is already held by another (client, cookie) pair
844 * @returns -EEXIST if the lock is already held by the same (client, cookie) pair
846 CEPH_RBD_API
int rbd_lock_exclusive(rbd_image_t image
, const char *cookie
);
849 * Take a shared lock on the image.
851 * Other clients may also take a shared lock, as lock as they use the
854 * @param image the image to lock
855 * @param cookie user-defined identifier for this instance of the lock
856 * @param tag user-defined identifier for this shared use of the lock
857 * @returns 0 on success, negative error code on failure
858 * @returns -EBUSY if the lock is already held by another (client, cookie) pair
859 * @returns -EEXIST if the lock is already held by the same (client, cookie) pair
861 CEPH_RBD_API
int rbd_lock_shared(rbd_image_t image
, const char *cookie
,
865 * Release a shared or exclusive lock on the image.
867 * @param image the image to unlock
868 * @param cookie user-defined identifier for the instance of the lock
869 * @returns 0 on success, negative error code on failure
870 * @returns -ENOENT if the lock is not held by the specified (client, cookie) pair
872 CEPH_RBD_API
int rbd_unlock(rbd_image_t image
, const char *cookie
);
875 * Release a shared or exclusive lock that was taken by the specified client.
877 * @param image the image to unlock
878 * @param client the entity holding the lock (as given by rbd_list_lockers())
879 * @param cookie user-defined identifier for the instance of the lock to break
880 * @returns 0 on success, negative error code on failure
881 * @returns -ENOENT if the lock is not held by the specified (client, cookie) pair
883 CEPH_RBD_API
int rbd_break_lock(rbd_image_t image
, const char *client
,
889 CEPH_RBD_API ssize_t
rbd_read(rbd_image_t image
, uint64_t ofs
, size_t len
,
892 * @param op_flags: see librados.h constants beginning with LIBRADOS_OP_FLAG
894 CEPH_RBD_API ssize_t
rbd_read2(rbd_image_t image
, uint64_t ofs
, size_t len
,
895 char *buf
, int op_flags
);
896 /* DEPRECATED; use rbd_read_iterate2 */
897 CEPH_RBD_API
int64_t rbd_read_iterate(rbd_image_t image
, uint64_t ofs
, size_t len
,
898 int (*cb
)(uint64_t, size_t, const char *, void *),
902 * iterate read over an image
904 * Reads each region of the image and calls the callback. If the
905 * buffer pointer passed to the callback is NULL, the given extent is
906 * defined to be zeros (a hole). Normally the granularity for the
907 * callback is the image stripe size.
909 * @param image image to read
910 * @param ofs offset to start from
911 * @param len bytes of source image to cover
912 * @param cb callback for each region
913 * @returns 0 success, error otherwise
915 CEPH_RBD_API
int rbd_read_iterate2(rbd_image_t image
, uint64_t ofs
, uint64_t len
,
916 int (*cb
)(uint64_t, size_t, const char *, void *),
919 * get difference between two versions of an image
921 * This will return the differences between two versions of an image
922 * via a callback, which gets the offset and length and a flag
923 * indicating whether the extent exists (1), or is known/defined to
924 * be zeros (a hole, 0). If the source snapshot name is NULL, we
925 * interpret that as the beginning of time and return all allocated
926 * regions of the image. The end version is whatever is currently
927 * selected for the image handle (either a snapshot or the writeable
930 * @param fromsnapname start snapshot name, or NULL
931 * @param ofs start offset
932 * @param len len in bytes of region to report on
933 * @param include_parent 1 if full history diff should include parent
934 * @param whole_object 1 if diff extents should cover whole object
935 * @param cb callback to call for each allocated region
936 * @param arg argument to pass to the callback
937 * @returns 0 on success, or negative error code on error
939 CEPH_RBD_API
int rbd_diff_iterate(rbd_image_t image
,
940 const char *fromsnapname
,
941 uint64_t ofs
, uint64_t len
,
942 int (*cb
)(uint64_t, size_t, int, void *),
944 CEPH_RBD_API
int rbd_diff_iterate2(rbd_image_t image
,
945 const char *fromsnapname
,
946 uint64_t ofs
, uint64_t len
,
947 uint8_t include_parent
, uint8_t whole_object
,
948 int (*cb
)(uint64_t, size_t, int, void *),
950 CEPH_RBD_API ssize_t
rbd_write(rbd_image_t image
, uint64_t ofs
, size_t len
,
953 * @param op_flags: see librados.h constants beginning with LIBRADOS_OP_FLAG
955 CEPH_RBD_API ssize_t
rbd_write2(rbd_image_t image
, uint64_t ofs
, size_t len
,
956 const char *buf
, int op_flags
);
957 CEPH_RBD_API
int rbd_discard(rbd_image_t image
, uint64_t ofs
, uint64_t len
);
958 CEPH_RBD_API ssize_t
rbd_writesame(rbd_image_t image
, uint64_t ofs
, size_t len
,
959 const char *buf
, size_t data_len
, int op_flags
);
960 CEPH_RBD_API ssize_t
rbd_compare_and_write(rbd_image_t image
, uint64_t ofs
,
961 size_t len
, const char *cmp_buf
,
962 const char *buf
, uint64_t *mismatch_off
,
965 CEPH_RBD_API
int rbd_aio_write(rbd_image_t image
, uint64_t off
, size_t len
,
966 const char *buf
, rbd_completion_t c
);
969 * @param op_flags: see librados.h constants beginning with LIBRADOS_OP_FLAG
971 CEPH_RBD_API
int rbd_aio_write2(rbd_image_t image
, uint64_t off
, size_t len
,
972 const char *buf
, rbd_completion_t c
,
974 CEPH_RBD_API
int rbd_aio_writev(rbd_image_t image
, const struct iovec
*iov
,
975 int iovcnt
, uint64_t off
, rbd_completion_t c
);
976 CEPH_RBD_API
int rbd_aio_read(rbd_image_t image
, uint64_t off
, size_t len
,
977 char *buf
, rbd_completion_t c
);
979 * @param op_flags: see librados.h constants beginning with LIBRADOS_OP_FLAG
981 CEPH_RBD_API
int rbd_aio_read2(rbd_image_t image
, uint64_t off
, size_t len
,
982 char *buf
, rbd_completion_t c
, int op_flags
);
983 CEPH_RBD_API
int rbd_aio_readv(rbd_image_t image
, const struct iovec
*iov
,
984 int iovcnt
, uint64_t off
, rbd_completion_t c
);
985 CEPH_RBD_API
int rbd_aio_discard(rbd_image_t image
, uint64_t off
, uint64_t len
,
987 CEPH_RBD_API
int rbd_aio_writesame(rbd_image_t image
, uint64_t off
, size_t len
,
988 const char *buf
, size_t data_len
,
989 rbd_completion_t c
, int op_flags
);
990 CEPH_RBD_API ssize_t
rbd_aio_compare_and_write(rbd_image_t image
,
991 uint64_t off
, size_t len
,
992 const char *cmp_buf
, const char *buf
,
993 rbd_completion_t c
, uint64_t *mismatch_off
,
996 CEPH_RBD_API
int rbd_aio_create_completion(void *cb_arg
,
997 rbd_callback_t complete_cb
,
998 rbd_completion_t
*c
);
999 CEPH_RBD_API
int rbd_aio_is_complete(rbd_completion_t c
);
1000 CEPH_RBD_API
int rbd_aio_wait_for_complete(rbd_completion_t c
);
1001 CEPH_RBD_API ssize_t
rbd_aio_get_return_value(rbd_completion_t c
);
1002 CEPH_RBD_API
void *rbd_aio_get_arg(rbd_completion_t c
);
1003 CEPH_RBD_API
void rbd_aio_release(rbd_completion_t c
);
1004 CEPH_RBD_API
int rbd_flush(rbd_image_t image
);
1006 * Start a flush if caching is enabled. Get a callback when
1007 * the currently pending writes are on disk.
1009 * @param image the image to flush writes to
1010 * @param c what to call when flushing is complete
1011 * @returns 0 on success, negative error code on failure
1013 CEPH_RBD_API
int rbd_aio_flush(rbd_image_t image
, rbd_completion_t c
);
1016 * Drop any cached data for an image
1018 * @param image the image to invalidate cached data for
1019 * @returns 0 on success, negative error code on failure
1021 CEPH_RBD_API
int rbd_invalidate_cache(rbd_image_t image
);
1023 CEPH_RBD_API
int rbd_poll_io_events(rbd_image_t image
, rbd_completion_t
*comps
, int numcomp
);
1025 CEPH_RBD_API
int rbd_metadata_get(rbd_image_t image
, const char *key
, char *value
, size_t *val_len
);
1026 CEPH_RBD_API
int rbd_metadata_set(rbd_image_t image
, const char *key
, const char *value
);
1027 CEPH_RBD_API
int rbd_metadata_remove(rbd_image_t image
, const char *key
);
1029 * List all metadatas associated with this image.
1031 * This iterates over all metadatas, key_len and val_len are filled in
1032 * with the number of bytes put into the keys and values buffers.
1034 * If the provided buffers are too short, the required lengths are
1035 * still filled in, but the data is not and -ERANGE is returned.
1036 * Otherwise, the buffers are filled with the keys and values
1037 * of the image, with a '\0' after each.
1039 * @param image which image (and implicitly snapshot) to list clones of
1040 * @param start_after which name to begin listing after
1041 * (use the empty string to start at the beginning)
1042 * @param max the maximum number of names to lis(if 0 means no limit)
1043 * @param keys buffer in which to store pool names
1044 * @param keys_len number of bytes in pools buffer
1045 * @param values buffer in which to store image names
1046 * @param vals_len number of bytes in images buffer
1047 * @returns number of children on success, negative error code on failure
1048 * @returns -ERANGE if either buffer is too short
1050 CEPH_RBD_API
int rbd_metadata_list(rbd_image_t image
, const char *start
, uint64_t max
,
1051 char *keys
, size_t *key_len
, char *values
, size_t *vals_len
);
1053 // RBD image mirroring support functions
1054 CEPH_RBD_API
int rbd_mirror_image_enable(rbd_image_t image
);
1055 CEPH_RBD_API
int rbd_mirror_image_disable(rbd_image_t image
, bool force
);
1056 CEPH_RBD_API
int rbd_mirror_image_promote(rbd_image_t image
, bool force
);
1057 CEPH_RBD_API
int rbd_mirror_image_demote(rbd_image_t image
);
1058 CEPH_RBD_API
int rbd_mirror_image_resync(rbd_image_t image
);
1059 CEPH_RBD_API
int rbd_mirror_image_get_info(rbd_image_t image
,
1060 rbd_mirror_image_info_t
*mirror_image_info
,
1062 CEPH_RBD_API
int rbd_mirror_image_get_status(rbd_image_t image
,
1063 rbd_mirror_image_status_t
*mirror_image_status
,
1064 size_t status_size
);
1065 CEPH_RBD_API
int rbd_mirror_image_get_instance_id(rbd_image_t image
,
1067 size_t *id_max_length
);
1068 CEPH_RBD_API
int rbd_aio_mirror_image_promote(rbd_image_t image
, bool force
,
1069 rbd_completion_t c
);
1070 CEPH_RBD_API
int rbd_aio_mirror_image_demote(rbd_image_t image
,
1071 rbd_completion_t c
);
1072 CEPH_RBD_API
int rbd_aio_mirror_image_get_info(rbd_image_t image
,
1073 rbd_mirror_image_info_t
*mirror_image_info
,
1075 rbd_completion_t c
);
1076 CEPH_RBD_API
int rbd_aio_mirror_image_get_status(rbd_image_t image
,
1077 rbd_mirror_image_status_t
*mirror_image_status
,
1079 rbd_completion_t c
);
1081 // RBD groups support functions
1082 CEPH_RBD_API
int rbd_group_create(rados_ioctx_t p
, const char *name
);
1083 CEPH_RBD_API
int rbd_group_remove(rados_ioctx_t p
, const char *name
);
1084 CEPH_RBD_API
int rbd_group_list(rados_ioctx_t p
, char *names
, size_t *size
);
1085 CEPH_RBD_API
int rbd_group_rename(rados_ioctx_t p
, const char *src_name
,
1086 const char *dest_name
);
1087 CEPH_RBD_API
int rbd_group_info_cleanup(rbd_group_info_t
*group_info
,
1088 size_t group_info_size
);
1091 * Register an image metadata change watcher.
1093 * @param image the image to watch
1094 * @param handle where to store the internal id assigned to this watch
1095 * @param watch_cb what to do when a notify is received on this image
1096 * @param arg opaque value to pass to the callback
1097 * @returns 0 on success, negative error code on failure
1099 CEPH_RBD_API
int rbd_update_watch(rbd_image_t image
, uint64_t *handle
,
1100 rbd_update_callback_t watch_cb
, void *arg
);
1103 * Unregister an image watcher.
1105 * @param image the image to unwatch
1106 * @param handle which watch to unregister
1107 * @returns 0 on success, negative error code on failure
1109 CEPH_RBD_API
int rbd_update_unwatch(rbd_image_t image
, uint64_t handle
);
1112 * List any watchers of an image.
1114 * Watchers will be allocated and stored in the passed watchers array. If there
1115 * are more watchers than max_watchers, -ERANGE will be returned and the number
1116 * of watchers will be stored in max_watchers.
1118 * The caller should call rbd_watchers_list_cleanup when finished with the list
1121 * @param image the image to list watchers for.
1122 * @param watchers an array to store watchers in.
1123 * @param max_watchers capacity of the watchers array.
1124 * @returns 0 on success, negative error code on failure.
1125 * @returns -ERANGE if there are too many watchers for the passed array.
1126 * @returns the number of watchers in max_watchers.
1128 CEPH_RBD_API
int rbd_watchers_list(rbd_image_t image
,
1129 rbd_image_watcher_t
*watchers
,
1130 size_t *max_watchers
);
1132 CEPH_RBD_API
void rbd_watchers_list_cleanup(rbd_image_watcher_t
*watchers
,
1133 size_t num_watchers
);
1135 CEPH_RBD_API
int rbd_config_image_list(rbd_image_t image
,
1136 rbd_config_option_t
*options
,
1138 CEPH_RBD_API
void rbd_config_image_list_cleanup(rbd_config_option_t
*options
,
1141 CEPH_RBD_API
int rbd_group_image_add(rados_ioctx_t group_p
,
1142 const char *group_name
,
1143 rados_ioctx_t image_p
,
1144 const char *image_name
);
1145 CEPH_RBD_API
int rbd_group_image_remove(rados_ioctx_t group_p
,
1146 const char *group_name
,
1147 rados_ioctx_t image_p
,
1148 const char *image_name
);
1149 CEPH_RBD_API
int rbd_group_image_remove_by_id(rados_ioctx_t group_p
,
1150 const char *group_name
,
1151 rados_ioctx_t image_p
,
1152 const char *image_id
);
1153 CEPH_RBD_API
int rbd_group_image_list(rados_ioctx_t group_p
,
1154 const char *group_name
,
1155 rbd_group_image_info_t
*images
,
1156 size_t group_image_info_size
,
1157 size_t *num_entries
);
1158 CEPH_RBD_API
int rbd_group_image_list_cleanup(rbd_group_image_info_t
*images
,
1159 size_t group_image_info_size
,
1160 size_t num_entries
);
1162 CEPH_RBD_API
int rbd_group_snap_create(rados_ioctx_t group_p
,
1163 const char *group_name
,
1164 const char *snap_name
);
1165 CEPH_RBD_API
int rbd_group_snap_remove(rados_ioctx_t group_p
,
1166 const char *group_name
,
1167 const char *snap_name
);
1168 CEPH_RBD_API
int rbd_group_snap_rename(rados_ioctx_t group_p
,
1169 const char *group_name
,
1170 const char *old_snap_name
,
1171 const char *new_snap_name
);
1172 CEPH_RBD_API
int rbd_group_snap_list(rados_ioctx_t group_p
,
1173 const char *group_name
,
1174 rbd_group_snap_info_t
*snaps
,
1175 size_t group_snap_info_size
,
1176 size_t *num_entries
);
1177 CEPH_RBD_API
int rbd_group_snap_list_cleanup(rbd_group_snap_info_t
*snaps
,
1178 size_t group_snap_info_size
,
1179 size_t num_entries
);
1180 CEPH_RBD_API
int rbd_group_snap_rollback(rados_ioctx_t group_p
,
1181 const char *group_name
,
1182 const char *snap_name
);
1183 CEPH_RBD_API
int rbd_group_snap_rollback_with_progress(rados_ioctx_t group_p
,
1184 const char *group_name
,
1185 const char *snap_name
,
1186 librbd_progress_fn_t cb
,
1189 CEPH_RBD_API
int rbd_namespace_create(rados_ioctx_t io
,
1190 const char *namespace_name
);
1191 CEPH_RBD_API
int rbd_namespace_remove(rados_ioctx_t io
,
1192 const char *namespace_name
);
1193 CEPH_RBD_API
int rbd_namespace_list(rados_ioctx_t io
, char *namespace_names
,
1195 CEPH_RBD_API
int rbd_namespace_exists(rados_ioctx_t io
,
1196 const char *namespace_name
,
1199 CEPH_RBD_API
int rbd_pool_init(rados_ioctx_t io
, bool force
);
1201 CEPH_RBD_API
void rbd_pool_stats_create(rbd_pool_stats_t
*stats
);
1202 CEPH_RBD_API
void rbd_pool_stats_destroy(rbd_pool_stats_t stats
);
1203 CEPH_RBD_API
int rbd_pool_stats_option_add_uint64(rbd_pool_stats_t stats
,
1205 uint64_t* stat_val
);
1206 CEPH_RBD_API
int rbd_pool_stats_get(rados_ioctx_t io
, rbd_pool_stats_t stats
);