From 3677076bb4746c6d9f353c8a971035df7b855a0b Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 11 Mar 2014 12:01:31 -0700 Subject: [PATCH] rgw: add data_extra pool to bucket Signed-off-by: Yehuda Sadeh --- src/cls/user/cls_user_types.cc | 1 + src/cls/user/cls_user_types.h | 9 ++++++-- src/rgw/rgw_common.h | 40 ++++++++++++++++++++++++---------- src/rgw/rgw_json_enc.cc | 2 ++ 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/cls/user/cls_user_types.cc b/src/cls/user/cls_user_types.cc index 1ccd19bd27c..b3a00f02435 100644 --- a/src/cls/user/cls_user_types.cc +++ b/src/cls/user/cls_user_types.cc @@ -21,6 +21,7 @@ void cls_user_bucket::dump(Formatter *f) const { encode_json("name", name, f); encode_json("data_pool", data_pool,f); + encode_json("data_extra_pool", data_extra_pool,f); encode_json("index_pool", index_pool,f); encode_json("marker", marker,f); encode_json("bucket_id", bucket_id,f); diff --git a/src/cls/user/cls_user_types.h b/src/cls/user/cls_user_types.h index fce25c37fd2..5abb488ca0d 100644 --- a/src/cls/user/cls_user_types.h +++ b/src/cls/user/cls_user_types.h @@ -17,18 +17,20 @@ struct cls_user_bucket { std::string index_pool; std::string marker; std::string bucket_id; + std::string data_extra_pool; void encode(bufferlist& bl) const { - ENCODE_START(6, 3, bl); + ENCODE_START(7, 3, bl); ::encode(name, bl); ::encode(data_pool, bl); ::encode(marker, bl); ::encode(bucket_id, bl); ::encode(index_pool, bl); + ::encode(data_extra_pool, bl); ENCODE_FINISH(bl); } void decode(bufferlist::iterator& bl) { - DECODE_START_LEGACY_COMPAT_LEN(6, 3, 3, bl); + DECODE_START_LEGACY_COMPAT_LEN(7, 3, 3, bl); ::decode(name, bl); ::decode(data_pool, bl); if (struct_v >= 2) { @@ -48,6 +50,9 @@ struct cls_user_bucket { } else { index_pool = data_pool; } + if (struct_v >= 7) { + ::decode(data_extra_pool, bl); + } DECODE_FINISH(bl); } diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 1be05870fa5..77a67155e6c 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -565,6 +565,7 @@ WRITE_CLASS_ENCODER(RGWUserInfo) struct rgw_bucket { std::string name; std::string data_pool; + std::string data_extra_pool; /* if not set, then we should use data_pool instead */ std::string index_pool; std::string marker; std::string bucket_id; @@ -577,6 +578,7 @@ struct rgw_bucket { rgw_bucket(const cls_user_bucket& b) { name = b.name; data_pool = b.data_pool; + data_extra_pool = b.data_extra_pool; index_pool = b.index_pool; marker = b.marker; bucket_id = b.bucket_id; @@ -592,30 +594,24 @@ struct rgw_bucket { void convert(cls_user_bucket *b) { b->name = name; b->data_pool = data_pool; + b->data_extra_pool = data_extra_pool; b->index_pool = index_pool; b->marker = marker; b->bucket_id = bucket_id; } - void clear() { - name = ""; - data_pool = ""; - index_pool = ""; - marker = ""; - bucket_id = ""; - } - void encode(bufferlist& bl) const { - ENCODE_START(6, 3, bl); + ENCODE_START(7, 3, bl); ::encode(name, bl); ::encode(data_pool, bl); ::encode(marker, bl); ::encode(bucket_id, bl); ::encode(index_pool, bl); + ::encode(data_extra_pool, bl); ENCODE_FINISH(bl); } void decode(bufferlist::iterator& bl) { - DECODE_START_LEGACY_COMPAT_LEN(6, 3, 3, bl); + DECODE_START_LEGACY_COMPAT_LEN(7, 3, 3, bl); ::decode(name, bl); ::decode(data_pool, bl); if (struct_v >= 2) { @@ -635,8 +631,19 @@ struct rgw_bucket { } else { index_pool = data_pool; } + if (struct_v >= 7) { + ::decode(data_extra_pool, bl); + } DECODE_FINISH(bl); } + + const string& get_data_extra_pool() { + if (data_extra_pool.empty()) { + return data_pool; + } + return data_extra_pool; + } + void dump(Formatter *f) const; void decode_json(JSONObj *obj); static void generate_test_instances(list& o); @@ -651,8 +658,19 @@ inline ostream& operator<<(ostream& out, const rgw_bucket &b) { out << b.name; if (b.name.compare(b.data_pool)) { out << "(@"; + string s; if (!b.index_pool.empty() && b.data_pool.compare(b.index_pool)) - out << "{i=" << b.index_pool << "}"; + s = "i=" + b.index_pool; + if (!b.data_extra_pool.empty() && b.data_pool.compare(b.data_extra_pool)) { + if (!s.empty()) { + s += ","; + } + s += "e=" + b.data_extra_pool; + } + if (!s.empty()) { + out << "{" << s << "}"; + } + out << b.data_pool << "[" << b.marker << "])"; } return out; diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index 81ec599fc97..044414a6df5 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -487,6 +487,7 @@ void rgw_bucket::dump(Formatter *f) const { encode_json("name", name, f); encode_json("pool", data_pool, f); + encode_json("data_extra_pool", data_extra_pool, f); encode_json("index_pool", index_pool, f); encode_json("marker", marker, f); encode_json("bucket_id", bucket_id, f); @@ -495,6 +496,7 @@ void rgw_bucket::dump(Formatter *f) const void rgw_bucket::decode_json(JSONObj *obj) { JSONDecoder::decode_json("name", name, obj); JSONDecoder::decode_json("pool", data_pool, obj); + JSONDecoder::decode_json("data_extra_pool", data_extra_pool, obj); JSONDecoder::decode_json("index_pool", index_pool, obj); JSONDecoder::decode_json("marker", marker, obj); JSONDecoder::decode_json("bucket_id", bucket_id, obj);