]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rgw_put_system_obj takes bufferlist
authorCasey Bodley <cbodley@redhat.com>
Wed, 10 Jan 2018 14:37:02 +0000 (09:37 -0500)
committerCasey Bodley <cbodley@redhat.com>
Fri, 12 Jan 2018 19:26:13 +0000 (14:26 -0500)
all callers were converting from bufferlist to const char*, then
RGWRados::put_system_obj() copied that back into a new bufferlist

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_metadata.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_role.cc
src/rgw/rgw_tools.cc
src/rgw/rgw_tools.h
src/rgw/rgw_user.cc

index d50782dfb3dc1adac07421916e865850efa8635a..66aa0489eb0e273f401bc0a12000d04ef5b4db04 100644 (file)
@@ -383,7 +383,7 @@ int write_history(RGWRados *store, const RGWMetadataLogHistory& state,
 
   auto& pool = store->get_zone_params().log_pool;
   const auto& oid = RGWMetadataLogHistory::oid;
-  return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(),
+  return rgw_put_system_obj(store, pool, oid, bl,
                             exclusive, objv_tracker, real_time{});
 }
 
@@ -1006,8 +1006,7 @@ int RGWMetadataManager::store_in_heap(RGWMetadataHandler *handler, const string&
   otracker.write_version = objv_tracker->write_version;
   string oid = heap_oid(handler, key, objv_tracker->write_version);
   int ret = rgw_put_system_obj(store, heap_pool, oid,
-                               bl.c_str(), bl.length(), false,
-                               &otracker, mtime, pattrs);
+                               bl, false, &otracker, mtime, pattrs);
   if (ret < 0) {
     ldout(store->ctx(), 0) << "ERROR: rgw_put_system_obj() oid=" << oid << " returned ret=" << ret << dendl;
     return ret;
@@ -1059,8 +1058,7 @@ int RGWMetadataManager::put_entry(RGWMetadataHandler *handler, const string& key
     goto done;
   }
 
-  ret = rgw_put_system_obj(store, pool, oid,
-                           bl.c_str(), bl.length(), exclusive,
+  ret = rgw_put_system_obj(store, pool, oid, bl, exclusive,
                            objv_tracker, mtime, pattrs);
 
   if (ret < 0) {
index cca45ea38143482b04034d590e6804aed0d66663..0d79e58f07aa57cbd20b9f574a9014333dc15853 100644 (file)
@@ -608,7 +608,7 @@ int RGWSystemMetaObj::set_as_default(bool exclusive)
 
   encode(default_info, bl);
 
-  int ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(),
+  int ret = rgw_put_system_obj(store, pool, oid, bl,
                                exclusive, NULL, real_time(), NULL);
   if (ret < 0)
     return ret;
@@ -697,7 +697,7 @@ int RGWSystemMetaObj::store_name(bool exclusive)
   bufferlist bl;
   using ceph::encode;
   encode(nameToId, bl);
-  return  rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), exclusive, NULL, real_time(), NULL);
+  return rgw_put_system_obj(store, pool, oid, bl, exclusive, NULL, real_time(), NULL);
 }
 
 int RGWSystemMetaObj::rename(const string& new_name)
@@ -814,7 +814,7 @@ int RGWSystemMetaObj::store_info(bool exclusive)
   bufferlist bl;
   using ceph::encode;
   encode(*this, bl);
-  return  rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), exclusive, NULL, real_time(), NULL);
+  return rgw_put_system_obj(store, pool, oid, bl, exclusive, NULL, real_time(), NULL);
 }
 
 int RGWSystemMetaObj::write(bool exclusive)
