Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw-admin: support for processing all gc objects including unexpired. #17482

Merged
merged 1 commit into from Dec 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/rgw/rgw_admin.cc
Expand Up @@ -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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yaozongyou need also to update the template at src/test/cli/radosgw-admin/help.t

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the help.t has been already updated, see the last file diffs.

cout << " lc list list all bucket lifecycle progress\n";
cout << " lc process manually process lifecycle\n";
cout << " metadata get get metadata info\n";
Expand Down Expand Up @@ -5927,7 +5928,7 @@ int main(int argc, const char **argv)
}

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;
Expand Down
10 changes: 5 additions & 5 deletions src/rgw/rgw_gc.cc
Expand Up @@ -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();
Expand Down Expand Up @@ -160,7 +160,7 @@ int RGWGC::process(int index, int max_secs)
do {
int max = 100;
std::list<cls_rgw_gc_obj_info> 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;
Expand Down Expand Up @@ -236,15 +236,15 @@ int RGWGC::process(int index, int max_secs)
return 0;
}

int RGWGC::process()
int RGWGC::process(bool expired_only)
{
int max_secs = cct->_conf->rgw_gc_processor_max_time;

const int start = ceph::util::generate_random_number(0, max_objs - 1);

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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/rgw/rgw_gc.h
Expand Up @@ -55,8 +55,8 @@ class RGWGC {

int list(int *index, string& marker, uint32_t max, bool expired_only, std::list<cls_rgw_gc_obj_info>& 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();
Expand Down
4 changes: 2 additions & 2 deletions src/rgw/rgw_rados.cc
Expand Up @@ -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<string, int> *progress_map)
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_rados.h
Expand Up @@ -3508,7 +3508,7 @@ class RGWRados
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<cls_rgw_gc_obj_info>& 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);

Expand Down
3 changes: 2 additions & 1 deletion src/test/cli/radosgw-admin/help.t
Expand Up @@ -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
Expand Down