From: Yehuda Sadeh Date: Fri, 4 Jan 2019 01:36:54 +0000 (-0800) Subject: rgw: lifecycle: do filter checks later X-Git-Tag: v14.1.0~314^2~24 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0e226a27bffc3290d08a6ada7007f3cfa46adbe7;p=ceph.git rgw: lifecycle: do filter checks later 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 --- diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 3bbd519f8504..5e4f325b52f0 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -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 *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;