]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: track bucket instance oid
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 26 Jul 2013 23:40:34 +0000 (16:40 -0700)
committerGreg Farnum <greg@inktank.com>
Mon, 29 Jul 2013 22:06:56 +0000 (15:06 -0700)
We now keep the bucket instance oid in rgw_bucket. The reason
we need it is that the bucket might have been created before
the entrypoint / bucket instance separation.

Fixes: #5790
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/rgw/rgw_common.h
src/rgw/rgw_rados.cc

index 543bdf213774875ca63d80c28aacdf8efce740a1..8e4126de271884d52816167e8fe8a9e409781167 100644 (file)
@@ -542,6 +542,10 @@ struct rgw_bucket {
   std::string marker;
   std::string bucket_id;
 
+  std::string oid; /*
+                    * runtime in-memory only info. If not empty, points to the bucket instance object
+                    */
+
   rgw_bucket() { }
   rgw_bucket(const char *n) : name(n) {
     assert(*n == '.'); // only rgw private buckets should be initialized without pool
index 22c93f33ad58d579a7cddbdd5013f26b6dd3227b..9e8f563741519b51876f3de3a3cbb50c5c4600a8 100644 (file)
@@ -4548,9 +4548,13 @@ void RGWRados::get_bucket_meta_oid(rgw_bucket& bucket, string& oid)
 
 void RGWRados::get_bucket_instance_obj(rgw_bucket& bucket, rgw_obj& obj)
 {
-  string oid;
-  get_bucket_meta_oid(bucket, oid);
-  obj.init(zone.domain_root, oid);
+  if (!bucket.oid.empty()) {
+    obj.init(zone.domain_root, bucket.oid);
+  } else {
+    string oid;
+    get_bucket_meta_oid(bucket, oid);
+    obj.init(zone.domain_root, oid);
+  }
 }
 
 int RGWRados::get_bucket_instance_info(void *ctx, const string& meta_key, RGWBucketInfo& info,
@@ -4569,7 +4573,11 @@ int RGWRados::get_bucket_instance_info(void *ctx, rgw_bucket& bucket, RGWBucketI
                                        time_t *pmtime, map<string, bufferlist> *pattrs)
 {
   string oid;
-  get_bucket_meta_oid(bucket, oid);
+  if (!bucket.oid.empty()) {
+    get_bucket_meta_oid(bucket, oid);
+  } else {
+    oid = bucket.oid;
+  }
 
   return get_bucket_instance_from_oid(ctx, oid, info, pmtime, pattrs);
 }
@@ -4593,6 +4601,7 @@ int RGWRados::get_bucket_instance_from_oid(void *ctx, string& oid, RGWBucketInfo
     ldout(cct, 0) << "ERROR: could not decode buffer info, caught buffer::error" << dendl;
     return -EIO;
   }
+  info.bucket.oid = oid;
   return 0;
 }
 
@@ -4635,6 +4644,7 @@ int RGWRados::get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& inf
 
   if (entry_point.has_bucket_info) {
     info = entry_point.old_bucket_info;
+    info.bucket.oid = bucket_name;
     info.ep_objv = ot.read_version;
     ldout(cct, 20) << "rgw_get_bucket_info: old bucket info, bucket=" << info.bucket << " owner " << info.owner << dendl;
     return 0;