mirror of
https://github.com/ceph/ceph
synced 2025-04-01 00:26:47 +00:00
cls/rbd: extend parent_attach to support reattach
Signed-off-by: Mykola Golub <mgolub@suse.com>
This commit is contained in:
parent
e2ed984d51
commit
6795f0267d
src/cls/rbd
@ -586,7 +586,8 @@ int write(cls_method_context_t hctx, const std::string& snap_key,
|
||||
|
||||
namespace parent {
|
||||
|
||||
int attach(cls_method_context_t hctx, cls_rbd_parent parent) {
|
||||
int attach(cls_method_context_t hctx, cls_rbd_parent parent,
|
||||
bool reattach) {
|
||||
int r = check_exists(hctx);
|
||||
if (r < 0) {
|
||||
CLS_LOG(20, "cls_rbd::image::parent::attach: child doesn't exist");
|
||||
@ -621,7 +622,8 @@ int attach(cls_method_context_t hctx, cls_rbd_parent parent) {
|
||||
|
||||
if (r == 0 &&
|
||||
(on_disk_parent.head_overlap ||
|
||||
on_disk_parent_without_overlap != parent)) {
|
||||
on_disk_parent_without_overlap != parent) &&
|
||||
!reattach) {
|
||||
CLS_LOG(20, "cls_rbd::parent::attach: existing legacy parent "
|
||||
"pool=%" PRIi64 ", ns=%s, id=%s, snapid=%" PRIu64 ", "
|
||||
"overlap=%" PRIu64,
|
||||
@ -1679,7 +1681,7 @@ int set_parent(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int r = image::parent::attach(hctx, parent);
|
||||
int r = image::parent::attach(hctx, parent, false);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
@ -1816,17 +1818,22 @@ int parent_overlap_get(cls_method_context_t hctx, bufferlist *in,
|
||||
int parent_attach(cls_method_context_t hctx, bufferlist *in, bufferlist *out) {
|
||||
cls::rbd::ParentImageSpec parent_image_spec;
|
||||
uint64_t parent_overlap;
|
||||
bool reattach = false;
|
||||
|
||||
auto iter = in->cbegin();
|
||||
try {
|
||||
decode(parent_image_spec, iter);
|
||||
decode(parent_overlap, iter);
|
||||
if (!iter.end()) {
|
||||
decode(reattach, iter);
|
||||
}
|
||||
} catch (const buffer::error &err) {
|
||||
CLS_LOG(20, "cls_rbd::parent_attach: invalid decode");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int r = image::parent::attach(hctx, {parent_image_spec, parent_overlap});
|
||||
int r = image::parent::attach(hctx, {parent_image_spec, parent_overlap},
|
||||
reattach);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
|
@ -445,18 +445,19 @@ int parent_overlap_get(librados::IoCtx* ioctx, const std::string &oid,
|
||||
|
||||
void parent_attach(librados::ObjectWriteOperation* op,
|
||||
const cls::rbd::ParentImageSpec& parent_image_spec,
|
||||
uint64_t parent_overlap) {
|
||||
uint64_t parent_overlap, bool reattach) {
|
||||
bufferlist in_bl;
|
||||
encode(parent_image_spec, in_bl);
|
||||
encode(parent_overlap, in_bl);
|
||||
encode(reattach, in_bl);
|
||||
op->exec("rbd", "parent_attach", in_bl);
|
||||
}
|
||||
|
||||
int parent_attach(librados::IoCtx *ioctx, const std::string &oid,
|
||||
const cls::rbd::ParentImageSpec& parent_image_spec,
|
||||
uint64_t parent_overlap) {
|
||||
uint64_t parent_overlap, bool reattach) {
|
||||
librados::ObjectWriteOperation op;
|
||||
parent_attach(&op, parent_image_spec, parent_overlap);
|
||||
parent_attach(&op, parent_image_spec, parent_overlap, reattach);
|
||||
return ioctx->operate(oid, &op);
|
||||
}
|
||||
|
||||
|
@ -111,10 +111,10 @@ int parent_overlap_get(librados::IoCtx* ioctx, const std::string &oid,
|
||||
|
||||
void parent_attach(librados::ObjectWriteOperation* op,
|
||||
const cls::rbd::ParentImageSpec& parent_image_spec,
|
||||
uint64_t parent_overlap);
|
||||
uint64_t parent_overlap, bool reattach);
|
||||
int parent_attach(librados::IoCtx *ioctx, const std::string &oid,
|
||||
const cls::rbd::ParentImageSpec& parent_image_spec,
|
||||
uint64_t parent_overlap);
|
||||
uint64_t parent_overlap, bool reattach);
|
||||
|
||||
void parent_detach(librados::ObjectWriteOperation* op);
|
||||
int parent_detach(librados::IoCtx *ioctx, const std::string &oid);
|
||||
|
Loading…
Reference in New Issue
Block a user