From: Yao Zongyou Date: Tue, 5 Sep 2017 09:33:04 +0000 (+0800) Subject: rgw-admin: support for processing all gc objects including unexpired. X-Git-Tag: v13.0.2~750^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ceccb54f191182813cae70841e87b9969c3d4aeb;p=ceph.git rgw-admin: support for processing all gc objects including unexpired. Signed-off-by: Yao Zongyou --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index e750d8c7ba79..5f3d44a8932a 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -166,7 +166,8 @@ void usage() cout << " usage trim trim usage (by user, date range)\n"; cout << " gc list dump expired garbage collection objects (specify\n"; cout << " --include-all to list all entries, including unexpired)\n"; - cout << " gc process manually process garbage\n"; + cout << " gc process manually process garbage (specify\n"; + cout << " --include-all to process all entries, including unexpired)\n"; cout << " lc list list all bucket lifecycle progress\n"; cout << " lc process manually process lifecycle\n"; cout << " metadata get get metadata info\n"; @@ -5927,7 +5928,7 @@ next: } if (opt_cmd == OPT_GC_PROCESS) { - int ret = store->process_gc(); + int ret = store->process_gc(!include_all); if (ret < 0) { cerr << "ERROR: gc processing returned error: " << cpp_strerror(-ret) << std::endl; return 1; diff --git a/src/rgw/rgw_gc.cc b/src/rgw/rgw_gc.cc index 216477e3462d..7557bfa0a6cc 100644 --- a/src/rgw/rgw_gc.cc +++ b/src/rgw/rgw_gc.cc @@ -128,7 +128,7 @@ int RGWGC::list(int *index, string& marker, uint32_t max, bool expired_only, std return 0; } -int RGWGC::process(int index, int max_secs) +int RGWGC::process(int index, int max_secs, bool expired_only) { rados::cls::lock::Lock l(gc_index_lock_name); utime_t end = ceph_clock_now(); @@ -160,7 +160,7 @@ int RGWGC::process(int index, int max_secs) do { int max = 100; std::list entries; - ret = cls_rgw_gc_list(store->gc_pool_ctx, obj_names[index], marker, max, true, entries, &truncated, next_marker); + ret = cls_rgw_gc_list(store->gc_pool_ctx, obj_names[index], marker, max, expired_only, entries, &truncated, next_marker); if (ret == -ENOENT) { ret = 0; goto done; @@ -236,7 +236,7 @@ done: return 0; } -int RGWGC::process() +int RGWGC::process(bool expired_only) { int max_secs = cct->_conf->rgw_gc_processor_max_time; @@ -244,7 +244,7 @@ int RGWGC::process() for (int i = 0; i < max_objs; i++) { int index = (i + start) % max_objs; - int ret = process(index, max_secs); + int ret = process(index, max_secs, expired_only); if (ret < 0) return ret; } @@ -278,7 +278,7 @@ void *RGWGC::GCWorker::entry() { do { utime_t start = ceph_clock_now(); dout(2) << "garbage collection: start" << dendl; - int r = gc->process(); + int r = gc->process(true); if (r < 0) { dout(0) << "ERROR: garbage collection process() returned error r=" << r << dendl; } diff --git a/src/rgw/rgw_gc.h b/src/rgw/rgw_gc.h index 491796b50e86..bab44b7fd34c 100644 --- a/src/rgw/rgw_gc.h +++ b/src/rgw/rgw_gc.h @@ -55,8 +55,8 @@ public: int list(int *index, string& marker, uint32_t max, bool expired_only, std::list& result, bool *truncated); void list_init(int *index) { *index = 0; } - int process(int index, int process_max_secs); - int process(); + int process(int index, int process_max_secs, bool expired_only); + int process(bool expired_only); bool going_down(); void start_processor(); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index cfcacfbd252b..7ba982ae22ea 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -12622,9 +12622,9 @@ int RGWRados::list_gc_objs(int *index, string& marker, uint32_t max, bool expire return gc->list(index, marker, max, expired_only, result, truncated); } -int RGWRados::process_gc() +int RGWRados::process_gc(bool expired_only) { - return gc->process(); + return gc->process(expired_only); } int RGWRados::list_lc_progress(const string& marker, uint32_t max_entries, map *progress_map) diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 73f9efabb7ff..433f4659ccf9 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -3508,7 +3508,7 @@ public: int gc_operate(string& oid, librados::ObjectReadOperation *op, bufferlist *pbl); int list_gc_objs(int *index, string& marker, uint32_t max, bool expired_only, std::list& result, bool *truncated); - int process_gc(); + int process_gc(bool expired_only); int process_expire_objects(); int defer_gc(void *ctx, const RGWBucketInfo& bucket_info, const rgw_obj& obj); diff --git a/src/test/cli/radosgw-admin/help.t b/src/test/cli/radosgw-admin/help.t index 3f65f9c61083..b44d0b308cd4 100644 --- a/src/test/cli/radosgw-admin/help.t +++ b/src/test/cli/radosgw-admin/help.t @@ -108,7 +108,8 @@ usage trim trim usage (by user, date range) gc list dump expired garbage collection objects (specify --include-all to list all entries, including unexpired) - gc process manually process garbage + gc process manually process garbage (specify + --include-all to process all entries, including unexpired) lc list list all bucket lifecycle progress lc process manually process lifecycle metadata get get metadata info