From: Gabriel BenHanokh Date: Sun, 23 Jun 2024 15:54:22 +0000 (+0000) Subject: Fixes: https://tracker.ceph.com/issues/66286 X-Git-Tag: v19.1.1~4^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c36680e60ad0de554d844f269f483e57810af041;p=ceph.git Fixes: https://tracker.ceph.com/issues/66286 Improve display of ref_count in the rados commandline utility New test cases were added to detect behavior after server side copy in the following cases: 1) delete original only 2) delete destination only 3) delete original then delete destination (this will lead to orphaned tail-objects without the changes made in this PR) d) delete destination then delete original (this will lead to orphaned tail-objects without the changes made in this PR) Add call to GC between tests to help control the used disk space since we keep writing huge files of 5GB each Signed-off-by: Gabriel BenHanokh (cherry picked from commit d496d20c803590d41d711e446feab41476c0f20c) --- diff --git a/qa/workunits/rgw/test_rgw_orphan_list.sh b/qa/workunits/rgw/test_rgw_orphan_list.sh index 34d550ceade67..4acf9490200d2 100755 --- a/qa/workunits/rgw/test_rgw_orphan_list.sh +++ b/qa/workunits/rgw/test_rgw_orphan_list.sh @@ -376,6 +376,95 @@ done mys3cmd rb --recursive s3://$o_bkt +############################################################ +# copy multipart objects and delete destination + +o_bkt="orig-mp-bkt-5" +d_bkt="copy-mp-bkt-5" + +mys3cmd mb s3://$o_bkt + +for f in $(seq 2) ;do + dest_obj="orig-multipart-obj-$f" + mys3cmd put -q $huge_obj s3://${o_bkt}/$dest_obj +done + +mys3cmd mb s3://$d_bkt + +mys3cmd cp s3://${o_bkt}/orig-multipart-obj-1 \ + s3://${d_bkt}/copied-multipart-obj-1 + +for f in $(seq 5 5) ;do + dest_obj="orig-multipart-obj-$f" + mys3cmd put -q $huge_obj s3://${d_bkt}/$dest_obj +done + +mys3cmd rb --recursive s3://$d_bkt + +##################################################################### +# FORCE GARBAGE COLLECTION +sleep 6 # since for testing age at which gc can happen is 5 secs +radosgw-admin gc process --include-all +##################################################################### + +############################################################ +# copy multipart objects and delete original then destination + +o_bkt="orig-mp-bkt-6" +d_bkt="copy-mp-bkt-6" + +mys3cmd mb s3://$o_bkt + +for f in $(seq 2) ;do + dest_obj="orig-multipart-obj-$f" + mys3cmd put -q $huge_obj s3://${o_bkt}/$dest_obj +done + +mys3cmd mb s3://$d_bkt + +mys3cmd cp s3://${o_bkt}/orig-multipart-obj-1 \ + s3://${d_bkt}/copied-multipart-obj-1 + +for f in $(seq 5 5) ;do + dest_obj="orig-multipart-obj-$f" + mys3cmd put -q $huge_obj s3://${d_bkt}/$dest_obj +done + +mys3cmd rb --recursive s3://$o_bkt +mys3cmd rb --recursive s3://$d_bkt + +############################################################ +# copy multipart objects and delete destination then original + +o_bkt="orig-mp-bkt-7" +d_bkt="copy-mp-bkt-7" + +mys3cmd mb s3://$o_bkt + +for f in $(seq 2) ;do + dest_obj="orig-multipart-obj-$f" + mys3cmd put -q $huge_obj s3://${o_bkt}/$dest_obj +done + +mys3cmd mb s3://$d_bkt + +mys3cmd cp s3://${o_bkt}/orig-multipart-obj-1 \ + s3://${d_bkt}/copied-multipart-obj-1 + +for f in $(seq 5 5) ;do + dest_obj="orig-multipart-obj-$f" + mys3cmd put -q $huge_obj s3://${d_bkt}/$dest_obj +done + +mys3cmd rb --recursive s3://$d_bkt +mys3cmd rb --recursive s3://$o_bkt + +##################################################################### +# FORCE GARBAGE COLLECTION +sleep 6 # since for testing age at which gc can happen is 5 secs +radosgw-admin gc process --include-all +##################################################################### + ######################################################################## # SWIFT TESTS diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index e6c5819666a7e..a76e8cb0be198 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -59,6 +59,8 @@ #include "RadosImport.h" #include "osd/ECUtil.h" +#include "objclass/objclass.h" +#include "cls/refcount/cls_refcount_ops.h" using namespace std::chrono_literals; using namespace librados; @@ -2750,8 +2752,30 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else ret = 0; - string s(bl.c_str(), bl.length()); - cout << s; + + if (attr_name == "refcount") { + obj_refcount oref; + auto p = bl.cbegin(); + decode(oref, p); + for (auto itr = oref.refs.begin(); itr != oref.refs.end(); itr++) { + if (!itr->first.empty()) { + cout << itr->first << "::" << itr->second << std::endl; + } + else { + cout << "wildcard reference::" << itr->second << std::endl; + } + } + if (!oref.retired_refs.empty()) { + cout << "--------------------------------------" << std::endl; + for (const auto & ref : oref.retired_refs) { + cout << "retired_refs::" << ref << std::endl; + } + } + } + else { + string s(bl.c_str(), bl.length()); + cout << s << std::endl; + } } else if (strcmp(nargs[0], "rmxattr") == 0) { if (!pool_name || nargs.size() < (obj_name ? 2 : 3)) { usage(cerr);