~james-page/ubuntu/vivid/ceph/0.93

« back to all changes in this revision

Viewing changes to src/rgw/rgw_dencoder.cc

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-07-30 10:15:40 UTC
  • mfrom: (0.1.29 sid)
  • Revision ID: package-import@ubuntu.com-20140730101540-b7gsn9jqkye4a5ty
Tags: 0.80.5-1
* New upstream stable release:
  - d/p/firefly-post-release.patch: Dropped, no longer required.
  - d/lib{rados2,cephfs1}.symbols: Update with new symbols.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
#include "common/Formatter.h"
10
10
 
 
11
static string shadow_ns = RGW_OBJ_NS_SHADOW;
 
12
 
11
13
void RGWObjManifestPart::generate_test_instances(std::list<RGWObjManifestPart*>& o)
12
14
{
13
15
  o.push_back(new RGWObjManifestPart);
20
22
  o.push_back(p);
21
23
}
22
24
 
 
25
void RGWObjManifest::obj_iterator::seek(uint64_t o)
 
26
{
 
27
  ofs = o;
 
28
  if (manifest->explicit_objs) {
 
29
    explicit_iter = manifest->objs.upper_bound(ofs);
 
30
    if (explicit_iter != manifest->objs.begin()) {
 
31
      --explicit_iter;
 
32
    }
 
33
    if (ofs >= manifest->obj_size) {
 
34
      ofs = manifest->obj_size;
 
35
      return;
 
36
    }
 
37
    update_explicit_pos();
 
38
    update_location();
 
39
    return;
 
40
  }
 
41
  if (o < manifest->get_head_size()) {
 
42
    rule_iter = manifest->rules.begin();
 
43
    stripe_ofs = 0;
 
44
    stripe_size = manifest->get_head_size();
 
45
    if (rule_iter != manifest->rules.end()) {
 
46
      cur_part_id = rule_iter->second.start_part_num;
 
47
      cur_override_prefix = rule_iter->second.override_prefix;
 
48
    }
 
49
    update_location();
 
50
    return;
 
51
  }
 
52
 
 
53
  rule_iter = manifest->rules.upper_bound(ofs);
 
54
  next_rule_iter = rule_iter;
 
55
  if (rule_iter != manifest->rules.begin()) {
 
56
    --rule_iter;
 
57
  }
 
58
 
 
59
  if (rule_iter == manifest->rules.end()) {
 
60
    update_location();
 
61
    return;
 
62
  }
 
63
 
 
64
  RGWObjManifestRule& rule = rule_iter->second;
 
65
 
 
66
  if (rule.part_size > 0) {
 
67
    cur_part_id = rule.start_part_num + (ofs - rule.start_ofs) / rule.part_size;
 
68
  } else {
 
69
    cur_part_id = rule.start_part_num;
 
70
  }
 
71
  part_ofs = rule.start_ofs + (cur_part_id - rule.start_part_num) * rule.part_size;
 
72
 
 
73
  if (rule.stripe_max_size > 0) {
 
74
    cur_stripe = (ofs - part_ofs) / rule.stripe_max_size;
 
75
 
 
76
    stripe_ofs = part_ofs + cur_stripe * rule.stripe_max_size;
 
77
    if (!cur_part_id && manifest->get_head_size() > 0) {
 
78
      cur_stripe++;
 
79
    }
 
80
  } else {
 
81
    cur_stripe = 0;
 
82
    stripe_ofs = part_ofs;
 
83
  }
 
84
 
 
85
  if (!rule.part_size) {
 
86
    stripe_size = rule.stripe_max_size;
 
87
    stripe_size = MIN(manifest->get_obj_size() - stripe_ofs, stripe_size);
 
88
  } else {
 
89
    uint64_t next = MIN(stripe_ofs + rule.stripe_max_size, part_ofs + rule.part_size);
 
90
    stripe_size = next - stripe_ofs;
 
91
  }
 
92
 
 
93
  cur_override_prefix = rule.override_prefix;
 
94
 
 
95
  update_location();
 
96
}
 
97
 
 
98
void RGWObjManifest::obj_iterator::update_location()
 
