]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: remove the rgw_get_bucket_info functions
authorGreg Farnum <gregory.farnum@dreamhost.com>
Tue, 4 Oct 2011 20:42:19 +0000 (13:42 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Wed, 5 Oct 2011 16:25:55 +0000 (09:25 -0700)
Push them down into the RGWAccess layers.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/rgw/rgw_access.h
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket.cc
src/rgw/rgw_fs.cc
src/rgw/rgw_fs.h
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 0008432f41aa5eba9228d212bc8adba14db5c6c4..03d0a66229f52a5d4ba71e9917fbcf2bd96b67e8 100644 (file)
@@ -263,6 +263,10 @@ public:
   virtual void set_intent_cb(void *ctx, int (*cb)(void *user_ctx, rgw_obj& obj, RGWIntentEvent intent)) {}
 
   virtual int get_bucket_stats(rgw_bucket& bucket, map<RGWObjCategory, RGWBucketStats>& stats) { return -ENOTSUP; }
+
+  /* The bucket here can either be the bucket name identifier, or the ID
+   * in period format: ".123" */
+  virtual int get_bucket_info(string& bucket, RGWBucketInfo& info) = 0;
 };
 
 class RGWStoreManager {
index b14247d7ef0d3330aef19ae650da7d70f7232963..402515f3ab08fc27d5abc7d4ae20a5f7cc622e00 100644 (file)
@@ -342,7 +342,7 @@ static int create_bucket(string bucket_str, string& user_id, string& display_nam
   policy.create_default(user_id, display_name);
   policy.encode(aclbl);
 
-  ret = rgw_get_bucket_info(bucket_str, bucket_info);
+  ret = rgwstore->get_bucket_info(bucket_str, bucket_info);
   if (ret < 0)
     return ret;
 
@@ -515,7 +515,7 @@ int process_intent_log(rgw_bucket& bucket, string& oid, time_t epoch, int flags,
 int bucket_stats(rgw_bucket& bucket, Formatter *formatter)
 {
   RGWBucketInfo bucket_info;
-  int r = rgw_get_bucket_info(bucket.name, bucket_info);
+  int r = rgwstore->get_bucket_info(bucket.name, bucket_info);
   if (r < 0)
     return r;
 
@@ -828,7 +828,12 @@ int main(int argc, char **argv)
 
   if ((!bucket_name.empty()) || bucket_id >= 0) {
     if (bucket_id >= 0) {
-      int ret = rgw_get_bucket_info_id(bucket_id, bucket_info);
+      char bucket_char[16];
+      snprintf(bucket_char, sizeof(bucket_char), ".%lld",
+               (long long unsigned)bucket_id);
+      string bucket_string(bucket_char);
+      int ret = rgwstore->get_bucket_info(bucket_string, bucket_info);
+
       if (ret < 0) {
         cerr << "could not retrieve bucket info for bucket_id=" << bucket_id << std::endl;
         return ret;
@@ -841,7 +846,7 @@ int main(int argc, char **argv)
     } else {
       string bucket_name_str = bucket_name;
       RGWBucketInfo bucket_info;
-      int r = rgw_get_bucket_info(bucket_name_str, bucket_info);
+      int r = rgwstore->get_bucket_info(bucket_name_str, bucket_info);
       if (r < 0) {
         cerr << "could not get bucket info for bucket=" << bucket_name_str << std::endl;
         return r;
index db8251bc94ff0e9f6fb887b37132ca237f8fff40..8a5346daae05d873bd179310918674907ecec7af 100644 (file)
 static rgw_bucket pi_buckets(BUCKETS_POOL_NAME);
 
 static string pool_name_prefix = "p";
-
-int rgw_get_bucket_info(string& bucket_name, RGWBucketInfo& info)
-{
-  bufferlist bl;
-
-  int ret = rgw_get_obj(pi_buckets, bucket_name, bl);
-  if (ret < 0) {
-    if (ret != -ENOENT)
-      return ret;
-
-    info.bucket.name = bucket_name;
-    info.bucket.pool = bucket_name; // for now
-    return 0;
-  }
-
-  bufferlist::iterator iter = bl.begin();
-  try {
-    ::decode(info, iter);
-  } catch (buffer::error& err) {
-    RGW_LOG(0) << "ERROR: could not decode buffer info, caught buffer::error" << dendl;
-    return -EIO;
-  }
-
-  RGW_LOG(0) << "rgw_get_bucket_info: bucket=" << info.bucket << " owner " << info.owner << dendl;
-
-  return 0;
-}
-
-int rgw_get_bucket_info_id(uint64_t bucket_id, RGWBucketInfo& info)
-{
-  char bucket_char[16];
-  snprintf(bucket_char, sizeof(bucket_char), ".%lld",
-           (long long unsigned)bucket_id);
-  string bucket_string(bucket_char);
-
-  return rgw_get_bucket_info(bucket_string, info);
-}
index a43991db0ff1fc0391ec9922d5720ac931c682fc..d687651509302057d0845ce268b9bc8a22b80f3a 100644 (file)
@@ -660,3 +660,7 @@ done:
   return r;
 }
 
+int RGWFS::get_bucket_info(string& bucket_name, RGWBucketInfo& info)
+{
+  return -ENOTSUP;
+}
index e3a9009a4a9a3504bafeb5b8dc4d3d9ec0d0fa8c..0260c720529270ace443f98acb10de5c6c8f8ac9 100644 (file)
@@ -64,6 +64,8 @@ public:
   void finish_get_obj(void **handle);
   int read(void *ctx, rgw_obj& obj, off_t ofs, size_t size, bufferlist& bl);
   int obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime);
+
+  virtual int get_bucket_info(string& bucket_name, RGWBucketInfo& info);
 };
 
 #endif
index 0edd2fc389c46a7b3782b312ef2a65658bc12201..17ba579da1df86a2dbe95dcc4663c2c144f28942 100644 (file)
@@ -235,7 +235,7 @@ int read_acls(struct req_state *s, bool only_bucket)
 
   if (s->bucket_name_str.size()) {
     RGWBucketInfo bucket_info;
-    ret = rgw_get_bucket_info(s->bucket_name_str, bucket_info);
+    ret = rgwstore->get_bucket_info(s->bucket_name_str, bucket_info);
     if (ret < 0) {
       RGW_LOG(0) << "couldn't get bucket from bucket_name (name=" << s->bucket_name_str << ")" << dendl;
       return ret;
@@ -834,7 +834,7 @@ int RGWCopyObj::verify_permission()
 
   RGWBucketInfo bucket_info;
 
-  ret = rgw_get_bucket_info(src_bucket_name, bucket_info);
+  ret = rgwstore->get_bucket_info(src_bucket_name, bucket_info);
   if (ret < 0)
     return ret;
 
index 2e335746d6c71b8acad1e9614279850a8c6d020d..2064f9a9aada8b15dc0805e2243732c2a534b3c0 100644 (file)
@@ -1715,6 +1715,34 @@ int RGWRados::get_bucket_stats(rgw_bucket& bucket, map<RGWObjCategory, RGWBucket
   return 0;
 }
 
+int RGWRados::get_bucket_info(string& bucket_name, RGWBucketInfo& info)
+{
+  bufferlist bl;
+
+  int ret = rgw_get_obj(pi_buckets_rados, bucket_name, bl);
+  if (ret < 0) {
+    if (ret != -ENOENT)
+      return ret;
+
+    info.bucket.name = bucket_name;
+    info.bucket.pool = bucket_name; // for now
+    return 0;
+  }
+
+  bufferlist::iterator iter = bl.begin();
+  try {
+    ::decode(info, iter);
+  } catch (buffer::error& err) {
+    RGW_LOG(0) << "ERROR: could not decode buffer info, caught buffer::error" << dendl;
+    return -EIO;
+  }
+
+  RGW_LOG(0) << "rgw_get_bucket_info: bucket=" << info.bucket << " owner " << info.owner << dendl;
+
+  return 0;
+}
+
+
 int RGWRados::tmap_get(rgw_obj& obj, bufferlist& header, std::map<string, bufferlist>& m)
 {
   bufferlist bl;
index 71330c7fe8a7e5ac6127a1c14db1c3efe94fae74..0df2a52aa2502d3fc2a2df3ed67b908dbfc0d731 100644 (file)
@@ -291,6 +291,7 @@ public:
 
   int decode_policy(bufferlist& bl, ACLOwner *owner);
   int get_bucket_stats(rgw_bucket& bucket, map<RGWObjCategory, RGWBucketStats>& stats);
+  virtual int get_bucket_info(string& bucket_name, RGWBucketInfo& info);
 
   int cls_rgw_init_index(rgw_bucket& bucket, string& oid);
   int cls_obj_prepare_op(rgw_bucket& bucket, uint8_t op, string& tag, string& name);