]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: move a bunch of stuff into rgw_dencoder
authorSage Weil <sage@redhat.com>
Sat, 19 Jul 2014 05:27:25 +0000 (22:27 -0700)
committerSage Weil <sage@redhat.com>
Sat, 19 Jul 2014 05:39:46 +0000 (22:39 -0700)
This will help out ceph-dencoder ...

Signed-off-by: Sage Weil <sage@redhat.com>
src/rgw/Makefile.am
src/rgw/rgw_acl.cc
src/rgw/rgw_acl_s3.cc
src/rgw/rgw_acl_s3.h
src/rgw/rgw_dencoder.cc
src/rgw/rgw_rados.cc

index f31ded37eeeba0cbb256aec56a2d23623ac0132b..c1ac7f4c08248a571ba5ca5d275f81ef3fec11c4 100644 (file)
@@ -32,7 +32,8 @@ librgw_la_SOURCES =  \
        rgw/rgw_metadata.cc \
        rgw/rgw_replica_log.cc \
        rgw/rgw_keystone.cc \
-       rgw/rgw_quota.cc
+       rgw/rgw_quota.cc \
+       rgw/rgw_dencoder.cc
 librgw_la_CXXFLAGS = -Woverloaded-virtual ${AM_CXXFLAGS}
 noinst_LTLIBRARIES += librgw.la
 
index 657eb6e455da4d3a0cc154fcd71fadab675549f8..669a83d10ea8832e582c862bd4740439ec14e766 100644 (file)
@@ -118,8 +118,3 @@ bool RGWAccessControlPolicy::verify_permission(string& uid, int user_perm_mask,
 }
 
 
-ACLGroupTypeEnum ACLGrant::uri_to_group(string& uri)
-{
-  // this is required for backward compatibility
-  return ACLGrant_S3::uri_to_group(uri);
-}
index 8dca6233feed1bb6bac66be2a0a16b5e9cd32d2f..785324c99872a727c2681e4f35e5fd13c750fef2 100644 (file)
@@ -247,16 +247,6 @@ bool ACLGrant_S3::group_to_uri(ACLGroupTypeEnum group, string& uri)
   }
 }
 
