From 71cf9c25247e61fdd74207fbec8e2f2d624bfedb Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 19 Oct 2016 08:39:10 -0700 Subject: [PATCH] wip --- src/cls/user/cls_user_types.cc | 5 - src/cls/user/cls_user_types.h | 47 +++-- src/rgw/rgw_admin.cc | 14 +- src/rgw/rgw_bucket.cc | 64 +++--- src/rgw/rgw_bucket.h | 2 +- src/rgw/rgw_common.cc | 3 +- src/rgw/rgw_common.h | 57 +++--- src/rgw/rgw_dencoder.cc | 13 +- src/rgw/rgw_json_enc.cc | 12 +- src/rgw/rgw_op.cc | 9 +- src/rgw/rgw_rados.cc | 348 +++++++++++++++++---------------- src/rgw/rgw_rados.h | 158 +++++++++------ 12 files changed, 402 insertions(+), 330 deletions(-) diff --git a/src/cls/user/cls_user_types.cc b/src/cls/user/cls_user_types.cc index b8fc71a9f894b9..34bcd9b5d8219a 100644 --- a/src/cls/user/cls_user_types.cc +++ b/src/cls/user/cls_user_types.cc @@ -11,8 +11,6 @@ void cls_user_gen_test_bucket(cls_user_bucket *bucket, int i) snprintf(buf, sizeof(buf), ".%d", i); bucket->name = string("buck") + buf; - bucket->data_pool = string(".data.pool") + buf; - bucket->index_pool = string(".index.pool") + buf; bucket->marker = string("mark") + buf; bucket->bucket_id = string("bucket.id") + buf; } @@ -20,9 +18,6 @@ void cls_user_gen_test_bucket(cls_user_bucket *bucket, int i) void cls_user_bucket::dump(Formatter *f) const { encode_json("name", name, f); - encode_json("data_pool", data_pool,f); - encode_json("data_extra_pool", data_extra_pool,f); - encode_json("index_pool", index_pool,f); encode_json("marker", marker,f); encode_json("bucket_id", bucket_id,f); } diff --git a/src/cls/user/cls_user_types.h b/src/cls/user/cls_user_types.h index cfcff99428f2b0..97bd959243edd0 100644 --- a/src/cls/user/cls_user_types.h +++ b/src/cls/user/cls_user_types.h @@ -14,26 +14,34 @@ */ struct cls_user_bucket { std::string name; - std::string data_pool; - std::string index_pool; std::string marker; std::string bucket_id; - std::string data_extra_pool; + std::string placement_id; + struct { + std::string data_pool; + std::string index_pool; + std::string data_extra_pool; + } explicit_placement; void encode(bufferlist& bl) const { - ENCODE_START(7, 3, bl); + ENCODE_START(8, 8, bl); ::encode(name, bl); - ::encode(data_pool, bl); ::encode(marker, bl); ::encode(bucket_id, bl); - ::encode(index_pool, bl); - ::encode(data_extra_pool, bl); + ::encode(placement_id, bl); + if (placement_id.empty()) { + ::encode(explicit_placement.data_pool, bl); + ::encode(explicit_placement.index_pool, bl); + ::encode(explicit_placement.data_extra_pool, bl); + } ENCODE_FINISH(bl); } void decode(bufferlist::iterator& bl) { - DECODE_START_LEGACY_COMPAT_LEN(7, 3, 3, bl); + DECODE_START_LEGACY_COMPAT_LEN(8, 3, 3, bl); ::decode(name, bl); - ::decode(data_pool, bl); + if (struct_v < 8) { + ::decode(explicit_placement.data_pool, bl); + } if (struct_v >= 2) { ::decode(marker, bl); if (struct_v <= 3) { @@ -46,13 +54,22 @@ struct cls_user_bucket { ::decode(bucket_id, bl); } } - if (struct_v >= 5) { - ::decode(index_pool, bl); + if (struct_v < 8) { + if (struct_v >= 5) { + ::decode(explicit_placement.index_pool, bl); + } else { + explicit_placement.index_pool = explicit_placement.data_pool; + } + if (struct_v >= 7) { + ::decode(explicit_placement.data_extra_pool, bl); + } } else { - index_pool = data_pool; - } - if (struct_v >= 7) { - ::decode(data_extra_pool, bl); + ::decode(placement_id, bl); + if (placement_id.empty()) { + ::decode(explicit_placement.data_pool, bl); + ::decode(explicit_placement.index_pool, bl); + ::decode(explicit_placement.data_extra_pool, bl); + } } DECODE_FINISH(bl); } diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 2cb734bca7aea0..ea2b14db9eb7c1 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -853,14 +853,14 @@ int bucket_stats(rgw_bucket& bucket, int shard_id, Formatter *formatter) map stats; string bucket_ver, master_ver; string max_marker; - int ret = store->get_bucket_stats(bucket, shard_id, &bucket_ver, &master_ver, stats, &max_marker); + int ret = store->get_bucket_stats(bucket_info, shard_id, &bucket_ver, &master_ver, stats, &max_marker); if (ret < 0) { cerr << "error getting bucket stats ret=" << ret << std::endl; return ret; } formatter->open_object_section("stats"); formatter->dump_string("bucket", bucket.name); - ::encode_json("placement", bucket.placement, formatter); + ::encode_json("explicit_placement", bucket.explicit_placement, formatter); formatter->dump_string("id", bucket.bucket_id); formatter->dump_string("marker", bucket.marker); @@ -4517,7 +4517,7 @@ int main(int argc, char **argv) formatter->open_array_section("objects"); while (is_truncated) { map result; - int r = store->cls_bucket_list(bucket, RGW_NO_SHARD, marker, prefix, 1000, true, + int r = store->cls_bucket_list(bucket_info, RGW_NO_SHARD, marker, prefix, 1000, true, result, &is_truncated, &marker, bucket_object_check_filter); @@ -4588,7 +4588,7 @@ int main(int argc, char **argv) list oid_list; rgw_obj_key key(object, object_version); oid_list.push_back(key); - ret = store->remove_objs_from_index(bucket, oid_list); + 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 1; @@ -5318,7 +5318,7 @@ int main(int argc, char **argv) do { list entries; - ret = store->list_bi_log_entries(bucket, shard_id, marker, max_entries - count, entries, &truncated); + ret = store->list_bi_log_entries(bucket_info, shard_id, marker, max_entries - count, entries, &truncated); if (ret < 0) { cerr << "ERROR: list_bi_log_entries(): " << cpp_strerror(-ret) << std::endl; return -ret; @@ -5427,7 +5427,7 @@ int main(int argc, char **argv) cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl; return -ret; } - ret = store->trim_bi_log_entries(bucket, shard_id, start_marker, end_marker); + ret = store->trim_bi_log_entries(bucket_info, shard_id, start_marker, end_marker); if (ret < 0) { cerr << "ERROR: trim_bi_log_entries(): " << cpp_strerror(-ret) << std::endl; return -ret; @@ -5446,7 +5446,7 @@ int main(int argc, char **argv) return -ret; } map markers; - ret = store->get_bi_log_status(bucket, shard_id, markers); + ret = store->get_bi_log_status(bucket_info, shard_id, markers); if (ret < 0) { cerr << "ERROR: trim_bi_log_entries(): " << cpp_strerror(-ret) << std::endl; return -ret; diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 1ae31f069f48bd..5b419edee540c2 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -151,13 +151,13 @@ int rgw_read_user_buckets(RGWRados * store, return 0; } -int rgw_bucket_sync_user_stats(RGWRados *store, const rgw_user& user_id, rgw_bucket& bucket) +int rgw_bucket_sync_user_stats(RGWRados *store, const rgw_user& user_id, RGWBucketInfo& bucket_info) { string buckets_obj_id; rgw_get_buckets_obj(user_id, buckets_obj_id); rgw_raw_obj obj(store->get_zone_params().user_uid_pool, buckets_obj_id); - return store->cls_user_sync_bucket_stats(obj, bucket); + return store->cls_user_sync_bucket_stats(obj, bucket_info); } int rgw_bucket_sync_user_stats(RGWRados *store, const string& tenant_name, const string& bucket_name) @@ -170,7 +170,7 @@ int rgw_bucket_sync_user_stats(RGWRados *store, const string& tenant_name, const return ret; } - ret = rgw_bucket_sync_user_stats(store, bucket_info.owner, bucket_info.bucket); + ret = rgw_bucket_sync_user_stats(store, bucket_info.owner, bucket_info); if (ret < 0) { ldout(store->ctx(), 0) << "ERROR: could not sync user stats for bucket " << bucket_name << ": ret=" << ret << dendl; return ret; @@ -479,7 +479,6 @@ void check_bad_user_bucket_mapping(RGWRados *store, const rgw_user& user_id, if (actual_bucket.name.compare(bucket.name) != 0 || actual_bucket.tenant.compare(bucket.tenant) != 0 || - actual_bucket.placement.compare(bucket.placement) != 0 || actual_bucket.marker.compare(bucket.marker) != 0 || actual_bucket.bucket_id.compare(bucket.bucket_id) != 0) { cout << "bucket info mismatch: expected " << actual_bucket << " got " << bucket << std::endl; @@ -528,11 +527,11 @@ int rgw_remove_bucket(RGWRados *store, rgw_bucket& bucket, bool delete_children) string bucket_ver, master_ver; - ret = store->get_bucket_stats(bucket, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, NULL); + ret = store->get_bucket_info(obj_ctx, bucket.tenant, bucket.name, info, NULL); if (ret < 0) return ret; - ret = store->get_bucket_info(obj_ctx, bucket.tenant, bucket.name, info, NULL); + ret = store->get_bucket_stats(info, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, NULL); if (ret < 0) return ret; @@ -563,14 +562,14 @@ int rgw_remove_bucket(RGWRados *store, rgw_bucket& bucket, bool delete_children) } - ret = rgw_bucket_sync_user_stats(store, bucket.tenant, bucket.name); + ret = rgw_bucket_sync_user_stats(store, bucket.tenant, info); if ( ret < 0) { dout(1) << "WARNING: failed sync user stats before bucket delete. ret=" << ret << dendl; } RGWObjVersionTracker objv_tracker; - ret = store->delete_bucket(bucket, objv_tracker); + ret = store->delete_bucket(info, objv_tracker); if (ret < 0) { lderr(store->ctx()) << "ERROR: could not remove bucket " << bucket.name << dendl; return ret; @@ -619,11 +618,11 @@ int rgw_remove_bucket_bypass_gc(RGWRados *store, rgw_bucket& bucket, string bucket_ver, master_ver; - ret = store->get_bucket_stats(bucket, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, NULL); + ret = store->get_bucket_info(obj_ctx, bucket.tenant, bucket.name, info, NULL); if (ret < 0) return ret; - ret = store->get_bucket_info(obj_ctx, bucket.tenant, bucket.name, info, NULL); + ret = store->get_bucket_stats(info, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, NULL); if (ret < 0) return ret; @@ -663,7 +662,7 @@ int rgw_remove_bucket_bypass_gc(RGWRados *store, rgw_bucket& bucket, 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); + store->obj_to_raw(head_obj, &raw_head_obj); for (; miter != manifest.obj_end() && max_aio--; ++miter) { @@ -689,7 +688,7 @@ int rgw_remove_bucket_bypass_gc(RGWRados *store, rgw_bucket& bucket, } } // for all shadow objs - ret = store->delete_obj_aio(head_obj, bucket, info, astate, handles, keep_index_consistent); + ret = store->delete_obj_aio(head_obj, info, astate, handles, keep_index_consistent); if (ret < 0) { lderr(store->ctx()) << "ERROR: delete obj aio failed with " << ret << dendl; return ret; @@ -718,7 +717,7 @@ int rgw_remove_bucket_bypass_gc(RGWRados *store, rgw_bucket& bucket, return ret; } - ret = rgw_bucket_sync_user_stats(store, bucket.tenant, bucket.name); + ret = rgw_bucket_sync_user_stats(store, bucket.tenant, info); if (ret < 0) { dout(1) << "WARNING: failed sync user stats before bucket delete. ret=" << ret << dendl; } @@ -1076,7 +1075,7 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state, return 0; if (fix_index) { - int r = store->remove_objs_from_index(bucket, objs_to_unlink); + int r = store->remove_objs_from_index(bucket_info, objs_to_unlink); if (r < 0) { set_err_msg(err_msg, "ERROR: remove_obj_from_index() returned error: " + cpp_strerror(-r)); @@ -1093,6 +1092,7 @@ int RGWBucket::check_object_index(RGWBucketAdminOpState& op_state, { bool fix_index = op_state.will_fix_index(); + rgw_bucket bucket = op_state.get_bucket(); if (!fix_index) { @@ -1100,11 +1100,7 @@ int RGWBucket::check_object_index(RGWBucketAdminOpState& op_state, return -EINVAL; } -/* - dout(0) << "Checking objects, decreasing bucket 2-phase commit timeout.\n"\ - << "** Note that timeout will reset only when operation completes successfully **" << dendl; -*/ - store->cls_obj_set_bucket_tag_timeout(bucket, BUCKET_TAG_TIMEOUT); + store->cls_obj_set_bucket_tag_timeout(bucket_info, BUCKET_TAG_TIMEOUT); string prefix; rgw_obj_key marker; @@ -1113,7 +1109,7 @@ int RGWBucket::check_object_index(RGWBucketAdminOpState& op_state, while (is_truncated) { map result; - int r = store->cls_bucket_list(bucket, RGW_NO_SHARD, marker, prefix, 1000, true, + 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) { @@ -1123,7 +1119,7 @@ int RGWBucket::check_object_index(RGWBucketAdminOpState& op_state, } } - store->cls_obj_set_bucket_tag_timeout(bucket, 0); + store->cls_obj_set_bucket_tag_timeout(bucket_info, 0); return 0; } @@ -1137,14 +1133,14 @@ int RGWBucket::check_index(RGWBucketAdminOpState& op_state, rgw_bucket bucket = op_state.get_bucket(); bool fix_index = op_state.will_fix_index(); - int r = store->bucket_check_index(bucket, &existing_stats, &calculated_stats); + int r = store->bucket_check_index(bucket_info, &existing_stats, &calculated_stats); if (r < 0) { set_err_msg(err_msg, "failed to check index error=" + cpp_strerror(-r)); return r; } if (fix_index) { - r = store->bucket_rebuild_index(bucket); + r = store->bucket_rebuild_index(bucket_info); if (r < 0) { set_err_msg(err_msg, "failed to rebuild index err=" + cpp_strerror(-r)); return r; @@ -1363,7 +1359,6 @@ int RGWBucketAdminOp::remove_object(RGWRados *store, RGWBucketAdminOpState& op_s static int bucket_stats(RGWRados *store, const std::string& tenant_name, std::string& bucket_name, Formatter *formatter) { RGWBucketInfo bucket_info; - rgw_bucket bucket; map stats; real_time mtime; @@ -1372,11 +1367,11 @@ static int bucket_stats(RGWRados *store, const std::string& tenant_name, std::st if (r < 0) return r; - bucket = bucket_info.bucket; + rgw_bucket& bucket = bucket_info.bucket; string bucket_ver, master_ver; string max_marker; - int ret = store->get_bucket_stats(bucket, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, &max_marker); + int ret = store->get_bucket_stats(bucket_info, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, &max_marker); if (ret < 0) { cerr << "error getting bucket stats ret=" << ret << std::endl; return ret; @@ -1386,7 +1381,6 @@ static int bucket_stats(RGWRados *store, const std::string& tenant_name, std::st formatter->open_object_section("stats"); formatter->dump_string("bucket", bucket.name); - encode_json("placement", bucket.placement, formatter); formatter->dump_string("id", bucket.bucket_id); formatter->dump_string("marker", bucket.marker); ::encode_json("owner", bucket_info.owner, formatter); @@ -2118,21 +2112,19 @@ class RGWBucketInstanceMetadataHandler : public RGWMetadataHandler { string bucket_name; parse_bucket(key, tenant_name, bucket_name); - rgw_bucket bucket; RGWZonePlacementInfo rule_info; - ret = store->set_bucket_location_by_rule(bci.info.placement_rule, - tenant_name, bucket_name, bucket, &rule_info); + bci.info.bucket.name = bucket_name; + bci.info.bucket.tenant = tenant_name; + ret = store->select_bucket_location_by_rule(bci.info.placement_rule, bci.info.bucket, &rule_info); if (ret < 0) { ldout(store->ctx(), 0) << "ERROR: select_bucket_placement() returned " << ret << dendl; return ret; } - bci.info.bucket.tenant = bucket.tenant; - bci.info.bucket.placement = bucket.placement; bci.info.index_type = rule_info.index_type; } else { - /* existing bucket, keep its placement pools */ - bci.info.bucket.placement = old_bci.info.bucket.placement; - bci.info.index_type = old_bci.info.index_type; + /* existing bucket, keep its placement */ + bci.info.bucket.explicit_placement = old_bci.info.bucket.explicit_placement; + bci.info.placement_rule = old_bci.info.placement_rule; } // are we actually going to perform this put, or is it too old? @@ -2153,7 +2145,7 @@ class RGWBucketInstanceMetadataHandler : public RGWMetadataHandler { objv_tracker = bci.info.objv_tracker; - ret = store->init_bucket_index(bci.info.bucket, bci.info.num_shards); + ret = store->init_bucket_index(bci.info, bci.info.num_shards); if (ret < 0) return ret; diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index ee52ad626b7eca..f2e1e0bb763358 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -46,7 +46,7 @@ extern int rgw_bucket_delete_bucket_obj(RGWRados *store, const string& bucket_name, RGWObjVersionTracker& objv_tracker); -extern int rgw_bucket_sync_user_stats(RGWRados *store, const rgw_user& user_id, rgw_bucket& bucket); +extern int rgw_bucket_sync_user_stats(RGWRados *store, const rgw_user& user_id, const RGWBucketInfo& bucket_info); extern int rgw_bucket_sync_user_stats(RGWRados *store, const string& tenant_name, const string& bucket_name); extern void rgw_make_bucket_entry_name(const string& tenant_name, diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index b31a9b16f3f9d8..6af1811d1496c8 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -1395,7 +1395,8 @@ void rgw_raw_obj::decode_from_rgw_obj(bufferlist::iterator& bl) rgw_obj old_obj; ::decode(old_obj, bl); - RGWRados::obj_to_raw(old_obj, this); + get_obj_bucket_and_oid_loc(old_obj, oid, loc); + pool = old_obj.get_explicit_data_pool(); } std::string rgw_bucket::get_key(char tenant_delim, char id_delim) const diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index b4965f82ced7e6..316e72dc820158 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -892,7 +892,7 @@ struct rgw_bucket { std::string name; std::string marker; std::string bucket_id; - rgw_data_placement_target placement; + rgw_data_placement_target explicit_placement; std::string oid; /* * runtime in-memory only info. If not empty, points to the bucket instance object @@ -903,32 +903,33 @@ struct rgw_bucket { rgw_bucket(const cls_user_bucket& b) : name(b.name), marker(b.marker), bucket_id(b.bucket_id), - placement(b.data_pool, b.data_extra_pool, b.index_pool) {} + explicit_placement(b.explicit_placement.data_pool, + b.explicit_placement.data_extra_pool, + b.explicit_placement.index_pool) {} void convert(cls_user_bucket *b) { b->name = name; - b->data_pool = placement.data_pool.to_str(); - b->data_extra_pool = placement.data_extra_pool.to_str(); - b->index_pool = placement.index_pool.to_str(); b->marker = marker; b->bucket_id = bucket_id; + b->explicit_placement.data_pool = explicit_placement.data_pool.to_str(); + b->explicit_placement.data_extra_pool = explicit_placement.data_extra_pool.to_str(); + b->explicit_placement.index_pool = explicit_placement.index_pool.to_str(); } void encode(bufferlist& bl) const { - ENCODE_START(9, 3, bl); + ENCODE_START(10, 10, bl); ::encode(name, bl); - ::encode(placement.data_pool.name, bl); ::encode(marker, bl); ::encode(bucket_id, bl); - ::encode(placement.index_pool.name, bl); - ::encode(placement.data_extra_pool.name, bl); ::encode(tenant, bl); ENCODE_FINISH(bl); } void decode(bufferlist::iterator& bl) { - DECODE_START_LEGACY_COMPAT_LEN(9, 3, 3, bl); + DECODE_START_LEGACY_COMPAT_LEN(10, 3, 3, bl); ::decode(name, bl); - ::decode(placement.data_pool.name, bl); + if (struct_v < 10) { + ::decode(explicit_placement.data_pool.name, bl); + } if (struct_v >= 2) { ::decode(marker, bl); if (struct_v <= 3) { @@ -941,13 +942,15 @@ struct rgw_bucket { ::decode(bucket_id, bl); } } - if (struct_v >= 5) { - ::decode(placement.index_pool.name, bl); - } else { - placement.index_pool = placement.data_pool; - } - if (struct_v >= 7) { - ::decode(placement.data_extra_pool.name, bl); + if (struct_v < 10) { + if (struct_v >= 5) { + ::decode(explicit_placement.index_pool.name, bl); + } else { + explicit_placement.index_pool = explicit_placement.data_pool; + } + if (struct_v >= 7) { + ::decode(explicit_placement.data_extra_pool.name, bl); + } } if (struct_v >= 8) { ::decode(tenant, bl); @@ -960,7 +963,7 @@ struct rgw_bucket { char id_delim = ':') const; const rgw_pool& get_data_extra_pool() const { - return placement.get_data_extra_pool(); + return explicit_placement.get_data_extra_pool(); } void dump(Formatter *f) const; @@ -1612,6 +1615,7 @@ class rgw_obj { const std::string& get_loc() const { return loc; } const std::string& get_instance() const { return instance; } rgw_bucket bucket; + std::string placement_id; std::string ns; bool in_extra_data; /* in-memory only member, does not serialize */ @@ -1875,14 +1879,6 @@ 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); @@ -1951,6 +1947,13 @@ class rgw_obj { return (r < 0); } + + const rgw_pool& get_explicit_data_pool() { + if (!in_extra_data || bucket.explicit_placement.data_extra_pool.empty()) { + return bucket.explicit_placement.data_pool; + } + return bucket.explicit_placement.data_extra_pool; + } }; WRITE_CLASS_ENCODER(rgw_obj) diff --git a/src/rgw/rgw_dencoder.cc b/src/rgw/rgw_dencoder.cc index d12340719dbf84..83401e4a88096b 100644 --- a/src/rgw/rgw_dencoder.cc +++ b/src/rgw/rgw_dencoder.cc @@ -18,8 +18,8 @@ static void init_bucket(rgw_bucket *b, const char *t, const char *n, const char b->name = n; b->marker = m; b->bucket_id = id; - b->placement.data_pool = rgw_pool(dp); - b->placement.index_pool = rgw_pool(ip); + b->explicit_placement.data_pool = rgw_pool(dp); + b->explicit_placement.index_pool = rgw_pool(ip); } void RGWObjManifestPart::generate_test_instances(std::list& o) @@ -112,7 +112,14 @@ void RGWObjManifest::obj_iterator::seek(uint64_t o) void RGWObjManifest::obj_iterator::update_location() { if (manifest->explicit_objs) { - RGWRados::obj_to_raw(explicit_iter->second.loc, &location); + /* this is tricky, we don't have reference to store here, so we can't call store->obj_to_raw(), + * but since we're dealing with a manifest with explict objs, we can get location.pool out + * of these, as the old encoding (that was used when explicit_objs were around) had put the + * pool in the rgw_obj::bucket structure */ + get_obj_bucket_and_oid_loc(explicit_iter->second.loc, location.oid, location.loc); + + location.pool = explicit_iter->second.loc.get_explicit_data_pool(); + return; } diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index e85ac564634b0e..5d2cf696e45a5b 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -575,7 +575,7 @@ void rgw_bucket::dump(Formatter *f) const encode_json("marker", marker, f); encode_json("bucket_id", bucket_id, f); encode_json("tenant", tenant, f); - encode_json("placement", placement, f); + encode_json("explicit_placement", explicit_placement, f); } void rgw_bucket::decode_json(JSONObj *obj) { @@ -583,12 +583,12 @@ void rgw_bucket::decode_json(JSONObj *obj) { JSONDecoder::decode_json("marker", marker, obj); JSONDecoder::decode_json("bucket_id", bucket_id, obj); JSONDecoder::decode_json("tenant", tenant, obj); - JSONDecoder::decode_json("placement", placement, obj); - if (placement.data_pool.empty()) { + JSONDecoder::decode_json("explicit_placement", explicit_placement, obj); + if (explicit_placement.data_pool.empty()) { /* decoding old format */ - JSONDecoder::decode_json("pool", placement.data_pool, obj); - JSONDecoder::decode_json("data_extra_pool", placement.data_extra_pool, obj); - JSONDecoder::decode_json("index_pool", placement.index_pool, obj); + JSONDecoder::decode_json("pool", explicit_placement.data_pool, obj); + JSONDecoder::decode_json("data_extra_pool", explicit_placement.data_extra_pool, obj); + JSONDecoder::decode_json("index_pool", explicit_placement.index_pool, obj); } } diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 68c2e7a7d56b89..9d853f1e77fe1e 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -2259,9 +2259,10 @@ void RGWCreateBucket::execute() if (s->bucket_exists) { string selected_placement_rule; rgw_bucket bucket; + bucket.tenant = s->bucket_tenant; + bucket.name = s->bucket_name; op_ret = store->select_bucket_placement(*(s->user), zonegroup_id, placement_rule, - s->bucket_tenant, s->bucket_name, bucket, &selected_placement_rule, nullptr); if (selected_placement_rule != s->bucket_info.placement_rule) { op_ret = -EEXIST; @@ -2454,7 +2455,7 @@ void RGWDeleteBucket::execute() } } - op_ret = rgw_bucket_sync_user_stats(store, s->user->user_id, s->bucket); + op_ret = rgw_bucket_sync_user_stats(store, s->user->user_id, s->bucket_info); if ( op_ret < 0) { ldout(s->cct, 1) << "WARNING: failed to sync user stats before bucket delete: op_ret= " << op_ret << dendl; } @@ -2473,7 +2474,7 @@ void RGWDeleteBucket::execute() } } - op_ret = store->delete_bucket(s->bucket, ot); + op_ret = store->delete_bucket(s->bucket_info, ot); if (op_ret == 0) { op_ret = rgw_unlink_bucket(store, s->user->user_id, s->bucket.tenant, s->bucket.name, false); @@ -5025,7 +5026,7 @@ bool RGWBulkDelete::Deleter::delete_single(const acct_path_t& path) RGWObjVersionTracker ot; ot.read_version = binfo.ep_objv; - ret = store->delete_bucket(binfo.bucket, ot); + ret = store->delete_bucket(binfo, ot); if (0 == ret) { ret = rgw_unlink_bucket(store, binfo.owner, binfo.bucket.tenant, binfo.bucket.name, false); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 55b207e220f81c..0f806410bbd962 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2191,7 +2191,7 @@ RGWPutObjProcessor_Aio::~RGWPutObjProcessor_Aio() rgw_raw_obj raw_head; if (!head_obj.empty()) { - RGWRados::obj_to_raw(head_obj, &raw_head); + store->obj_to_raw(head_obj, &raw_head); } /** @@ -2404,7 +2404,7 @@ int RGWPutObjProcessor_Atomic::prepare_init(RGWRados *store, string *oid_rand) { RGWPutObjProcessor::prepare(store, oid_rand); - int r = store->get_max_chunk_size(bucket, &max_chunk_size); + int r = store->get_max_chunk_size(head_obj, &max_chunk_size); if (r < 0) { return r; } @@ -3089,11 +3089,6 @@ int RGWRados::get_required_alignment(const rgw_pool& pool, uint64_t *alignment) return 0; } -int RGWRados::get_required_alignment(const rgw_bucket& bucket, uint64_t *alignment) -{ - return get_required_alignment(bucket.placement.data_pool, alignment); -} - int RGWRados::get_max_chunk_size(const rgw_pool& pool, uint64_t *max_chunk_size) { uint64_t alignment; @@ -3121,9 +3116,14 @@ int RGWRados::get_max_chunk_size(const rgw_pool& pool, uint64_t *max_chunk_size) return 0; } -int RGWRados::get_max_chunk_size(const rgw_bucket& bucket, uint64_t *max_chunk_size) +int RGWRados::get_max_chunk_size(const rgw_obj& obj, uint64_t *max_chunk_size) { - return get_max_chunk_size(bucket.placement.data_pool, max_chunk_size); + rgw_pool pool; + if (!zone_params.get_data_pool(obj, &pool)) { + ldout(cct, 0) << "ERROR: failed to get data pool for object " << obj << dendl; + return -EIO; + } + return get_max_chunk_size(pool, max_chunk_size); } void RGWRados::finalize() @@ -4183,9 +4183,19 @@ void RGWRados::build_bucket_index_marker(const string& shard_id_str, const strin } } -int RGWRados::open_bucket_index_ctx(rgw_bucket& bucket, librados::IoCtx& index_ctx) +int RGWRados::open_bucket_index_ctx(RGWBucketInfo& bucket_info, librados::IoCtx& index_ctx) { - int r = open_pool_ctx(bucket.placement.index_pool, index_ctx); + string *rule = &bucket_info.placement_rule; + if (rule->empty()) { + rule = &zonegroup.default_placement; + } + auto iter = zone_params.placement_pools.find(*rule); + if (iter == zone_params.placement_pools.end()) { + ldout(cct, 0) << "could not find placement rule " << *rule << " within zonegroup " << dendl; + return -EINVAL; + } + + int r = open_pool_ctx(iter->second.index_pool, index_ctx); if (r < 0) return r; @@ -4904,7 +4914,6 @@ int RGWRados::Bucket::List::list_objects(int max, vector *result, { RGWRados *store = target->get_store(); CephContext *cct = store->ctx(); - rgw_bucket& bucket = target->get_bucket(); int shard_id = target->get_shard_id(); int count = 0; @@ -4966,8 +4975,9 @@ int RGWRados::Bucket::List::list_objects(int max, vector *result, ldout(cct, 20) << "setting cur_marker=" << cur_marker.name << "[" << cur_marker.instance << "]" << dendl; } std::map ent_map; - int r = store->cls_bucket_list(bucket, shard_id, cur_marker, cur_prefix, read_ahead + 1 - count, params.list_versions, ent_map, - &truncated, &cur_marker); + 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; @@ -5085,16 +5095,16 @@ int RGWRados::create_pool(rgw_pool& pool) return 0; } -int RGWRados::init_bucket_index(rgw_bucket& bucket, int num_shards) +int RGWRados::init_bucket_index(RGWBucketInfo& bucket_info, int num_shards) { librados::IoCtx index_ctx; // context for new bucket - int r = open_bucket_index_ctx(bucket, index_ctx); + int r = open_bucket_index_ctx(bucket_info, index_ctx); if (r < 0) return r; string dir_oid = dir_oid_prefix; - dir_oid.append(bucket.marker); + dir_oid.append(bucket_info.bucket.marker); map bucket_objs; get_bucket_index_objects(dir_oid, num_shards, bucket_objs); @@ -5125,8 +5135,7 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, for (int i = 0; i < MAX_CREATE_RETRIES; i++) { int ret = 0; - ret = select_bucket_placement(owner, zonegroup_id, placement_rule, - bucket.tenant, bucket.name, bucket, + ret = select_bucket_placement(owner, zonegroup_id, placement_rule, bucket, &selected_placement_rule_name, &rule_info); if (ret < 0) return ret; @@ -5143,10 +5152,6 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, bucket.bucket_id = pmaster_bucket->bucket_id; } - int r = init_bucket_index(bucket, bucket_index_max_shards); - if (r < 0) - return r; - RGWObjVersionTracker& objv_tracker = info.objv_tracker; if (pobjv) { @@ -5173,6 +5178,12 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, if (pquota_info) { info.quota = *pquota_info; } + + int r = init_bucket_index(info, bucket_index_max_shards); + if (r < 0) { + return r; + } + ret = put_linked_bucket_info(info, exclusive, ceph::real_time(), pep_objv, &attrs, true); if (ret == -EEXIST) { /* we need to reread the info and return it, caller will have a use for it */ @@ -5193,7 +5204,7 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, /* remove bucket index */ librados::IoCtx index_ctx; // context for new bucket map bucket_objs; - int r = open_bucket_index(bucket, index_ctx, bucket_objs); + int r = open_bucket_index(info, index_ctx, bucket_objs); if (r < 0) return r; @@ -5220,8 +5231,7 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, } int RGWRados::select_new_bucket_location(RGWUserInfo& user_info, const string& zonegroup_id, const string& request_rule, - const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule_name, - RGWZonePlacementInfo *rule_info) + rgw_bucket& bucket, string *pselected_rule_name, RGWZonePlacementInfo *rule_info) { /* first check that rule exists within the specific zonegroup */ @@ -5262,20 +5272,16 @@ int RGWRados::select_new_bucket_location(RGWUserInfo& user_info, const string& z if (pselected_rule_name) *pselected_rule_name = rule; - return set_bucket_location_by_rule(rule, tenant_name, bucket_name, bucket, rule_info); + return select_bucket_location_by_rule(rule, bucket, rule_info); } -int RGWRados::set_bucket_location_by_rule(const string& location_rule, const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, - RGWZonePlacementInfo *rule_info) +int RGWRados::select_bucket_location_by_rule(const string& location_rule, rgw_bucket& bucket, RGWZonePlacementInfo *rule_info) { - bucket.tenant = tenant_name; - bucket.name = bucket_name; - if (location_rule.empty()) { /* we can only reach here if we're trying to set a bucket location from a bucket * created on a different zone, using a legacy / default pool configuration */ - return select_legacy_bucket_placement(tenant_name, bucket_name, bucket, rule_info); + return select_legacy_bucket_placement(bucket, rule_info); } /* @@ -5298,10 +5304,6 @@ int RGWRados::set_bucket_location_by_rule(const string& location_rule, const str RGWZonePlacementInfo& placement_info = piter->second; - bucket.placement.data_pool = placement_info.data_pool; - bucket.placement.data_extra_pool = placement_info.data_extra_pool; - bucket.placement.index_pool = placement_info.index_pool; - if (rule_info) { *rule_info = placement_info; } @@ -5310,23 +5312,21 @@ int RGWRados::set_bucket_location_by_rule(const string& location_rule, const str } int RGWRados::select_bucket_placement(RGWUserInfo& user_info, const string& zonegroup_id, const string& placement_rule, - const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, - string *pselected_rule_name, RGWZonePlacementInfo *rule_info) + rgw_bucket& bucket, string *pselected_rule_name, RGWZonePlacementInfo *rule_info) { if (!get_zone_params().placement_pools.empty()) { return select_new_bucket_location(user_info, zonegroup_id, placement_rule, - tenant_name, bucket_name, bucket, pselected_rule_name, rule_info); + bucket, pselected_rule_name, rule_info); } if (pselected_rule_name) { pselected_rule_name->clear(); } - return select_legacy_bucket_placement(tenant_name, bucket_name, bucket, rule_info); + return select_legacy_bucket_placement(bucket, rule_info); } -int RGWRados::select_legacy_bucket_placement(const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, - RGWZonePlacementInfo *rule_info) +int RGWRados::select_legacy_bucket_placement(rgw_bucket& bucket, RGWZonePlacementInfo *rule_info) { bufferlist map_bl; map m; @@ -5398,8 +5398,6 @@ int RGWRados::select_legacy_bucket_placement(const string& tenant_name, const st miter = m.begin(); pool_name = miter->first; } - bucket.placement.data_pool = pool_name; - bucket.placement.index_pool = pool_name; rule_info->data_pool = pool_name; rule_info->data_extra_pool = pool_name; @@ -5409,6 +5407,33 @@ int RGWRados::select_legacy_bucket_placement(const string& tenant_name, const st return 0; } +bool RGWRados::get_obj_data_pool(const rgw_obj& obj, rgw_pool *pool) +{ + if (!zone_params.get_data_pool(obj, pool)) { + ldout(cct, 1) << "WARNING: placement for obj=" << obj << " is not found, setting default pool" << dendl; + RGWZonePlacementInfo placement; + if (!zone_params.get_placement(zonegroup.default_placement, &placement)) { + ldout(cct, 0) << "ERROR: misconfiguration, default placement '" << zonegroup.default_placement << "' is not defined in zone params" << dendl; + return false; + } + + if (!obj.in_extra_data) { + *pool = placement.data_pool; + } else { + *pool = placement.data_extra_pool; + } + } + + return true; +} + +bool RGWRados::obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj) +{ + get_obj_bucket_and_oid_loc(obj, raw_obj->oid, raw_obj->loc); + + return get_obj_data_pool(obj, &raw_obj->pool); +} + int RGWRados::update_placement_map() { bufferlist header; @@ -5512,19 +5537,19 @@ int RGWRados::create_pools(vector& names, vector& retcodes) int RGWRados::get_obj_ioctx(const rgw_obj& obj, librados::IoCtx *ioctx) { - const rgw_bucket& bucket = obj.bucket; string oid, key; get_obj_bucket_and_oid_loc(obj, oid, key); - int r; - - if (!obj.is_in_extra_data()) { - r = open_pool_ctx(bucket.placement.data_pool, *ioctx); - } else { - r = open_pool_ctx(bucket.placement.get_data_extra_pool(), *ioctx); + rgw_pool pool; + if (!get_obj_data_pool(obj, &pool)) { + ldout(cct, 0) << "ERROR: cannot get data pool for obj=" << obj << ", probably misconfiguration" << dendl; + return -EIO; } - if (r < 0) + + int r = open_pool_ctx(pool, *ioctx); + if (r < 0) { return r; + } ioctx->locator_set_key(key); @@ -5535,15 +5560,16 @@ int RGWRados::get_obj_ref(const rgw_obj& obj, rgw_rados_ref *ref) { get_obj_bucket_and_oid_loc(obj, ref->oid, ref->key); - int r; - - if (!obj.is_in_extra_data()) { - r = open_pool_ctx(obj.bucket.placement.data_pool, ref->ioctx); - } else { - r = open_pool_ctx(obj.bucket.placement.get_data_extra_pool(), ref->ioctx); + rgw_pool pool; + if (!get_obj_data_pool(obj, &pool)) { + ldout(cct, 0) << "ERROR: cannot get data pool for obj=" << obj << ", probably misconfiguration" << dendl; + return -EIO; } - if (r < 0) + + int r = open_pool_ctx(pool, ref->ioctx); + if (r < 0) { return r; + } ref->ioctx.locator_set_key(ref->key); @@ -5575,11 +5601,6 @@ int RGWRados::get_raw_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_po return 0; } -void RGWRados::obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj) -{ - rgw_obj_to_raw(obj, raw_obj); -} - int RGWRados::get_system_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool) { return get_raw_obj_ref(obj, ref, pool); @@ -5819,7 +5840,15 @@ int RGWRados::BucketShard::init(const rgw_bucket& _bucket, const rgw_obj& obj) { bucket = _bucket; - int ret = store->open_bucket_index_shard(bucket, index_ctx, obj.get_hash_object(), &bucket_obj, &shard_id); + RGWObjectCtx obj_ctx(store); + + RGWBucketInfo bucket_info; + int ret = store->get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, NULL); + if (ret < 0) { + return ret; + } + + ret = store->open_bucket_index_shard(bucket_info, index_ctx, obj.get_hash_object(), &bucket_obj, &shard_id); if (ret < 0) { ldout(store->ctx(), 0) << "ERROR: open_bucket_index_shard() returned ret=" << ret << dendl; return ret; @@ -6576,7 +6605,7 @@ int RGWRados::rewrite_obj(RGWBucketInfo& dest_bucket_info, rgw_obj& obj) uint64_t max_chunk_size; - ret = get_max_chunk_size(obj.bucket, &max_chunk_size); + ret = get_max_chunk_size(obj, &max_chunk_size); if (ret < 0) { ldout(cct, 0) << "ERROR: failed to get max_chunk_size() for bucket " << obj.bucket << dendl; return ret; @@ -7049,13 +7078,25 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, } uint64_t max_chunk_size; - ret = get_max_chunk_size(dest_obj.bucket, &max_chunk_size); + ret = get_max_chunk_size(dest_obj, &max_chunk_size); if (ret < 0) { ldout(cct, 0) << "ERROR: failed to get max_chunk_size() for bucket " << dest_obj.bucket << dendl; return ret; } - bool copy_data = !astate->has_manifest || (src_obj.bucket.placement.data_pool != dest_obj.bucket.placement.data_pool); + rgw_pool src_pool; + rgw_pool dest_pool; + if (!get_obj_data_pool(src_obj, &src_pool)) { + ldout(cct, 0) << "ERROR: failed to locate data pool for " << src_obj << dendl; + return -EIO; + } + if (!get_obj_data_pool(dest_obj, &dest_pool)) { + ldout(cct, 0) << "ERROR: failed to locate data pool for " << dest_obj << dendl; + return -EIO; + } + + + bool copy_data = !astate->has_manifest || (src_pool != dest_pool); bool copy_first = false; if (astate->has_manifest) { if (!astate->manifest.has_tail()) { @@ -7294,7 +7335,7 @@ bool RGWRados::is_meta_master() * bucket: the bucket to check * Returns false is the bucket is not synced */ -bool RGWRados::is_syncing_bucket_meta(rgw_bucket& bucket) +bool RGWRados::is_syncing_bucket_meta(const rgw_bucket& bucket) { /* no current period */ @@ -7325,11 +7366,12 @@ bool RGWRados::is_syncing_bucket_meta(rgw_bucket& bucket) * bucket: the name of the bucket to delete * Returns 0 on success, -ERR# otherwise. */ -int RGWRados::delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_tracker) +int RGWRados::delete_bucket(RGWBucketInfo& bucket_info, RGWObjVersionTracker& objv_tracker) { + const rgw_bucket& bucket = bucket_info.bucket; librados::IoCtx index_ctx; map bucket_objs; - int r = open_bucket_index(bucket, index_ctx, bucket_objs); + int r = open_bucket_index(bucket_info, index_ctx, bucket_objs); if (r < 0) return r; @@ -7340,7 +7382,7 @@ int RGWRados::delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_track do { #define NUM_ENTRIES 1000 - r = cls_bucket_list(bucket, RGW_NO_SHARD, marker, prefix, NUM_ENTRIES, true, ent_map, + r = cls_bucket_list(bucket_info, RGW_NO_SHARD, marker, prefix, NUM_ENTRIES, true, ent_map, &is_truncated, &marker); if (r < 0) return r; @@ -7486,9 +7528,10 @@ int RGWRados::send_chain_to_gc(cls_rgw_obj_chain& chain, const string& tag, bool return gc->send_chain(chain, tag, sync); } -int RGWRados::open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx, string& bucket_oid) +int RGWRados::open_bucket_index(RGWBucketInfo& bucket_info, librados::IoCtx& index_ctx, string& bucket_oid) { - int r = open_bucket_index_ctx(bucket, index_ctx); + const rgw_bucket& bucket = bucket_info.bucket; + int r = open_bucket_index_ctx(bucket_info, index_ctx); if (r < 0) return r; @@ -7503,9 +7546,10 @@ int RGWRados::open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx, return 0; } -int RGWRados::open_bucket_index_base(rgw_bucket& bucket, librados::IoCtx& index_ctx, +int RGWRados::open_bucket_index_base(RGWBucketInfo& bucket_info, librados::IoCtx& index_ctx, string& bucket_oid_base) { - int r = open_bucket_index_ctx(bucket, index_ctx); + const rgw_bucket& bucket = bucket_info.bucket; + int r = open_bucket_index_ctx(bucket_info, index_ctx); if (r < 0) return r; @@ -7521,34 +7565,27 @@ int RGWRados::open_bucket_index_base(rgw_bucket& bucket, librados::IoCtx& index_ } -int RGWRados::open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx, +int RGWRados::open_bucket_index(RGWBucketInfo& bucket_info, librados::IoCtx& index_ctx, map& bucket_objs, int shard_id, map *bucket_instance_ids) { string bucket_oid_base; - int ret = open_bucket_index_base(bucket, index_ctx, bucket_oid_base); - if (ret < 0) - return ret; - - RGWObjectCtx obj_ctx(this); - - // Get the bucket info - RGWBucketInfo binfo; - ret = get_bucket_instance_info(obj_ctx, bucket, binfo, NULL, NULL); - if (ret < 0) + int ret = open_bucket_index_base(bucket_info, index_ctx, bucket_oid_base); + if (ret < 0) { return ret; + } - get_bucket_index_objects(bucket_oid_base, binfo.num_shards, bucket_objs, shard_id); + get_bucket_index_objects(bucket_oid_base, bucket_info.num_shards, bucket_objs, shard_id); if (bucket_instance_ids) { - get_bucket_instance_ids(binfo, shard_id, bucket_instance_ids); + get_bucket_instance_ids(bucket_info, shard_id, bucket_instance_ids); } return 0; } template -int RGWRados::open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx, +int RGWRados::open_bucket_index(RGWBucketInfo& bucket_info, librados::IoCtx& index_ctx, map& oids, map& bucket_objs, int shard_id, map *bucket_instance_ids) { - int ret = open_bucket_index(bucket, index_ctx, oids, shard_id, bucket_instance_ids); + int ret = open_bucket_index(bucket_info, index_ctx, oids, shard_id, bucket_instance_ids); if (ret < 0) return ret; @@ -7559,24 +7596,18 @@ int RGWRados::open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx, return 0; } -int RGWRados::open_bucket_index_shard(rgw_bucket& bucket, librados::IoCtx& index_ctx, +int RGWRados::open_bucket_index_shard(RGWBucketInfo& bucket_info, librados::IoCtx& index_ctx, const string& obj_key, string *bucket_obj, int *shard_id) { string bucket_oid_base; - int ret = open_bucket_index_base(bucket, index_ctx, bucket_oid_base); + int ret = open_bucket_index_base(bucket_info, index_ctx, bucket_oid_base); if (ret < 0) return ret; RGWObjectCtx obj_ctx(this); - // Get the bucket info - RGWBucketInfo binfo; - ret = get_bucket_instance_info(obj_ctx, bucket, binfo, NULL, NULL); - if (ret < 0) - return ret; - - ret = get_bucket_index_object(bucket_oid_base, obj_key, binfo.num_shards, - (RGWBucketInfo::BIShardsHashType)binfo.bucket_index_shard_hash_type, bucket_obj, shard_id); + ret = get_bucket_index_object(bucket_oid_base, obj_key, bucket_info.num_shards, + (RGWBucketInfo::BIShardsHashType)bucket_info.bucket_index_shard_hash_type, bucket_obj, shard_id); if (ret < 0) { ldout(cct, 10) << "get_bucket_index_object() returned ret=" << ret << dendl; return ret; @@ -7600,7 +7631,7 @@ static void accumulate_raw_stats(const rgw_bucket_dir_header& header, } } -int RGWRados::bucket_check_index(rgw_bucket& bucket, +int RGWRados::bucket_check_index(RGWBucketInfo& bucket_info, map *existing_stats, map *calculated_stats) { @@ -7609,7 +7640,7 @@ int RGWRados::bucket_check_index(rgw_bucket& bucket, // value - bucket index check OP returned result with the given bucket index object (shard) map oids; map bucket_objs_ret; - int ret = open_bucket_index(bucket, index_ctx, oids, bucket_objs_ret); + int ret = open_bucket_index(bucket_info, index_ctx, oids, bucket_objs_ret); if (ret < 0) return ret; @@ -7627,11 +7658,11 @@ int RGWRados::bucket_check_index(rgw_bucket& bucket, return 0; } -int RGWRados::bucket_rebuild_index(rgw_bucket& bucket) +int RGWRados::bucket_rebuild_index(RGWBucketInfo& bucket_info) { librados::IoCtx index_ctx; map bucket_objs; - int r = open_bucket_index(bucket, index_ctx, bucket_objs); + int r = open_bucket_index(bucket_info, index_ctx, bucket_objs); if (r < 0) return r; @@ -8700,7 +8731,7 @@ int RGWRados::Object::Read::prepare(int64_t *pofs, int64_t *pend) } state.obj = astate->obj; - RGWRados::obj_to_raw(state.obj, &state.head_obj); + store->obj_to_raw(state.obj, &state.head_obj); r = store->get_obj_ioctx(state.obj, &state.io_ctx); if (r < 0) { @@ -10387,14 +10418,15 @@ int RGWRados::raw_obj_stat(rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, return 0; } -int RGWRados::get_bucket_stats(rgw_bucket& bucket, int shard_id, string *bucket_ver, string *master_ver, +int RGWRados::get_bucket_stats(RGWBucketInfo& bucket_info, int shard_id, string *bucket_ver, string *master_ver, map& stats, string *max_marker) { map headers; map bucket_instance_ids; - int r = cls_bucket_head(bucket, shard_id, headers, &bucket_instance_ids); - if (r < 0) + int r = cls_bucket_head(bucket_info, shard_id, headers, &bucket_instance_ids); + if (r < 0) { return r; + } assert(headers.size() == bucket_instance_ids.size()); @@ -10425,12 +10457,12 @@ int RGWRados::get_bucket_stats(rgw_bucket& bucket, int shard_id, string *bucket_ return 0; } -int RGWRados::get_bi_log_status(rgw_bucket& bucket, int shard_id, +int RGWRados::get_bi_log_status(RGWBucketInfo& bucket_info, int shard_id, map& markers) { map headers; map bucket_instance_ids; - int r = cls_bucket_head(bucket, shard_id, headers, &bucket_instance_ids); + int r = cls_bucket_head(bucket_info, shard_id, headers, &bucket_instance_ids); if (r < 0) return r; @@ -10488,19 +10520,12 @@ class RGWGetBucketStatsContext : public RGWGetDirHeader_CB { } }; -int RGWRados::get_bucket_stats_async(rgw_bucket& bucket, int shard_id, RGWGetBucketStats_CB *ctx) +int RGWRados::get_bucket_stats_async(RGWBucketInfo& bucket_info, int shard_id, RGWGetBucketStats_CB *ctx) { - RGWBucketInfo binfo; - RGWObjectCtx obj_ctx(this); - - int r = get_bucket_instance_info(obj_ctx, bucket, binfo, NULL, NULL); - if (r < 0) - return r; - int num_aio = 0; - RGWGetBucketStatsContext *get_ctx = new RGWGetBucketStatsContext(ctx, binfo.num_shards); + RGWGetBucketStatsContext *get_ctx = new RGWGetBucketStatsContext(ctx, bucket_info.num_shards); assert(get_ctx); - r = cls_bucket_head_async(bucket, shard_id, get_ctx, &num_aio); + int r = cls_bucket_head_async(bucket_info, shard_id, get_ctx, &num_aio); get_ctx->put(); if (r < 0) { ctx->put(); @@ -10923,6 +10948,8 @@ int RGWRados::omap_del(rgw_raw_obj& obj, const std::string& key) int RGWRados::update_containers_stats(map& m) { + RGWObjectCtx obj_ctx(this); + map::iterator iter; for (iter = m.begin(); iter != m.end(); ++iter) { RGWBucketEnt& ent = iter->second; @@ -10932,7 +10959,14 @@ int RGWRados::update_containers_stats(map& m) ent.size_rounded = 0; map headers; - int r = cls_bucket_head(bucket, RGW_NO_SHARD, headers); + + RGWBucketInfo bucket_info; + int ret = get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, NULL); + if (ret < 0) { + return ret; + } + + int r = cls_bucket_head(bucket_info, RGW_NO_SHARD, headers); if (r < 0) return r; @@ -11068,17 +11102,17 @@ int RGWRados::list_raw_objects(const rgw_pool& pool, const string& prefix_filter return oids.size(); } -int RGWRados::list_bi_log_entries(rgw_bucket& bucket, int shard_id, string& marker, uint32_t max, +int RGWRados::list_bi_log_entries(RGWBucketInfo& bucket_info, int shard_id, string& marker, uint32_t max, std::list& result, bool *truncated) { - ldout(cct, 20) << __func__ << ": " << bucket << " marker " << marker << " shard_id=" << shard_id << " max " << max << dendl; + ldout(cct, 20) << __func__ << ": " << bucket_info.bucket << " marker " << marker << " shard_id=" << shard_id << " max " << max << dendl; result.clear(); librados::IoCtx index_ctx; map oids; map bi_log_lists; map bucket_instance_ids; - int r = open_bucket_index(bucket, index_ctx, oids, shard_id, &bucket_instance_ids); + int r = open_bucket_index(bucket_info, index_ctx, oids, shard_id, &bucket_instance_ids); if (r < 0) return r; @@ -11167,11 +11201,11 @@ int RGWRados::list_bi_log_entries(rgw_bucket& bucket, int shard_id, string& mark return 0; } -int RGWRados::trim_bi_log_entries(rgw_bucket& bucket, int shard_id, string& start_marker, string& end_marker) +int RGWRados::trim_bi_log_entries(RGWBucketInfo& bucket_info, int shard_id, string& start_marker, string& end_marker) { librados::IoCtx index_ctx; map bucket_objs; - int r = open_bucket_index(bucket, index_ctx, bucket_objs, shard_id); + int r = open_bucket_index(bucket_info, index_ctx, bucket_objs, shard_id); if (r < 0) return r; @@ -11395,30 +11429,30 @@ int RGWRados::cls_obj_complete_cancel(BucketShard& bs, string& tag, rgw_obj& obj return cls_obj_complete_op(bs, CLS_RGW_OP_CANCEL, tag, -1 /* pool id */, 0, ent, RGW_OBJ_CATEGORY_NONE, NULL, bilog_flags); } -int RGWRados::cls_obj_set_bucket_tag_timeout(rgw_bucket& bucket, uint64_t timeout) +int RGWRados::cls_obj_set_bucket_tag_timeout(RGWBucketInfo& bucket_info, uint64_t timeout) { librados::IoCtx index_ctx; map bucket_objs; - int r = open_bucket_index(bucket, index_ctx, bucket_objs); + int r = open_bucket_index(bucket_info, index_ctx, bucket_objs); if (r < 0) return r; return CLSRGWIssueSetTagTimeout(index_ctx, bucket_objs, cct->_conf->rgw_bucket_index_max_aio, timeout)(); } -int RGWRados::cls_bucket_list(rgw_bucket& bucket, int shard_id, rgw_obj_key& start, const string& prefix, +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& m, bool *is_truncated, rgw_obj_key *last_entry, bool (*force_check_filter)(const string& name)) { - ldout(cct, 10) << "cls_bucket_list " << bucket << " start " << start.name << "[" << start.instance << "] num_entries " << num_entries << dendl; + ldout(cct, 10) << "cls_bucket_list " << bucket_info.bucket << " start " << start.name << "[" << start.instance << "] num_entries " << num_entries << dendl; librados::IoCtx index_ctx; // key - oid (for different shards if there is any) // value - list result for the corresponding oid (shard), it is filled by the AIO callback map oids; map list_results; - int r = open_bucket_index(bucket, index_ctx, oids, shard_id); + int r = open_bucket_index(bucket_info, index_ctx, oids, shard_id); if (r < 0) return r; @@ -11479,7 +11513,7 @@ int RGWRados::cls_bucket_list(rgw_bucket& bucket, int shard_id, rgw_obj_key& sta * 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, dirent, e, updates[vnames[pos]]); + r = check_disk_state(sub_ctx, bucket_info.bucket, dirent, e, updates[vnames[pos]]); if (r < 0 && r != -ENOENT) { return r; } @@ -11578,14 +11612,14 @@ int RGWRados::cls_obj_usage_log_trim(string& oid, string& user, uint64_t start_e return r; } -int RGWRados::remove_objs_from_index(rgw_bucket& bucket, list& oid_list) +int RGWRados::remove_objs_from_index(RGWBucketInfo& bucket_info, list& oid_list) { librados::IoCtx index_ctx; string dir_oid; uint8_t suggest_flag = (get_zone().log_data ? CEPH_RGW_DIR_SUGGEST_LOG_OP : 0); - int r = open_bucket_index(bucket, index_ctx, dir_oid); + int r = open_bucket_index(bucket_info, index_ctx, dir_oid); if (r < 0) return r; @@ -11595,7 +11629,7 @@ int RGWRados::remove_objs_from_index(rgw_bucket& bucket, list& oid_ for (iter = oid_list.begin(); iter != oid_list.end(); ++iter) { rgw_obj_key& key = *iter; - dout(2) << "RGWRados::remove_objs_from_index bucket=" << bucket << " obj=" << key.name << ":" << key.instance << dendl; + dout(2) << "RGWRados::remove_objs_from_index bucket=" << bucket_info.bucket << " obj=" << key.name << ":" << key.instance << dendl; rgw_bucket_dir_entry entry; entry.ver.epoch = (uint64_t)-1; // ULLONG_MAX, needed to that objclass doesn't skip out request key.transform(&entry.key); @@ -11720,12 +11754,12 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx, return 0; } -int RGWRados::cls_bucket_head(rgw_bucket& bucket, int shard_id, map& headers, map *bucket_instance_ids) +int RGWRados::cls_bucket_head(RGWBucketInfo& bucket_info, int shard_id, map& headers, map *bucket_instance_ids) { librados::IoCtx index_ctx; map oids; map list_results; - int r = open_bucket_index(bucket, index_ctx, oids, list_results, shard_id, bucket_instance_ids); + int r = open_bucket_index(bucket_info, index_ctx, oids, list_results, shard_id, bucket_instance_ids); if (r < 0) return r; @@ -11740,11 +11774,11 @@ int RGWRados::cls_bucket_head(rgw_bucket& bucket, int shard_id, map bucket_objs; - int r = open_bucket_index(bucket, index_ctx, bucket_objs, shard_id); + int r = open_bucket_index(bucket_info, index_ctx, bucket_objs, shard_id); if (r < 0) return r; @@ -11807,10 +11841,10 @@ int RGWRados::cls_user_get_header_async(const string& user_id, RGWGetUserHeader_ return 0; } -int RGWRados::cls_user_sync_bucket_stats(rgw_raw_obj& user_obj, rgw_bucket& bucket) +int RGWRados::cls_user_sync_bucket_stats(rgw_raw_obj& user_obj, RGWBucketInfo& bucket_info) { map headers; - int r = cls_bucket_head(bucket, RGW_NO_SHARD, headers); + int r = cls_bucket_head(bucket_info, RGW_NO_SHARD, headers); if (r < 0) { ldout(cct, 20) << "cls_bucket_header() returned " << r << dendl; return r; @@ -11818,7 +11852,7 @@ int RGWRados::cls_user_sync_bucket_stats(rgw_raw_obj& user_obj, rgw_bucket& buck cls_user_bucket_entry entry; - bucket.convert(&entry.bucket); + bucket_info.bucket.convert(&entry.bucket); map::iterator hiter = headers.begin(); for (; hiter != headers.end(); ++hiter) { @@ -11843,30 +11877,6 @@ int RGWRados::cls_user_sync_bucket_stats(rgw_raw_obj& user_obj, rgw_bucket& buck return 0; } -int RGWRados::update_user_bucket_stats(const string& user_id, rgw_bucket& bucket, RGWStorageStats& stats) -{ - cls_user_bucket_entry entry; - - entry.size = stats.size; - entry.size_rounded = stats.size_rounded; - entry.count += stats.num_objects; - - list entries; - entries.push_back(entry); - - string buckets_obj_id; - rgw_get_buckets_obj(user_id, buckets_obj_id); - rgw_raw_obj obj(get_zone_params().user_uid_pool, buckets_obj_id); - - int r = cls_user_update_buckets(obj, entries, false); - if (r < 0) { - ldout(cct, 20) << "cls_user_update_buckets() returned " << r << dendl; - return r; - } - - return 0; -} - int RGWRados::cls_user_list_buckets(rgw_raw_obj& obj, const string& in_marker, const string& end_marker, @@ -12416,7 +12426,7 @@ int RGWRados::delete_raw_obj_aio(const rgw_raw_obj& obj, list& handles, bool keep_index_consistent) { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 37d06b74379a26..e2c5a3796121f5 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -35,6 +35,7 @@ class RGWMetaSyncProcessorThread; class RGWDataSyncProcessorThread; class RGWSyncLogTrimThread; class RGWRESTConn; +struct RGWZoneGroup; /* flags for put_obj_meta() */ #define PUT_OBJ_CREATE 0x01 @@ -73,17 +74,6 @@ static inline void get_obj_bucket_and_oid_loc(const rgw_obj& obj, string& oid, s int rgw_policy_from_attrset(CephContext *cct, map& attrset, RGWAccessControlPolicy *policy); -static inline void rgw_obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj) -{ - get_obj_bucket_and_oid_loc(obj, raw_obj->oid, raw_obj->loc); - - if (!obj.is_in_extra_data()) { - raw_obj->pool = obj.bucket.placement.data_pool; - } else { - raw_obj->pool = obj.bucket.placement.get_data_extra_pool(); - } -} - static inline bool rgw_raw_obj_to_obj(const rgw_bucket& bucket, const rgw_raw_obj& raw_obj, rgw_obj *obj) { string name; @@ -272,6 +262,8 @@ struct RGWObjManifestRule { WRITE_CLASS_ENCODER(RGWObjManifestRule) class RGWObjManifest { + rgw_raw_obj head_obj; /* in-memory only, calculated from obj */ + bool raw_head_initialized{false}; protected: bool explicit_objs; /* old manifest? */ map objs; @@ -279,7 +271,6 @@ class RGWObjManifest { uint64_t obj_size; rgw_obj obj; - rgw_raw_obj head_obj; /* in-memory only, calculated from obj */ uint64_t head_size; uint64_t max_head_size; @@ -440,8 +431,6 @@ class RGWObjManifest { tail_instance = obj.get_instance(); } - rgw_obj_to_raw(obj, &head_obj); - update_iterators(); DECODE_FINISH(bl); } @@ -477,7 +466,7 @@ class RGWObjManifest { void set_head(const rgw_obj& _o, uint64_t _s) { obj = _o; - rgw_obj_to_raw(obj, &head_obj); + raw_head_initialized = false; head_size = _s; if (explicit_objs && head_size > 0) { @@ -490,9 +479,7 @@ class RGWObjManifest { return obj; } - const rgw_raw_obj& get_head() { - return head_obj; - } + const rgw_raw_obj& get_head(RGWRados *store); void set_tail_bucket(const rgw_bucket& _b) { tail_bucket = _b; @@ -605,7 +592,7 @@ class RGWObjManifest { bool operator!=(const obj_iterator& rhs) { return (ofs != rhs.ofs); } - const rgw_raw_obj& get_location() { + const rgw_raw_obj& get_location(RGWRados *store) { return location; } @@ -953,8 +940,6 @@ class RGWSystemMetaObj { }; WRITE_CLASS_ENCODER(RGWSystemMetaObj) -struct RGWZoneGroup; - struct RGWZonePlacementInfo { string index_pool; string data_pool; @@ -1097,6 +1082,70 @@ struct RGWZoneParams : RGWSystemMetaObj { void dump(Formatter *f) const; void decode_json(JSONObj *obj); static void generate_test_instances(list& o); + + bool find_placement(const rgw_data_placement_target& placement, string *placement_id) { + for (const auto& pp : placement_pools) { + const RGWZonePlacementInfo& info = pp.second; + if (info.index_pool == placement.index_pool.to_str() && + info.data_pool == placement.data_pool.to_str() && + info.data_extra_pool == placement.data_extra_pool.to_str()) { + *placement_id = pp.first; + return true; + } + } + return false; + } + + bool get_placement(const string& placement_id, RGWZonePlacementInfo *placement) const { + auto iter = placement_pools.find(placement_id); + if (iter == placement_pools.end()) { + return false; + } + *placement = iter->second; + return true; + } + + bool get_index_pool(const rgw_obj& obj, rgw_pool *pool) { + if (!obj.bucket.explicit_placement.index_pool.empty()) { + *pool = obj.bucket.explicit_placement.index_pool; + return true; + } + if (obj.placement_id.empty()) { + return false; + } + auto iter = placement_pools.find(obj.placement_id); + if (iter == placement_pools.end()) { + return false; + } + pool->init(iter->second.index_pool); + return true; + } + + bool get_data_pool(const rgw_obj& obj, rgw_pool *pool) const { + const rgw_data_placement_target& explicit_placement = obj.bucket.explicit_placement; + if (!explicit_placement.data_pool.empty()) { + if (!obj.in_extra_data) { + *pool = explicit_placement.data_pool; + } else { + *pool = explicit_placement.get_data_extra_pool(); + } + return true; + } + if (obj.placement_id.empty()) { + return false; + } + auto iter = placement_pools.find(obj.placement_id); + if (iter == placement_pools.end()) { + return false; + } + if (!obj.in_extra_data) { + pool->init(iter->second.data_pool); + } else { + pool->init(iter->second.data_extra_pool); + } + pool->init(iter->second.index_pool); + return true; + } }; WRITE_CLASS_ENCODER(RGWZoneParams) @@ -1928,16 +1977,16 @@ class RGWRados int open_objexp_pool_ctx(); int open_pool_ctx(const rgw_pool& pool, librados::IoCtx& io_ctx); - int open_bucket_index_ctx(rgw_bucket& bucket, librados::IoCtx& index_ctx); - int open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx, string& bucket_oid); - int open_bucket_index_base(rgw_bucket& bucket, librados::IoCtx& index_ctx, + int open_bucket_index_ctx(RGWBucketInfo& bucket_info, librados::IoCtx& index_ctx); + int open_bucket_index(RGWBucketInfo& bucket_info, librados::IoCtx& index_ctx, string& bucket_oid); + int open_bucket_index_base(RGWBucketInfo& bucket_info, librados::IoCtx& index_ctx, string& bucket_oid_base); - int open_bucket_index_shard(rgw_bucket& bucket, librados::IoCtx& index_ctx, + int open_bucket_index_shard(RGWBucketInfo& bucket_info, librados::IoCtx& index_ctx, const string& obj_key, string *bucket_obj, int *shard_id); - int open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx, + int open_bucket_index(RGWBucketInfo& bucket_info, librados::IoCtx& index_ctx, map& bucket_objs, int shard_id = -1, map *bucket_instance_ids = NULL); template - int open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx, + int open_bucket_index(RGWBucketInfo& bucket_info, librados::IoCtx& index_ctx, map& oids, map& bucket_objs, int shard_id = -1, map *bucket_instance_ids = NULL); void build_bucket_index_marker(const string& shard_id_str, const string& shard_marker, @@ -2174,12 +2223,10 @@ class RGWRados } int get_required_alignment(const rgw_pool& pool, uint64_t *alignment); - int get_required_alignment(const rgw_bucket& bucket, uint64_t *alignment); int get_max_chunk_size(const rgw_pool& pool, uint64_t *max_chunk_size); - int get_max_chunk_size(const rgw_bucket& bucket, uint64_t *max_chunk_size); + int get_max_chunk_size(const rgw_obj& obj, uint64_t *max_chunk_size); int get_raw_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool = NULL); - static void obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj); int list_raw_objects(const rgw_pool& pool, const string& prefix_filter, int max, RGWListRawObjsCtx& ctx, list& oids, @@ -2247,17 +2294,17 @@ class RGWRados * create a bucket with name bucket and the given list of attrs * returns 0 on success, -ERR# otherwise. */ - int init_bucket_index(rgw_bucket& bucket, int num_shards); + int init_bucket_index(RGWBucketInfo& bucket_info, int num_shards); int select_bucket_placement(RGWUserInfo& user_info, const string& zonegroup_id, const string& rule, - const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule_name, - RGWZonePlacementInfo *rule_info); - int select_legacy_bucket_placement(const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, - RGWZonePlacementInfo *rule_info); + rgw_bucket& bucket, string *pselected_rule_name, RGWZonePlacementInfo *rule_info); + int select_legacy_bucket_placement(rgw_bucket& bucket, RGWZonePlacementInfo *rule_info); int select_new_bucket_location(RGWUserInfo& user_info, const string& zonegroup_id, const string& rule, - const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule_name, - RGWZonePlacementInfo *rule_info); - int set_bucket_location_by_rule(const string& location_rule, const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, - RGWZonePlacementInfo *rule_info); + rgw_bucket& bucket, string *pselected_rule_name, RGWZonePlacementInfo *rule_info); + int select_bucket_location_by_rule(const string& location_rule, rgw_bucket& bucket, RGWZonePlacementInfo *rule_info); + + bool get_obj_data_pool(const rgw_obj& obj, rgw_pool *pool); + bool obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj); + int create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, const string& zonegroup_id, const string& placement_rule, @@ -2775,14 +2822,14 @@ class RGWRados * bucket: the name of the bucket to delete * Returns 0 on success, -ERR# otherwise. */ - int delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_tracker); + int delete_bucket(RGWBucketInfo& bucket_info, RGWObjVersionTracker& objv_tracker); bool is_meta_master(); /** * Check to see if the bucket metadata is synced */ - bool is_syncing_bucket_meta(rgw_bucket& bucket); + bool is_syncing_bucket_meta(const rgw_bucket& bucket); void wakeup_meta_sync_shards(set& shard_ids); void wakeup_data_sync_shards(const string& source_zone, map >& shard_ids); @@ -2957,9 +3004,9 @@ class RGWRados } int decode_policy(bufferlist& bl, ACLOwner *owner); - int get_bucket_stats(rgw_bucket& bucket, int shard_id, string *bucket_ver, string *master_ver, + int get_bucket_stats(RGWBucketInfo& bucket_info, int shard_id, string *bucket_ver, string *master_ver, map& stats, string *max_marker); - int get_bucket_stats_async(rgw_bucket& bucket, int shard_id, RGWGetBucketStats_CB *cb); + int get_bucket_stats_async(RGWBucketInfo& bucket_info, int shard_id, RGWGetBucketStats_CB *cb); int get_user_stats(const rgw_user& user, RGWStorageStats& stats); int get_user_stats_async(const rgw_user& user, RGWGetUserStats_CB *cb); void get_bucket_instance_obj(const rgw_bucket& bucket, rgw_raw_obj& obj); @@ -2995,16 +3042,16 @@ class RGWRados int cls_obj_complete_del(BucketShard& bs, string& tag, int64_t pool, uint64_t epoch, rgw_obj& obj, ceph::real_time& removed_mtime, list *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(rgw_bucket& bucket, uint64_t timeout); - int cls_bucket_list(rgw_bucket& bucket, int shard_id, rgw_obj_key& start, const string& prefix, + 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& m, bool *is_truncated, rgw_obj_key *last_entry, bool (*force_check_filter)(const string& name) = NULL); - int cls_bucket_head(rgw_bucket& bucket, int shard_id, map& headers, map *bucket_instance_ids = NULL); - int cls_bucket_head_async(rgw_bucket& bucket, int shard_id, RGWGetDirHeader_CB *ctx, int *num_aio); - int list_bi_log_entries(rgw_bucket& bucket, int shard_id, string& marker, uint32_t max, std::list& result, bool *truncated); - int trim_bi_log_entries(rgw_bucket& bucket, int shard_id, string& marker, string& end_marker); - int get_bi_log_status(rgw_bucket& bucket, int shard_id, map& max_marker); + int cls_bucket_head(RGWBucketInfo& bucket_info, int shard_id, map& headers, map *bucket_instance_ids = NULL); + int cls_bucket_head_async(RGWBucketInfo& bucket_info, int shard_id, RGWGetDirHeader_CB *ctx, int *num_aio); + int list_bi_log_entries(RGWBucketInfo& bucket_info, int shard_id, string& marker, uint32_t max, std::list& result, bool *truncated); + int trim_bi_log_entries(RGWBucketInfo& bucket_info, int shard_id, string& marker, string& end_marker); + int get_bi_log_status(RGWBucketInfo& bucket_info, int shard_id, map& max_marker); int bi_get_instance(rgw_obj& obj, rgw_bucket_dir_entry *dirent); int bi_get(rgw_bucket& bucket, rgw_obj& obj, BIIndexType index_type, rgw_cls_bi_entry *entry); @@ -3077,11 +3124,11 @@ class RGWRados int process_lc(); int list_lc_progress(const string& marker, uint32_t max_entries, map *progress_map); - int bucket_check_index(rgw_bucket& bucket, + int bucket_check_index(RGWBucketInfo& bucket_info, map *existing_stats, map *calculated_stats); - int bucket_rebuild_index(rgw_bucket& bucket); - int remove_objs_from_index(rgw_bucket& bucket, list& oid_list); + int bucket_rebuild_index(RGWBucketInfo& bucket_info); + int remove_objs_from_index(RGWBucketInfo& bucket_info, list& oid_list); int move_rados_obj(librados::IoCtx& src_ioctx, const string& src_oid, const string& src_locator, librados::IoCtx& dst_ioctx, @@ -3091,8 +3138,7 @@ class RGWRados int cls_user_get_header(const string& user_id, cls_user_header *header); int cls_user_get_header_async(const string& user_id, RGWGetUserHeader_CB *ctx); - int cls_user_sync_bucket_stats(rgw_raw_obj& user_obj, rgw_bucket& bucket); - int update_user_bucket_stats(const string& user_id, rgw_bucket& bucket, RGWStorageStats& stats); + int cls_user_sync_bucket_stats(rgw_raw_obj& user_obj, RGWBucketInfo& bucket_info); int cls_user_list_buckets(rgw_raw_obj& obj, const string& in_marker, const string& end_marker, @@ -3165,7 +3211,7 @@ class RGWRados librados::Rados* get_rados_handle(); int delete_raw_obj_aio(const rgw_raw_obj& obj, list& handles); - int delete_obj_aio(const rgw_obj& obj, rgw_bucket& bucket, RGWBucketInfo& info, RGWObjState *astate, + int delete_obj_aio(const rgw_obj& obj, RGWBucketInfo& info, RGWObjState *astate, list& handles, bool keep_index_consistent); private: /**