From: Matt Benjamin Date: Tue, 19 Feb 2019 18:29:03 +0000 (-0500) Subject: rgw: lifecycle: alternate solution to prefix_map conflict X-Git-Tag: v15.1.0~2658^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b05a9e117c24a91ac1d01e0870c3bcd0da7100f7;p=ceph.git rgw: lifecycle: alternate solution to prefix_map conflict A rule containing a tag filter but no constraining prefix is legal, as is a sequence of >1 such rules. As currently designed, enforcement requires rules to be installed in prefix_map as well as rule_map, though only the latter is encoded. Fixes: http://tracker.ceph.com/issues/37879 Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index bea92b2b18bd2..36c75a4c06812 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -127,8 +127,8 @@ bool RGWLifecycleConfiguration::_add_rule(const LCRule& rule) if (rule.get_filter().has_tags()){ op.obj_tags = rule.get_filter().get_tags(); } - auto ret = prefix_map.emplace(std::move(prefix), std::move(op)); - return ret.second; + prefix_map.emplace(std::move(prefix), std::move(op)); + return true; } int RGWLifecycleConfiguration::check_and_add_rule(const LCRule& rule) @@ -334,7 +334,8 @@ static bool obj_has_expired(CephContext *cct, ceph::real_time mtime, int days, c return (timediff >= cmp); } -int RGWLC::handle_multipart_expiration(RGWRados::Bucket *target, const map& prefix_map) +int RGWLC::handle_multipart_expiration( + RGWRados::Bucket *target, const multimap& prefix_map) { MultipartMetaFilter mp_filter; vector objs; @@ -983,7 +984,12 @@ int RGWLC::bucket_lc_process(string& shard_id) return -1; } - map& prefix_map = config.get_prefix_map(); + multimap& prefix_map = config.get_prefix_map(); + + ldpp_dout(this, 10) << __func__ << "() prefix_map size=" + << prefix_map.size() + << dendl; + rgw_obj_key pre_marker; rgw_obj_key next_marker; for(auto prefix_iter = prefix_map.begin(); prefix_iter != prefix_map.end(); ++prefix_iter) { diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index 3566f7c1ce968..4097ffcfdfae1 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -391,7 +391,7 @@ class RGWLifecycleConfiguration { protected: CephContext *cct; - map prefix_map; + multimap prefix_map; multimap rule_map; bool _add_rule(const LCRule& rule); bool has_same_action(const lc_op& first, const lc_op& second); @@ -432,7 +432,7 @@ public: bool valid(); multimap& get_rule_map() { return rule_map; } - map& get_prefix_map() { return prefix_map; } + multimap& get_prefix_map() { return prefix_map; } /* void create_default(string id, string name) { ACLGrant grant; @@ -499,7 +499,8 @@ class RGWLC : public DoutPrefixProvider { private: - int handle_multipart_expiration(RGWRados::Bucket *target, const map& prefix_map); + int handle_multipart_expiration(RGWRados::Bucket *target, + const multimap& prefix_map); }; namespace rgw::lc {