-ACLGroupTypeEnum ACLGrant_S3::uri_to_group(string& uri)
-{
-  if (uri.compare(rgw_uri_all_users) == 0)
-    return ACL_GROUP_ALL_USERS;
-  else if (uri.compare(rgw_uri_auth_users) == 0)
-    return ACL_GROUP_AUTHENTICATED_USERS;
-
-  return ACL_GROUP_NONE;
-}
-
 bool RGWAccessControlList_S3::xml_end(const char *el) {
   XMLObjIter iter = find("Grant");
   ACLGrant_S3 *grant = static_cast<ACLGrant_S3 *>(iter.get_next());
index 7727732f4bda88222d0cfb64895fc7d6888810fa..13a11c1676865032cc92d8033a4b4cccb13e0e50 100644 (file)
@@ -15,6 +15,7 @@
 #include "rgw_xml.h"
 #include "rgw_acl.h"
 
+
 using namespace std;
 
 class RGWRados;
index 4ec4736c9ae5e5d6f67107b29bd1502869474806..9f923bcc4a7859c2a419aa7354e34cb224f8199e 100644 (file)
@@ -10,6 +10,8 @@
 
 #include "common/Formatter.h"
 
+static string shadow_ns = RGW_OBJ_NS_SHADOW;
+
 void RGWObjManifestPart::generate_test_instances(std::list<RGWObjManifestPart*>& o)
 {
   o.push_back(new RGWObjManifestPart);
@@ -22,6 +24,110 @@ void RGWObjManifestPart::generate_test_instances(std::list<RGWObjManifestPart*>&
   o.push_back(p);
 }
 
+void RGWObjManifest::obj_iterator::seek(uint64_t o)
+{
+  ofs = o;
+  if (manifest->explicit_objs) {
+    explicit_iter = manifest->objs.upper_bound(ofs);
+    if (explicit_iter != manifest->objs.begin()) {
+      --explicit_iter;
+    }
+    if (ofs >= manifest->obj_size) {
+      ofs = manifest->obj_size;
+      return;
+    }
+    update_explicit_pos();
+    update_location();
+    return;
+  }
+  if (o < manifest->get_head_size()) {
+    rule_iter = manifest->rules.begin();
+    stripe_ofs = 0;
+    stripe_size = manifest->get_head_size();
+    if (rule_iter != manifest->rules.end()) {
+      cur_part_id = rule_iter->second.start_part_num;
+      cur_override_prefix = rule_iter->second.override_prefix;
+    }
+    update_location();
+    return;
+  }
+
+  rule_iter = manifest->rules.upper_bound(ofs);
+  next_rule_iter = rule_iter;
+  if (rule_iter != manifest->rules.begin()) {
+    --rule_iter;
+  }
+
+  if (rule_iter == manifest->rules.end()) {
+    update_location();
+    return;
+  }
+
+  RGWObjManifestRule& rule = rule_iter->second;
+
+  if (rule.part_size > 0) {
+    cur_part_id = rule.start_part_num + (ofs - rule.start_ofs) / rule.part_size;
+  } else {
+    cur_part_id = rule.start_part_num;
+  }
+  part_ofs = rule.start_ofs + (cur_part_id - rule.start_part_num) * rule.part_size;
+
+  if (rule.stripe_max_size > 0) {
+    cur_stripe = (ofs - part_ofs) / rule.stripe_max_size;
+
+    stripe_ofs = part_ofs + cur_stripe * rule.stripe_max_size;
+    if (!cur_part_id && manifest->get_head_size() > 0) {
+      cur_stripe++;
+    }
+  } else {
+    cur_stripe = 0;
+    stripe_ofs = part_ofs;
+  }
+
+  if (!rule.part_size) {
+    stripe_size = rule.stripe_max_size;
+    stripe_size = MIN(manifest->get_obj_size() - stripe_ofs, stripe_size);
+  } else {
+    uint64_t next = MIN(stripe_ofs + rule.stripe_max_size, part_ofs + rule.part_size);
+    stripe_size = next - stripe_ofs;
+  }
+
+  cur_override_prefix = rule.override_prefix;
+
+  update_location();
+}
+
+void RGWObjManifest::obj_iterator::update_location()
+{
+  if (manifest->explicit_objs) {
+    location = explicit_iter->second.loc;
+    return;
+  }
+
+  const rgw_obj& head = manifest->get_head();
+
+  if (ofs < manifest->get_head_size()) {
+    location = head;
+    return;
+  }
+
+  manifest->get_implicit_location(cur_part_id, cur_stripe, ofs, &cur_override_prefix, &location);
+}
+
+void RGWObjManifest::obj_iterator::update_explicit_pos()
+{
+  ofs = explicit_iter->first;
+  stripe_ofs = ofs;
+
+  map<uint64_t, RGWObjManifestPart>::iterator next_iter = explicit_iter;
+  ++next_iter;
+  if (next_iter != manifest->objs.end()) {
+    stripe_size = next_iter->first - ofs;
+  } else {
+    stripe_size = manifest->obj_size - ofs;
+  }
+}
+
 void RGWObjManifest::generate_test_instances(std::list<RGWObjManifest*>& o)
 {
   RGWObjManifest *m = new RGWObjManifest;
@@ -40,6 +146,52 @@ void RGWObjManifest::generate_test_instances(std::list<RGWObjManifest*>& o)
   o.push_back(new RGWObjManifest);
 }
 
+void RGWObjManifest::get_implicit_location(uint64_t cur_part_id, uint64_t cur_stripe, uint64_t ofs, string *override_prefix, rgw_obj *location)
+{
+  string oid;
+  if (!override_prefix || override_prefix->empty()) {
+    oid = prefix;
+  } else {
+    oid = *override_prefix;
+  }
+  string ns;
+
+  if (!cur_part_id) {
+    if (ofs < max_head_size) {
+      *location = head_obj;
+      return;
+    } else {
+      char buf[16];
+      snprintf(buf, sizeof(buf), "%d", (int)cur_stripe);
+      oid += buf;
+      ns = shadow_ns;
+    }
+  } else {
+    char buf[32];
+    if (cur_stripe == 0) {
+      snprintf(buf, sizeof(buf), ".%d", (int)cur_part_id);
+      oid += buf;
+      ns= RGW_OBJ_NS_MULTIPART;
+    } else {
+      snprintf(buf, sizeof(buf), ".%d_%d", (int)cur_part_id, (int)cur_stripe);
+      oid += buf;
+      ns = shadow_ns;
+    }
+  }
+
+  rgw_bucket *bucket;
+
+  if (!tail_bucket.name.empty()) {
+    bucket = &tail_bucket;
+  } else {
+    bucket = &head_obj.bucket;
+  }
+
+  location->init_ns(*bucket, oid, ns);
+}
+
+
+
 void rgw_log_entry::generate_test_instances(list<rgw_log_entry*>& o)
 {
   rgw_log_entry *e = new rgw_log_entry;
@@ -97,6 +249,22 @@ void ACLGranteeType::generate_test_instances(list<ACLGranteeType*>& o)
 static string rgw_uri_all_users = RGW_URI_ALL_USERS;
 static string rgw_uri_auth_users = RGW_URI_AUTH_USERS;
 
+ACLGroupTypeEnum ACLGrant::uri_to_group(string& uri)
+{
+  // this is required for backward compatibility
+  return ACLGrant_S3::uri_to_group(uri);
+}
+
+ACLGroupTypeEnum ACLGrant_S3::uri_to_group(string& uri)
+{
+  if (uri.compare(rgw_uri_all_users) == 0)
+    return ACL_GROUP_ALL_USERS;
+  else if (uri.compare(rgw_uri_auth_users) == 0)
+    return ACL_GROUP_AUTHENTICATED_USERS;
+
+  return ACL_GROUP_NONE;
+}
+
 void ACLGrant::generate_test_instances(list<ACLGrant*>& o)
 {
   string id, name, email;
index bf3eceefe942ddb0fa40b9fc8bc58ac3b0a7f4a8..6ab81b09c92da2797ee96af45d34099d862c847c 100644 (file)
@@ -532,110 +532,6 @@ void RGWObjVersionTracker::prepare_op_for_write(ObjectWriteOperation *op)
   }
 }
 
-void RGWObjManifest::obj_iterator::update_explicit_pos()
-{
-  ofs = explicit_iter->first;
-  stripe_ofs = ofs;
-
-  map<uint64_t, RGWObjManifestPart>::iterator next_iter = explicit_iter;
-  ++next_iter;
-  if (next_iter != manifest->objs.end()) {
-    stripe_size = next_iter->first - ofs;
-  } else {
-    stripe_size = manifest->obj_size - ofs;
-  }
-}
-
-void RGWObjManifest::obj_iterator::seek(uint64_t o)
-{
-  ofs = o;
-  if (manifest->explicit_objs) {
-    explicit_iter = manifest->objs.upper_bound(ofs);
-    if (explicit_iter != manifest->objs.begin()) {
-      --explicit_iter;
-    }
-    if (ofs >= manifest->obj_size) {
-      ofs = manifest->obj_size;
-      return;
-    }
-    update_explicit_pos();
-    update_location();
-    return;
-  }
-  if (o < manifest->get_head_size()) {
-    rule_iter = manifest->rules.begin();
-    stripe_ofs = 0;
-    stripe_size = manifest->get_head_size();
-    if (rule_iter != manifest->rules.end()) {
-      cur_part_id = rule_iter->second.start_part_num;
-      cur_override_prefix = rule_iter->second.override_prefix;
-    }
-    update_location();
-    return;
-  }
-
-  rule_iter = manifest->rules.upper_bound(ofs);
-  next_rule_iter = rule_iter;
-  if (rule_iter != manifest->rules.begin()) {
-    --rule_iter;
-  }
-
-  if (rule_iter == manifest->rules.end()) {
-    update_location();
-    return;
-  }
-
-  RGWObjManifestRule& rule = rule_iter->second;
-
-  if (rule.part_size > 0) {
-    cur_part_id = rule.start_part_num + (ofs - rule.start_ofs) / rule.part_size;
-  } else {
-    cur_part_id = rule.start_part_num;
-  }
-  part_ofs = rule.start_ofs + (cur_part_id - rule.start_part_num) * rule.part_size;
-
-  if (rule.stripe_max_size > 0) {
-    cur_stripe = (ofs - part_ofs) / rule.stripe_max_size;
-
-    stripe_ofs = part_ofs + cur_stripe * rule.stripe_max_size;
-    if (!cur_part_id && manifest->get_head_size() > 0) {
-      cur_stripe++;
-    }
-  } else {
-    cur_stripe = 0;
-    stripe_ofs = part_ofs;
-  }
-
-  if (!rule.part_size) {
-    stripe_size = rule.stripe_max_size;
-    stripe_size = MIN(manifest->get_obj_size() - stripe_ofs, stripe_size);
-  } else {
-    uint64_t next = MIN(stripe_ofs + rule.stripe_max_size, part_ofs + rule.part_size);
-    stripe_size = next - stripe_ofs;
-  }
-
-  cur_override_prefix = rule.override_prefix;
-
-  update_location();
-}
-
-void RGWObjManifest::obj_iterator::update_location()
-{
-  if (manifest->explicit_objs) {
-    location = explicit_iter->second.loc;
-    return;
-  }
-
-  const rgw_obj& head = manifest->get_head();
-
-  if (ofs < manifest->get_head_size()) {
-    location = head;
-    return;
-  }
-
-  manifest->get_implicit_location(cur_part_id, cur_stripe, ofs, &cur_override_prefix, &location);
-}
-
 void RGWObjManifest::obj_iterator::operator++()
 {
   if (manifest->explicit_objs) {
@@ -811,50 +707,6 @@ const RGWObjManifest::obj_iterator& RGWObjManifest::obj_end()
   return end_iter;
 }
 
-void RGWObjManifest::get_implicit_location(uint64_t cur_part_id, uint64_t cur_stripe, uint64_t ofs, string *override_prefix, rgw_obj *location)
-{
-  string oid;
-  if (!override_prefix || override_prefix->empty()) {
-    oid = prefix;
-  } else {
-    oid = *override_prefix;
-  }
-  string ns;
-
-  if (!cur_part_id) {
-    if (ofs < max_head_size) {
-      *location = head_obj;
-      return;
-    } else {
-      char buf[16];
-      snprintf(buf, sizeof(buf), "%d", (int)cur_stripe);
-      oid += buf;
-      ns = shadow_ns;
-    }
-  } else {
-    char buf[32];
-    if (cur_stripe == 0) {
-      snprintf(buf, sizeof(buf), ".%d", (int)cur_part_id);
-      oid += buf;
-      ns= RGW_OBJ_NS_MULTIPART;
-    } else {
-      snprintf(buf, sizeof(buf), ".%d_%d", (int)cur_part_id, (int)cur_stripe);
-      oid += buf;
-      ns = shadow_ns;
-    }
-  }
-
-  rgw_bucket *bucket;
-
-  if (!tail_bucket.name.empty()) {
-    bucket = &tail_bucket;
-  } else {
-    bucket = &head_obj.bucket;
-  }
-
-  location->init_ns(*bucket, oid, ns);
-}
-
 RGWObjManifest::obj_iterator RGWObjManifest::obj_find(uint64_t ofs)
 {
   if (ofs > obj_size) {