]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: automatic pool creation for placement pools
authorYehuda Sadeh <yehuda@inktank.com>
Wed, 26 Jun 2013 05:55:53 +0000 (22:55 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 26 Jun 2013 05:55:53 +0000 (22:55 -0700)
With the new pools configuration, now we auto create the
pools when needed (through bucket creation). Also, make
sure only to configure default placement in zone structure,
if old config hasn't been done yet.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index bafcef77cc31769443473e183f598db9fc302697..30fdac966cdf549de04adbfceca7b329565e7968 100644 (file)
@@ -1083,7 +1083,7 @@ int main(int argc, char **argv)
         cerr << "WARNING: failed to initialize region" << std::endl;
       }
       RGWZoneParams zone;
-      zone.init_default();
+      zone.init_default(store);
       ret = read_decode_json(infile, zone);
       if (ret < 0) {
         return 1;
index bc0f5c2ad0f1a4f9f74f8730dc70ad71b91b79f6..31c119b725ebe235fa2f11e97ca977d8fe796d07 100644 (file)
@@ -227,7 +227,8 @@ int RGWRegion::create_default()
 
   RGWZoneParams zone_params;
   zone_params.name = zone_name;
-  zone_params.init_default();
+  zone_params.init_default(store);
+
   int r = zone_params.store_info(cct, store, *this);
   if (r < 0) {
     derr << "error storing zone params: " << cpp_strerror(-r) << dendl;
@@ -259,8 +260,7 @@ int RGWRegion::store_info(bool exclusive)
 }
 
 
-
-void RGWZoneParams::init_default()
+void RGWZoneParams::init_default(RGWRados *store)
 {
   domain_root = ".rgw";
   control_pool = ".rgw.control";
@@ -273,10 +273,17 @@ void RGWZoneParams::init_default()
   user_swift_pool = ".users.swift";
   user_uid_pool = ".users.uid";
 
-  RGWZonePlacementInfo default_placement;
-  default_placement.index_pool = ".rgw.buckets";
-  default_placement.data_pool = ".rgw.buckets";
-  placement_pools["default-placement"] = default_placement;
+  /* check for old pools config */
+  rgw_obj obj(domain_root, avail_pools);
+  int r =  store->obj_stat(NULL, obj, NULL, NULL, NULL, NULL, NULL, NULL);
+  if (r < 0) {
+    ldout(store->ctx(), 0) << "couldn't find old data placement pools config, setting up new ones for the zone" << dendl;
+    /* a new system, let's set new placement info */
+    RGWZonePlacementInfo default_placement;
+    default_placement.index_pool = ".rgw.buckets.index";
+    default_placement.data_pool = ".rgw.buckets";
+    placement_pools["default-placement"] = default_placement;
+  }
 }
 
 string RGWZoneParams::get_pool_name(CephContext *cct)
@@ -865,6 +872,11 @@ int RGWRados::init_complete()
   ret = region_map.read(cct, this);
   if (ret < 0) {
     ldout(cct, 0) << "WARNING: cannot read region map" << dendl;
+    ret = region_map.update(region);
+    if (ret < 0) {
+      ldout(cct, 0) << "ERROR: failed to update regionmap with local region info" << dendl;
+      return -EIO;
+    }
   } else {
     string master_region = region_map.master_region;
     if (master_region.empty()) {
@@ -1091,14 +1103,9 @@ int RGWRados::open_bucket_pool_ctx(const string& bucket_name, const string& pool
   if (!pools_initialized)
     return r;
 
-  /* couldn't find bucket, might be a racing bucket creation,
-     where client haven't gotten updated map, try to read
-     the bucket object .. which will trigger update of osdmap
-     if that is the case */
-  time_t mtime;
-  r = root_pool_ctx.stat(bucket_name, NULL, &mtime);
-  if (r < 0)
-    return -ENOENT;
+  r = rados->pool_create(pool.c_str());
+  if (r < 0 && r != -EEXIST)
+    return r;
 
   r = rados->ioctx_create(pool.c_str(), io_ctx);
 
index 72fa4cbd6d1ac850a107827357f2f81b041c9307..54f4366ff3fbee0898e5daa73cf39cebb4eb5652 100644 (file)
@@ -435,7 +435,7 @@ struct RGWZoneParams {
   static string get_pool_name(CephContext *cct);
   void init_name(CephContext *cct, RGWRegion& region);
   int init(CephContext *cct, RGWRados *store, RGWRegion& region);
-  void init_default();
+  void init_default(RGWRados *store);
   int store_info(CephContext *cct, RGWRados *store, RGWRegion& region);
 
   void encode(bufferlist& bl) const {