From: Casey Bodley Date: Mon, 18 Feb 2019 22:15:15 +0000 (-0500) Subject: rgw: add 'datalog autotrim' admin command X-Git-Tag: v12.2.12~6^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=486af66a9f698fbe298fed66a0c3f006b3faeb06;p=ceph.git rgw: add 'datalog autotrim' admin command Signed-off-by: Casey Bodley (cherry picked from commit 832eaefa95c797870aa1a5fbdc885ca45a128c80) Conflicts: src/rgw/rgw_admin.cc: g_conf() -> g_conf, http.start() -> set_threaded() --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 13ce136ccd1..e6d25c9be18 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -453,6 +453,7 @@ enum { OPT_DATA_SYNC_RUN, OPT_DATALOG_LIST, OPT_DATALOG_STATUS, + OPT_DATALOG_AUTOTRIM, OPT_DATALOG_TRIM, OPT_OPSTATE_LIST, OPT_OPSTATE_SET, @@ -892,6 +893,8 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_ } else if (strcmp(prev_cmd, "datalog") == 0) { if (strcmp(cmd, "list") == 0) return OPT_DATALOG_LIST; + if (strcmp(cmd, "autotrim") == 0) + return OPT_DATALOG_AUTOTRIM; if (strcmp(cmd, "trim") == 0) return OPT_DATALOG_TRIM; if (strcmp(cmd, "status") == 0) @@ -7239,6 +7242,24 @@ next: formatter->flush(cout); } + if (opt_cmd == OPT_DATALOG_AUTOTRIM) { + RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry()); + RGWHTTPManager http(store->ctx(), crs.get_completion_mgr()); + int ret = http.set_threaded(); + if (ret < 0) { + cerr << "failed to initialize http client with " << cpp_strerror(ret) << std::endl; + return -ret; + } + + auto num_shards = g_conf->rgw_data_log_num_shards; + std::vector markers(num_shards); + ret = crs.run(create_admin_data_log_trim_cr(store, &http, num_shards, markers)); + if (ret < 0) { + cerr << "automated datalog trim failed with " << cpp_strerror(ret) << std::endl; + return -ret; + } + } + if (opt_cmd == OPT_DATALOG_TRIM) { utime_t start_time, end_time; diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index 088f3aa8dcc..f487c6b70a1 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -3439,6 +3439,14 @@ int DataLogTrimCR::operate() return 0; } +RGWCoroutine* create_admin_data_log_trim_cr(RGWRados *store, + RGWHTTPManager *http, + int num_shards, + std::vector& markers) +{ + return new DataLogTrimCR(store, http, num_shards, markers); +} + class DataLogTrimPollCR : public RGWCoroutine { RGWRados *store; RGWHTTPManager *http; diff --git a/src/rgw/rgw_data_sync.h b/src/rgw/rgw_data_sync.h index 257781316d7..05822d604ad 100644 --- a/src/rgw/rgw_data_sync.h +++ b/src/rgw/rgw_data_sync.h @@ -566,4 +566,10 @@ extern RGWCoroutine* create_data_log_trim_cr(RGWRados *store, RGWHTTPManager *http, int num_shards, utime_t interval); +// factory function for datalog trim via radosgw-admin +RGWCoroutine* create_admin_data_log_trim_cr(RGWRados *store, + RGWHTTPManager *http, + int num_shards, + std::vector& markers); + #endif