diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2024-09-10 13:54:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-10 13:54:57 +0200 |
commit | b23f1e29b39e03b439c4fd2a92673015f5753f9a (patch) | |
tree | 810b8daf4a560c7b264a89087c9a8dd3f0121ece /src/cls | |
parent | Merge pull request #59675 from zdover23/wip-doc-2024-09-10-README-md-vstart (diff) | |
parent | cls/rbd: async methods for group snap list (diff) | |
download | ceph-b23f1e29b39e03b439c4fd2a92673015f5753f9a.tar.xz ceph-b23f1e29b39e03b439c4fd2a92673015f5753f9a.zip |
Merge pull request #59107 from nbalacha/wip-nbalacha-async-sorted-snaps
librbd: make "group snap list" async and optionally sorted by snap creation time
Reviewed-by: Ramana Raja <rraja@redhat.com>
Reviewed-by: Mykola Golub <mgolub@suse.com>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'src/cls')
-rw-r--r-- | src/cls/rbd/cls_rbd_client.cc | 74 | ||||
-rw-r--r-- | src/cls/rbd/cls_rbd_client.h | 10 |
2 files changed, 62 insertions, 22 deletions
diff --git a/src/cls/rbd/cls_rbd_client.cc b/src/cls/rbd/cls_rbd_client.cc index ad480c47d5c..458bfd985c3 100644 --- a/src/cls/rbd/cls_rbd_client.cc +++ b/src/cls/rbd/cls_rbd_client.cc @@ -2757,28 +2757,65 @@ int group_snap_get_by_id(librados::IoCtx *ioctx, const std::string &oid, return 0; } + +void group_snap_list_start(librados::ObjectReadOperation *op, + const cls::rbd::GroupSnapshot &start, + uint64_t max_return) +{ + bufferlist bl; + encode(start, bl); + encode(max_return, bl); + + op->exec("rbd", "group_snap_list", bl); +} + +int group_snap_list_finish(bufferlist::const_iterator *iter, + std::vector<cls::rbd::GroupSnapshot> *snapshots) +{ + try { + decode(*snapshots, *iter); + } catch (const ceph::buffer::error &err) { + return -EBADMSG; + } + return 0; +} + int group_snap_list(librados::IoCtx *ioctx, const std::string &oid, const cls::rbd::GroupSnapshot &start, uint64_t max_return, std::vector<cls::rbd::GroupSnapshot> *snapshots) { - using ceph::encode; - using ceph::decode; - bufferlist inbl, outbl; - encode(start, inbl); - encode(max_return, inbl); + librados::ObjectReadOperation op; + group_snap_list_start(&op, start, max_return); - int r = ioctx->exec(oid, "rbd", "group_snap_list", inbl, outbl); + bufferlist out_bl; + int r = ioctx->operate(oid, &op, &out_bl); if (r < 0) { return r; } - auto iter = outbl.cbegin(); + + auto it = out_bl.cbegin(); + return group_snap_list_finish(&it, snapshots); +} + +void group_snap_list_order_start(librados::ObjectReadOperation *op, + const std::string &start, + uint64_t max_return) +{ + bufferlist bl; + encode(start, bl); + encode(max_return, bl); + op->exec("rbd", "group_snap_list_order", bl); +} + +int group_snap_list_order_finish(bufferlist::const_iterator *iter, + std::map<std::string, uint64_t> *snap_order) +{ try { - decode(*snapshots, iter); + decode(*snap_order, *iter); } catch (const ceph::buffer::error &err) { return -EBADMSG; } - return 0; } @@ -2786,24 +2823,17 @@ int group_snap_list_order(librados::IoCtx *ioctx, const std::string &oid, const std::string &start, uint64_t max_return, std::map<std::string, uint64_t> *snap_order) { - using ceph::encode; - using ceph::decode; - bufferlist inbl, outbl; - encode(start, inbl); - encode(max_return, inbl); + librados::ObjectReadOperation op; + group_snap_list_order_start(&op, start, max_return); - int r = ioctx->exec(oid, "rbd", "group_snap_list_order", inbl, outbl); + bufferlist out_bl; + int r = ioctx->operate(oid, &op, &out_bl); if (r < 0) { return r; } - auto iter = outbl.cbegin(); - try { - decode(*snap_order, iter); - } catch (const ceph::buffer::error &err) { - return -EBADMSG; - } - return 0; + auto it = out_bl.cbegin(); + return group_snap_list_order_finish(&it, snap_order); } // rbd_trash functions diff --git a/src/cls/rbd/cls_rbd_client.h b/src/cls/rbd/cls_rbd_client.h index 4005c51836c..b1553bd1f17 100644 --- a/src/cls/rbd/cls_rbd_client.h +++ b/src/cls/rbd/cls_rbd_client.h @@ -580,10 +580,20 @@ int group_snap_remove(librados::IoCtx *ioctx, const std::string &oid, int group_snap_get_by_id(librados::IoCtx *ioctx, const std::string &oid, const std::string &snap_id, cls::rbd::GroupSnapshot *snapshot); +void group_snap_list_start(librados::ObjectReadOperation *op, + const cls::rbd::GroupSnapshot &start, + uint64_t max_return); +int group_snap_list_finish(ceph::buffer::list::const_iterator *iter, + std::vector<cls::rbd::GroupSnapshot> *snapshots); int group_snap_list(librados::IoCtx *ioctx, const std::string &oid, const cls::rbd::GroupSnapshot &start, uint64_t max_return, std::vector<cls::rbd::GroupSnapshot> *snapshots); +void group_snap_list_order_start(librados::ObjectReadOperation *op, + const std::string &start_snap_id, + uint64_t max_return); +int group_snap_list_order_finish(ceph::buffer::list::const_iterator *iter, + std::map<std::string, uint64_t> *snap_order); int group_snap_list_order(librados::IoCtx *ioctx, const std::string &oid, const std::string &snap_id, uint64_t max_return, std::map<std::string, uint64_t> *snap_order); |