@@ -898,7 +898,8 @@ int RGWRealm::create_control(bool exclusive)
 {
   auto pool = rgw_pool{get_pool(cct)};
   auto oid = get_control_oid();
-  return rgw_put_system_obj(store, pool, oid, nullptr, 0, exclusive,
+  bufferlist bl;
+  return rgw_put_system_obj(store, pool, oid, bl, exclusive,
                             nullptr, real_time(), nullptr);
 }
 
@@ -1050,7 +1051,7 @@ int RGWPeriodConfig::write(RGWRados *store, const std::string& realm_id)
   bufferlist bl;
   using ceph::encode;
   encode(*this, bl);
-  return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(),
+  return rgw_put_system_obj(store, pool, oid, bl,
                             false, nullptr, real_time(), nullptr);
 }
 
@@ -1234,7 +1235,7 @@ int RGWPeriod::set_latest_epoch(epoch_t epoch, bool exclusive,
   using ceph::encode;
   encode(info, bl);
 
-  return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(),
+  return rgw_put_system_obj(store, pool, oid, bl,
                             exclusive, objv, real_time(), nullptr);
 }
 
@@ -1371,7 +1372,7 @@ int RGWPeriod::store_info(bool exclusive)
   using ceph::encode;
   encode(*this, bl);
 
-  return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(),
+  return rgw_put_system_obj(store, pool, oid, bl,
                             exclusive, NULL, real_time(), NULL);
 }
 
@@ -4155,7 +4156,7 @@ int RGWRados::replace_region_with_zonegroup()
   }
 
   /* mark as converted */
-  ret = rgw_put_system_obj(this, pool, oid, bl.c_str(), bl.length(),
+  ret = rgw_put_system_obj(this, pool, oid, bl,
                           true, NULL, real_time(), NULL);
   if (ret < 0 ) {
     ldout(cct, 0) << __func__ << " failed to mark cluster as converted: ret "<< ret << " " << cpp_strerror(-ret)
index a3682eb147d324e22659ccf8453a2842790651c2..8f4b7d1fcf2ddf521cd1e47074caca5e8b438ff7 100644 (file)
@@ -3050,16 +3050,14 @@ public:
   int aio_put_obj_data(void *ctx, rgw_raw_obj& obj, bufferlist& bl,
                         off_t ofs, bool exclusive, void **handle);
 
-  int put_system_obj(void *ctx, rgw_raw_obj& obj, const char *data, size_t len, bool exclusive,
+  int put_system_obj(void *ctx, rgw_raw_obj& obj, bufferlist& data, bool exclusive,
               ceph::real_time *mtime, map<std::string, bufferlist>& attrs, RGWObjVersionTracker *objv_tracker,
               ceph::real_time set_mtime) {
-    bufferlist bl;
-    bl.append(data, len);
     int flags = PUT_OBJ_CREATE;
     if (exclusive)
       flags |= PUT_OBJ_EXCL;
 
-    return put_system_obj_impl(obj, len, mtime, attrs, flags, bl, objv_tracker, set_mtime);
+    return put_system_obj_impl(obj, data.length(), mtime, attrs, flags, data, objv_tracker, set_mtime);
   }
   int aio_wait(void *handle);
   bool aio_completed(void *handle);
index 5c67e0980a5259fb9e88251f102c844d0eb52c77..8fe173d9cffe4b35520534faa8475545ead82af5 100644 (file)
@@ -31,7 +31,7 @@ int RGWRole::store_info(bool exclusive)
   bufferlist bl;
   encode(*this, bl);
   return rgw_put_system_obj(store, store->get_zone_params().roles_pool, oid,
-                bl.c_str(), bl.length(), exclusive, NULL, real_time(), NULL);
+                bl, exclusive, NULL, real_time(), NULL);
 }
 
 int RGWRole::store_name(bool exclusive)
@@ -45,15 +45,16 @@ int RGWRole::store_name(bool exclusive)
   using ceph::encode;
   encode(nameToId, bl);
   return rgw_put_system_obj(store, store->get_zone_params().roles_pool, oid,
-              bl.c_str(), bl.length(), exclusive, NULL, real_time(), NULL);
+              bl, exclusive, NULL, real_time(), NULL);
 }
 
 int RGWRole::store_path(bool exclusive)
 {
   string oid = tenant + get_path_oid_prefix() + path + get_info_oid_prefix() + id;
 
+  bufferlist bl;
   return rgw_put_system_obj(store, store->get_zone_params().roles_pool, oid,
-              NULL, 0, exclusive, NULL, real_time(), NULL);
+              bl, exclusive, NULL, real_time(), NULL);
 }
 
 int RGWRole::create(bool exclusive)
