]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: pool names are not global
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 10 Aug 2012 22:59:44 +0000 (15:59 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 29 Aug 2012 21:22:45 +0000 (14:22 -0700)
Move all hard coded pool names outside of the global
namespace.

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

index ed082eeddf8afb4bb96329ba570d07e001a6e680..2cd209e6e9edabc3106cee7b1b9095e20793f358 100644 (file)
@@ -37,8 +37,6 @@ namespace ceph {
 using ceph::crypto::MD5;
 
 
-#define RGW_CONTROL_BUCKET ".rgw.control"
-
 #define RGW_ATTR_PREFIX  "user.rgw."
 
 #define RGW_ATTR_ACL           RGW_ATTR_PREFIX "acl"
index 1183b1d09951dc2d1423401f6dc661b3b53cefef..779a394f7ccdad67f61e6fb144833277f57cff38 100644 (file)
@@ -8,8 +8,6 @@
 
 #define dout_subsys ceph_subsys_rgw
 
-static rgw_bucket log_bucket(RGW_LOG_POOL_NAME);
-
 static void set_param_str(struct req_state *s, const char *name, string& str)
 {
   const char *p = s->env->get(name);
@@ -265,13 +263,13 @@ int rgw_log_op(RGWRados *store, struct req_state *s)
   string oid = render_log_object_name(s->cct->_conf->rgw_log_object_name, &bdt,
                                      s->bucket.bucket_id, entry.bucket.c_str());
 
-  rgw_obj obj(log_bucket, oid);
+  rgw_obj obj(store->params.log_pool, oid);
 
   int ret = store->append_async(obj, bl.length(), bl);
   if (ret == -ENOENT) {
     string id;
     map<std::string, bufferlist> attrs;
-    ret = store->create_bucket(id, log_bucket, attrs, true);
+    ret = store->create_bucket(id, store->params.log_pool, attrs, true);
     if (ret < 0)
       goto done;
     // retry
@@ -286,7 +284,7 @@ done:
 
 int rgw_log_intent(RGWRados *store, rgw_obj& obj, RGWIntentEvent intent, const utime_t& timestamp, bool utc)
 {
-  rgw_bucket intent_log_bucket(RGW_INTENT_LOG_POOL_NAME);
+  rgw_bucket intent_log_bucket(store->params.intent_log_pool);
 
   rgw_intent_log_entry entry;
   entry.obj = obj;
index 6b5e50a6dedfd1db7099ec193e2adaacbb796ead..e24a157639c3d4e79bc46d587476594663c393f9 100644 (file)
@@ -6,10 +6,6 @@
 
 class RGWRados;
 
-#define RGW_LOG_POOL_NAME ".log"
-#define RGW_INTENT_LOG_POOL_NAME ".intent-log"
-#define RGW_USAGE_LOG_POOL_NAME ".usage"
-
 struct rgw_log_entry {
   string object_owner;
   string bucket_owner;
index 46b56473691300fa40f3f98d8d04f6a648e880fe..d02774c1827fa0c8646478be605bd00c5fabf7a8 100644 (file)
@@ -58,6 +58,15 @@ static RGWObjCategory main_category = RGW_OBJ_CATEGORY_MAIN;
 void RGWRadosParams::init_default()
 {
   domain_root = ".rgw";
+  control_pool = ".rgw.control";
+  gc_pool = ".rgw.gc";
+  log_pool = ".log";
+  intent_log_pool = ".intent-log";
+  usage_log_pool = ".usage";
+  user_keys_pool = ".users";
+  user_email_pool = ".users.email";
+  user_swift_pool = ".users.swift";
+  user_uid_pool = ".users.uid";
 }
 
 
@@ -211,15 +220,16 @@ int RGWRados::open_root_pool_ctx()
 
 int RGWRados::open_gc_pool_ctx()
 {
-  int r = rados->ioctx_create(RGW_GC_BUCKET, gc_pool_ctx);
+  const char *gc_pool = params.gc_pool.name.c_str();
+  int r = rados->ioctx_create(gc_pool, gc_pool_ctx);
   if (r == -ENOENT) {
-    r = rados->pool_create(RGW_GC_BUCKET);
+    r = rados->pool_create(gc_pool);
     if (r == -EEXIST)
       r = 0;
     if (r < 0)
       return r;
 
-    r = rados->ioctx_create(RGW_GC_BUCKET, gc_pool_ctx);
+    r = rados->ioctx_create(gc_pool, gc_pool_ctx);
   }
 
   return r;
@@ -227,15 +237,16 @@ int RGWRados::open_gc_pool_ctx()
 
 int RGWRados::init_watch()
 {
-  int r = rados->ioctx_create(RGW_CONTROL_BUCKET, control_pool_ctx);
+  const char *control_pool = params.control_pool.name.c_str();
+  int r = rados->ioctx_create(control_pool, control_pool_ctx);
   if (r == -ENOENT) {
-    r = rados->pool_create(RGW_CONTROL_BUCKET);
+    r = rados->pool_create(control_pool);
     if (r == -EEXIST)
       r = 0;
     if (r < 0)
       return r;
 
-    r = rados->ioctx_create(RGW_CONTROL_BUCKET, control_pool_ctx);
+    r = rados->ioctx_create(control_pool, control_pool_ctx);
     if (r < 0)
       return r;
   }
@@ -355,7 +366,8 @@ struct log_list_state {
 int RGWRados::log_list_init(const string& prefix, RGWAccessHandle *handle)
 {
   log_list_state *state = new log_list_state;
-  int r = rados->ioctx_create(RGW_LOG_POOL_NAME, state->io_ctx);
+  const char *log_pool = params.log_pool.name.c_str();
+  int r = rados->ioctx_create(log_pool, state->io_ctx);
   if (r < 0)
     return r;
   state->prefix = prefix;
@@ -387,7 +399,8 @@ int RGWRados::log_list_next(RGWAccessHandle handle, string *name)
 int RGWRados::log_remove(const string& name)
 {
   librados::IoCtx io_ctx;
-  int r = rados->ioctx_create(RGW_LOG_POOL_NAME, io_ctx);
+  const char *log_pool = params.log_pool.name.c_str();
+  int r = rados->ioctx_create(log_pool, io_ctx);
   if (r < 0)
     return r;
   return io_ctx.remove(name);
@@ -406,7 +419,8 @@ struct log_show_state {
 int RGWRados::log_show_init(const string& name, RGWAccessHandle *handle)
 {
   log_show_state *state = new log_show_state;
-  int r = rados->ioctx_create(RGW_LOG_POOL_NAME, state->io_ctx);
+  const char *log_pool = params.log_pool.name.c_str();
+  int r = rados->ioctx_create(log_pool, state->io_ctx);
   if (r < 0)
     return r;
   state->name = name;
@@ -2891,17 +2905,18 @@ int RGWRados::cls_obj_usage_log_add(const string& oid, rgw_usage_log_info& info)
 {
   librados::IoCtx io_ctx;
 
-  int r = rados->ioctx_create(RGW_USAGE_LOG_POOL_NAME, io_ctx);
+  const char *usage_log_pool = params.usage_log_pool.name.c_str();
+  int r = rados->ioctx_create(usage_log_pool, io_ctx);
   if (r == -ENOENT) {
     string id;
     map<std::string, bufferlist> attrs;
-    rgw_bucket pool(RGW_USAGE_LOG_POOL_NAME);
+    rgw_bucket pool(usage_log_pool);
     r = create_bucket(id, pool, attrs, true);
     if (r < 0)
       return r;
  
     // retry
-    r = rados->ioctx_create(RGW_USAGE_LOG_POOL_NAME, io_ctx);
+    r = rados->ioctx_create(usage_log_pool, io_ctx);
   }
   if (r < 0)
     return r;
@@ -2920,7 +2935,8 @@ int RGWRados::cls_obj_usage_log_read(string& oid, string& user, uint64_t start_e
 
   *is_truncated = false;
 
-  int r = rados->ioctx_create(RGW_USAGE_LOG_POOL_NAME, io_ctx);
+  const char *usage_log_pool = params.usage_log_pool.name.c_str();
+  int r = rados->ioctx_create(usage_log_pool, io_ctx);
   if (r < 0)
     return r;
 
@@ -2934,7 +2950,8 @@ int RGWRados::cls_obj_usage_log_trim(string& oid, string& user, uint64_t start_e
 {
   librados::IoCtx io_ctx;
 
-  int r = rados->ioctx_create(RGW_USAGE_LOG_POOL_NAME, io_ctx);
+  const char *usage_log_pool = params.usage_log_pool.name.c_str();
+  int r = rados->ioctx_create(usage_log_pool, io_ctx);
   if (r < 0)
     return r;
 
@@ -3063,7 +3080,6 @@ int RGWRados::remove_temp_objects(string date, string time)
   }
   time_t epoch = mktime(&tm);
 
-  rgw_bucket bucket(RGW_INTENT_LOG_POOL_NAME);
   string prefix, delim, marker;
   vector<RGWObjEnt> objs;
   map<string, bool> common_prefixes;
@@ -3072,7 +3088,7 @@ int RGWRados::remove_temp_objects(string date, string time)
   bool is_truncated;
   IntentLogNameFilter filter(date.c_str(), &tm);
   RGWPoolIterCtx iter_ctx;
-  int r = pool_iterate_begin(bucket, iter_ctx);
+  int r = pool_iterate_begin(params.intent_log_pool, iter_ctx);
   if (r < 0) {
     cerr << "failed to list objects" << std::endl;
     return r;
@@ -3087,7 +3103,7 @@ int RGWRados::remove_temp_objects(string date, string time)
     }
     vector<RGWObjEnt>::iterator iter;
     for (iter = objs.begin(); iter != objs.end(); ++iter) {
-      process_intent_log(bucket, (*iter).name, epoch, I_DEL_OBJ | I_DEL_DIR, true);
+      process_intent_log(params.intent_log_pool, (*iter).name, epoch, I_DEL_OBJ | I_DEL_DIR, true);
     }
   } while (is_truncated);
 
index dba5196c78c21fc7960bb5f0502dbdaed255a86c..0030da4919dc06260761b7962934d83b8bb19152 100644 (file)
@@ -184,6 +184,16 @@ struct RGWPoolIterCtx {
 
 struct RGWRadosParams {
   rgw_bucket domain_root;
+  rgw_bucket control_pool;
+  rgw_bucket gc_pool;
+  rgw_bucket log_pool;
+  rgw_bucket intent_log_pool;
+  rgw_bucket usage_log_pool;
+
+  rgw_bucket user_keys_pool;
+  rgw_bucket user_email_pool;
+  rgw_bucket user_swift_pool;
+  rgw_bucket user_uid_pool;
 
   void init_default();
 };
index a61696113334d4f4c442e1c0da8f89f6443d30f1..a3e19b707d5df6afdabfdc6a4621d9980380887a 100644 (file)
 
 using namespace std;
 
-static rgw_bucket ui_key_bucket(USER_INFO_POOL_NAME);
-static rgw_bucket ui_email_bucket(USER_INFO_EMAIL_POOL_NAME);
-static rgw_bucket ui_swift_bucket(USER_INFO_SWIFT_POOL_NAME);
-static rgw_bucket ui_uid_bucket(USER_INFO_UID_POOL_NAME);
 
 /**
  * Get the anonymous (ie, unauthenticated) user info.
@@ -78,12 +74,12 @@ int rgw_store_user_info(RGWRados *store, RGWUserInfo& info, bool exclusive)
   ::encode(ui, uid_bl);
   ::encode(info, uid_bl);
 
-  ret = rgw_put_obj(store, info.user_id, ui_uid_bucket, info.user_id, uid_bl.c_str(), uid_bl.length(), exclusive);
+  ret = rgw_put_obj(store, info.user_id, store->params.user_uid_pool, info.user_id, uid_bl.c_str(), uid_bl.length(), exclusive);
   if (ret < 0)
     return ret;
 
   if (info.user_email.size()) {
-    ret = rgw_put_obj(store, info.user_id, ui_email_bucket, info.user_email, uid_bl.c_str(), uid_bl.length(), exclusive);
+    ret = rgw_put_obj(store, info.user_id, store->params.user_email_pool, info.user_email, uid_bl.c_str(), uid_bl.length(), exclusive);
     if (ret < 0)
       return ret;
   }
@@ -92,7 +88,7 @@ int rgw_store_user_info(RGWRados *store, RGWUserInfo& info, bool exclusive)
     map<string, RGWAccessKey>::iterator iter = info.access_keys.begin();
     for (; iter != info.access_keys.end(); ++iter) {
       RGWAccessKey& k = iter->second;
-      ret = rgw_put_obj(store, k.id, ui_key_bucket, k.id, uid_bl.c_str(), uid_bl.length(), exclusive);
+      ret = rgw_put_obj(store, k.id, store->params.user_keys_pool, k.id, uid_bl.c_str(), uid_bl.length(), exclusive);
       if (ret < 0)
         return ret;
     }
@@ -101,7 +97,7 @@ int rgw_store_user_info(RGWRados *store, RGWUserInfo& info, bool exclusive)
   map<string, RGWAccessKey>::iterator siter;
   for (siter = info.swift_keys.begin(); siter != info.swift_keys.end(); ++siter) {
     RGWAccessKey& k = siter->second;
-    ret = rgw_put_obj(store, info.user_id, ui_swift_bucket, k.id, uid_bl.c_str(), uid_bl.length(), exclusive);
+    ret = rgw_put_obj(store, info.user_id, store->params.user_swift_pool, k.id, uid_bl.c_str(), uid_bl.length(), exclusive);
     if (ret < 0)
       return ret;
   }
@@ -137,7 +133,7 @@ int rgw_get_user_info_from_index(RGWRados *store, string& key, rgw_bucket& bucke
  */
 int rgw_get_user_info_by_uid(RGWRados *store, string& uid, RGWUserInfo& info)
 {
-  return rgw_get_user_info_from_index(store, uid, ui_uid_bucket, info);
+  return rgw_get_user_info_from_index(store, uid, store->params.user_uid_pool, info);
 }
 
 /**
@@ -146,7 +142,7 @@ int rgw_get_user_info_by_uid(RGWRados *store, string& uid, RGWUserInfo& info)
  */
 int rgw_get_user_info_by_email(RGWRados *store, string& email, RGWUserInfo& info)
 {
-  return rgw_get_user_info_from_index(store, email, ui_email_bucket, info);
+  return rgw_get_user_info_from_index(store, email, store->params.user_email_pool, info);
 }
 
 /**
@@ -155,7 +151,7 @@ int rgw_get_user_info_by_email(RGWRados *store, string& email, RGWUserInfo& info
  */
 extern int rgw_get_user_info_by_swift(RGWRados *store, string& swift_name, RGWUserInfo& info)
 {
-  return rgw_get_user_info_from_index(store, swift_name, ui_swift_bucket, info);
+  return rgw_get_user_info_from_index(store, swift_name, store->params.user_swift_pool, info);
 }
 
 /**
@@ -164,7 +160,7 @@ extern int rgw_get_user_info_by_swift(RGWRados *store, string& swift_name, RGWUs
  */
 extern int rgw_get_user_info_by_access_key(RGWRados *store, string& access_key, RGWUserInfo& info)
 {
-  return rgw_get_user_info_from_index(store, access_key, ui_key_bucket, info);
+  return rgw_get_user_info_from_index(store, access_key, store->params.user_keys_pool, info);
 }
 
 static void get_buckets_obj(string& user_id, string& buckets_obj_id)
@@ -176,7 +172,7 @@ static void get_buckets_obj(string& user_id, string& buckets_obj_id)
 static int rgw_read_buckets_from_attr(RGWRados *store, string& user_id, RGWUserBuckets& buckets)
 {
   bufferlist bl;
-  rgw_obj obj(ui_uid_bucket, user_id);
+  rgw_obj obj(store->params.user_uid_pool, user_id);
   int ret = store->get_attr(NULL, obj, RGW_ATTR_BUCKETS, bl);
   if (ret)
     return ret;
@@ -203,7 +199,7 @@ int rgw_read_user_buckets(RGWRados *store, string user_id, RGWUserBuckets& bucke
     string buckets_obj_id;
     get_buckets_obj(user_id, buckets_obj_id);
     bufferlist bl;
-    rgw_obj obj(ui_uid_bucket, buckets_obj_id);
+    rgw_obj obj(store->params.user_uid_pool, buckets_obj_id);
     bufferlist header;
     map<string,bufferlist> m;
 
@@ -256,7 +252,7 @@ int rgw_write_buckets_attr(RGWRados *store, string user_id, RGWUserBuckets& buck
   bufferlist bl;
   buckets.encode(bl);
 
-  rgw_obj obj(ui_uid_bucket, user_id);
+  rgw_obj obj(store->params.user_uid_pool, user_id);
 
   int ret = store->set_attr(NULL, obj, RGW_ATTR_BUCKETS, bl);
 
@@ -280,7 +276,7 @@ int rgw_add_bucket(RGWRados *store, string user_id, rgw_bucket& bucket)
     string buckets_obj_id;
     get_buckets_obj(user_id, buckets_obj_id);
 
-    rgw_obj obj(ui_uid_bucket, buckets_obj_id);
+    rgw_obj obj(store->params.user_uid_pool, buckets_obj_id);
     ret = store->omap_set(obj, bucket_name, bl);
     if (ret < 0) {
       ldout(store->ctx(), 0) << "ERROR: error adding bucket to directory: "
@@ -321,7 +317,7 @@ int rgw_remove_user_bucket_info(RGWRados *store, string user_id, rgw_bucket& buc
     string buckets_obj_id;
     get_buckets_obj(user_id, buckets_obj_id);
 
-    rgw_obj obj(ui_uid_bucket, buckets_obj_id);
+    rgw_obj obj(store->params.user_uid_pool, buckets_obj_id);
     ret = store->omap_del(obj, bucket.name);
     if (ret < 0) {
       ldout(store->ctx(), 0) << "ERROR: error removing bucket from directory: "
@@ -343,28 +339,28 @@ int rgw_remove_user_bucket_info(RGWRados *store, string user_id, rgw_bucket& buc
 
 int rgw_remove_key_index(RGWRados *store, RGWAccessKey& access_key)
 {
-  rgw_obj obj(ui_key_bucket, access_key.id);
+  rgw_obj obj(store->params.user_keys_pool, access_key.id);
   int ret = store->delete_obj(NULL, obj);
   return ret;
 }
 
 int rgw_remove_uid_index(RGWRados *store, string& uid)
 {
-  rgw_obj obj(ui_uid_bucket, uid);
+  rgw_obj obj(store->params.user_uid_pool, uid);
   int ret = store->delete_obj(NULL, obj);
   return ret;
 }
 
 int rgw_remove_email_index(RGWRados *store, string& email)
 {
-  rgw_obj obj(ui_email_bucket, email);
+  rgw_obj obj(store->params.user_email_pool, email);
   int ret = store->delete_obj(NULL, obj);
   return ret;
 }
 
 int rgw_remove_swift_name_index(RGWRados *store, string& swift_name)
 {
-  rgw_obj obj(ui_swift_bucket, swift_name);
+  rgw_obj obj(store->params.user_swift_pool, swift_name);
   int ret = store->delete_obj(NULL, obj);
   return ret;
 }
@@ -411,7 +407,7 @@ int rgw_delete_user(RGWRados *store, RGWUserInfo& info) {
     }
   }
 
-  rgw_obj email_obj(ui_email_bucket, info.user_email);
+  rgw_obj email_obj(store->params.user_email_pool, info.user_email);
   ldout(store->ctx(), 10) << "removing email index: " << info.user_email << dendl;
   ret = store->delete_obj(NULL, email_obj);
   if (ret < 0 && ret != -ENOENT) {
@@ -421,7 +417,7 @@ int rgw_delete_user(RGWRados *store, RGWUserInfo& info) {
 
   string buckets_obj_id;
   get_buckets_obj(info.user_id, buckets_obj_id);
-  rgw_obj uid_bucks(ui_uid_bucket, buckets_obj_id);
+  rgw_obj uid_bucks(store->params.user_uid_pool, buckets_obj_id);
   ldout(store->ctx(), 10) << "removing user buckets index" << dendl;
   ret = store->delete_obj(NULL, uid_bucks);
   if (ret < 0 && ret != -ENOENT) {
@@ -429,7 +425,7 @@ int rgw_delete_user(RGWRados *store, RGWUserInfo& info) {
     return ret;
   }
   
-  rgw_obj uid_obj(ui_uid_bucket, info.user_id);
+  rgw_obj uid_obj(store->params.user_uid_pool, info.user_id);
   ldout(store->ctx(), 10) << "removing user index: " << info.user_id << dendl;
   ret = store->delete_obj(NULL, uid_obj);
   if (ret < 0 && ret != -ENOENT) {
index 1e570f1b6badbf3170ddbe25f63c1869d73c6432..3ae6b38a15655dab45d71cfb49239121eb67fe08 100644 (file)
@@ -9,10 +9,6 @@
 
 using namespace std;
 
-#define USER_INFO_POOL_NAME ".users"
-#define USER_INFO_EMAIL_POOL_NAME ".users.email"
-#define USER_INFO_SWIFT_POOL_NAME ".users.swift"
-#define USER_INFO_UID_POOL_NAME ".users.uid"
 #define RGW_USER_ANON_ID "anonymous"
 
 /**