Skip to content

Commit

Permalink
rgw: use rgw_raw_obj in manifest code
Browse files Browse the repository at this point in the history
This drags in multiple related changes that are needed in order to
support that.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
  • Loading branch information
yehudasa committed Oct 13, 2016
1 parent 6f67578 commit e414516
Show file tree
Hide file tree
Showing 9 changed files with 334 additions and 213 deletions.
2 changes: 1 addition & 1 deletion src/cls/rgw/cls_rgw_types.h
Expand Up @@ -854,7 +854,7 @@ struct cls_rgw_obj_chain {

cls_rgw_obj_chain() {}

void push_obj(const string& pool, cls_rgw_obj_key& key, string& loc) {
void push_obj(const string& pool, const cls_rgw_obj_key& key, const string& loc) {
cls_rgw_obj obj;
obj.pool = pool;
obj.key = key;
Expand Down
13 changes: 6 additions & 7 deletions src/rgw/rgw_bucket.cc
Expand Up @@ -659,13 +659,12 @@ int rgw_remove_bucket_bypass_gc(RGWRados *store, rgw_bucket& bucket,
}

if (astate->has_manifest) {
rgw_obj head_obj;
RGWObjManifest& manifest = astate->manifest;
RGWObjManifest::obj_iterator miter = manifest.obj_begin();
rgw_obj head_obj = manifest.get_obj();
rgw_raw_obj raw_head_obj;
RGWRados::obj_to_raw(head_obj, &raw_head_obj);

if (miter.get_location().ns.empty()) {
head_obj = miter.get_location();
}

for (; miter != manifest.obj_end() && max_aio--; ++miter) {
if (!max_aio) {
Expand All @@ -677,13 +676,13 @@ int rgw_remove_bucket_bypass_gc(RGWRados *store, rgw_bucket& bucket,
max_aio = concurrent_max;
}

rgw_obj last_obj = miter.get_location();
if (last_obj == head_obj) {
rgw_raw_obj last_obj = miter.get_location();
if (last_obj == raw_head_obj) {
// have the head obj deleted at the end
continue;
}

ret = store->delete_obj_aio(last_obj, bucket, info, astate, handles, keep_index_consistent);
ret = store->delete_raw_obj_aio(last_obj, handles);
if (ret < 0) {
lderr(store->ctx()) << "ERROR: delete obj aio failed with " << ret << dendl;
return ret;
Expand Down
20 changes: 16 additions & 4 deletions src/rgw/rgw_common.h
Expand Up @@ -830,7 +830,7 @@ struct rgw_raw_obj {
oid = _oid;
}

bool empty() {
bool empty() const {
return oid.empty();
}

Expand Down Expand Up @@ -873,6 +873,10 @@ struct rgw_raw_obj {
return (r < 0);
}

bool operator==(const rgw_raw_obj& o) const {
return (pool == o.pool && oid == o.oid && loc == o.loc);
}

void dump(Formatter *f) const;
void decode_json(JSONObj *obj);
};
Expand Down Expand Up @@ -1684,15 +1688,15 @@ class rgw_obj {
}
}

bool empty() {
bool empty() const {
return object.empty();
}

bool have_null_instance() {
return instance == "null";
}

bool have_instance() {
bool have_instance() const {
return !instance.empty();
}

Expand Down Expand Up @@ -1780,7 +1784,7 @@ class rgw_obj {
}
}

string& get_hash_object() {
const string& get_hash_object() const {
return index_hash_source.empty() ? orig_obj : index_hash_source;
}
/**
Expand Down Expand Up @@ -1880,6 +1884,14 @@ class rgw_obj {
return in_extra_data;
}

const rgw_pool& get_data_pool() const {
if (!in_extra_data) {
return bucket.placement.data_pool;
} else {
return bucket.placement.data_extra_pool;
}
}

void encode(bufferlist& bl) const {
ENCODE_START(5, 3, bl);
::encode(bucket.name, bl);
Expand Down
16 changes: 10 additions & 6 deletions src/rgw/rgw_dencoder.cc
Expand Up @@ -112,11 +112,11 @@ void RGWObjManifest::obj_iterator::seek(uint64_t o)
void RGWObjManifest::obj_iterator::update_location()
{
if (manifest->explicit_objs) {
location = explicit_iter->second.loc;
RGWRados::obj_to_raw(explicit_iter->second.loc, &location);
return;
}

const rgw_obj& head = manifest->get_head();
const rgw_raw_obj& head = manifest->get_head();

if (ofs < manifest->get_head_size()) {
location = head;
Expand Down Expand Up @@ -159,7 +159,7 @@ 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)
void RGWObjManifest::get_implicit_location(uint64_t cur_part_id, uint64_t cur_stripe, uint64_t ofs, string *override_prefix, rgw_raw_obj *location)
{
string oid;
if (!override_prefix || override_prefix->empty()) {
Expand Down Expand Up @@ -194,17 +194,21 @@ void RGWObjManifest::get_implicit_location(uint64_t cur_part_id, uint64_t cur_st

rgw_bucket *bucket;

rgw_obj loc;

if (!tail_bucket.name.empty()) {
bucket = &tail_bucket;
} else {
bucket = &head_obj.bucket;
bucket = &obj.bucket;
}

location->init_ns(*bucket, oid, ns);
loc.init_ns(*bucket, oid, ns);

// Always overwrite instance with tail_instance
// to get the right shadow object location
location->set_instance(tail_instance);
loc.set_instance(tail_instance);

RGWRados::obj_to_raw(loc, location);
}


Expand Down
9 changes: 6 additions & 3 deletions src/rgw/rgw_op.cc
Expand Up @@ -2567,9 +2567,9 @@ int RGWPutObjProcessor_Multipart::prepare(RGWRados *store, string *oid_rand)
return r;
}

head_obj = manifest_gen.get_cur_obj();
cur_obj = manifest_gen.get_cur_obj();
rgw_raw_obj_to_obj(bucket, cur_obj, &head_obj);
head_obj.index_hash_source = obj_str;
cur_obj = head_obj;

return 0;
}
Expand Down Expand Up @@ -4734,7 +4734,10 @@ void RGWAbortMultipart::execute()
store->update_gc_chain(meta_obj, obj_part.manifest, &chain);
RGWObjManifest::obj_iterator oiter = obj_part.manifest.obj_begin();
if (oiter != obj_part.manifest.obj_end()) {
rgw_obj head = oiter.get_location();
rgw_obj head;
rgw_raw_obj raw_head = oiter.get_location();
rgw_raw_obj_to_obj(s->bucket, raw_head, &head);

rgw_obj_key key;
head.get_index_key(&key);
remove_objs.push_back(key);
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_op.h
Expand Up @@ -1525,7 +1525,7 @@ static inline int put_data_and_throttle(RGWPutObjProcessor *processor,

do {
void *handle;
rgw_obj obj;
rgw_raw_obj obj;

int ret = processor->handle_data(data, ofs, hash, &handle, &obj, &again);
if (ret < 0)
Expand Down
4 changes: 2 additions & 2 deletions src/rgw/rgw_orphan.cc
Expand Up @@ -437,8 +437,8 @@ int RGWOrphanSearch::handle_stat_result(map<int, list<string> >& oids, RGWRados:

RGWObjManifest::obj_iterator miter;
for (miter = manifest.obj_begin(); miter != manifest.obj_end(); ++miter) {
const rgw_obj& loc = miter.get_location();
string s = bucket.bucket_id + "_" + loc.get_object();
const rgw_raw_obj& loc = miter.get_location();
string s = loc.oid;
obj_oids.insert(obj_fingerprint(s));
}
}
Expand Down

0 comments on commit e414516

Please sign in to comment.