mirror of
https://github.com/ceph/ceph
synced 2025-01-04 02:02:36 +00:00
cls_rbd: rename parent size -> overlap
The use of 'size' to describe the amount that we overlap with the parent was confusing; overlap is more intuitive (to me, at least!). Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
parent
3948e0690e
commit
87cadffd7c
@ -81,7 +81,7 @@ struct cls_rbd_parent {
|
||||
int64_t pool; ///< parent pool id
|
||||
string id; ///< parent image id
|
||||
snapid_t snapid; ///< parent snapid we refer to
|
||||
uint64_t size; ///< portion of this image mapped onto parent
|
||||
uint64_t overlap; ///< portion of this image mapped onto parent
|
||||
|
||||
/// true if our parent pointer information is defined
|
||||
bool exists() const {
|
||||
@ -95,7 +95,7 @@ struct cls_rbd_parent {
|
||||
::encode(pool, bl);
|
||||
::encode(id, bl);
|
||||
::encode(snapid, bl);
|
||||
::encode(size, bl);
|
||||
::encode(overlap, bl);
|
||||
ENCODE_FINISH(bl);
|
||||
}
|
||||
void decode(bufferlist::iterator& bl) {
|
||||
@ -103,7 +103,7 @@ struct cls_rbd_parent {
|
||||
::decode(pool, bl);
|
||||
::decode(id, bl);
|
||||
::decode(snapid, bl);
|
||||
::decode(size, bl);
|
||||
::decode(overlap, bl);
|
||||
DECODE_FINISH(bl);
|
||||
}
|
||||
};
|
||||
@ -468,9 +468,9 @@ int set_size(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
|
||||
r = 0;
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (parent.exists() && parent.size > size) {
|
||||
if (parent.exists() && parent.overlap > size) {
|
||||
bufferlist parentbl;
|
||||
parent.size = size;
|
||||
parent.overlap = size;
|
||||
::encode(parent, parentbl);
|
||||
r = cls_cxx_map_set_val(hctx, "parent", &parentbl);
|
||||
if (r < 0) {
|
||||
@ -784,7 +784,7 @@ int get_parent(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
|
||||
::encode(parent.pool, *out);
|
||||
::encode(parent.id, *out);
|
||||
::encode(parent.snapid, *out);
|
||||
::encode(parent.size, *out);
|
||||
::encode(parent.overlap, *out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -833,9 +833,9 @@ int set_parent(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
|
||||
cls_rbd_parent parent;
|
||||
r = read_key(hctx, "parent", &parent);
|
||||
if (r == 0) {
|
||||
CLS_LOG(20, "set_parent existing parent pool=%lld id=%s snapid=%llu size=%llu",
|
||||
CLS_LOG(20, "set_parent existing parent pool=%lld id=%s snapid=%llu overlap=%llu",
|
||||
parent.pool, parent.id.c_str(), parent.snapid.val,
|
||||
parent.size);
|
||||
parent.overlap);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
@ -844,14 +844,12 @@ int set_parent(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
|
||||
r = read_key(hctx, "size", &our_size);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (our_size < size)
|
||||
size = our_size;
|
||||
|
||||
bufferlist parentbl;
|
||||
parent.pool = pool;
|
||||
parent.id = id;
|
||||
parent.snapid = snapid;
|
||||
parent.size = size;
|
||||
parent.overlap = MIN(our_size, size);
|
||||
::encode(parent, parentbl);
|
||||
r = cls_cxx_map_set_val(hctx, "parent", &parentbl);
|
||||
if (r < 0) {
|
||||
|
@ -165,7 +165,7 @@ namespace librbd {
|
||||
int get_parent(librados::IoCtx *ioctx, const std::string &oid,
|
||||
snapid_t snap_id, int64_t *parent_pool,
|
||||
string *parent_image, snapid_t *parent_snap_id,
|
||||
uint64_t *parent_size)
|
||||
uint64_t *parent_overlap)
|
||||
{
|
||||
bufferlist inbl, outbl;
|
||||
::encode(snap_id, inbl);
|
||||
@ -179,7 +179,7 @@ namespace librbd {
|
||||
::decode(*parent_pool, iter);
|
||||
::decode(*parent_image, iter);
|
||||
::decode(*parent_snap_id, iter);
|
||||
::decode(*parent_size, iter);
|
||||
::decode(*parent_overlap, iter);
|
||||
} catch (const buffer::error &err) {
|
||||
return -EBADMSG;
|
||||
}
|
||||
@ -189,13 +189,13 @@ namespace librbd {
|
||||
|
||||
int set_parent(librados::IoCtx *ioctx, const std::string &oid,
|
||||
int64_t parent_pool, const string& parent_image,
|
||||
snapid_t parent_snap_id, uint64_t parent_size)
|
||||
snapid_t parent_snap_id, uint64_t parent_overlap)
|
||||
{
|
||||
bufferlist inbl, outbl;
|
||||
::encode(parent_pool, inbl);
|
||||
::encode(parent_image, inbl);
|
||||
::encode(parent_snap_id, inbl);
|
||||
::encode(parent_size, inbl);
|
||||
::encode(parent_overlap, inbl);
|
||||
|
||||
return ioctx->exec(oid, "rbd", "set_parent", inbl, outbl);
|
||||
}
|
||||
|
@ -42,10 +42,10 @@ namespace librbd {
|
||||
int get_parent(librados::IoCtx *ioctx, const std::string &oid,
|
||||
snapid_t snap_id, int64_t *parent_pool,
|
||||
std::string *parent_image, snapid_t *parent_snap_id,
|
||||
uint64_t *parent_size);
|
||||
uint64_t *parent_overlap);
|
||||
int set_parent(librados::IoCtx *ioctx, const std::string &oid,
|
||||
int64_t parent_pool, const std::string& parent_image, snapid_t parent_snap_id,
|
||||
uint64_t parent_size);
|
||||
uint64_t parent_overlap);
|
||||
int remove_parent(librados::IoCtx *ioctx, const std::string &oid);
|
||||
int snapshot_add(librados::IoCtx *ioctx, const std::string &oid,
|
||||
snapid_t snap_id, const std::string &snap_name);
|
||||
|
Loading…
Reference in New Issue
Block a user