cls_rgw_obj_key(const string &_name) : name(_name) {}
cls_rgw_obj_key(const string& n, const string& i) : name(n), instance(i) {}
+ void set(const string& _name) {
+ name = _name;
+ }
+
bool operator==(const cls_rgw_obj_key& k) const {
return (name.compare(k.name) == 0) &&
(instance.compare(k.instance) == 0);
}
return (r < 0);
}
+ bool operator<=(const cls_rgw_obj_key& k) const {
+ return !(k < *this);
+ }
+ bool empty() {
+ return name.empty();
+ }
void encode(bufferlist &bl) const {
ENCODE_START(1, 1, bl);
::encode(name, bl);
string prefix;
string delim;
- vector<RGWObjEnt> result;
+ vector<rgw_bucket_dir_entry> result;
map<string, bool> common_prefixes;
string ns;
count += result.size();
- for (vector<RGWObjEnt>::iterator iter = result.begin(); iter != result.end(); ++iter) {
+ for (vector<rgw_bucket_dir_entry>::iterator iter = result.begin(); iter != result.end(); ++iter) {
rgw_obj_key key = iter->key;
rgw_obj obj(bucket, key);
string prefix;
string delim;
- vector<RGWObjEnt> result;
+ vector<rgw_bucket_dir_entry> result;
map<string, bool> common_prefixes;
string ns;
count += result.size();
- for (vector<RGWObjEnt>::iterator iter = result.begin(); iter != result.end(); ++iter) {
- RGWObjEnt& entry = *iter;
+ for (vector<rgw_bucket_dir_entry>::iterator iter = result.begin(); iter != result.end(); ++iter) {
+ rgw_bucket_dir_entry& entry = *iter;
encode_json("entry", entry, formatter);
}
formatter->flush(cout);
return 1;
}
- rgw_obj obj(bucket, key.name);
- obj.set_instance(key.instance);
+ rgw_obj obj(bucket, key);
ret = store->bi_put(bucket, obj, entry);
if (ret < 0) {
bool is_truncated = true;
- rgw_obj_key marker;
+ rgw_obj_index_key marker;
string prefix;
formatter->open_object_section("result");
formatter->dump_string("bucket", bucket_name);
formatter->open_array_section("objects");
while (is_truncated) {
- map<string, RGWObjEnt> result;
+ map<string, rgw_bucket_dir_entry> result;
int r = store->cls_bucket_list(bucket_info, RGW_NO_SHARD, marker, prefix, 1000, true,
result, &is_truncated, &marker,
bucket_object_check_filter);
if (r == -ENOENT)
break;
- map<string, RGWObjEnt>::iterator iter;
+ map<string, rgw_bucket_dir_entry>::iterator iter;
for (iter = result.begin(); iter != result.end(); ++iter) {
rgw_obj_key key = iter->second.key;
- RGWObjEnt& entry = iter->second;
+ rgw_bucket_dir_entry& entry = iter->second;
formatter->open_object_section("object");
formatter->dump_string("name", key.name);
formatter->dump_string("instance", key.instance);
- formatter->dump_int("size", entry.size);
- utime_t ut(entry.mtime);
+ formatter->dump_int("size", entry.meta.size);
+ utime_t ut(entry.meta.mtime);
ut.gmtime(formatter->dump_stream("mtime"));
- if ((entry.size < min_rewrite_size) ||
- (entry.size > max_rewrite_size) ||
+ if ((entry.meta.size < min_rewrite_size) ||
+ (entry.meta.size > max_rewrite_size) ||
(start_epoch > 0 && start_epoch > (uint64_t)ut.sec()) ||
(end_epoch > 0 && end_epoch < (uint64_t)ut.sec())) {
formatter->dump_string("status", "Skipped");
} else {
- rgw_obj obj(bucket, key.name);
- obj.set_instance(key.instance);
+ rgw_obj obj(bucket, key);
bool need_rewrite = true;
if (min_rewrite_stripe_size > 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- list<rgw_obj_key> oid_list;
+ list<rgw_obj_index_key> oid_list;
rgw_obj_key key(object, object_version);
- oid_list.push_back(key);
+ rgw_obj_index_key index_key;
+ key.get_index_key(&index_key);
+ oid_list.push_back(index_key);
ret = store->remove_objs_from_index(bucket_info, oid_list);
if (ret < 0) {
cerr << "ERROR: remove_obj_from_index() returned error: " << cpp_strerror(-ret) << std::endl;
return rgw_bucket_instance_store_info(store, key, bl, false, &attrs, objv_tracker, real_time());
}
-static void dump_mulipart_index_results(list<rgw_obj_key>& objs_to_unlink,
+static void dump_mulipart_index_results(list<rgw_obj_index_key>& objs_to_unlink,
Formatter *f)
{
// make sure that an appropiately titled header has been opened previously
- list<rgw_obj_key>::iterator oiter = objs_to_unlink.begin();
+ auto oiter = objs_to_unlink.begin();
f->open_array_section("invalid_multipart_entries");
{
int ret;
map<RGWObjCategory, RGWStorageStats> stats;
- std::vector<RGWObjEnt> objs;
+ std::vector<rgw_bucket_dir_entry> objs;
map<string, bool> common_prefixes;
RGWBucketInfo info;
RGWObjectCtx obj_ctx(store);
if (ret < 0)
return ret;
- std::vector<RGWObjEnt>::iterator it = objs.begin();
+ std::vector<rgw_bucket_dir_entry>::iterator it = objs.begin();
for (; it != objs.end(); ++it) {
- ret = rgw_remove_object(store, info, bucket, (*it).key);
+ rgw_obj_key key(it->key);
+ ret = rgw_remove_object(store, info, bucket, key);
if (ret < 0)
return ret;
}
{
int ret;
map<RGWObjCategory, RGWStorageStats> stats;
- std::vector<RGWObjEnt> objs;
+ std::vector<rgw_bucket_dir_entry> objs;
map<string, bool> common_prefixes;
RGWBucketInfo info;
RGWObjectCtx obj_ctx(store);
return ret;
while (!objs.empty()) {
- std::vector<RGWObjEnt>::iterator it = objs.begin();
+ std::vector<rgw_bucket_dir_entry>::iterator it = objs.begin();
for (; it != objs.end(); ++it) {
RGWObjState *astate = NULL;
- rgw_obj obj(bucket, (*it).key.name);
- obj.set_instance((*it).key.instance);
+ rgw_obj obj(bucket, (*it).key);
ret = store->get_obj_state(&obj_ctx, obj, &astate, false);
if (ret == -ENOENT) {
return 0;
}
-static void dump_bucket_index(map<string, RGWObjEnt> result, Formatter *f)
+static void dump_bucket_index(map<string, rgw_bucket_dir_entry> result, Formatter *f)
{
- map<string, RGWObjEnt>::iterator iter;
+ map<string, rgw_bucket_dir_entry>::iterator iter;
for (iter = result.begin(); iter != result.end(); ++iter) {
f->dump_string("object", iter->first);
}
}
int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
- list<rgw_obj_key>& objs_to_unlink, std::string *err_msg)
+ list<rgw_obj_index_key>& objs_to_unlink, std::string *err_msg)
{
bool fix_index = op_state.will_fix_index();
rgw_bucket bucket = op_state.get_bucket();
bool is_truncated;
map<string, bool> meta_objs;
- map<rgw_obj_key, string> all_objs;
+ map<rgw_obj_index_key, string> all_objs;
RGWBucketInfo bucket_info;
RGWObjectCtx obj_ctx(store);
list_op.params.list_versions = true;
do {
- vector<RGWObjEnt> result;
+ vector<rgw_bucket_dir_entry> result;
int r = list_op.list_objects(max, &result, &common_prefixes, &is_truncated);
if (r < 0) {
set_err_msg(err_msg, "failed to list objects in bucket=" + bucket.name +
return r;
}
- vector<RGWObjEnt>::iterator iter;
+ vector<rgw_bucket_dir_entry>::iterator iter;
for (iter = result.begin(); iter != result.end(); ++iter) {
- RGWObjEnt& ent = *iter;
+ rgw_bucket_dir_entry& ent = *iter;
rgw_obj obj(bucket, ent.key);
obj.set_ns(ns);
- rgw_obj_key key;
+ rgw_obj_index_key key;
obj.get_index_key(&key);
string oid = key.name;
} while (is_truncated);
- map<rgw_obj_key, string>::iterator aiter;
- for (aiter = all_objs.begin(); aiter != all_objs.end(); ++aiter) {
+ for (auto aiter = all_objs.begin(); aiter != all_objs.end(); ++aiter) {
string& name = aiter->second;
+ rgw_obj_index_key index_key(aiter->first);
+
if (meta_objs.find(name) == meta_objs.end()) {
objs_to_unlink.push_back(aiter->first);
}
store->cls_obj_set_bucket_tag_timeout(bucket_info, BUCKET_TAG_TIMEOUT);
string prefix;
- rgw_obj_key marker;
+ rgw_obj_index_key marker;
bool is_truncated = true;
Formatter *formatter = flusher.get_formatter();
formatter->open_object_section("objects");
while (is_truncated) {
- map<string, RGWObjEnt> result;
+ map<string, rgw_bucket_dir_entry> result;
int r = store->cls_bucket_list(bucket_info, RGW_NO_SHARD, marker, prefix, 1000, true,
result, &is_truncated, &marker,
RGWFormatterFlusher& flusher)
{
int ret;
- map<string, RGWObjEnt> result;
+ map<string, rgw_bucket_dir_entry> result;
map<RGWObjCategory, RGWStorageStats> existing_stats;
map<RGWObjCategory, RGWStorageStats> calculated_stats;
- list<rgw_obj_key> objs_to_unlink;
+ list<rgw_obj_index_key> objs_to_unlink;
RGWBucket bucket;
formatter->open_array_section("buckets");
if (store->list_buckets_init(&handle) >= 0) {
- RGWObjEnt obj;
+ rgw_bucket_dir_entry obj;
while (store->list_buckets_next(obj, &handle) >= 0) {
if (show_stats)
bucket_stats(store, user_id.tenant, obj.key.name, formatter);
int init(RGWRados *storage, RGWBucketAdminOpState& op_state);
int check_bad_index_multipart(RGWBucketAdminOpState& op_state,
- list<rgw_obj_key>& objs_to_unlink, std::string *err_msg = NULL);
+ list<rgw_obj_index_key>& objs_to_unlink, std::string *err_msg = NULL);
int check_object_index(RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher,
int list_objects_raw_init(rgw_pool& pool, RGWAccessHandle *handle) {
return T::list_objects_raw_init(pool, handle);
}
- int list_objects_raw_next(RGWObjEnt& obj, RGWAccessHandle *handle) {
+ int list_objects_raw_next(rgw_bucket_dir_entry& obj, RGWAccessHandle *handle) {
return T::list_objects_raw_next(obj, handle);
}
void init_meta_info(bool *found_bad_meta);
};
+typedef cls_rgw_obj_key rgw_obj_index_key;
+
struct rgw_obj_key {
string name;
string instance;
+ string ns;
rgw_obj_key() {}
// cppcheck-suppress noExplicitConstructor
- rgw_obj_key(const string& n) {
- set(n);
- }
- rgw_obj_key(const string& n, const string& i) {
- set(n, i);
- }
+ rgw_obj_key(const string& n) : name(n) {}
+ rgw_obj_key(const string& n, const string& i) : name(n), instance(i) {}
- // cppcheck-suppress noExplicitConstructor
- rgw_obj_key(const cls_rgw_obj_key& k) {
- set(k);
- }
-
- void set(const cls_rgw_obj_key& k) {
- name = k.name;
+ rgw_obj_key(const rgw_obj_index_key& k) {
+ parse_index_key(k.name, &name, &ns);
instance = k.instance;
}
- void transform(cls_rgw_obj_key *k) {
- k->name = name;
- k->instance = instance;
+ static void parse_index_key(const string& key, string *name, string *ns) {
+ if (key[0] != '_') {
+ *name = key;
+ ns->clear();
+ return;
+ }
+ if (key[1] == '_') {
+ *name = key.substr(1);
+ ns->clear();
+ return;
+ }
+ ssize_t pos = key.find('_', 1);
+ if (pos < 0) {
+ /* shouldn't happen, just use key */
+ *name = key;
+ ns->clear();
+ return;
+ }
+
+ *name = key.substr(pos + 1);
+ *ns = key.substr(1, pos -1);
}
void set(const string& n) {
name = n;
instance.clear();
+ ns.clear();
+ }
+
+ string get_index_key_name() const {
+ if (ns.empty()) {
+ if (name.size() < 1 || name[0] != '_') {
+ return name;
+ }
+ return string("_") + name;
+ };
+
+ char buf[ns.size() + 16];
+ snprintf(buf, sizeof(buf), "_%s_", ns.c_str());
+ return string(buf) + name;
+ };
+
+ void get_index_key(rgw_obj_index_key *key) const {
+ key->name = get_index_key_name();
+ key->instance = instance;
}
void set(const string& n, const string& i) {
name = n;
instance = i;
+ ns.clear();
}
bool empty() const {
return !(k < *this);
}
void encode(bufferlist& bl) const {
- ENCODE_START(1, 1, bl);
+ ENCODE_START(2, 1, bl);
::encode(name, bl);
::encode(instance, bl);
+ ::encode(ns, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
- DECODE_START(1, bl);
+ DECODE_START(2, bl);
::decode(name, bl);
::decode(instance, bl);
+ if (struct_v >= 2) {
+ ::decode(ns, bl);
+ }
DECODE_FINISH(bl);
}
void dump(Formatter *f) const;
}
}
+inline ostream& operator<<(ostream& out, const rgw_obj_index_key &o) {
+ if (o.instance.empty()) {
+ return out << o.name;
+ } else {
+ return out << o.name << "[" << o.instance << "]";
+ }
+}
+
struct rgw_aws4_auth {
string date;
string expires;
~req_state();
};
-/** Store basic data on an object */
-struct RGWObjEnt {
- rgw_obj_key key;
- std::string ns;
- rgw_user owner;
- std::string owner_display_name;
- uint64_t size{0};
- uint64_t accounted_size{0};
- ceph::real_time mtime;
- string etag;
- string content_type;
- string tag;
- uint32_t flags;
- uint64_t versioned_epoch;
-
- RGWObjEnt() : flags(0), versioned_epoch(0) {}
-
- void dump(Formatter *f) const;
-
- bool is_current() {
- uint32_t test_flags = RGW_BUCKET_DIRENT_FLAG_VER | RGW_BUCKET_DIRENT_FLAG_CURRENT;
- return (flags & RGW_BUCKET_DIRENT_FLAG_VER) == 0 ||
- (flags & test_flags) == test_flags;
- }
- bool is_delete_marker() { return (flags & RGW_BUCKET_DIRENT_FLAG_DELETE_MARKER) != 0; }
- bool is_visible() {
- return is_current() && !is_delete_marker();
- }
-};
-
/** Store basic data on bucket */
struct RGWBucketEnt {
rgw_bucket bucket;
rgw_obj(const rgw_bucket& b, const std::string& name) {
init(b, name);
}
- rgw_obj(const rgw_bucket& b, const rgw_obj_key& k) : in_extra_data(false) {
- from_index_key(b, k);
+ rgw_obj(const rgw_bucket& b, const rgw_obj_key& k) {
+ init(b, k.name);
+ instance = k.instance;
+ }
+ rgw_obj(const rgw_bucket& b, const rgw_obj_index_key& k) : bucket(b) {
+ rgw_obj_key::parse_index_key(k.name, &name, &ns);
+ set_instance(k.instance);
}
void init(const rgw_bucket& b, const std::string& name) {
bucket = b;
name = n;
}
+ void set_key(const rgw_obj_key& k) {
+ set_name(k.name);
+ set_instance(k.instance);
+ }
+
string get_oid() const {
if (ns.empty() && !need_to_encode_instance()) {
if (name.size() < 1 || name[0] != '_') {
return string(buf) + name;
};
- void from_index_key(const rgw_bucket& b, const rgw_obj_key& key) {
- if (key.name[0] != '_') {
- init(b, key.name);
- set_instance(key.instance);
- return;
- }
- if (key.name[1] == '_') {
- init(b, key.name.substr(1));
- set_instance(key.instance);
- return;
- }
- ssize_t pos = key.name.find('_', 1);
- if (pos < 0) {
- /* shouldn't happen, just use key */
- init(b, key.name);
- set_instance(key.instance);
- return;
- }
-
- init_ns(b, key.name.substr(pos + 1), key.name.substr(1, pos -1));
- set_instance(key.instance);
- }
-
- void get_index_key(rgw_obj_key *key) const {
+ void get_index_key(rgw_obj_index_key *key) const {
key->name = get_index_key_name();
key->instance = instance;
}
string op_id = store->unique_id(store->get_new_req_id());
map<string, bufferlist> attrs;
- rgw_obj src_obj(bucket_info.bucket, key.name);
- src_obj.set_instance(key.instance);
+ rgw_obj src_obj(bucket_info.bucket, key);
rgw_obj dest_obj(src_obj);
string client_id = store->zone_id() + buf;
string op_id = store->unique_id(store->get_new_req_id());
- rgw_obj src_obj(bucket_info.bucket, key.name);
- src_obj.set_instance(key.instance);
+ rgw_obj src_obj(bucket_info.bucket, key);
rgw_obj dest_obj(src_obj);
{
RGWObjectCtx obj_ctx(store);
- rgw_obj obj(bucket_info.bucket, key.name);
- obj.set_instance(key.instance);
+ rgw_obj obj(bucket_info.bucket, key);
ldout(store->ctx(), 0) << __func__ << "(): deleting obj=" << obj << dendl;
return item_name.substr(prefix.length());
}
-void RGWSwiftWebsiteListingFormatter::dump_object(const RGWObjEnt& objent)
+void RGWSwiftWebsiteListingFormatter::dump_object(const rgw_bucket_dir_entry& objent)
{
const auto name = format_name(objent.key.name);
ss << boost::format(R"(<tr class="item %s">)")
<< boost::format(R"(<td class="colname"><a href="%s">%s</a></td>)")
% url_encode(name)
% HTMLHelper::escape(name)
- << boost::format(R"(<td class="colsize">%lld</td>)") % objent.size
+ << boost::format(R"(<td class="colsize">%lld</td>)") % objent.meta.size
<< boost::format(R"(<td class="coldate">%s</td>)")
- % dump_time_to_str(objent.mtime)
+ % dump_time_to_str(objent.meta.mtime)
<< R"(</tr>)";
}
void generate_header(const std::string& dir_path,
const std::string& css_path);
void generate_footer();
- void dump_object(const RGWObjEnt& objent);
+ void dump_object(const rgw_bucket_dir_entry& objent);
void dump_subdir(const std::string& name);
};
}
ctx->locator_set_key(obj.loc);
- rgw_obj key_obj;
- key_obj.set_name(obj.key.name);
- key_obj.set_instance(obj.key.instance);
- dout(0) << "gc::process: removing " << obj.pool << ":" << key_obj.get_oid() << dendl;
+ const string& oid = obj.key.name; /* just stored raw oid there */
+
+ dout(0) << "gc::process: removing " << obj.pool << ":" << obj.key.name << dendl;
ObjectWriteOperation op;
cls_refcount_put(op, info.tag, true);
- ret = ctx->operate(key_obj.get_oid(), &op);
+ ret = ctx->operate(oid, &op);
if (ret == -ENOENT)
ret = 0;
if (ret < 0) {
remove_tag = false;
- dout(0) << "failed to remove " << obj.pool << ":" << key_obj.get_oid() << "@" << obj.loc << dendl;
+ dout(0) << "failed to remove " << obj.pool << ":" << oid << "@" << obj.loc << dendl;
}
if (going_down()) // leave early, even if tag isn't removed, it's ok
encode_json("instance", instance, f);
}
-void RGWObjEnt::dump(Formatter *f) const
-{
- encode_json("name", key.name, f);
- encode_json("instance", key.instance, f);
- encode_json("namespace", ns, f);
- encode_json("owner", owner.to_str(), f);
- encode_json("owner_display_name", owner_display_name, f);
- encode_json("size", size, f);
- utime_t ut(mtime);
- encode_json("mtime", ut, f);
- encode_json("etag", etag, f);
- encode_json("content_type", content_type, f);
- encode_json("tag", tag, f);
- encode_json("flags", flags, f);
-}
-
void RGWBucketEnt::dump(Formatter *f) const
{
encode_json("bucket", bucket, f);
map<string, bufferlist> bucket_attrs;
string next_marker, no_ns, list_versions;
bool is_truncated;
- vector<RGWObjEnt> objs;
+ vector<rgw_bucket_dir_entry> objs;
RGWObjectCtx obj_ctx(store);
vector<std::string> result;
result = split(shard_id, ':');
utime_t now = ceph_clock_now();
for (auto obj_iter = objs.begin(); obj_iter != objs.end(); ++obj_iter) {
- if (obj_has_expired(now - ceph::real_clock::to_time_t(obj_iter->mtime), prefix_iter->second.expiration)) {
+ rgw_obj_key key(obj_iter->key);
+
+ if (!key.ns.empty()) {
+ continue;
+ }
+
+ if (obj_has_expired(now - ceph::real_clock::to_time_t(obj_iter->meta.mtime), prefix_iter->second.expiration)) {
RGWObjectCtx rctx(store);
- rgw_obj obj(bucket_info.bucket, obj_iter->key.name);
+ rgw_obj obj(bucket_info.bucket, key);
RGWObjState *state;
int ret = store->get_obj_state(&rctx, obj, &state, false);
if (ret < 0) {
return ret;
}
- if (state->mtime != obj_iter->mtime)//Check mtime again to avoid delete a recently update object as much as possible
+ if (state->mtime != obj_iter->meta.mtime)//Check mtime again to avoid delete a recently update object as much as possible
continue;
ret = remove_expired_obj(bucket_info, obj_iter->key, true);
if (ret < 0) {
ldout(cct, 0) << "ERROR: remove_expired_obj " << dendl;
} else {
- ldout(cct, 10) << "DELETED:" << bucket_name << ":" << obj_iter->key.name << dendl;
+ ldout(cct, 10) << "DELETED:" << bucket_name << ":" << key << dendl;
}
}
}
pre_marker = list_op.get_next_marker();
}
list_op.params.prefix = prefix_iter->first;
- RGWObjEnt pre_obj;
+ rgw_bucket_dir_entry pre_obj;
do {
if (!objs.empty()) {
pre_obj = objs.back();
} else {
remove_indeed = false;
}
- mtime = obj_iter->mtime;
+ mtime = obj_iter->meta.mtime;
expiration = prefix_iter->second.expiration;
} else {
if (prefix_iter->second.noncur_expiration <=0) {
continue;
}
remove_indeed = true;
- mtime = (obj_iter == objs.begin())?pre_obj.mtime:(obj_iter - 1)->mtime;
+ mtime = (obj_iter == objs.begin())?pre_obj.meta.mtime:(obj_iter - 1)->meta.mtime;
expiration = prefix_iter->second.noncur_expiration;
}
if (obj_has_expired(now - ceph::real_clock::to_time_t(mtime), expiration)) {
if (obj_iter->is_visible()) {
RGWObjectCtx rctx(store);
- rgw_obj obj(bucket_info.bucket, obj_iter->key.name);
- obj.set_instance(obj_iter->key.instance);
+ rgw_obj obj(bucket_info.bucket, obj_iter->key);
RGWObjState *state;
int ret = store->get_obj_state(&rctx, obj, &state, false);
if (ret < 0) {
return ret;
}
- if (state->mtime != obj_iter->mtime)//Check mtime again to avoid delete a recently update object as much as possible
+ if (state->mtime != obj_iter->meta.mtime)//Check mtime again to avoid delete a recently update object as much as possible
continue;
}
ret = remove_expired_obj(bucket_info, obj_iter->key, remove_indeed);
if (ret < 0) {
ldout(cct, 0) << "ERROR: remove_expired_obj " << dendl;
} else {
- ldout(cct, 10) << "DELETED:" << bucket_name << ":" << obj_iter->key.name << dendl;
+ ldout(cct, 10) << "DELETED:" << bucket_name << ":" << obj_iter->key << dendl;
}
}
}
obj.init_ns(bucket, oid, mp_ns);
obj.set_in_extra_data(true);
} else {
- obj = rgw_obj(bucket, object.name);
- obj.set_instance(object.instance);
+ obj = rgw_obj(bucket, object);
}
RGWObjectCtx *obj_ctx = static_cast<RGWObjectCtx *>(s->obj_ctx);
int ret = get_obj_policy_from_attr(s->cct, store, *obj_ctx,
}
s->object_acl = new RGWAccessControlPolicy(s->cct);
- rgw_obj obj(s->bucket, s->object.name);
- obj.set_instance(s->object.instance);
+ rgw_obj obj(s->bucket, s->object);
store->set_atomic(s->obj_ctx, obj);
if (prefetch_data) {
int RGWGetObj::verify_permission()
{
- obj = rgw_obj(s->bucket, s->object.name);
- obj.set_instance(s->object.instance);
+ obj = rgw_obj(s->bucket, s->object);
store->set_atomic(s->obj_ctx, obj);
if (get_data) {
store->set_prefetch_data(s->obj_ctx, obj);
}
int RGWGetObj::read_user_manifest_part(rgw_bucket& bucket,
- const RGWObjEnt& ent,
+ const rgw_bucket_dir_entry& ent,
RGWAccessControlPolicy * const bucket_policy,
const off_t start_ofs,
const off_t end_ofs)
RGWRados::Object op_target(store, s->bucket_info, obj_ctx, part);
RGWRados::Object::Read read_op(&op_target);
- read_op.conds.if_match = ent.etag.c_str();
+ read_op.conds.if_match = ent.meta.etag.c_str();
read_op.params.attrs = &attrs;
read_op.params.obj_size = &obj_size;
read_op.params.perr = &s->err;
if (need_decompress)
{
- if (cs_info.orig_size != ent.size) {
+ if (cs_info.orig_size != ent.meta.size) {
// hmm.. something wrong, object not as expected, abort!
ldout(s->cct, 0) << "ERROR: expected cs_info.orig_size=" << cs_info.orig_size <<
- ", actual read size=" << ent.size << dendl;
+ ", actual read size=" << ent.meta.size << dendl;
return -EIO;
}
decompress.emplace(s->cct, &cs_info, partial_content, filter);
}
else
{
- if (obj_size != ent.size) {
+ if (obj_size != ent.meta.size) {
// hmm.. something wrong, object not as expected, abort!
- ldout(s->cct, 0) << "ERROR: expected obj_size=" << obj_size << ", actual read size=" << ent.size << dendl;
+ ldout(s->cct, 0) << "ERROR: expected obj_size=" << obj_size << ", actual read size=" << ent.meta.size << dendl;
return -EIO;
}
}
return -EPERM;
}
- if (ent.size == 0) {
+ if (ent.meta.size == 0) {
return 0;
}
uint64_t * const pobj_size,
string * const pobj_sum,
int (*cb)(rgw_bucket& bucket,
- const RGWObjEnt& ent,
+ const rgw_bucket_dir_entry& ent,
RGWAccessControlPolicy * const bucket_policy,
off_t start_ofs,
off_t end_ofs,
bool found_start = false, found_end = false, handled_end = false;
string delim;
bool is_truncated;
- vector<RGWObjEnt> objs;
+ vector<rgw_bucket_dir_entry> objs;
utime_t start_time = ceph_clock_now();
return r;
}
- for (RGWObjEnt& ent : objs) {
+ for (rgw_bucket_dir_entry& ent : objs) {
uint64_t cur_total_len = obj_ofs;
- uint64_t start_ofs = 0, end_ofs = ent.size;
+ uint64_t start_ofs = 0, end_ofs = ent.meta.size;
- if (!found_start && cur_total_len + ent.size > (uint64_t)ofs) {
+ if (!found_start && cur_total_len + ent.meta.size > (uint64_t)ofs) {
start_ofs = ofs - obj_ofs;
found_start = true;
}
- obj_ofs += ent.size;
+ obj_ofs += ent.meta.size;
if (pobj_sum) {
- etag_sum.Update((const byte *)ent.etag.c_str(),
- ent.etag.length());
+ etag_sum.Update((const byte *)ent.meta.etag.c_str(),
+ ent.meta.etag.length());
}
if (!found_end && obj_ofs > (uint64_t)end) {
off_t end,
map<uint64_t, rgw_slo_part>& slo_parts,
int (*cb)(rgw_bucket& bucket,
- const RGWObjEnt& ent,
+ const rgw_bucket_dir_entry& ent,
RGWAccessControlPolicy *bucket_policy,
off_t start_ofs,
off_t end_ofs,
for (; iter != slo_parts.end() && !found_end; ++iter) {
rgw_slo_part& part = iter->second;
- RGWObjEnt ent;
+ rgw_bucket_dir_entry ent;
ent.key.name = part.obj_name;
- ent.size = part.size;
- ent.etag = part.etag;
+ ent.meta.size = part.size;
+ ent.meta.etag = part.etag;
uint64_t cur_total_len = obj_ofs;
- uint64_t start_ofs = 0, end_ofs = ent.size;
+ uint64_t start_ofs = 0, end_ofs = ent.meta.size;
- if (!found_start && cur_total_len + ent.size > (uint64_t)ofs) {
+ if (!found_start && cur_total_len + ent.meta.size > (uint64_t)ofs) {
start_ofs = ofs - obj_ofs;
found_start = true;
}
- obj_ofs += ent.size;
+ obj_ofs += ent.meta.size;
if (!found_end && obj_ofs > (uint64_t)end) {
end_ofs = end - cur_total_len + 1;
}
static int get_obj_user_manifest_iterate_cb(rgw_bucket& bucket,
- const RGWObjEnt& ent,
+ const rgw_bucket_dir_entry& ent,
RGWAccessControlPolicy * const bucket_policy,
const off_t start_ofs,
const off_t end_ofs,
rgw_bucket cs_bucket(copy_source_bucket_info.bucket);
rgw_obj_key cs_object(copy_source_object_name, copy_source_version_id);
- rgw_obj obj(cs_bucket, cs_object.name);
- obj.set_instance(cs_object.instance);
+ rgw_obj obj(cs_bucket, cs_object);
store->set_atomic(s->obj_ctx, obj);
store->set_prefetch_data(s->obj_ctx, obj);
new_end = lst;
rgw_obj_key obj_key(copy_source_object_name, copy_source_version_id);
- rgw_obj obj(copy_source_bucket_info.bucket, obj_key.name);
- obj.set_instance(obj_key.instance);
+ rgw_obj obj(copy_source_bucket_info.bucket, obj_key);
RGWRados::Object op_target(store, copy_source_bucket_info, *static_cast<RGWObjectCtx *>(s->obj_ctx), obj);
RGWRados::Object::Read read_op(&op_target);
return;
}
- rgw_obj obj(s->bucket, s->object.name);
- obj.set_instance(s->object.instance);
+ rgw_obj obj(s->bucket, s->object);
map<string, bufferlist> attrs;
uint64_t min_part_size = s->cct->_conf->rgw_multipart_min_part_size;
- list<rgw_obj_key> remove_objs; /* objects to be removed from index listing */
+ list<rgw_obj_index_key> remove_objs; /* objects to be removed from index listing */
bool versioned_object = s->bucket_info.versioning_enabled();
compressed = true;
}
- rgw_obj_key remove_key;
+ rgw_obj_index_key remove_key;
src_obj.get_index_key(&remove_key);
remove_objs.push_back(remove_key);
meta_obj.index_hash_source = s->object.name;
cls_rgw_obj_chain chain;
- list<rgw_obj_key> remove_objs;
+ list<rgw_obj_index_key> remove_objs;
do {
op_ret = list_multipart_parts(store, s, upload_id, meta_oid, max_parts,
rgw_raw_obj raw_head = oiter.get_location().get_raw_obj(store);
rgw_raw_obj_to_obj(s->bucket, raw_head, &head);
- rgw_obj_key key;
+ rgw_obj_index_key key;
head.get_index_key(&key);
remove_objs.push_back(key);
}
void RGWListBucketMultiparts::execute()
{
- vector<RGWObjEnt> objs;
+ vector<rgw_bucket_dir_entry> objs;
string marker_meta;
op_ret = get_params();
op_ret = list_op.list_objects(max_uploads, &objs, &common_prefixes,
&is_truncated);
if (!objs.empty()) {
- vector<RGWObjEnt>::iterator iter;
+ vector<rgw_bucket_dir_entry>::iterator iter;
RGWMultipartUploadEntry entry;
for (iter = objs.begin(); iter != objs.end(); ++iter) {
- rgw_obj_key& key = iter->key;
+ rgw_obj_key key(iter->key);
if (!entry.mp.from_meta(key.name))
continue;
entry.obj = *iter;
void pre_exec();
void execute();
int read_user_manifest_part(rgw_bucket& bucket,
- const RGWObjEnt& ent,
+ const rgw_bucket_dir_entry& ent,
RGWAccessControlPolicy *bucket_policy,
off_t start_ofs,
off_t end_ofs);
string encoding_type;
bool list_versions;
int max;
- vector<RGWObjEnt> objs;
+ vector<rgw_bucket_dir_entry> objs;
map<string, bool> common_prefixes;
int default_max;
};
struct RGWMultipartUploadEntry {
- RGWObjEnt obj;
+ rgw_bucket_dir_entry obj;
RGWMPObj mp;
};
int count = 0;
do {
- vector<RGWObjEnt> result;
+ vector<rgw_bucket_dir_entry> result;
#define MAX_LIST_OBJS_ENTRIES 100
ret = list_op.list_objects(MAX_LIST_OBJS_ENTRIES, &result, NULL, &truncated);
return -ret;
}
- for (vector<RGWObjEnt>::iterator iter = result.begin(); iter != result.end(); ++iter) {
- RGWObjEnt& entry = *iter;
+ for (vector<rgw_bucket_dir_entry>::iterator iter = result.begin(); iter != result.end(); ++iter) {
+ rgw_bucket_dir_entry& entry = *iter;
if (entry.key.instance.empty()) {
ldout(store->ctx(), 20) << "obj entry: " << entry.key.name << dendl;
} else {
ldout(store->ctx(), 20) << "obj entry: " << entry.key.name << " [" << entry.key.instance << "]" << dendl;
}
- ldout(store->ctx(), 20) << __func__ << ": entry.key.name=" << entry.key.name << " entry.key.instance=" << entry.key.instance << " entry.ns=" << entry.ns << dendl;
+ ldout(store->ctx(), 20) << __func__ << ": entry.key.name=" << entry.key.name << " entry.key.instance=" << entry.key.instance << dendl;
rgw_obj obj(bucket_info.bucket, entry.key);
- obj.set_ns(entry.ns);
RGWRados::Object op_target(store, bucket_info, obj_ctx, obj);
* handle is updated.
* returns 0 on success, -ERR# otherwise.
*/
-int RGWRados::list_buckets_next(RGWObjEnt& obj, RGWAccessHandle *handle)
+int RGWRados::list_buckets_next(rgw_bucket_dir_entry& obj, RGWAccessHandle *handle)
{
librados::NObjectIterator *state = (librados::NObjectIterator *)*handle;
return -ENOENT;
}
- obj.key.set((*state)->get_oid());
+ obj.key.name = (*state)->get_oid();
if (obj.key.name[0] == '_') {
obj.key.name = obj.key.name.substr(1);
}
#define MAX_OBJEXP_SHARDS_PRIME 7877
-int RGWRados::objexp_key_shard(const rgw_obj_key& key)
+int RGWRados::objexp_key_shard(const rgw_obj_index_key& key)
{
string obj_key = key.name + key.instance;
int num_shards = cct->_conf->rgw_objexp_hints_num_shards;
const string& tenant_name,
const string& bucket_name,
const string& bucket_id,
- const rgw_obj_key& obj_key)
+ const rgw_obj_index_key& obj_key)
{
const string keyext = objexp_hint_get_keyext(tenant_name, bucket_name,
bucket_id, obj_key);
* common_prefixes: if delim is filled in, any matching prefixes are placed here.
* is_truncated: if number of objects in the bucket is bigger than max, then truncated.
*/
-int RGWRados::Bucket::List::list_objects(int max, vector<RGWObjEnt> *result,
+int RGWRados::Bucket::List::list_objects(int max, vector<rgw_bucket_dir_entry> *result,
map<string, bool> *common_prefixes,
bool *is_truncated)
{
rgw_obj marker_obj(b, params.marker);
rgw_obj end_marker_obj(b, params.end_marker);
rgw_obj prefix_obj;
- rgw_obj_key cur_end_marker;
+ rgw_obj_index_key cur_end_marker;
if (!params.ns.empty()) {
marker_obj.set_ns(params.ns);
end_marker_obj.set_ns(params.ns);
end_marker_obj.get_index_key(&cur_end_marker);
}
- rgw_obj_key cur_marker;
+ rgw_obj_index_key cur_marker;
marker_obj.get_index_key(&cur_marker);
const bool cur_end_marker_valid = !params.end_marker.empty();
cur_marker.set(skip_after_delim);
ldout(cct, 20) << "setting cur_marker=" << cur_marker.name << "[" << cur_marker.instance << "]" << dendl;
}
- std::map<string, RGWObjEnt> ent_map;
+ std::map<string, rgw_bucket_dir_entry> ent_map;
int r = store->cls_bucket_list(target->get_bucket_info(), shard_id, cur_marker, cur_prefix,
read_ahead + 1 - count, params.list_versions, ent_map,
&truncated, &cur_marker);
if (r < 0)
return r;
- std::map<string, RGWObjEnt>::iterator eiter;
+ std::map<string, rgw_bucket_dir_entry>::iterator eiter;
for (eiter = ent_map.begin(); eiter != ent_map.end(); ++eiter) {
- rgw_obj_key obj = eiter->second.key;
- RGWObjEnt& entry = eiter->second;
- rgw_obj_key key = obj;
- string instance;
- string ns;
+ rgw_bucket_dir_entry& entry = eiter->second;
+ rgw_obj_index_key index_key = entry.key;
- bool valid = rgw_obj::parse_raw_oid(obj.name, &obj.name, &instance, &ns);
+ rgw_obj_key obj(index_key);
+
+ bool valid = rgw_obj::parse_raw_oid(index_key.name, &obj.name, &obj.instance, &obj.ns);
if (!valid) {
ldout(cct, 0) << "ERROR: could not parse object name: " << obj.name << dendl;
continue;
}
- bool check_ns = (ns == params.ns);
+ bool check_ns = (obj.ns == params.ns);
if (!params.list_versions && !entry.is_visible()) {
continue;
}
continue;
}
- if (cur_end_marker_valid && cur_end_marker <= obj) {
+ if (cur_end_marker_valid && cur_end_marker <= index_key) {
truncated = false;
goto done;
}
if (count < max) {
- params.marker = key;
- next_marker = key;
+ params.marker = index_key;
+ next_marker = index_key;
}
- if (params.filter && !params.filter->filter(obj.name, key.name))
+ if (params.filter && !params.filter->filter(obj.name, index_key.name))
continue;
if (params.prefix.size() && (obj.name.compare(0, params.prefix.size(), params.prefix) != 0))
goto done;
}
- entry.key = obj;
- entry.ns = ns;
result->emplace_back(std::move(entry));
count++;
}
int RGWRados::on_last_entry_in_listing(RGWBucketInfo& bucket_info,
const std::string& obj_prefix,
const std::string& obj_delim,
- std::function<int(const RGWObjEnt&)> handler)
+ std::function<int(const rgw_bucket_dir_entry&)> handler)
{
RGWRados::Bucket target(this, bucket_info);
RGWRados::Bucket::List list_op(&target);
bool is_truncated = false;
- boost::optional<RGWObjEnt> last_entry;
+ boost::optional<rgw_bucket_dir_entry> last_entry;
/* We need to rewind to the last object in a listing. */
do {
/* List bucket entries in chunks. */
static constexpr int MAX_LIST_OBJS = 100;
- std::vector<RGWObjEnt> entries(MAX_LIST_OBJS);
+ std::vector<rgw_bucket_dir_entry> entries(MAX_LIST_OBJS);
int ret = list_op.list_objects(MAX_LIST_OBJS, &entries, nullptr,
&is_truncated);
}
/* This code will be executed on latest version of the object. */
- const auto handler = [&](const RGWObjEnt& entry) -> int {
+ const auto handler = [&](const rgw_bucket_dir_entry& entry) -> int {
std::string no_client_id;
std::string no_op_id;
std::string no_zone;
}
if (!real_clock::is_zero(meta.delete_at)) {
- rgw_obj_key obj_key;
+ rgw_obj_index_key obj_key;
obj.get_index_key(&obj_key);
r = store->objexp_hint_add(meta.delete_at,
if (r < 0)
return r;
- std::map<string, RGWObjEnt> ent_map;
- rgw_obj_key marker;
+ std::map<string, rgw_bucket_dir_entry> ent_map;
+ rgw_obj_index_key marker;
string prefix;
bool is_truncated;
return r;
string ns;
- std::map<string, RGWObjEnt>::iterator eiter;
- rgw_obj_key obj;
+ std::map<string, rgw_bucket_dir_entry>::iterator eiter;
+ rgw_obj_index_key obj;
string instance;
for (eiter = ent_map.begin(); eiter != ent_map.end(); ++eiter) {
obj = eiter->second.key;
try {
::decode(ts, bl);
- rgw_obj_key obj_key;
+ rgw_obj_index_key obj_key;
obj.get_index_key(&obj_key);
objexp_hint_add(ts, bucket.tenant, bucket.name, bucket.bucket_id, obj_key);
const string& content_type,
bufferlist *acl_bl,
RGWObjCategory category,
- list<rgw_obj_key> *remove_objs)
+ list<rgw_obj_index_key> *remove_objs)
{
if (blind) {
return 0;
return ret;
}
- RGWObjEnt ent;
+ rgw_bucket_dir_entry ent;
obj.get_index_key(&ent.key);
- ent.size = size;
- ent.accounted_size = accounted_size;
- ent.mtime = ut;
- ent.etag = etag;
+ ent.meta.size = size;
+ ent.meta.accounted_size = accounted_size;
+ ent.meta.mtime = ut;
+ ent.meta.etag = etag;
ACLOwner owner;
if (acl_bl && acl_bl->length()) {
int ret = store->decode_policy(*acl_bl, &owner);
ldout(store->ctx(), 0) << "WARNING: could not decode policy ret=" << ret << dendl;
}
}
- ent.owner = owner.get_id();
- ent.owner_display_name = owner.get_display_name();
- ent.content_type = content_type;
+ ent.meta.owner = owner.get_id().to_str();
+ ent.meta.owner_display_name = owner.get_display_name();
+ ent.meta.content_type = content_type;
ret = store->cls_obj_complete_add(*bs, optag, poolid, epoch, ent, category, remove_objs, bilog_flags);
int RGWRados::Bucket::UpdateIndex::complete_del(int64_t poolid, uint64_t epoch,
real_time& removed_mtime,
- list<rgw_obj_key> *remove_objs)
+ list<rgw_obj_index_key> *remove_objs)
{
if (blind) {
return 0;
return 0;
}
-int RGWRados::pool_iterate(RGWPoolIterCtx& ctx, uint32_t num, vector<RGWObjEnt>& objs,
+int RGWRados::pool_iterate(RGWPoolIterCtx& ctx, uint32_t num, vector<rgw_bucket_dir_entry>& objs,
bool *is_truncated, RGWAccessListFilter *filter)
{
librados::IoCtx& io_ctx = ctx.io_ctx;
uint32_t i;
for (i = 0; i < num && iter != io_ctx.nobjects_end(); ++i, ++iter) {
- RGWObjEnt e;
+ rgw_bucket_dir_entry e;
string oid = iter->get_oid();
ldout(cct, 20) << "RGWRados::pool_iterate: got " << oid << dendl;
ctx.initialized = true;
}
- vector<RGWObjEnt> objs;
+ vector<rgw_bucket_dir_entry> objs;
int r = pool_iterate(ctx.iter_ctx, max, objs, is_truncated, &filter);
if (r < 0) {
if(r != -ENOENT)
return r;
}
- vector<RGWObjEnt>::iterator iter;
+ vector<rgw_bucket_dir_entry>::iterator iter;
for (iter = objs.begin(); iter != objs.end(); ++iter) {
oids.push_back(iter->key.name);
}
int RGWRados::cls_obj_complete_op(BucketShard& bs, RGWModifyOp op, string& tag,
int64_t pool, uint64_t epoch,
- RGWObjEnt& ent, RGWObjCategory category,
- list<rgw_obj_key> *remove_objs, uint16_t bilog_flags)
+ rgw_bucket_dir_entry& ent, RGWObjCategory category,
+ list<rgw_obj_index_key> *remove_objs, uint16_t bilog_flags)
{
list<cls_rgw_obj_key> *pro = NULL;
list<cls_rgw_obj_key> ro;
if (remove_objs) {
- for (list<rgw_obj_key>::iterator iter = remove_objs->begin(); iter != remove_objs->end(); ++iter) {
- cls_rgw_obj_key k;
- iter->transform(&k);
- ro.push_back(k);
+ for (auto iter = remove_objs->begin(); iter != remove_objs->end(); ++iter) {
+ ro.push_back(*iter);
}
pro = &ro;
}
ObjectWriteOperation o;
rgw_bucket_dir_entry_meta dir_meta;
- dir_meta.size = ent.size;
- dir_meta.accounted_size = ent.accounted_size;
- dir_meta.mtime = ent.mtime;
- dir_meta.etag = ent.etag;
- dir_meta.owner = ent.owner.to_str();
- dir_meta.owner_display_name = ent.owner_display_name;
- dir_meta.content_type = ent.content_type;
+ dir_meta = ent.meta;
dir_meta.category = category;
rgw_bucket_entry_ver ver;
int RGWRados::cls_obj_complete_add(BucketShard& bs, string& tag,
int64_t pool, uint64_t epoch,
- RGWObjEnt& ent, RGWObjCategory category,
- list<rgw_obj_key> *remove_objs, uint16_t bilog_flags)
+ rgw_bucket_dir_entry& ent, RGWObjCategory category,
+ list<rgw_obj_index_key> *remove_objs, uint16_t bilog_flags)
{
return cls_obj_complete_op(bs, CLS_RGW_OP_ADD, tag, pool, epoch, ent, category, remove_objs, bilog_flags);
}
int64_t pool, uint64_t epoch,
rgw_obj& obj,
real_time& removed_mtime,
- list<rgw_obj_key> *remove_objs,
+ list<rgw_obj_index_key> *remove_objs,
uint16_t bilog_flags)
{
- RGWObjEnt ent;
- ent.mtime = removed_mtime;
+ rgw_bucket_dir_entry ent;
+ ent.meta.mtime = removed_mtime;
obj.get_index_key(&ent.key);
return cls_obj_complete_op(bs, CLS_RGW_OP_DEL, tag, pool, epoch, ent, RGW_OBJ_CATEGORY_NONE, remove_objs, bilog_flags);
}
int RGWRados::cls_obj_complete_cancel(BucketShard& bs, string& tag, rgw_obj& obj, uint16_t bilog_flags)
{
- RGWObjEnt ent;
+ rgw_bucket_dir_entry ent;
obj.get_index_key(&ent.key);
return cls_obj_complete_op(bs, CLS_RGW_OP_CANCEL, tag, -1 /* pool id */, 0, ent, RGW_OBJ_CATEGORY_NONE, NULL, bilog_flags);
}
return CLSRGWIssueSetTagTimeout(index_ctx, bucket_objs, cct->_conf->rgw_bucket_index_max_aio, timeout)();
}
-int RGWRados::cls_bucket_list(RGWBucketInfo& bucket_info, int shard_id, rgw_obj_key& start, const string& prefix,
- uint32_t num_entries, bool list_versions, map<string, RGWObjEnt>& m,
- bool *is_truncated, rgw_obj_key *last_entry,
+int RGWRados::cls_bucket_list(RGWBucketInfo& bucket_info, int shard_id, rgw_obj_index_key& start, const string& prefix,
+ uint32_t num_entries, bool list_versions, map<string, rgw_bucket_dir_entry>& m,
+ bool *is_truncated, rgw_obj_index_key *last_entry,
bool (*force_check_filter)(const string& name))
{
ldout(cct, 10) << "cls_bucket_list " << bucket_info.bucket << " start " << start.name << "[" << start.instance << "] num_entries " << num_entries << dendl;
const string& name = vcurrents[pos]->first;
struct rgw_bucket_dir_entry& dirent = vcurrents[pos]->second;
- // fill it in with initial values; we may correct later
- RGWObjEnt e;
- e.key.set(dirent.key.name, dirent.key.instance);
- e.size = dirent.meta.size;
- e.accounted_size = dirent.meta.accounted_size;
- e.mtime = dirent.meta.mtime;
- e.etag = dirent.meta.etag;
- e.owner = dirent.meta.owner;
- e.owner_display_name = dirent.meta.owner_display_name;
- e.content_type = dirent.meta.content_type;
- e.tag = dirent.tag;
- e.flags = dirent.flags;
- e.versioned_epoch = dirent.versioned_epoch;
-
bool force_check = force_check_filter && force_check_filter(dirent.key.name);
if ((!dirent.exists && !dirent.is_delete_marker()) || !dirent.pending_map.empty() || force_check) {
/* there are uncommitted ops. We need to check the current state,
* and if the tags are old we need to do cleanup as well. */
librados::IoCtx sub_ctx;
sub_ctx.dup(index_ctx);
- r = check_disk_state(sub_ctx, bucket_info.bucket, dirent, e, updates[vnames[pos]]);
+ r = check_disk_state(sub_ctx, bucket_info.bucket, dirent, dirent, updates[vnames[pos]]);
if (r < 0 && r != -ENOENT) {
return r;
}
}
if (r >= 0) {
- ldout(cct, 10) << "RGWRados::cls_bucket_list: got " << e.key.name << "[" << e.key.instance << "]" << dendl;
- m[name] = std::move(e);
+ ldout(cct, 10) << "RGWRados::cls_bucket_list: got " << dirent.key.name << "[" << dirent.key.instance << "]" << dendl;
+ m[name] = std::move(dirent);
++count;
}
return r;
}
-int RGWRados::remove_objs_from_index(RGWBucketInfo& bucket_info, list<rgw_obj_key>& oid_list)
+int RGWRados::remove_objs_from_index(RGWBucketInfo& bucket_info, list<rgw_obj_index_key>& oid_list)
{
librados::IoCtx index_ctx;
string dir_oid;
bufferlist updates;
- list<rgw_obj_key>::iterator iter;
-
- for (iter = oid_list.begin(); iter != oid_list.end(); ++iter) {
- rgw_obj_key& key = *iter;
- dout(2) << "RGWRados::remove_objs_from_index bucket=" << bucket_info.bucket << " obj=" << key.name << ":" << key.instance << dendl;
+ for (auto iter = oid_list.begin(); iter != oid_list.end(); ++iter) {
rgw_bucket_dir_entry entry;
+ entry.key = *iter;
+ dout(2) << "RGWRados::remove_objs_from_index bucket=" << bucket_info.bucket << " obj=" << entry.key.name << ":" << entry.key.instance << dendl;
entry.ver.epoch = (uint64_t)-1; // ULLONG_MAX, needed to that objclass doesn't skip out request
- key.transform(&entry.key);
updates.append(CEPH_RGW_REMOVE | suggest_flag);
::encode(entry, updates);
}
int RGWRados::check_disk_state(librados::IoCtx io_ctx,
rgw_bucket& bucket,
rgw_bucket_dir_entry& list_state,
- RGWObjEnt& object,
+ rgw_bucket_dir_entry& object,
bufferlist& suggested_updates)
{
uint8_t suggest_flag = (get_zone().log_data ? CEPH_RGW_DIR_SUGGEST_LOG_OP : 0);
- rgw_obj obj;
std::string name, instance, loc, ns;
- rgw_obj_key key;
- key.set(list_state.key);
- name = key.name;
- if (!rgw_obj::strip_namespace_from_name(name, ns, instance)) {
- // well crap
- assert(0 == "got bad object name off disk");
+ if (!rgw_obj::strip_namespace_from_name(list_state.key.name, ns, instance)) {
+ ldout(cct, 0) << "ERROR: got bad object name off backend: name=" << name << dendl;
+ return -EIO;
}
- obj.init(bucket, name);
- obj.set_ns(ns);
- obj.set_instance(key.instance);
+
+ rgw_obj obj(bucket, list_state.key);
string oid;
get_obj_bucket_and_oid_loc(obj, oid, loc);
string content_type;
ACLOwner owner;
- object.size = astate->size;
- object.accounted_size = astate->accounted_size;
- object.mtime = astate->mtime;
+ object.meta.size = astate->size;
+ object.meta.accounted_size = astate->accounted_size;
+ object.meta.mtime = astate->mtime;
map<string, bufferlist>::iterator iter = astate->attrset.find(RGW_ATTR_ETAG);
if (iter != astate->attrset.end()) {
}
}
- object.etag = etag;
- object.content_type = content_type;
- object.owner = owner.get_id();
- object.owner_display_name = owner.get_display_name();
+ object.meta.etag = etag;
+ object.meta.content_type = content_type;
+ object.meta.owner = owner.get_id().to_str();
+ object.meta.owner_display_name = owner.get_display_name();
// encode suggested updates
list_state.ver.pool = io_ctx.get_id();
list_state.ver.epoch = astate->epoch;
- list_state.meta.size = object.size;
- list_state.meta.accounted_size = object.accounted_size;
- list_state.meta.mtime = object.mtime;
+ list_state.meta.size = object.meta.size;
+ list_state.meta.accounted_size = object.meta.accounted_size;
+ list_state.meta.mtime = object.meta.mtime;
list_state.meta.category = main_category;
list_state.meta.etag = etag;
list_state.meta.content_type = content_type;
* get the next bucket in the listing. obj is filled in,
* handle is updated.
*/
- int list_buckets_next(RGWObjEnt& obj, RGWAccessHandle *handle);
+ int list_buckets_next(rgw_bucket_dir_entry& obj, RGWAccessHandle *handle);
/// list logs
int log_list_init(const string& prefix, RGWAccessHandle *handle);
const bufferlist *data;
RGWObjManifest *manifest;
const string *ptag;
- list<rgw_obj_key> *remove_objs;
+ list<rgw_obj_index_key> *remove_objs;
ceph::real_time set_mtime;
rgw_user owner;
RGWObjCategory category;
uint64_t olh_epoch;
string marker_version_id;
uint32_t bilog_flags;
- list<rgw_obj_key> *remove_objs;
+ list<rgw_obj_index_key> *remove_objs;
ceph::real_time expiration_time;
ceph::real_time unmod_since;
ceph::real_time mtime; /* for setting delete marker mtime */
uint64_t accounted_size, ceph::real_time& ut,
const string& etag, const string& content_type,
bufferlist *acl_bl, RGWObjCategory category,
- list<rgw_obj_key> *remove_objs);
+ list<rgw_obj_index_key> *remove_objs);
int complete_del(int64_t poolid, uint64_t epoch,
ceph::real_time& removed_mtime, /* mtime of removed object */
- list<rgw_obj_key> *remove_objs);
+ list<rgw_obj_index_key> *remove_objs);
int cancel();
const string *get_optag() { return &optag; }
public:
explicit List(RGWRados::Bucket *_target) : target(_target) {}
- int list_objects(int max, vector<RGWObjEnt> *result, map<string, bool> *common_prefixes, bool *is_truncated);
+ int list_objects(int max, vector<rgw_bucket_dir_entry> *result, map<string, bool> *common_prefixes, bool *is_truncated);
rgw_obj_key& get_next_marker() {
return next_marker;
}
int on_last_entry_in_listing(RGWBucketInfo& bucket_info,
const std::string& obj_prefix,
const std::string& obj_delim,
- std::function<int(const RGWObjEnt&)> handler);
+ std::function<int(const rgw_bucket_dir_entry&)> handler);
bool swift_versioning_enabled(const RGWBucketInfo& bucket_info) const {
return bucket_info.has_swift_versioning() &&
int cls_rgw_init_index(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid);
int cls_obj_prepare_op(BucketShard& bs, RGWModifyOp op, string& tag, rgw_obj& obj, uint16_t bilog_flags);
int cls_obj_complete_op(BucketShard& bs, RGWModifyOp op, string& tag, int64_t pool, uint64_t epoch,
- RGWObjEnt& ent, RGWObjCategory category, list<rgw_obj_key> *remove_objs, uint16_t bilog_flags);
- int cls_obj_complete_add(BucketShard& bs, string& tag, int64_t pool, uint64_t epoch, RGWObjEnt& ent,
- RGWObjCategory category, list<rgw_obj_key> *remove_objs, uint16_t bilog_flags);
+ rgw_bucket_dir_entry& ent, RGWObjCategory category, list<rgw_obj_index_key> *remove_objs, uint16_t bilog_flags);
+ int cls_obj_complete_add(BucketShard& bs, string& tag, int64_t pool, uint64_t epoch, rgw_bucket_dir_entry& ent,
+ RGWObjCategory category, list<rgw_obj_index_key> *remove_objs, uint16_t bilog_flags);
int cls_obj_complete_del(BucketShard& bs, string& tag, int64_t pool, uint64_t epoch, rgw_obj& obj,
- ceph::real_time& removed_mtime, list<rgw_obj_key> *remove_objs, uint16_t bilog_flags);
+ ceph::real_time& removed_mtime, list<rgw_obj_index_key> *remove_objs, uint16_t bilog_flags);
int cls_obj_complete_cancel(BucketShard& bs, string& tag, rgw_obj& obj, uint16_t bilog_flags);
int cls_obj_set_bucket_tag_timeout(RGWBucketInfo& bucket_info, uint64_t timeout);
- int cls_bucket_list(RGWBucketInfo& bucket_info, int shard_id, rgw_obj_key& start, const string& prefix,
- uint32_t num_entries, bool list_versions, map<string, RGWObjEnt>& m,
- bool *is_truncated, rgw_obj_key *last_entry,
+ int cls_bucket_list(RGWBucketInfo& bucket_info, int shard_id, rgw_obj_index_key& start, const string& prefix,
+ uint32_t num_entries, bool list_versions, map<string, rgw_bucket_dir_entry>& m,
+ bool *is_truncated, rgw_obj_index_key *last_entry,
bool (*force_check_filter)(const string& name) = NULL);
int cls_bucket_head(const RGWBucketInfo& bucket_info, int shard_id, map<string, struct rgw_bucket_dir_header>& headers, map<int, string> *bucket_instance_ids = NULL);
int cls_bucket_head_async(const RGWBucketInfo& bucket_info, int shard_id, RGWGetDirHeader_CB *ctx, int *num_aio);
librados::AioCompletion *completion = nullptr);
string objexp_hint_get_shardname(int shard_num);
- int objexp_key_shard(const rgw_obj_key& key);
+ int objexp_key_shard(const rgw_obj_index_key& key);
void objexp_get_shard(int shard_num,
string& shard); /* out */
int objexp_hint_add(const ceph::real_time& delete_at,
const string& tenant_name,
const string& bucket_name,
const string& bucket_id,
- const rgw_obj_key& obj_key);
+ const rgw_obj_index_key& obj_key);
int objexp_hint_list(const string& oid,
const ceph::real_time& start_time,
const ceph::real_time& end_time,
map<RGWObjCategory, RGWStorageStats> *existing_stats,
map<RGWObjCategory, RGWStorageStats> *calculated_stats);
int bucket_rebuild_index(RGWBucketInfo& bucket_info);
- int remove_objs_from_index(RGWBucketInfo& bucket_info, list<rgw_obj_key>& oid_list);
+ int remove_objs_from_index(RGWBucketInfo& bucket_info, list<rgw_obj_index_key>& oid_list);
int move_rados_obj(librados::IoCtx& src_ioctx,
const string& src_oid, const string& src_locator,
librados::IoCtx& dst_ioctx,
int check_disk_state(librados::IoCtx io_ctx,
rgw_bucket& bucket,
rgw_bucket_dir_entry& list_state,
- RGWObjEnt& object,
+ rgw_bucket_dir_entry& object,
bufferlist& suggested_updates);
/**
* filter: if not NULL, will be used to filter returned objects
* Returns: 0 on success, -ERR# otherwise.
*/
- int pool_iterate(RGWPoolIterCtx& ctx, uint32_t num, vector<RGWObjEnt>& objs,
+ int pool_iterate(RGWPoolIterCtx& ctx, uint32_t num, vector<rgw_bucket_dir_entry>& objs,
bool *is_truncated, RGWAccessListFilter *filter);
uint64_t next_bucket_id();
s->formatter->dump_string(name, buf);
}
-void dump_owner(struct req_state *s, rgw_user& id, string& name,
+void dump_owner(struct req_state *s, const rgw_user& id, string& name,
const char *section)
{
if (!section)
bool force_no_error = false);
extern void dump_start(struct req_state *s);
extern void list_all_buckets_start(struct req_state *s);
-extern void dump_owner(struct req_state *s, rgw_user& id, string& name,
+extern void dump_owner(struct req_state *s, const rgw_user& id, string& name,
const char *section = NULL);
extern void dump_header(struct req_state* s,
const boost::string_ref& name,
s->formatter->open_array_section("Entries");
}
- vector<RGWObjEnt>::iterator iter;
+ vector<rgw_bucket_dir_entry>::iterator iter;
for (iter = objs.begin(); iter != objs.end(); ++iter) {
const char *section_name = (iter->is_delete_marker() ? "DeleteMarker"
: "Version");
if (objs_container) {
s->formatter->dump_bool("IsDeleteMarker", iter->is_delete_marker());
}
+ rgw_obj_key key(iter->key);
if (encode_key) {
string key_name;
- url_encode(iter->key.name, key_name);
+ url_encode(key.name, key_name);
s->formatter->dump_string("Key", key_name);
} else {
- s->formatter->dump_string("Key", iter->key.name);
+ s->formatter->dump_string("Key", key.name);
}
- string version_id = iter->key.instance;
+ string version_id = key.instance;
if (version_id.empty()) {
version_id = "null";
}
s->formatter->dump_int("VersionedEpoch", iter->versioned_epoch);
}
s->formatter->dump_string("RgwxTag", iter->tag);
- utime_t ut(iter->mtime);
+ utime_t ut(iter->meta.mtime);
ut.gmtime_nsec(s->formatter->dump_stream("RgwxMtime"));
}
s->formatter->dump_string("VersionId", version_id);
s->formatter->dump_bool("IsLatest", iter->is_current());
- dump_time(s, "LastModified", &iter->mtime);
+ dump_time(s, "LastModified", &iter->meta.mtime);
if (!iter->is_delete_marker()) {
- s->formatter->dump_format("ETag", "\"%s\"", iter->etag.c_str());
- s->formatter->dump_int("Size", iter->accounted_size);
+ s->formatter->dump_format("ETag", "\"%s\"", iter->meta.etag.c_str());
+ s->formatter->dump_int("Size", iter->meta.accounted_size);
s->formatter->dump_string("StorageClass", "STANDARD");
}
- dump_owner(s, iter->owner, iter->owner_display_name);
+ dump_owner(s, iter->meta.owner, iter->meta.owner_display_name);
s->formatter->close_section();
}
if (objs_container) {
}
if (op_ret >= 0) {
- vector<RGWObjEnt>::iterator iter;
+ vector<rgw_bucket_dir_entry>::iterator iter;
for (iter = objs.begin(); iter != objs.end(); ++iter) {
+ rgw_obj_key key(iter->key);
s->formatter->open_array_section("Contents");
if (encode_key) {
string key_name;
- url_encode(iter->key.name, key_name);
+ url_encode(key.name, key_name);
s->formatter->dump_string("Key", key_name);
} else {
- s->formatter->dump_string("Key", iter->key.name);
+ s->formatter->dump_string("Key", key.name);
}
- dump_time(s, "LastModified", &iter->mtime);
- s->formatter->dump_format("ETag", "\"%s\"", iter->etag.c_str());
- s->formatter->dump_int("Size", iter->accounted_size);
+ dump_time(s, "LastModified", &iter->meta.mtime);
+ s->formatter->dump_format("ETag", "\"%s\"", iter->meta.etag.c_str());
+ s->formatter->dump_int("Size", iter->meta.accounted_size);
s->formatter->dump_string("StorageClass", "STANDARD");
- dump_owner(s, iter->owner, iter->owner_display_name);
+ dump_owner(s, iter->meta.owner, iter->meta.owner_display_name);
if (s->system_request) {
s->formatter->dump_string("RgwxTag", iter->tag);
}
dump_owner(s, s->user->user_id, s->user->display_name, "Initiator");
dump_owner(s, s->user->user_id, s->user->display_name);
s->formatter->dump_string("StorageClass", "STANDARD");
- dump_time(s, "Initiated", &iter->obj.mtime);
+ dump_time(s, "Initiated", &iter->obj.meta.mtime);
s->formatter->close_section();
}
if (!common_prefixes.empty()) {
void RGWListBucket_ObjStore_SWIFT::send_response()
{
- vector<RGWObjEnt>::iterator iter = objs.begin();
+ vector<rgw_bucket_dir_entry>::iterator iter = objs.begin();
map<string, bool>::iterator pref_iter = common_prefixes.begin();
dump_start(s);
while (iter != objs.end() || pref_iter != common_prefixes.end()) {
bool do_pref = false;
bool do_objs = false;
- rgw_obj_key& key = iter->key;
+ rgw_obj_key key(iter->key);
if (pref_iter == common_prefixes.end())
do_objs = true;
else if (iter == objs.end())
s->formatter->open_object_section("object");
s->formatter->dump_string("name", key.name);
- s->formatter->dump_string("hash", iter->etag);
- s->formatter->dump_int("bytes", iter->accounted_size);
- string single_content_type = iter->content_type;
- if (iter->content_type.size()) {
+ s->formatter->dump_string("hash", iter->meta.etag);
+ s->formatter->dump_int("bytes", iter->meta.accounted_size);
+ string single_content_type = iter->meta.content_type;
+ if (iter->meta.content_type.size()) {
// content type might hold multiple values, just dump the last one
- ssize_t pos = iter->content_type.rfind(',');
+ ssize_t pos = iter->meta.content_type.rfind(',');
if (pos > 0) {
++pos;
while (single_content_type[pos] == ' ')
}
s->formatter->dump_string("content_type", single_content_type);
}
- dump_time(s, "last_modified", &iter->mtime);
+ dump_time(s, "last_modified", &iter->meta.mtime);
s->formatter->close_section();
}
htmler.dump_subdir(subdir_name);
}
- for (const RGWObjEnt& obj : objs) {
+ for (const rgw_bucket_dir_entry& obj : objs) {
if (! common_prefixes.count(obj.key.name + '/')) {
htmler.dump_object(obj);
}