mirror of
https://github.com/ceph/ceph
synced 2025-01-20 01:51:34 +00:00
Merge pull request #19280 from Songweibin/wip-parent-info
rbd: add parent info when moving child into trash bin Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
commit
3c003554be
@ -388,7 +388,7 @@ int journal_get_order(cls_method_context_t hctx, bufferlist *in,
|
||||
* none
|
||||
*
|
||||
* Output:
|
||||
* order (uint8_t)
|
||||
* splay_width (uint8_t)
|
||||
* @returns 0 on success, negative error code on failure
|
||||
*/
|
||||
int journal_get_splay_width(cls_method_context_t hctx, bufferlist *in,
|
||||
|
@ -980,7 +980,7 @@ class RBD(object):
|
||||
with nogil:
|
||||
ret = rbd_trash_get(_ioctx, _image_id, &c_info)
|
||||
if ret != 0:
|
||||
raise make_ex(ret, 'error restoring image from trash')
|
||||
raise make_ex(ret, 'error retrieving image from trash')
|
||||
|
||||
__source_string = ['USER', 'MIRRORING']
|
||||
info = {
|
||||
|
@ -197,6 +197,7 @@ int do_list(librbd::RBD &rbd, librados::IoCtx& io_ctx, bool long_flag,
|
||||
tbl.define_column("SOURCE", TextTable::LEFT, TextTable::LEFT);
|
||||
tbl.define_column("DELETED_AT", TextTable::LEFT, TextTable::LEFT);
|
||||
tbl.define_column("STATUS", TextTable::LEFT, TextTable::LEFT);
|
||||
tbl.define_column("PARENT", TextTable::LEFT, TextTable::LEFT);
|
||||
}
|
||||
|
||||
for (const auto& entry : trash_entries) {
|
||||
@ -233,6 +234,16 @@ int do_list(librbd::RBD &rbd, librados::IoCtx& io_ctx, bool long_flag,
|
||||
std::string time_str = ctime(&entry.deletion_time);
|
||||
time_str = time_str.substr(0, time_str.length() - 1);
|
||||
|
||||
std::string pool, image, snap, parent;
|
||||
r = im.parent_info(&pool, &image, &snap);
|
||||
if (r < 0 && r != -ENOENT)
|
||||
return r;
|
||||
bool has_parent = false;
|
||||
if (r != -ENOENT) {
|
||||
parent = pool + "/" + image + "@" + snap;
|
||||
has_parent = true;
|
||||
}
|
||||
|
||||
if (f) {
|
||||
f->open_object_section("image");
|
||||
f->dump_string("id", entry.id);
|
||||
@ -241,14 +252,23 @@ int do_list(librbd::RBD &rbd, librados::IoCtx& io_ctx, bool long_flag,
|
||||
f->dump_string("deleted_at", time_str);
|
||||
f->dump_string("status",
|
||||
delete_status(entry.deferment_end_time));
|
||||
if (has_parent) {
|
||||
f->open_object_section("parent");
|
||||
f->dump_string("pool", pool);
|
||||
f->dump_string("image", image);
|
||||
f->dump_string("snapshot", snap);
|
||||
f->close_section();
|
||||
}
|
||||
f->close_section();
|
||||
} else {
|
||||
tbl << entry.id
|
||||
<< entry.name
|
||||
<< del_source
|
||||
<< time_str
|
||||
<< delete_status(entry.deferment_end_time)
|
||||
<< TextTable::endrow;
|
||||
<< delete_status(entry.deferment_end_time);
|
||||
if (has_parent)
|
||||
tbl << parent;
|
||||
tbl << TextTable::endrow;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user