]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: lifecycle: do filter checks later
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 4 Jan 2019 01:36:54 +0000 (17:36 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 4 Jan 2019 03:00:24 +0000 (19:00 -0800)
Filter checks (currently only tags checks) need to access the objects
themselves, while the action checks don't. Make action checks happen first
to avoid unnecessary rados operations if objects don't pass action checks.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_lc.cc

index 3bbd519f85048986f80c02e62030513a299fe29a..5e4f325b52f01a985ecc5fffcdc14c928a58c918 100644 (file)
@@ -886,22 +886,8 @@ void LCOpRule::build()
 
 int LCOpRule::process(rgw_bucket_dir_entry& o)
 {
-  bool cont = false;
-
   lc_op_ctx ctx(env, o);
 
-  for (auto& f : filters) {
-    if (f->check(ctx)) {
-      cont = true;
-      break;
-    }
-  }
-
-  if (!cont) {
-    ldout(env.store->ctx(), 20) << __func__ << "(): key=" << o.key << ": no rule match, skipping" << dendl;
-    return 0;
-  }
-
   unique_ptr<LCOpAction> *selected = nullptr;
   real_time exp;
 
@@ -918,6 +904,29 @@ int LCOpRule::process(rgw_bucket_dir_entry& o)
 
   if (selected &&
       (*selected)->should_process()) {
+
+    /*
+     * Calling filter checks after action checks because
+     * all action checks (as they are implemented now) do
+     * not access the objects themselves, but return result
+     * from info from bucket index listing. The current tags filter
+     * check does access the objects, so we avoid unnecessary rados calls
+     * having filters check later in the process.
+     */
+
+    bool cont = false;
+    for (auto& f : filters) {
+      if (f->check(ctx)) {
+        cont = true;
+        break;
+      }
+    }
+
+    if (!cont) {
+      ldout(env.store->ctx(), 20) << __func__ << "(): key=" << o.key << ": no rule match, skipping" << dendl;
+      return 0;
+    }
+
     int r = (*selected)->process(ctx);
     if (r < 0) {
       ldout(ctx.cct, 0) << "ERROR: remove_expired_obj " << dendl;