99
{
 
100
  if (manifest->explicit_objs) {
 
101
    location = explicit_iter->second.loc;
 
102
    return;
 
103
  }
 
104
 
 
105
  const rgw_obj& head = manifest->get_head();
 
106
 
 
107
  if (ofs < manifest->get_head_size()) {
 
108
    location = head;
 
109
    return;
 
110
  }
 
111
 
 
112
  manifest->get_implicit_location(cur_part_id, cur_stripe, ofs, &cur_override_prefix, &location);
 
113
}
 
114
 
 
115
void RGWObjManifest::obj_iterator::update_explicit_pos()
 
116
{
 
117
  ofs = explicit_iter->first;
 
118
  stripe_ofs = ofs;
 
119
 
 
120
  map<uint64_t, RGWObjManifestPart>::iterator next_iter = explicit_iter;
 
121
  ++next_iter;
 
122
  if (next_iter != manifest->objs.end()) {
 
123
    stripe_size = next_iter->first - ofs;
 
124
  } else {
 
125
    stripe_size = manifest->obj_size - ofs;
 
126
  }
 
127
}
 
128
 
23
129
void RGWObjManifest::generate_test_instances(std::list<RGWObjManifest*>& o)
24
130
{
25
131
  RGWObjManifest *m = new RGWObjManifest;
38
144
  o.push_back(new RGWObjManifest);
39
145
}
40
146
 
 
147
void RGWObjManifest::get_implicit_location(uint64_t cur_part_id, uint64_t cur_stripe, uint64_t ofs, string *override_prefix, rgw_obj *location)
 
148
{
 
149
  string oid;
 
150
  if (!override_prefix || override_prefix->empty()) {
 
151
    oid = prefix;
 
152
  } else {
 
153
    oid = *override_prefix;
 
154
  }
 
155
  string ns;
 
156
 
 
157
  if (!cur_part_id) {
 
158
    if (ofs < max_head_size) {
 
159
      *location = head_obj;
 
160
      return;
 
161
    } else {
 
162
      char buf[16];
 
163
      snprintf(buf, sizeof(buf), "%d", (int)cur_stripe);
 
164
      oid += buf;
 
165
      ns = shadow_ns;
 
166
    }
 
167
  } else {
 
168
    char buf[32];
 
169
    if (cur_stripe == 0) {
 
170
      snprintf(buf, sizeof(buf), ".%d", (int)cur_part_id);
 
171
      oid += buf;
 
172
      ns= RGW_OBJ_NS_MULTIPART;
 
173
    } else {
 
174
      snprintf(buf, sizeof(buf), ".%d_%d", (int)cur_part_id, (int)cur_stripe);
 
175
      oid += buf;
 
176
      ns = shadow_ns;
 
177
    }
 
178
  }
 
179
 
 
180
  rgw_bucket *bucket;
 
181
 
 
182
  if (!tail_bucket.name.empty()) {
 
183
    bucket = &tail_bucket;
 
184
  } else {
 
185
    bucket = &head_obj.bucket;
 
186
  }
 
187
 
 
188
  location->init_ns(*bucket, oid, ns);
 
189
}
 
190
 
 
191
 
 
192
 
41
193
void rgw_log_entry::generate_test_instances(list<rgw_log_entry*>& o)
42
194
{
43
195
  rgw_log_entry *e = new rgw_log_entry;
95
247
static string rgw_uri_all_users = RGW_URI_ALL_USERS;
96
248
static string rgw_uri_auth_users = RGW_URI_AUTH_USERS;
97
249
 
 
250
ACLGroupTypeEnum ACLGrant::uri_to_group(string& uri)
 
251
{
 
252
  // this is required for backward compatibility
 
253
  return ACLGrant_S3::uri_to_group(uri);
 
254
}
 
255
 
 
256
ACLGroupTypeEnum ACLGrant_S3::uri_to_group(string& uri)
 
257
{
 
258
  if (uri.compare(rgw_uri_all_users) == 0)
 
259
    return ACL_GROUP_ALL_USERS;
 
260
  else if (uri.compare(rgw_uri_auth_users) == 0)
 
261
    return ACL_GROUP_AUTHENTICATED_USERS;
 
262
 
 
263
  return ACL_GROUP_NONE;
 
264
}
 
265
 
98
266
void ACLGrant::generate_test_instances(list<ACLGrant*>& o)
99
267
{
100
268
  string id, name, email;