diff options
author | Zhang Shaowen <zhangshaowen@cmss.chinamobile.com> | 2017-02-06 06:45:24 +0100 |
---|---|---|
committer | Zhang Shaowen <zhangshaowen@cmss.chinamobile.com> | 2017-02-17 05:43:55 +0100 |
commit | 2c3a7698bef836af9781c163cf2e1a235aa08648 (patch) | |
tree | 03e6c8ab77aa9052465de1b92164544dda221b95 /src/rgw/rgw_lc.h | |
parent | Merge pull request #13367 from tchaikov/wip-qa-jewel-x-singleton (diff) | |
download | ceph-2c3a7698bef836af9781c163cf2e1a235aa08648.tar.xz ceph-2c3a7698bef836af9781c163cf2e1a235aa08648.zip |
rgw: add support for noncurrentversion expiration in s3 lifecycle.
Fixes: http://tracker.ceph.com/issues/18916
Signed-off-by: Zhang Shaowen <zhangshaowen@cmss.chinamobile.com>
Diffstat (limited to 'src/rgw/rgw_lc.h')
-rw-r--r-- | src/rgw/rgw_lc.h | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index 5436abcdf1a..ac79f7f3237 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -55,6 +55,9 @@ public: // static void generate_test_instances(list<ACLOwner*>& o); void set_days(const string& _days) { days = _days; } int get_days() {return atoi(days.c_str()); } + bool empty() const{ + return days.empty(); + } }; WRITE_CLASS_ENCODER(LCExpiration) @@ -65,6 +68,7 @@ protected: string prefix; string status; LCExpiration expiration; + LCExpiration noncur_expiration; public: @@ -88,6 +92,10 @@ public: return expiration; } + LCExpiration& get_noncur_expiration() { + return noncur_expiration; + } + void set_id(string*_id) { id = *_id; } @@ -104,35 +112,53 @@ public: expiration = *_expiration; } + void set_noncur_expiration(LCExpiration*_noncur_expiration) { + noncur_expiration = *_noncur_expiration; + } + bool validate(); void encode(bufferlist& bl) const { - ENCODE_START(1, 1, bl); + ENCODE_START(2, 1, bl); ::encode(id, bl); ::encode(prefix, bl); ::encode(status, bl); ::encode(expiration, bl); + ::encode(noncur_expiration, bl); ENCODE_FINISH(bl); } void decode(bufferlist::iterator& bl) { - DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl); + DECODE_START_LEGACY_COMPAT_LEN(2, 1, 1, bl); ::decode(id, bl); ::decode(prefix, bl); ::decode(status, bl); ::decode(expiration, bl); + if (struct_v >=2) { + ::decode(noncur_expiration, bl); + } DECODE_FINISH(bl); } }; WRITE_CLASS_ENCODER(LCRule) +struct lc_op +{ + bool status; + int expiration; + int noncur_expiration; + + lc_op() : status(false), expiration(0), noncur_expiration(0) {} + +}; + class RGWLifecycleConfiguration { protected: CephContext *cct; - map<string, int> prefix_map; + map<string, lc_op> prefix_map; multimap<string, LCRule> rule_map; - void _add_rule(LCRule *rule); + bool _add_rule(LCRule *rule); public: RGWLifecycleConfiguration(CephContext *_cct) : cct(_cct) {} RGWLifecycleConfiguration() : cct(NULL) {} @@ -170,7 +196,7 @@ public: bool validate(); multimap<string, LCRule>& get_rule_map() { return rule_map; } - map<string, int>& get_prefix_map() { return prefix_map; } + map<string, lc_op>& get_prefix_map() { return prefix_map; } /* void create_default(string id, string name) { ACLGrant grant; @@ -227,6 +253,7 @@ class RGWLC { void stop_processor(); private: + int remove_expired_obj(RGWBucketInfo& bucket_info, rgw_obj_key obj_key, bool remove_indeed = true); bool obj_has_expired(double timediff, int days); }; |