]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgwlc: give radosgw-admin lc process more freedom to run
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 10 Apr 2020 14:47:46 +0000 (10:47 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Tue, 21 Apr 2020 17:40:32 +0000 (13:40 -0400)
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 <mbenjamin@redhat.com>
src/rgw/rgw_lc.cc
src/rgw/rgw_lc.h

index 77a898311740a72a94131405abf245fbd755b95d..96f6c4bca977c1050e131532d706de9b8c330aa2 100644 (file)
@@ -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<string, lc_op>& prefix_map,
-  LCWorker* worker, time_t stop_at)
+  LCWorker* worker, time_t stop_at, bool once)
 {
   MultipartMetaFilter mp_filter;
   vector<rgw_bucket_dir_entry> 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);
 
index 9aa64f65b07f101f47d52863711946e3f97fa4a4..8cfc1d78f03b383b4ee4364157baa2e169aa4cd0 100644 (file)
@@ -508,7 +508,8 @@ public:
   int list_lc_progress(const string& marker, uint32_t max_entries,
                       vector<cls_rgw_lc_entry>&);
   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<string, lc_op>& prefix_map,
-                                 LCWorker* worker,
-                                 time_t stop_at);
+                                 LCWorker* worker, time_t stop_at, bool once);
 };
 
 namespace rgw::lc {