]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: api adjustments following a merge
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 22 Jan 2015 23:26:01 +0000 (15:26 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 22 Jan 2015 23:26:01 +0000 (15:26 -0800)
Merged bucket sharding and object versioning.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/cls/rgw/cls_rgw_client.cc
src/cls/rgw/cls_rgw_client.h
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 38c459517b059a5056a008e2573a00837e0ea283..0556006d1c9fe4d3c016dbfdda07fb49137a7979 100644 (file)
@@ -178,7 +178,7 @@ void cls_rgw_bucket_complete_op(ObjectWriteOperation& o, RGWModifyOp op, string&
 }
 
 static bool issue_bucket_list_op(librados::IoCtx& io_ctx,
-    const string& oid, const string& start_obj, const string& filter_prefix,
+    const string& oid, const cls_rgw_obj_key& start_obj, const string& filter_prefix,
     uint32_t num_entries, bool list_versions, BucketIndexAioManager *manager,
     struct rgw_cls_list_ret *pdata) {
   bufferlist in;
@@ -196,7 +196,7 @@ static bool issue_bucket_list_op(librados::IoCtx& io_ctx,
 
 int CLSRGWIssueBucketList::issue_op(int shard_id, const string& oid)
 {
-  return issue_bucket_list_op(io_ctx, oid, start_obj, filter_prefix, num_entries, &manager, &result[shard_id]);
+  return issue_bucket_list_op(io_ctx, oid, start_obj, filter_prefix, num_entries, list_versions, &manager, &result[shard_id]);
 }
 
 void cls_rgw_remove_obj(librados::ObjectWriteOperation& o, list<string>& keep_attr_prefixes)
@@ -469,7 +469,8 @@ void cls_rgw_suggest_changes(ObjectWriteOperation& o, bufferlist& updates)
 
 int CLSRGWIssueGetDirHeader::issue_op(int shard_id, const string& oid)
 {
-  return issue_bucket_list_op(io_ctx, oid, "", "", 0, &manager, &result[shard_id]);
+  cls_rgw_obj_key nokey;
+  return issue_bucket_list_op(io_ctx, oid, nokey, "", 0, false, &manager, &result[shard_id]);
 }
 
 class GetDirHeaderCompletion : public ObjectOperationCompletion {
index 3ba23d1f2d1e4e8733721693784267eb5897c7d9..b8f8d8698bf459cae73beb4d36b3b49d2761a4ff 100644 (file)
@@ -354,7 +354,7 @@ int cls_rgw_clear_olh(librados::IoCtx& io_ctx, string& oid, const cls_rgw_obj_ke
 */
 
 class CLSRGWIssueBucketList : public CLSRGWConcurrentIO {
-  string start_obj;
+  cls_rgw_obj_key start_obj;
   string filter_prefix;
   uint32_t num_entries;
   bool list_versions;
@@ -362,7 +362,7 @@ class CLSRGWIssueBucketList : public CLSRGWConcurrentIO {
 protected:
   int issue_op(int shard_id, const string& oid);
 public:
-  CLSRGWIssueBucketList(librados::IoCtx& io_ctx, const string& _start_obj,
+  CLSRGWIssueBucketList(librados::IoCtx& io_ctx, const cls_rgw_obj_key& _start_obj,
                         const string& _filter_prefix, uint32_t _num_entries,
                         bool _list_versions,
                         map<int, string>& oids,
index 0b1e7b44db21f0f6236580d6e12647a761458efa..fd4024ebd957bab7ca6b8eb026d1a5014d318911 100644 (file)
@@ -2726,7 +2726,7 @@ void RGWInitMultipart::execute()
     obj.init_ns(s->bucket, tmp_obj_name, mp_ns);
     // the meta object will be indexed with 0 size, we c
     obj.set_in_extra_data(true);
-    obj.index_hash_source = s->object_str;
+    obj.index_hash_source = s->object.name;
 
     RGWRados::Object op_target(store, s->bucket_info, *(RGWObjectCtx *)s->obj_ctx, obj);
     op_target.set_versioning_disabled(true); /* no versioning for multipart meta */
@@ -2954,7 +2954,7 @@ void RGWCompleteMultipart::execute()
 
   meta_obj.init_ns(s->bucket, meta_oid, mp_ns);
   meta_obj.set_in_extra_data(true);
-  meta_obj.index_hash_source = s->object_str;
+  meta_obj.index_hash_source = s->object.name;
 
   ret = get_obj_attrs(store, s, meta_obj, attrs);
   if (ret < 0) {
@@ -3118,7 +3118,7 @@ void RGWAbortMultipart::execute()
         string oid = mp.get_part(obj_iter->second.num);
         rgw_obj obj;
         obj.init_ns(s->bucket, oid, mp_ns);
-        obj.index_hash_source = s->object_str;
+        obj.index_hash_source = s->object.name;
         ret = store->delete_obj(*obj_ctx, s->bucket_info, obj, 0);
         if (ret < 0 && ret != -ENOENT)
           return;
@@ -3127,7 +3127,7 @@ void RGWAbortMultipart::execute()
         RGWObjManifest::obj_iterator oiter;
         for (oiter = manifest.obj_begin(); oiter != manifest.obj_end(); ++oiter) {
           rgw_obj loc = oiter.get_location();
-          loc.index_hash_source = s->object_str;
+          loc.index_hash_source = s->object.name;
           ret = store->delete_obj(*obj_ctx, s->bucket_info, loc, 0);
           if (ret < 0 && ret != -ENOENT)
             return;
@@ -3139,7 +3139,7 @@ void RGWAbortMultipart::execute()
   // and also remove the metadata obj
   meta_obj.init_ns(s->bucket, meta_oid, mp_ns);
   meta_obj.set_in_extra_data(true);
-  meta_obj.index_hash_source = s->object_str;
+  meta_obj.index_hash_source = s->object.name;
   ret = store->delete_obj(*obj_ctx, s->bucket_info, meta_obj, 0);
   if (ret == -ENOENT) {
     ret = -ERR_NO_SUCH_BUCKET;
index b12a2b3ed975f34f90367ffca3db2468e2803d9d..2d80a059610aa149e11ad010ff39c57046d956cb 100644 (file)
@@ -3977,9 +3977,11 @@ int RGWRados::open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx,
   if (ret < 0)
     return ret;
 
+  RGWObjectCtx obj_ctx(this);
+
   // Get the bucket info
   RGWBucketInfo binfo;
-  ret = get_bucket_instance_info(NULL, bucket, binfo, NULL, NULL);
+  ret = get_bucket_instance_info(obj_ctx, bucket, binfo, NULL, NULL);
   if (ret < 0)
     return ret;
 
@@ -4014,9 +4016,11 @@ int RGWRados::open_bucket_index_shard(rgw_bucket& bucket, librados::IoCtx& index
   if (ret < 0)
     return ret;
 
+  RGWObjectCtx obj_ctx(this);
+
   // Get the bucket info
   RGWBucketInfo binfo;
-  ret = get_bucket_instance_info(NULL, bucket, binfo, NULL, NULL);
+  ret = get_bucket_instance_info(obj_ctx, bucket, binfo, NULL, NULL);
   if (ret < 0)
     return ret;
 
@@ -4941,10 +4945,10 @@ int RGWRados::SystemObject::Read::stat(RGWObjVersionTracker *objv_tracker)
 
 int RGWRados::Bucket::UpdateIndex::prepare(RGWModifyOp op)
 {
-  rgw_bucket& bucket = target->get_bucket();
   RGWRados *store = target->get_store();
   BucketShard *bs;
-  int ret = target->get_bucket_shard(&bs);
+  int ret = get_bucket_shard(&bs);
+  if (ret < 0) {
     ldout(store->ctx(), 5) << "failed to get BucketShard object: ret=" << ret << dendl;
     return ret;
   }
@@ -4962,7 +4966,7 @@ int RGWRados::Bucket::UpdateIndex::prepare(RGWModifyOp op)
       append_rand_alpha(store->ctx(), optag, optag, 32);
     }
   }
-  ret = store->cls_obj_prepare_op(*bs, bucket, op, optag, obj, bilog_flags);
+  ret = store->cls_obj_prepare_op(*bs, op, optag, obj, bilog_flags);
 
   return ret;
 }
@@ -4972,9 +4976,9 @@ int RGWRados::Bucket::UpdateIndex::complete(int64_t poolid, uint64_t epoch, uint
                                     list<rgw_obj_key> *remove_objs)
 {
   RGWRados *store = target->get_store();
-  rgw_bucket& bucket = target->get_bucket();
   BucketShard *bs;
-  int ret = target->get_bucket_shard(&bs);
+  int ret = get_bucket_shard(&bs);
+  if (ret < 0) {
     ldout(store->ctx(), 5) << "failed to get BucketShard object: ret=" << ret << dendl;
     return ret;
   }
@@ -4995,7 +4999,7 @@ int RGWRados::Bucket::UpdateIndex::complete(int64_t poolid, uint64_t epoch, uint
   ent.owner_display_name = owner.get_display_name();
   ent.content_type = content_type;
 
-  int ret = store->cls_obj_complete_add(*bs, optag, poolid, epoch, ent, category, remove_objs, bilog_flags);
+  ret = store->cls_obj_complete_add(*bs, optag, poolid, epoch, ent, category, remove_objs, bilog_flags);
 
   return ret;
 }
@@ -5004,7 +5008,8 @@ int RGWRados::Bucket::UpdateIndex::complete_del(int64_t poolid, uint64_t epoch)
 {
   RGWRados *store = target->get_store();
   BucketShard *bs;
-  int ret = target->get_bucket_shard(&bs);
+  int ret = get_bucket_shard(&bs);
+  if (ret < 0) {
     ldout(store->ctx(), 5) << "failed to get BucketShard object: ret=" << ret << dendl;
     return ret;
   }
@@ -5015,7 +5020,13 @@ int RGWRados::Bucket::UpdateIndex::complete_del(int64_t poolid, uint64_t epoch)
 int RGWRados::Bucket::UpdateIndex::cancel()
 {
   RGWRados *store = target->get_store();
-  return store->cls_obj_complete_cancel(target->get_bucket(), optag, obj, bilog_flags);
+  BucketShard *bs;
+  int ret = get_bucket_shard(&bs);
+  if (ret < 0) {
+    ldout(store->ctx(), 5) << "failed to get BucketShard object: ret=" << ret << dendl;
+    return ret;
+  }
+  return store->cls_obj_complete_cancel(*bs, optag, obj, bilog_flags);
 }
 
 int RGWRados::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl)
@@ -6514,7 +6525,9 @@ public:
 int RGWRados::get_bucket_stats_async(rgw_bucket& bucket, RGWGetBucketStats_CB *ctx)
 {
   RGWBucketInfo binfo;
-  int r = get_bucket_instance_info(NULL, bucket, binfo, NULL, NULL);
+  RGWObjectCtx obj_ctx(this);
+
+  int r = get_bucket_instance_info(obj_ctx, bucket, binfo, NULL, NULL);
   if (r < 0)
     return r;
 
@@ -7313,7 +7326,7 @@ int RGWRados::cls_obj_prepare_op(BucketShard& bs, RGWModifyOp op, string& tag,
   ObjectWriteOperation o;
   cls_rgw_obj_key key(obj.get_index_key_name(), obj.get_instance());
   cls_rgw_bucket_prepare_op(o, op, tag, key, obj.get_loc(), zone_public_config.log_data, bilog_flags);
-  r = bs.index_ctx.operate(bs.bucket_obj, &o);
+  int r = bs.index_ctx.operate(bs.bucket_obj, &o);
   return r;
 }
 
@@ -7434,7 +7447,7 @@ int RGWRados::cls_bucket_list(rgw_bucket& bucket, rgw_obj_key& start, const stri
   map<string, size_t> candidates;
   for (size_t i = 0; i < vcurrents.size(); ++i) {
     if (vcurrents[i] != vends[i]) {
-      candidates[vcurrents[i]->second.name] = i;
+      candidates[vcurrents[i]->first] = i;
     }
   }
 
@@ -7443,6 +7456,7 @@ int RGWRados::cls_bucket_list(rgw_bucket& bucket, rgw_obj_key& start, const stri
   while (count < num_entries && !candidates.empty()) {
     // Select the next one
     int pos = candidates.begin()->second;
+    const string& name = vcurrents[pos]->first;
     struct rgw_bucket_dir_entry& dirent = vcurrents[pos]->second;
 
     // fill it in with initial values; we may correct later
@@ -7470,7 +7484,7 @@ int RGWRados::cls_bucket_list(rgw_bucket& bucket, rgw_obj_key& start, const stri
       }
     }
     if (r >= 0) {
-      m[e.name] = e;
+      m[name] = e;
       ldout(cct, 10) << "RGWRados::cls_bucket_list: got " << e.key.name << "[" << e.key.instance << "]" << dendl;
       ++count;
     }
@@ -7479,7 +7493,7 @@ int RGWRados::cls_bucket_list(rgw_bucket& bucket, rgw_obj_key& start, const stri
     candidates.erase(candidates.begin());
     ++vcurrents[pos];
     if (vcurrents[pos] != vends[pos]) {
-      candidates[vcurrents[pos]->second.name] = pos;
+      candidates[vcurrents[pos]->first] = pos;
     }
   }
 
index aba5731f81ecc95230504e85e3be6bcae9e72895..08cbd32cab13011bb5b2dc113116f476d5d5ad0c 100644 (file)
@@ -1582,9 +1582,24 @@ public:
       rgw_obj obj;
       RGWObjState *obj_state;
       uint16_t bilog_flags;
+      BucketShard bs;
+      bool bs_initialized;
     public:
 
-      UpdateIndex(RGWRados::Bucket *_target, rgw_obj& _obj, RGWObjState *_state) : target(_target), obj(_obj), obj_state(_state), bilog_flags(0) {}
+      UpdateIndex(RGWRados::Bucket *_target, rgw_obj& _obj, RGWObjState *_state) : target(_target), obj(_obj), obj_state(_state), bilog_flags(0),
+                                                                                   bs(target->get_store()), bs_initialized(false) {}
+
+      int get_bucket_shard(BucketShard **pbs) {
+        if (!bs_initialized) {
+          int r = bs.init(target->get_bucket(), obj);
+          if (r < 0) {
+            return r;
+          }
+          bs_initialized = true;
+        }
+        *pbs = &bs;
+        return 0;
+      }
 
       void set_bilog_flags(uint16_t flags) {
         bilog_flags = flags;