]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add data_extra pool to bucket
authorYehuda Sadeh <yehuda@inktank.com>
Tue, 11 Mar 2014 19:01:31 +0000 (12:01 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Mon, 24 Mar 2014 21:58:05 +0000 (14:58 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/cls/user/cls_user_types.cc
src/cls/user/cls_user_types.h
src/rgw/rgw_common.h
src/rgw/rgw_json_enc.cc

index 1ccd19bd27cca808dc64f25dedd62d3ed81b81a1..b3a00f0243542f5878420b0b001b2d6b17dad3fe 100644 (file)
@@ -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);
index fce25c37fd2a73818d5c2dcf62415cf570cd90a7..5abb488ca0dd96237f7cbdab35a7d2604fb38293 100644 (file)
@@ -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);
   }
 
index 1be05870fa5b6e8ebcaafba485e97f631980c204..77a67155e6cbd183c223bae0fa93995ce41c92a3 100644 (file)
@@ -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<rgw_bucket*>& 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;
index 81ec599fc9708a97b8e878f249c31985e74726bc..044414a6df59f0cb406f5dd905b5440ba4a252ed 100644 (file)
@@ -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);