index 088fcc622e3cdf8400c166fc145278c462e8e9f9..504bb184212203aa822e8efd59b22313d09decc5 100644 (file)
@@ -18,7 +18,7 @@
 
 static std::map<std::string, std::string>* ext_mime_map;
 
-int rgw_put_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string& oid, const char *data, size_t size, bool exclusive,
+int rgw_put_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string& oid, bufferlist& data, bool exclusive,
                        RGWObjVersionTracker *objv_tracker, real_time set_mtime, map<string, bufferlist> *pattrs)
 {
   map<string,bufferlist> no_attrs;
@@ -27,12 +27,12 @@ int rgw_put_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string& o
 
   rgw_raw_obj obj(pool, oid);
 
-  int ret = rgwstore->put_system_obj(NULL, obj, data, size, exclusive, NULL, *pattrs, objv_tracker, set_mtime);
+  int ret = rgwstore->put_system_obj(NULL, obj, data, exclusive, NULL, *pattrs, objv_tracker, set_mtime);
 
   if (ret == -ENOENT) {
     ret = rgwstore->create_pool(pool);
     if (ret >= 0)
-      ret = rgwstore->put_system_obj(NULL, obj, data, size, exclusive, NULL, *pattrs, objv_tracker, set_mtime);
+      ret = rgwstore->put_system_obj(NULL, obj, data, exclusive, NULL, *pattrs, objv_tracker, set_mtime);
   }
 
   return ret;
index 00f404a6d1ca6f9e984c8db71c6823b6fbfbc00e..d9d3f1484e18adf2a606df80c169c6f1a100c73a 100644 (file)
@@ -16,7 +16,7 @@ struct RGWObjVersionTracker;
 
 struct obj_version;
 
-int rgw_put_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string& oid, const char *data, size_t size, bool exclusive,
+int rgw_put_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string& oid, bufferlist& data, bool exclusive,
                        RGWObjVersionTracker *objv_tracker, real_time set_mtime, map<string, bufferlist> *pattrs = NULL);
 int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, const rgw_pool& pool, const string& key, bufferlist& bl,
                        RGWObjVersionTracker *objv_tracker, real_time *pmtime, map<string, bufferlist> *pattrs = NULL,
index cc0af138bebd058066d24bc498c0140a9cf4e145..9f4de11935d0a6793838c2c0ba3382487458d7c7 100644 (file)
@@ -209,7 +209,7 @@ int rgw_store_user_info(RGWRados *store,
     if (!old_info ||
         old_info->user_email.compare(info.user_email) != 0) { /* only if new index changed */
       ret = rgw_put_system_obj(store, store->get_zone_params().user_email_pool, info.user_email,
-                               link_bl.c_str(), link_bl.length(), exclusive, NULL, real_time());
+                               link_bl, exclusive, NULL, real_time());
       if (ret < 0)
         return ret;
     }
@@ -223,8 +223,7 @@ int rgw_store_user_info(RGWRados *store,
        continue;
 
       ret = rgw_put_system_obj(store, store->get_zone_params().user_keys_pool, k.id,
-                               link_bl.c_str(), link_bl.length(), exclusive,
-                               NULL, real_time());
+                               link_bl, exclusive, NULL, real_time());
       if (ret < 0)
         return ret;
     }
@@ -237,8 +236,7 @@ int rgw_store_user_info(RGWRados *store,
       continue;
 
     ret = rgw_put_system_obj(store, store->get_zone_params().user_swift_pool, k.id,
-                             link_bl.c_str(), link_bl.length(), exclusive,
-                             NULL, real_time());
+                             link_bl, exclusive, NULL, real_time());
     if (ret < 0)
       return ret;
   }