mirror of
https://github.com/ceph/ceph
synced 2025-01-01 08:32:24 +00:00
librbd: add data pool option to API and config
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
parent
a0c82b4276
commit
8b72efd181
@ -1257,7 +1257,8 @@ OPTION(rbd_default_features, OPT_INT, 61) // only applies to format 2 images
|
||||
// +1 for layering, +2 for stripingv2,
|
||||
// +4 for exclusive lock, +8 for object map
|
||||
// +16 for fast-diff, +32 for deep-flatten,
|
||||
// +64 for journaling
|
||||
// +64 for journaling, +128 for data pool
|
||||
OPTION(rbd_default_data_pool, OPT_STR, "") // optional default pool for storing image data blocks
|
||||
|
||||
OPTION(rbd_default_map_options, OPT_STR, "") // default rbd map -o / --options
|
||||
|
||||
|
@ -177,6 +177,7 @@ enum {
|
||||
RBD_IMAGE_OPTION_JOURNAL_POOL = 7,
|
||||
RBD_IMAGE_OPTION_FEATURES_SET = 8,
|
||||
RBD_IMAGE_OPTION_FEATURES_CLEAR = 9,
|
||||
RBD_IMAGE_OPTION_DATA_POOL = 10
|
||||
};
|
||||
|
||||
CEPH_RBD_API void rbd_image_options_create(rbd_image_options_t* opts);
|
||||
|
@ -349,6 +349,7 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force,
|
||||
{RBD_IMAGE_OPTION_JOURNAL_POOL, STR},
|
||||
{RBD_IMAGE_OPTION_FEATURES_SET, UINT64},
|
||||
{RBD_IMAGE_OPTION_FEATURES_CLEAR, UINT64},
|
||||
{RBD_IMAGE_OPTION_DATA_POOL, STR},
|
||||
};
|
||||
|
||||
std::string image_option_name(int optname) {
|
||||
@ -373,6 +374,8 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force,
|
||||
return "features_set";
|
||||
case RBD_IMAGE_OPTION_FEATURES_CLEAR:
|
||||
return "features_clear";
|
||||
case RBD_IMAGE_OPTION_DATA_POOL:
|
||||
return "data_pool";
|
||||
default:
|
||||
return "unknown (" + stringify(optname) + ")";
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ cdef extern from "rbd/librbd.h" nogil:
|
||||
_RBD_FEATURE_FAST_DIFF "RBD_FEATURE_FAST_DIFF"
|
||||
_RBD_FEATURE_DEEP_FLATTEN "RBD_FEATURE_DEEP_FLATTEN"
|
||||
_RBD_FEATURE_JOURNALING "RBD_FEATURE_JOURNALING"
|
||||
_RBD_FEATURE_DATA_POOL "RBD_FEATURE_DATA_POOL"
|
||||
|
||||
_RBD_FEATURES_INCOMPATIBLE "RBD_FEATURES_INCOMPATIBLE"
|
||||
_RBD_FEATURES_RW_INCOMPATIBLE "RBD_FEATURES_RW_INCOMPATIBLE"
|
||||
@ -68,6 +69,7 @@ cdef extern from "rbd/librbd.h" nogil:
|
||||
_RBD_IMAGE_OPTION_ORDER "RBD_IMAGE_OPTION_ORDER"
|
||||
_RBD_IMAGE_OPTION_STRIPE_UNIT "RBD_IMAGE_OPTION_STRIPE_UNIT"
|
||||
_RBD_IMAGE_OPTION_STRIPE_COUNT "RBD_IMAGE_OPTION_STRIPE_COUNT"
|
||||
_RBD_IMAGE_OPTION_DATA_POOL "RBD_IMAGE_OPTION_DATA_POOL"
|
||||
|
||||
RBD_MAX_BLOCK_NAME_SIZE
|
||||
RBD_MAX_IMAGE_NAME_SIZE
|
||||
@ -292,6 +294,7 @@ RBD_FEATURE_OBJECT_MAP = _RBD_FEATURE_OBJECT_MAP
|
||||
RBD_FEATURE_FAST_DIFF = _RBD_FEATURE_FAST_DIFF
|
||||
RBD_FEATURE_DEEP_FLATTEN = _RBD_FEATURE_DEEP_FLATTEN
|
||||
RBD_FEATURE_JOURNALING = _RBD_FEATURE_JOURNALING
|
||||
RBD_FEATURE_DATA_POOL = _RBD_FEATURE_DATA_POOL
|
||||
|
||||
RBD_FEATURES_INCOMPATIBLE = _RBD_FEATURES_INCOMPATIBLE
|
||||
RBD_FEATURES_RW_INCOMPATIBLE = _RBD_FEATURES_RW_INCOMPATIBLE
|
||||
@ -322,7 +325,7 @@ RBD_IMAGE_OPTION_FEATURES = _RBD_IMAGE_OPTION_FEATURES
|
||||
RBD_IMAGE_OPTION_ORDER = _RBD_IMAGE_OPTION_ORDER
|
||||
RBD_IMAGE_OPTION_STRIPE_UNIT = _RBD_IMAGE_OPTION_STRIPE_UNIT
|
||||
RBD_IMAGE_OPTION_STRIPE_COUNT = _RBD_IMAGE_OPTION_STRIPE_COUNT
|
||||
|
||||
RBD_IMAGE_OPTION_DATA_POOL = _RBD_IMAGE_OPTION_DATA_POOL
|
||||
|
||||
class Error(Exception):
|
||||
pass
|
||||
@ -600,7 +603,8 @@ class RBD(object):
|
||||
return (major, minor, extra)
|
||||
|
||||
def create(self, ioctx, name, size, order=None, old_format=True,
|
||||
features=None, stripe_unit=None, stripe_count=None):
|
||||
features=None, stripe_unit=None, stripe_count=None,
|
||||
data_pool=None):
|
||||
"""
|
||||
Create an rbd image.
|
||||
|
||||
@ -622,6 +626,8 @@ class RBD(object):
|
||||
:type stripe_unit: int
|
||||
:param stripe_count: objects to stripe over before looping
|
||||
:type stripe_count: int
|
||||
:param data_pool: optional separate pool for data blocks
|
||||
:type data_pool: str
|
||||
:raises: :class:`ImageExists`
|
||||
:raises: :class:`TypeError`
|
||||
:raises: :class:`InvalidArgument`
|
||||
@ -639,9 +645,11 @@ class RBD(object):
|
||||
if old_format:
|
||||
if (features or
|
||||
((stripe_unit is not None) and stripe_unit != 0) or
|
||||
((stripe_count is not None) and stripe_count != 0)):
|
||||
raise InvalidArgument('format 1 images do not support feature'
|
||||
' masks or non-default striping')
|
||||
((stripe_count is not None) and stripe_count != 0) or
|
||||
data_pool):
|
||||
raise InvalidArgument('format 1 images do not support feature '
|
||||
'masks, non-default striping, nor data '
|
||||
'pool')
|
||||
with nogil:
|
||||
ret = rbd_create(_ioctx, _name, _size, &_order)
|
||||
else:
|
||||
@ -663,6 +671,10 @@ class RBD(object):
|
||||
rbd_image_options_set_uint64(opts,
|
||||
RBD_IMAGE_OPTION_STRIPE_COUNT,
|
||||
stripe_count)
|
||||
if data_pool is not None:
|
||||
rbd_image_options_set_string(opts,
|
||||
RBD_IMAGE_OPTION_DATA_POOL,
|
||||
data_pool)
|
||||
with nogil:
|
||||
ret = rbd_create4(_ioctx, _name, _size, opts)
|
||||
finally:
|
||||
@ -671,7 +683,8 @@ class RBD(object):
|
||||
raise make_ex(ret, 'error creating image')
|
||||
|
||||
def clone(self, p_ioctx, p_name, p_snapname, c_ioctx, c_name,
|
||||
features=None, order=None, stripe_unit=None, stripe_count=None):
|
||||
features=None, order=None, stripe_unit=None, stripe_count=None,
|
||||
data_pool=None):
|
||||
"""
|
||||
Clone a parent rbd snapshot into a COW sparse child.
|
||||
|
||||
@ -693,6 +706,8 @@ class RBD(object):
|
||||
:type stripe_unit: int
|
||||
:param stripe_count: objects to stripe over before looping
|
||||
:type stripe_count: int
|
||||
:param data_pool: optional separate pool for data blocks
|
||||
:type data_pool: str
|
||||
:raises: :class:`TypeError`
|
||||
:raises: :class:`InvalidArgument`
|
||||
:raises: :class:`ImageExists`
|
||||
@ -724,6 +739,9 @@ class RBD(object):
|
||||
if stripe_count is not None:
|
||||
rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_STRIPE_COUNT,
|
||||
stripe_count)
|
||||
if data_pool is not None:
|
||||
rbd_image_options_set_string(opts, RBD_IMAGE_OPTION_DATA_POOL,
|
||||
data_pool)
|
||||
with nogil:
|
||||
ret = rbd_clone3(_p_ioctx, _p_name, _p_snapname,
|
||||
_c_ioctx, _c_name, opts)
|
||||
@ -1432,7 +1450,7 @@ cdef class Image(object):
|
||||
return owner == 1
|
||||
|
||||
def copy(self, dest_ioctx, dest_name, features=None, order=None,
|
||||
stripe_unit=None, stripe_count=None):
|
||||
stripe_unit=None, stripe_count=None, data_pool=None):
|
||||
"""
|
||||
Copy the image to another location.
|
||||
|
||||
@ -1448,6 +1466,8 @@ cdef class Image(object):
|
||||
:type stripe_unit: int
|
||||
:param stripe_count: objects to stripe over before looping
|
||||
:type stripe_count: int
|
||||
:param data_pool: optional separate pool for data blocks
|
||||
:type data_pool: str
|
||||
:raises: :class:`TypeError`
|
||||
:raises: :class:`InvalidArgument`
|
||||
:raises: :class:`ImageExists`
|
||||
@ -1474,6 +1494,9 @@ cdef class Image(object):
|
||||
if stripe_count is not None:
|
||||
rbd_image_options_set_uint64(opts, RBD_IMAGE_OPTION_STRIPE_COUNT,
|
||||
stripe_count)
|
||||
if data_pool is not None:
|
||||
rbd_image_options_set_string(opts, RBD_IMAGE_OPTION_DATA_POOL,
|
||||
data_pool)
|
||||
with nogil:
|
||||
ret = rbd_copy3(self.image, _dest_ioctx, _dest_name, opts)
|
||||
finally:
|
||||
|
Loading…
Reference in New Issue
Block a user