]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
RGW - Fix DAOS and MOTR stores to not use rgw_obj_key::to_str() 49435/head
authorDaniel Gryniewicz <dang@redhat.com>
Wed, 14 Dec 2022 18:45:31 +0000 (13:45 -0500)
committerDaniel Gryniewicz <dang@redhat.com>
Wed, 14 Dec 2022 18:45:31 +0000 (13:45 -0500)
Signed-off-by: Daniel Gryniewicz <dang@redhat.com>
src/rgw/rgw_sal_daos.cc
src/rgw/rgw_sal_motr.cc

index 9ccb509251b9332f3d157505056ca1f58f77d276..a350bc9b01a2cc9ea19d8375c1b506ccdbb6541b 100644 (file)
@@ -662,7 +662,7 @@ int DaosBucket::list(const DoutPrefixProvider* dpp, ListParams& params, int max,
   uint32_t ncp = common_prefixes.size();
 
   char daos_marker[DS3_MAX_KEY_BUFF];
-  std::strncpy(daos_marker, params.marker.to_str().c_str(), sizeof(daos_marker));
+  std::strncpy(daos_marker, params.marker.get_oid().c_str(), sizeof(daos_marker));
 
   ret = ds3_bucket_list_obj(&nobj, object_infos.data(), &ncp,
                             common_prefixes.data(), params.prefix.c_str(),
@@ -1204,7 +1204,7 @@ DaosObject::DaosDeleteOp::DaosDeleteOp(DaosObject* _source) : source(_source) {}
 int DaosObject::DaosDeleteOp::delete_obj(const DoutPrefixProvider* dpp,
                                          optional_yield y) {
   ldpp_dout(dpp, 20) << "DaosDeleteOp::delete_obj "
-                     << source->get_key().to_str() << " from "
+                     << source->get_key().get_oid() << " from "
                      << source->get_bucket()->get_name() << dendl;
   if (source->get_instance() == "null") {
     source->clear_instance();
@@ -1212,7 +1212,7 @@ int DaosObject::DaosDeleteOp::delete_obj(const DoutPrefixProvider* dpp,
 
   // Open bucket
   int ret = 0;
-  std::string key = source->get_key().to_str();
+  std::string key = source->get_key().get_oid();
   DaosBucket* daos_bucket = source->get_daos_bucket();
   ret = daos_bucket->open(dpp);
   if (ret != 0) {
@@ -1289,15 +1289,15 @@ int DaosObject::lookup(const DoutPrefixProvider* dpp) {
     return ret;
   }
 
-  ret = ds3_obj_open(get_key().to_str().c_str(), &ds3o, daos_bucket->ds3b);
+  ret = ds3_obj_open(get_key().get_oid().c_str(), &ds3o, daos_bucket->ds3b);
 
   if (ret == -ENOENT) {
     ldpp_dout(dpp, 20) << "DEBUG: daos object (" << get_bucket()->get_name()
-                       << ", " << get_key().to_str()
+                       << ", " << get_key().get_oid()
                        << ") does not exist: ret=" << ret << dendl;
   } else if (ret != 0) {
     ldpp_dout(dpp, 0) << "ERROR: failed to open daos object ("
-                      << get_bucket()->get_name() << ", " << get_key().to_str()
+                      << get_bucket()->get_name() << ", " << get_key().get_oid()
                       << "): ret=" << ret << dendl;
   }
   return ret;
@@ -1320,11 +1320,11 @@ int DaosObject::create(const DoutPrefixProvider* dpp) {
     return ret;
   }
 
-  ret = ds3_obj_create(get_key().to_str().c_str(), &ds3o, daos_bucket->ds3b);
+  ret = ds3_obj_create(get_key().get_oid().c_str(), &ds3o, daos_bucket->ds3b);
 
   if (ret != 0) {
     ldpp_dout(dpp, 0) << "ERROR: failed to create daos object ("
-                      << get_bucket()->get_name() << ", " << get_key().to_str()
+                      << get_bucket()->get_name() << ", " << get_key().get_oid()
                       << "): ret=" << ret << dendl;
   }
   return ret;
@@ -1350,7 +1350,7 @@ int DaosObject::write(const DoutPrefixProvider* dpp, bufferlist&& data,
                           ds3o, nullptr);
   if (ret != 0) {
     ldpp_dout(dpp, 0) << "ERROR: failed to write into daos object ("
-                      << get_bucket()->get_name() << ", " << get_key().to_str()
+                      << get_bucket()->get_name() << ", " << get_key().get_oid()
                       << "): ret=" << ret << dendl;
   }
   return ret;
@@ -1363,7 +1363,7 @@ int DaosObject::read(const DoutPrefixProvider* dpp, bufferlist& data,
                          get_daos_bucket()->ds3b, ds3o, nullptr);
   if (ret != 0) {
     ldpp_dout(dpp, 0) << "ERROR: failed to read from daos object ("
-                      << get_bucket()->get_name() << ", " << get_key().to_str()
+                      << get_bucket()->get_name() << ", " << get_key().get_oid()
                       << "): ret=" << ret << dendl;
   }
   return ret;
@@ -1382,7 +1382,7 @@ int DaosObject::get_dir_entry_attrs(const DoutPrefixProvider* dpp,
     struct ds3_multipart_upload_info ui = {.encoded = value.data(),
                                            .encoded_length = size};
     ret = ds3_upload_get_info(&ui, bucket->get_name().c_str(),
-                              get_key().to_str().c_str(), store->ds3);
+                              get_key().get_oid().c_str(), store->ds3);
   } else {
     ret = lookup(dpp);
     if (ret != 0) {
@@ -1398,7 +1398,7 @@ int DaosObject::get_dir_entry_attrs(const DoutPrefixProvider* dpp,
 
   if (ret != 0) {
     ldpp_dout(dpp, 0) << "ERROR: failed to get info of daos object ("
-                      << get_bucket()->get_name() << ", " << get_key().to_str()
+                      << get_bucket()->get_name() << ", " << get_key().get_oid()
                       << "): ret=" << ret << dendl;
     return ret;
   }
@@ -1451,7 +1451,7 @@ int DaosObject::set_dir_entry_attrs(const DoutPrefixProvider* dpp,
   ret = ds3_obj_set_info(object_info.get(), get_daos_bucket()->ds3b, ds3o);
   if (ret != 0) {
     ldpp_dout(dpp, 0) << "ERROR: failed to set info of daos object ("
-                      << get_bucket()->get_name() << ", " << get_key().to_str()
+                      << get_bucket()->get_name() << ", " << get_key().get_oid()
                       << "): ret=" << ret << dendl;
   }
   return ret;
@@ -1467,9 +1467,9 @@ int DaosObject::mark_as_latest(const DoutPrefixProvider* dpp,
   std::unique_ptr<DaosObject> latest_object = std::make_unique<DaosObject>(
       store, rgw_obj_key(get_name(), DS3_LATEST_INSTANCE), get_bucket());
 
-  ldpp_dout(dpp, 20) << __func__ << ": key=" << get_key().to_str()
+  ldpp_dout(dpp, 20) << __func__ << ": key=" << get_key().get_oid()
                      << " latest_object_key= "
-                     << latest_object->get_key().to_str() << dendl;
+                     << latest_object->get_key().get_oid() << dendl;
 
   int ret = latest_object->lookup(dpp);
   if (ret == 0) {
@@ -1493,7 +1493,7 @@ int DaosObject::mark_as_latest(const DoutPrefixProvider* dpp,
   // Get or create the link [latest], make it link to the current latest
   // version.
   ret =
-      ds3_obj_mark_latest(get_key().to_str().c_str(), get_daos_bucket()->ds3b);
+      ds3_obj_mark_latest(get_key().get_oid().c_str(), get_daos_bucket()->ds3b);
   ldpp_dout(dpp, 20) << "DEBUG: ds3_obj_mark_latest ret=" << ret << dendl;
   return ret;
 }
@@ -1574,7 +1574,7 @@ int DaosAtomicWriter::complete(
   if (is_versioned)
     ent.flags =
         rgw_bucket_dir_entry::FLAG_VER | rgw_bucket_dir_entry::FLAG_CURRENT;
-  ldpp_dout(dpp, 20) << __func__ << ": key=" << obj.get_key().to_str()
+  ldpp_dout(dpp, 20) << __func__ << ": key=" << obj.get_key().get_oid()
                      << " etag: " << etag << dendl;
   if (user_data) ent.meta.user_data = *user_data;
 
index a40b1ac896be2b8b17b619f59d7917d5bbe65885..6aa12fa369a369e5994e85afbcb39d9007819618 100644 (file)
@@ -743,7 +743,7 @@ int MotrBucket::list(const DoutPrefixProvider *dpp, ListParams& params, int max,
   // Retrieve all `max` number of pairs.
   string bucket_index_iname = "motr.rgw.bucket.index." + info.bucket.name;
   keys[0] = params.marker.empty() ? params.prefix :
-                                    params.marker.to_str();
+                                    params.marker.get_oid();
   rc = store->next_query_by_name(bucket_index_iname, keys, vals, params.prefix,
                                                                  params.delim);
   if (rc < 0) {
@@ -944,18 +944,18 @@ int MotrObject::get_obj_state(const DoutPrefixProvider* dpp, RGWObjState **_stat
 {
   // Get object's metadata (those stored in rgw_bucket_dir_entry).
   bufferlist bl;
-  if (this->store->get_obj_meta_cache()->get(dpp, this->get_key().to_str(), bl)) {
+  if (this->store->get_obj_meta_cache()->get(dpp, this->get_key().get_oid(), bl)) {
     // Cache misses.
     string bucket_index_iname = "motr.rgw.bucket.index." + this->get_bucket()->get_name();
     int rc = this->store->do_idx_op_by_name(bucket_index_iname,
-                                  M0_IC_GET, this->get_key().to_str(), bl);
+                                  M0_IC_GET, this->get_key().get_oid(), bl);
     if (rc < 0) {
       ldpp_dout(dpp, 0) << "Failed to get object's entry from bucket index. " << dendl;
       return rc;
     }
 
     // Put into cache.
-    this->store->get_obj_meta_cache()->put(dpp, this->get_key().to_str(), bl);
+    this->store->get_obj_meta_cache()->put(dpp, this->get_key().get_oid(), bl);
   }
 
   rgw_bucket_dir_entry ent;
@@ -1011,10 +1011,10 @@ int MotrObject::get_obj_attrs(optional_yield y, const DoutPrefixProvider* dpp, r
   string bname, key;
   if (target_obj) {
     bname = target_obj->bucket.name;
-    key   = target_obj->key.to_str();
+    key   = target_obj->key.get_oid();
   } else {
     bname = this->get_bucket()->get_name();
-    key   = this->get_key().to_str();
+    key   = this->get_key().get_oid();
   }
   ldpp_dout(dpp, 20) << "MotrObject::get_obj_attrs(): "
                     << bname << "/" << key << dendl;
@@ -1228,16 +1228,16 @@ MotrObject::MotrDeleteOp::MotrDeleteOp(MotrObject *_source) :
 // 2. Delete an object when its versioning is turned on.
 int MotrObject::MotrDeleteOp::delete_obj(const DoutPrefixProvider* dpp, optional_yield y)
 {
-  ldpp_dout(dpp, 20) << "delete " << source->get_key().to_str() << " from " << source->get_bucket()->get_name() << dendl;
+  ldpp_dout(dpp, 20) << "delete " << source->get_key().get_oid() << " from " << source->get_bucket()->get_name() << dendl;
 
   // Delete from the cache first.
-  source->store->get_obj_meta_cache()->remove(dpp, source->get_key().to_str());
+  source->store->get_obj_meta_cache()->remove(dpp, source->get_key().get_oid());
 
   // Delete the object's entry from the bucket index.
   bufferlist bl;
   string bucket_index_iname = "motr.rgw.bucket.index." + source->get_bucket()->get_name();
   int rc = source->store->do_idx_op_by_name(bucket_index_iname,
-                                            M0_IC_DEL, source->get_key().to_str(), bl);
+                                            M0_IC_DEL, source->get_key().get_oid(), bl);
   if (rc < 0) {
     ldpp_dout(dpp, 0) << "Failed to del object's entry from bucket index. " << dendl;
     return rc;
@@ -1684,16 +1684,16 @@ int MotrObject::get_bucket_dir_ent(const DoutPrefixProvider *dpp, rgw_bucket_dir
       }
     }
   } else {
-    if (this->store->get_obj_meta_cache()->get(dpp, this->get_key().to_str(), bl)) {
+    if (this->store->get_obj_meta_cache()->get(dpp, this->get_key().get_oid(), bl)) {
       ldpp_dout(dpp, 20) <<__func__<< ": non-versioned bucket!" << dendl;
       rc = this->store->do_idx_op_by_name(bucket_index_iname,
-                                          M0_IC_GET, this->get_key().to_str(), bl);
+                                          M0_IC_GET, this->get_key().get_oid(), bl);
       if (rc < 0) {
         ldpp_dout(dpp, 0) << "ERROR: failed to get object's entry from bucket index: rc="
                           << rc << dendl;
         return rc;
       }
-      this->store->get_obj_meta_cache()->put(dpp, this->get_key().to_str(), bl);
+      this->store->get_obj_meta_cache()->put(dpp, this->get_key().get_oid(), bl);
     }
 
     bufferlist& blr = bl;
@@ -1811,7 +1811,7 @@ int MotrObject::get_part_objs(const DoutPrefixProvider* dpp,
       uint64_t part_size = mmpart->get_size();
 
       string part_obj_name = this->get_bucket()->get_name() + "." +
-                            this->get_key().to_str() +
+                            this->get_key().get_oid() +
                             ".part." + std::to_string(part_num);
       std::unique_ptr<rgw::sal::Object> obj;
       obj = this->bucket->get_object(rgw_obj_key(part_obj_name));
@@ -1981,7 +1981,7 @@ int MotrAtomicWriter::write()
       snprintf(fid_str, ARRAY_SIZE(fid_str), U128X_F, U128_P(&obj.meta.oid));
       ldpp_dout(dpp, 0) << "ERROR: failed to create/open motr object "
                         << fid_str << " (" << obj.get_bucket()->get_name()
-                        << "/" << obj.get_key().to_str() << "): rc=" << rc
+                        << "/" << obj.get_key().get_oid() << "): rc=" << rc
                         << dendl;
       goto err;
     }
@@ -2094,7 +2094,7 @@ int MotrAtomicWriter::complete(size_t accounted_size, const std::string& etag,
   bool is_versioned = obj.get_key().have_instance();
   if (is_versioned)
     ent.flags = rgw_bucket_dir_entry::FLAG_VER | rgw_bucket_dir_entry::FLAG_CURRENT;
-  ldpp_dout(dpp, 20) <<__func__<< ": key=" << obj.get_key().to_str()
+  ldpp_dout(dpp, 20) <<__func__<< ": key=" << obj.get_key().get_oid()
                     << " etag: " << etag << " user_data=" << user_data << dendl;
   if (user_data)
     ent.meta.user_data = *user_data;
@@ -2139,9 +2139,9 @@ int MotrAtomicWriter::complete(size_t accounted_size, const std::string& etag,
   // Insert an entry into bucket index.
   string bucket_index_iname = "motr.rgw.bucket.index." + obj.get_bucket()->get_name();
   rc = store->do_idx_op_by_name(bucket_index_iname,
-                                M0_IC_PUT, obj.get_key().to_str(), bl);
+                                M0_IC_PUT, obj.get_key().get_oid(), bl);
   if (rc == 0)
-    store->get_obj_meta_cache()->put(dpp, obj.get_key().to_str(), bl);
+    store->get_obj_meta_cache()->put(dpp, obj.get_key().get_oid(), bl);
 
   return rc;
 }
@@ -2209,7 +2209,7 @@ int MotrMultipartUpload::abort(const DoutPrefixProvider *dpp, CephContext *cct)
   string bucket_multipart_iname =
       "motr.rgw.bucket." + meta_obj->get_bucket()->get_name() + ".multiparts";
   return store->do_idx_op_by_name(bucket_multipart_iname,
-                                  M0_IC_DEL, meta_obj->get_key().to_str(), bl);
+                                  M0_IC_DEL, meta_obj->get_key().get_oid(), bl);
   return 0;
 }
 
@@ -2286,7 +2286,7 @@ int MotrMultipartUpload::init(const DoutPrefixProvider *dpp, optional_yield y,
     string bucket_multipart_iname =
       "motr.rgw.bucket." + obj->get_bucket()->get_name() + ".multiparts";
     rc = store->do_idx_op_by_name(bucket_multipart_iname,
-                                  M0_IC_PUT, obj->get_key().to_str(), bl);
+                                  M0_IC_PUT, obj->get_key().get_oid(), bl);
 
   } while (rc == -EEXIST);
 
@@ -2543,7 +2543,7 @@ int MotrMultipartUpload::complete(const DoutPrefixProvider *dpp,
   string bucket_multipart_iname =
       "motr.rgw.bucket." + meta_obj->get_bucket()->get_name() + ".multiparts";
   rc = this->store->do_idx_op_by_name(bucket_multipart_iname,
-                                      M0_IC_GET, meta_obj->get_key().to_str(), bl);
+                                      M0_IC_GET, meta_obj->get_key().get_oid(), bl);
   ldpp_dout(dpp, 20) << "MotrMultipartUpload::complete(): read entry from bucket multipart index rc=" << rc << dendl;
   if (rc < 0)
     return rc;
@@ -2581,7 +2581,7 @@ int MotrMultipartUpload::complete(const DoutPrefixProvider *dpp,
   // Now we can remove it from bucket multipart index.
   ldpp_dout(dpp, 20) << "MotrMultipartUpload::complete(): remove from bucket multipartindex " << dendl;
   return store->do_idx_op_by_name(bucket_multipart_iname,
-                                  M0_IC_DEL, meta_obj->get_key().to_str(), bl);
+                                  M0_IC_DEL, meta_obj->get_key().get_oid(), bl);
 }
 
 int MotrMultipartUpload::get_info(const DoutPrefixProvider *dpp, optional_yield y, rgw_placement_rule** rule, rgw::sal::Attrs* attrs)
@@ -2611,7 +2611,7 @@ int MotrMultipartUpload::get_info(const DoutPrefixProvider *dpp, optional_yield
   string bucket_multipart_iname =
       "motr.rgw.bucket." + meta_obj->get_bucket()->get_name() + ".multiparts";
   int rc = this->store->do_idx_op_by_name(bucket_multipart_iname,
-                                          M0_IC_GET, meta_obj->get_key().to_str(), bl);
+                                          M0_IC_GET, meta_obj->get_key().get_oid(), bl);
   if (rc < 0) {
     ldpp_dout(dpp, 0) << "Failed to get object's entry from bucket index. " << dendl;
     return rc;
@@ -2663,7 +2663,7 @@ std::unique_ptr<Writer> MotrMultipartUpload::get_writer(
 int MotrMultipartWriter::prepare(optional_yield y)
 {
   string part_obj_name = head_obj->get_bucket()->get_name() + "." +
-                        head_obj->get_key().to_str() +
+                        head_obj->get_key().get_oid() +
                         ".part." + std::to_string(part_num);
   ldpp_dout(dpp, 20) << "bucket=" << head_obj->get_bucket()->get_name() << "part_obj_name=" << part_obj_name << dendl;
   part_obj = std::make_unique<MotrObject>(this->store, rgw_obj_key(part_obj_name), head_obj->get_bucket());
@@ -2729,7 +2729,7 @@ int MotrMultipartWriter::complete(size_t accounted_size, const std::string& etag
   snprintf(buf, sizeof(buf), "%08d", (int)part_num);
   p.append(buf);
   string obj_part_iname = "motr.rgw.object." + head_obj->get_bucket()->get_name() + "." +
-                         head_obj->get_key().to_str() + ".parts";
+                         head_obj->get_key().get_oid() + ".parts";
   ldpp_dout(dpp, 20) << "MotrMultipartWriter::complete(): object part index = " << obj_part_iname << dendl;
   rc = store->do_idx_op_by_name(obj_part_iname, M0_IC_PUT, p, bl);
   if (rc < 0) {