From 759262cf1592cb7df3806e6964a80d75bead004a Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Fri, 10 Apr 2020 10:47:46 -0400 Subject: [PATCH] rgwlc: give radosgw-admin lc process more freedom to run Makes two primary changes: 1. allows the admin lc process to re-run a bucket (but not when a session is ACTIVE, to avoid overwriting session state) 2. to avoid confusion when rgw_lc_debug_interval is set and is small, don't force lc process to exit early, allowing one run to clear all expired objects during debug and test Signed-off-by: Matt Benjamin --- src/rgw/rgw_lc.cc | 19 ++++++++++--------- src/rgw/rgw_lc.h | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 77a898311740a..96f6c4bca977c 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -781,14 +781,14 @@ RGWLC::LCWorker::LCWorker(const DoutPrefixProvider* dpp, CephContext *cct, workpool = new WorkPool(this, wpw, 512); } -static inline bool worker_should_stop(time_t stop_at) +static inline bool worker_should_stop(time_t stop_at, bool once) { - return stop_at < time(nullptr); + return !once && stop_at < time(nullptr); } int RGWLC::handle_multipart_expiration( RGWRados::Bucket *target, const multimap& prefix_map, - LCWorker* worker, time_t stop_at) + LCWorker* worker, time_t stop_at, bool once) { MultipartMetaFilter mp_filter; vector objs; @@ -837,7 +837,7 @@ int RGWLC::handle_multipart_expiration( for (auto prefix_iter = prefix_map.begin(); prefix_iter != prefix_map.end(); ++prefix_iter) { - if (worker_should_stop(stop_at)) { + if (worker_should_stop(stop_at, once)) { ldout(cct, 5) << __func__ << " interval budget EXPIRED worker " << worker->ix << dendl; @@ -1334,7 +1334,7 @@ int LCOpRule::process(rgw_bucket_dir_entry& o, } int RGWLC::bucket_lc_process(string& shard_id, LCWorker* worker, - time_t stop_at) + time_t stop_at, bool once) { RGWLifecycleConfiguration config(cct); RGWBucketInfo bucket_info; @@ -1412,7 +1412,7 @@ int RGWLC::bucket_lc_process(string& shard_id, LCWorker* worker, for(auto prefix_iter = prefix_map.begin(); prefix_iter != prefix_map.end(); ++prefix_iter) { - if (worker_should_stop(stop_at)) { + if (worker_should_stop(stop_at, once)) { ldout(cct, 5) << __func__ << " interval budget EXPIRED worker " << worker->ix << dendl; @@ -1455,7 +1455,7 @@ int RGWLC::bucket_lc_process(string& shard_id, LCWorker* worker, worker->workpool->drain(); } - ret = handle_multipart_expiration(&target, prefix_map, worker, stop_at); + ret = handle_multipart_expiration(&target, prefix_map, worker, stop_at, once); return ret; } @@ -1648,7 +1648,8 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker, } } - if(!if_already_run_today(head.start_date)) { + if(!if_already_run_today(head.start_date) || + once) { head.start_date = now; head.marker.clear(); ret = bucket_lc_prepare(index, worker); @@ -1701,7 +1702,7 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker, << dendl; l.unlock(&store->getRados()->lc_pool_ctx, obj_names[index]); - ret = bucket_lc_process(entry.bucket, worker, thread_stop_at()); + ret = bucket_lc_process(entry.bucket, worker, thread_stop_at(), once); bucket_lc_post(index, max_lock_secs, entry, ret, worker); } while(1 && !once); diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index 9aa64f65b07f1..8cfc1d78f03b3 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -508,7 +508,8 @@ public: int list_lc_progress(const string& marker, uint32_t max_entries, vector&); int bucket_lc_prepare(int index, LCWorker* worker); - int bucket_lc_process(string& shard_id, LCWorker* worker, time_t stop_at); + int bucket_lc_process(string& shard_id, LCWorker* worker, time_t stop_at, + bool once); int bucket_lc_post(int index, int max_lock_sec, cls_rgw_lc_entry& entry, int& result, LCWorker* worker); bool going_down(); @@ -528,8 +529,7 @@ public: int handle_multipart_expiration(RGWRados::Bucket *target, const multimap& prefix_map, - LCWorker* worker, - time_t stop_at); + LCWorker* worker, time_t stop_at, bool once); }; namespace rgw::lc { -- 2.39.5