]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: metadata put of bucket instance sets bucket_id
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 20 Dec 2016 21:32:57 +0000 (13:32 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 9 Mar 2017 17:18:55 +0000 (09:18 -0800)
Need to parse the bucket id off the entry and then set it on the
bucket struct.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_bucket.cc
src/rgw/rgw_metadata.h

index da55fbfd6a87bdee5bf0237e4a8985a92e308b2c..8b2bc5f46df164cf37b578915a2b49891091dd22 100644 (file)
@@ -1922,7 +1922,7 @@ public:
     RGWObjectCtx obj_ctx(store);
 
     string tenant_name, bucket_name;
-    parse_bucket(entry, tenant_name, bucket_name);
+    parse_bucket(entry, &tenant_name, &bucket_name);
     int ret = store->get_bucket_entrypoint_info(obj_ctx, tenant_name, bucket_name, be, &ot, &mtime, &attrs);
     if (ret < 0)
       return ret;
@@ -1950,7 +1950,7 @@ public:
     RGWObjectCtx obj_ctx(store);
 
     string tenant_name, bucket_name;
-    parse_bucket(entry, tenant_name, bucket_name);
+    parse_bucket(entry, &tenant_name, &bucket_name);
     int ret = store->get_bucket_entrypoint_info(obj_ctx, tenant_name, bucket_name, old_be, &old_ot, &orig_mtime, &attrs);
     if (ret < 0 && ret != -ENOENT)
       return ret;
@@ -1988,7 +1988,7 @@ public:
     RGWObjectCtx obj_ctx(store);
 
     string tenant_name, bucket_name;
-    parse_bucket(entry, tenant_name, bucket_name);
+    parse_bucket(entry, &tenant_name, &bucket_name);
     int ret = store->get_bucket_entrypoint_info(obj_ctx, tenant_name, bucket_name, be, &objv_tracker, NULL, NULL);
     if (ret < 0)
       return ret;
@@ -2113,10 +2113,12 @@ public:
       rgw_bucket_instance_oid_to_key(key);
       string tenant_name;
       string bucket_name;
-      parse_bucket(key, tenant_name, bucket_name);
+      string bucket_instance;
+      parse_bucket(key, &tenant_name, &bucket_name, &bucket_instance);
 
       RGWZonePlacementInfo rule_info;
       bci.info.bucket.name = bucket_name;
+      bci.info.bucket.bucket_id = bucket_instance;
       bci.info.bucket.tenant = tenant_name;
       ret = store->select_bucket_location_by_rule(bci.info.placement_rule, bci.info.bucket, &rule_info);
       if (ret < 0) {
index d150e6cd36e53af0a2aba7b63a18a416d193e6e2..cd1150e6e66230b9aeb8cfe40b39be4b1b3819c2 100644 (file)
@@ -117,16 +117,27 @@ protected:
   /*
    * The tenant_name is always returned on purpose. May be empty, of course.
    */
-  static void parse_bucket(const string &bucket,
-                           string &tenant_name, string &bucket_name)
+  static void parse_bucket(const string& bucket,
+                           string *tenant_name,
+                           string *bucket_name,
+                           string *bucket_instance = nullptr /* optional */)
   {
     int pos = bucket.find('/');
     if (pos >= 0) {
-      tenant_name = bucket.substr(0, pos);
+      *tenant_name = bucket.substr(0, pos);
     } else {
-      tenant_name.clear();
+      tenant_name->clear();
+    }
+    string bn = bucket.substr(pos + 1);
+    pos = bn.find (':');
+    if (pos < 0) {
+      *bucket_name = std::move(bn);
+      return;
+    }
+    *bucket_name = bn.substr(0, pos);
+    if (bucket_instance) {
+      *bucket_instance = bn.substr(pos + 1);
     }
-    bucket_name = bucket.substr(pos + 1);
   }
 };