Skip to content

Commit d496d20

Browse files
committed
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 <[email protected]>
1 parent 067a93c commit d496d20

File tree

2 files changed

+115
-2
lines changed

2 files changed

+115
-2
lines changed

qa/workunits/rgw/test_rgw_orphan_list.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,95 @@ done
376376

377377
mys3cmd rb --recursive s3://$o_bkt
378378

379+
############################################################
380+
# copy multipart objects and delete destination
381+
382+
o_bkt="orig-mp-bkt-5"
383+
d_bkt="copy-mp-bkt-5"
384+
385+
mys3cmd mb s3://$o_bkt
386+
387+
for f in $(seq 2) ;do
388+
dest_obj="orig-multipart-obj-$f"
389+
mys3cmd put -q $huge_obj s3://${o_bkt}/$dest_obj
390+
done
391+
392+
mys3cmd mb s3://$d_bkt
393+
394+
mys3cmd cp s3://${o_bkt}/orig-multipart-obj-1 \
395+
s3://${d_bkt}/copied-multipart-obj-1
396+
397+
for f in $(seq 5 5) ;do
398+
dest_obj="orig-multipart-obj-$f"
399+
mys3cmd put -q $huge_obj s3://${d_bkt}/$dest_obj
400+
done
401+
402+
mys3cmd rb --recursive s3://$d_bkt
403+
404+
#####################################################################
405+
# FORCE GARBAGE COLLECTION
406+
sleep 6 # since for testing age at which gc can happen is 5 secs
407+
radosgw-admin gc process --include-all
408+
#####################################################################
409+
410+
############################################################
411+
# copy multipart objects and delete original then destination
412+
413+
o_bkt="orig-mp-bkt-6"
414+
d_bkt="copy-mp-bkt-6"
415+
416+
mys3cmd mb s3://$o_bkt
417+
418+
for f in $(seq 2) ;do
419+
dest_obj="orig-multipart-obj-$f"
420+
mys3cmd put -q $huge_obj s3://${o_bkt}/$dest_obj
421+
done
422+
423+
mys3cmd mb s3://$d_bkt
424+
425+
mys3cmd cp s3://${o_bkt}/orig-multipart-obj-1 \
426+
s3://${d_bkt}/copied-multipart-obj-1
427+
428+
for f in $(seq 5 5) ;do
429+
dest_obj="orig-multipart-obj-$f"
430+
mys3cmd put -q $huge_obj s3://${d_bkt}/$dest_obj
431+
done
432+
433+
mys3cmd rb --recursive s3://$o_bkt
434+
mys3cmd rb --recursive s3://$d_bkt
435+
436+
############################################################
437+
# copy multipart objects and delete destination then original
438+
439+
o_bkt="orig-mp-bkt-7"
440+
d_bkt="copy-mp-bkt-7"
441+
442+
mys3cmd mb s3://$o_bkt
443+
444+
for f in $(seq 2) ;do
445+
dest_obj="orig-multipart-obj-$f"
446+
mys3cmd put -q $huge_obj s3://${o_bkt}/$dest_obj
447+
done
448+
449+
mys3cmd mb s3://$d_bkt
450+
451+
mys3cmd cp s3://${o_bkt}/orig-multipart-obj-1 \
452+
s3://${d_bkt}/copied-multipart-obj-1
453+
454+
for f in $(seq 5 5) ;do
455+
dest_obj="orig-multipart-obj-$f"
456+
mys3cmd put -q $huge_obj s3://${d_bkt}/$dest_obj
457+
done
458+
459+
mys3cmd rb --recursive s3://$d_bkt
460+
mys3cmd rb --recursive s3://$o_bkt
461+
462+
#####################################################################
463+
# FORCE GARBAGE COLLECTION
464+
sleep 6 # since for testing age at which gc can happen is 5 secs
465+
radosgw-admin gc process --include-all
466+
#####################################################################
467+
379468
########################################################################
380469
# SWIFT TESTS
381470

src/tools/rados/rados.cc

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
#include "RadosImport.h"
6060

6161
#include "osd/ECUtil.h"
62+
#include "objclass/objclass.h"
63+
#include "cls/refcount/cls_refcount_ops.h"
6264

6365
using namespace std::chrono_literals;
6466
using namespace librados;
@@ -2750,8 +2752,30 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
27502752
}
27512753
else
27522754
ret = 0;
2753-
string s(bl.c_str(), bl.length());
2754-
cout << s;
2755+
2756+
if (attr_name == "refcount") {
2757+
obj_refcount oref;
2758+
auto p = bl.cbegin();
2759+
decode(oref, p);
2760+
for (auto itr = oref.refs.begin(); itr != oref.refs.end(); itr++) {
2761+
if (!itr->first.empty()) {
2762+
cout << itr->first << "::" << itr->second << std::endl;
2763+
}
2764+
else {
2765+
cout << "wildcard reference::" << itr->second << std::endl;
2766+
}
2767+
}
2768+
if (!oref.retired_refs.empty()) {
2769+
cout << "--------------------------------------" << std::endl;
2770+
for (const auto & ref : oref.retired_refs) {
2771+
cout << "retired_refs::" << ref << std::endl;
2772+
}
2773+
}
2774+
}
2775+
else {
2776+
string s(bl.c_str(), bl.length());
2777+
cout << s << std::endl;
2778+
}
27552779
} else if (strcmp(nargs[0], "rmxattr") == 0) {
27562780
if (!pool_name || nargs.size() < (obj_name ? 2 : 3)) {
27572781
usage(cerr);

0 commit comments

Comments
 (0)