summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-06-25 22:55:53 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-06-25 22:55:53 -0700
commitaf00f7334893dcefac8fe44e41c8c56bb3bdc0b1 (patch)
tree176ec5642f89243268e85e5bae53c09f91f63114
parent7a2566c60f79f5e684284b258ee59a9c52e5ba45 (diff)
downloadceph-af00f7334893dcefac8fe44e41c8c56bb3bdc0b1.tar.gz
rgw: automatic pool creation for placement pools
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>
-rw-r--r--src/rgw/rgw_admin.cc2
-rw-r--r--src/rgw/rgw_rados.cc37
-rw-r--r--src/rgw/rgw_rados.h2
3 files changed, 24 insertions, 17 deletions
diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc
index bafcef77cc3..30fdac966cd 100644
--- a/src/rgw/rgw_admin.cc
+++ b/src/rgw/rgw_admin.cc
@@ -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;
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index bc0f5c2ad0f..31c119b725e 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -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);
diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h
index 72fa4cbd6d1..54f4366ff3f 100644
--- a/src/rgw/rgw_rados.h
+++ b/src/rgw/rgw_rados.h
@@ -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 {