RGWObjectCtx rados_ctx(store, s); // XXX holds std::map
- auto sysobj_ctx = store->svc()->sysobj->init_obj_ctx();
+ auto sysobj_ctx = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj->init_obj_ctx();
s->sysobj_ctx = &sysobj_ctx;
/* XXX and -then- stash req_state pointers everywhere they are needed */
<< e.what() << dendl;
}
if (should_log) {
- rgw_log_op(store->getRados(), nullptr /* !rest */, s,
+ rgw_log_op(store, nullptr /* !rest */, s,
(op ? op->name() : "unknown"), olog);
}
const DoutPrefix dp(cct.get(), dout_subsys, "librgw: ");
store = RGWStoreManager::get_storage(&dp, g_ceph_context,
+ "rados",
run_gc,
run_lc,
run_quota,
r = rgw_perf_start(g_ceph_context);
- rgw_rest_init(g_ceph_context, store->svc()->zone->get_zonegroup());
+ rgw_rest_init(g_ceph_context, store->get_zonegroup());
mutex.lock();
init_timer.cancel_all_events();
ldh->init();
ldh->bind();
- rgw_log_usage_init(g_ceph_context, store->getRados());
+ rgw_log_usage_init(g_ceph_context, store);
// XXX ex-RGWRESTMgr_lib, mgr->set_logging(true)
fe->run();
- r = store->getRados()->register_to_service_map("rgw-nfs", service_map_meta);
+ r = store->register_to_service_map("rgw-nfs", service_map_meta);
if (r < 0) {
derr << "ERROR: failed to register to service map: " << cpp_strerror(-r) << dendl;
/* ignore error */
return 0;
} /* RGWLib::stop() */
- int RGWLibIO::set_uid(rgw::sal::RGWRadosStore *store, const rgw_user& uid)
+ int RGWLibIO::set_uid(rgw::sal::RGWStore *store, const rgw_user& uid)
{
const DoutPrefix dp(store->ctx(), dout_subsys, "librgw: ");
- int ret = store->ctl()->user->get_info_by_uid(&dp, uid, &user_info, null_yield);
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(uid);
+ /* object exists, but policy is broken */
+ int ret = user->load_by_id(&dp, null_yield);
if (ret < 0) {
derr << "ERROR: failed reading user info: uid=" << uid << " ret="
<< ret << dendl;
}
+ user_info = user->get_info();
return ret;
}
#include "rgw_acl_s3.h"
#include "rgw_user.h"
+#include "rgw_sal.h"
#define dout_subsys ceph_subsys_rgw
return env->get(header, NULL);
}
-static int parse_grantee_str(const DoutPrefixProvider *dpp, RGWUserCtl *user_ctl, string& grantee_str,
+static int parse_grantee_str(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store, string& grantee_str,
const struct s3_acl_header *perm, ACLGrant& grant)
{
string id_type, id_val_quoted;
int rgw_perm = perm->rgw_perm;
int ret;
- RGWUserInfo info;
-
ret = parse_key_value(grantee_str, id_type, id_val_quoted);
if (ret < 0)
return ret;
string id_val = rgw_trim_quotes(id_val_quoted);
if (strcasecmp(id_type.c_str(), "emailAddress") == 0) {
- ret = user_ctl->get_info_by_email(dpp, id_val, &info, null_yield);
+ std::unique_ptr<rgw::sal::RGWUser> user;
+ ret = store->get_user_by_email(dpp, id_val, null_yield, &user);
if (ret < 0)
return ret;
- grant.set_canon(info.user_id, info.display_name, rgw_perm);
+ grant.set_canon(user->get_id(), user->get_display_name(), rgw_perm);
} else if (strcasecmp(id_type.c_str(), "id") == 0) {
- rgw_user user(id_val);
- ret = user_ctl->get_info_by_uid(dpp, user, &info, null_yield);
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(rgw_user(id_val));
+ ret = user->load_by_id(dpp, null_yield);
if (ret < 0)
return ret;
- grant.set_canon(info.user_id, info.display_name, rgw_perm);
+ grant.set_canon(user->get_id(), user->get_display_name(), rgw_perm);
} else if (strcasecmp(id_type.c_str(), "uri") == 0) {
ACLGroupTypeEnum gid = grant.uri_to_group(id_val);
if (gid == ACL_GROUP_NONE)
return 0;
}
-static int parse_acl_header(const DoutPrefixProvider *dpp, RGWUserCtl *user_ctl, const RGWEnv *env,
- const struct s3_acl_header *perm, std::list<ACLGrant>& _grants)
+static int parse_acl_header(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store,
+ const RGWEnv *env, const struct s3_acl_header *perm,
+ std::list<ACLGrant>& _grants)
{
std::list<string> grantees;
std::string hacl_str;
for (list<string>::iterator it = grantees.begin(); it != grantees.end(); ++it) {
ACLGrant grant;
- int ret = parse_grantee_str(dpp, user_ctl, *it, perm, grant);
+ int ret = parse_grantee_str(dpp, store, *it, perm, grant);
if (ret < 0)
return ret;
{0, NULL}
};
-int RGWAccessControlPolicy_S3::create_from_headers(const DoutPrefixProvider *dpp, RGWUserCtl *user_ctl, const RGWEnv *env, ACLOwner& _owner)
+int RGWAccessControlPolicy_S3::create_from_headers(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore* store,
+ const RGWEnv *env, ACLOwner& _owner)
{
std::list<ACLGrant> grants;
int r = 0;
for (const struct s3_acl_header *p = acl_header_perms; p->rgw_perm; p++) {
- r = parse_acl_header(dpp, user_ctl, env, p, grants);
+ r = parse_acl_header(dpp, store, env, p, grants);
if (r < 0) {
return r;
}
/*
can only be called on object that was parsed
*/
-int RGWAccessControlPolicy_S3::rebuild(const DoutPrefixProvider *dpp, RGWUserCtl *user_ctl, ACLOwner *owner, RGWAccessControlPolicy& dest,
- std::string &err_msg)
+int RGWAccessControlPolicy_S3::rebuild(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore* store, ACLOwner *owner,
+ RGWAccessControlPolicy& dest, std::string &err_msg)
{
if (!owner)
return -EINVAL;
return -EPERM;
}
- RGWUserInfo owner_info;
- if (user_ctl->get_info_by_uid(dpp, owner->get_id(), &owner_info, null_yield) < 0) {
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(owner->get_id());
+ if (user->load_by_id(dpp, null_yield) < 0) {
ldout(cct, 10) << "owner info does not exist" << dendl;
err_msg = "Invalid id";
return -EINVAL;
}
ACLOwner& dest_owner = dest.get_owner();
dest_owner.set_id(owner->get_id());
- dest_owner.set_name(owner_info.display_name);
+ dest_owner.set_name(user->get_display_name());
ldpp_dout(dpp, 20) << "owner id=" << owner->get_id() << dendl;
ldpp_dout(dpp, 20) << "dest owner id=" << dest.get_owner().get_id() << dendl;
}
email = u.id;
ldout(cct, 10) << "grant user email=" << email << dendl;
- if (user_ctl->get_info_by_email(dpp, email, &grant_user, null_yield) < 0) {
+ if (store->get_user_by_email(dpp, email, null_yield, &user) < 0) {
ldout(cct, 10) << "grant user email not found or other error" << dendl;
err_msg = "The e-mail address you provided does not match any account on record.";
return -ERR_UNRESOLVABLE_EMAIL;
}
+ grant_user = user->get_info();
uid = grant_user.user_id;
}
case ACL_TYPE_CANON_USER:
}
}
- if (grant_user.user_id.empty() && user_ctl->get_info_by_uid(dpp, uid, &grant_user, null_yield) < 0) {
- ldout(cct, 10) << "grant user does not exist:" << uid << dendl;
- err_msg = "Invalid id";
- return -EINVAL;
- } else {
- ACLPermission& perm = src_grant.get_permission();
- new_grant.set_canon(uid, grant_user.display_name, perm.get_permissions());
- grant_ok = true;
- rgw_user new_id;
- new_grant.get_id(new_id);
- ldpp_dout(dpp, 10) << "new grant: " << new_id << ":" << grant_user.display_name << dendl;
+ if (grant_user.user_id.empty()) {
+ user = store->get_user(uid);
+ if (user->load_by_id(dpp, null_yield) < 0) {
+ ldout(cct, 10) << "grant user does not exist:" << uid << dendl;
+ err_msg = "Invalid id";
+ return -EINVAL;
+ } else {
+ grant_user = user->get_info();
+ }
}
+ ACLPermission& perm = src_grant.get_permission();
+ new_grant.set_canon(uid, grant_user.display_name, perm.get_permissions());
+ grant_ok = true;
+ rgw_user new_id;
+ new_grant.get_id(new_id);
+ ldout(cct, 10) << "new grant: " << new_id << ":" << grant_user.display_name << dendl;
}
break;
case ACL_TYPE_GROUP:
#include "rgw_acl.h"
class RGWUserCtl;
+namespace rgw { namespace sal { class RGWStore; } }
class ACLPermission_S3 : public ACLPermission, public XMLObj
{
bool xml_end(const char *el) override;
void to_xml(ostream& out);
- int rebuild(const DoutPrefixProvider *dpp, RGWUserCtl *user_ctl, ACLOwner *owner, RGWAccessControlPolicy& dest,
- std::string &err_msg);
+ int rebuild(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store, ACLOwner *owner,
+ RGWAccessControlPolicy& dest, std::string &err_msg);
bool compare_group_name(string& id, ACLGroupTypeEnum group) override;
virtual int create_canned(ACLOwner& _owner, ACLOwner& bucket_owner, const string& canned_acl) {
int ret = _acl.create_canned(owner, bucket_owner, canned_acl);
return ret;
}
- int create_from_headers(const DoutPrefixProvider *dpp, RGWUserCtl *user_ctl, const RGWEnv *env, ACLOwner& _owner);
+ int create_from_headers(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store,
+ const RGWEnv *env, ACLOwner& _owner);
};
/**
#include "rgw_common.h"
#include "rgw_user.h"
#include "rgw_acl_swift.h"
+#include "rgw_sal.h"
#define dout_subsys ceph_subsys_rgw
}
}
-static ACLGrant user_to_grant(const DoutPrefixProvider *dpp,
- CephContext* const cct,
- RGWUserCtl* const user_ctl,
+static ACLGrant user_to_grant(const DoutPrefixProvider *dpp,
+ CephContext* const cct,
+ rgw::sal::RGWStore* store,
const std::string& uid,
const uint32_t perm)
{
- rgw_user user(uid);
RGWUserInfo grant_user;
ACLGrant grant;
+ std::unique_ptr<rgw::sal::RGWUser> user;
- if (user_ctl->get_info_by_uid(dpp, user, &grant_user, null_yield) < 0) {
+ user = store->get_user(rgw_user(uid));
+ if (user->load_by_id(dpp, null_yield) < 0) {
ldout(cct, 10) << "grant user does not exist: " << uid << dendl;
/* skipping silently */
- grant.set_canon(user, std::string(), perm);
+ grant.set_canon(user->get_id(), std::string(), perm);
} else {
- grant.set_canon(user, grant_user.display_name, perm);
+ grant.set_canon(user->get_id(), user->get_display_name(), perm);
}
return grant;
}
-int RGWAccessControlPolicy_SWIFT::add_grants(const DoutPrefixProvider *dpp,
- RGWUserCtl* const user_ctl,
+int RGWAccessControlPolicy_SWIFT::add_grants(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore* store,
const std::vector<std::string>& uids,
const uint32_t perm)
{
const size_t pos = uid.find(':');
if (std::string::npos == pos) {
/* No, it don't have -- we've got just a regular user identifier. */
- grant = user_to_grant(dpp, cct, user_ctl, uid, perm);
+ grant = user_to_grant(dpp, cct, store, uid, perm);
} else {
/* Yes, *potentially* an HTTP referral. */
auto designator = uid.substr(0, pos);
boost::algorithm::trim(designatee);
if (! boost::algorithm::starts_with(designator, ".")) {
- grant = user_to_grant(dpp, cct, user_ctl, uid, perm);
+ grant = user_to_grant(dpp, cct, store, uid, perm);
} else if ((perm & SWIFT_PERM_WRITE) == 0 && is_referrer(designator)) {
/* HTTP referrer-based ACLs aren't acceptable for writes. */
grant = referrer_to_grant(designatee, perm);
}
-int RGWAccessControlPolicy_SWIFT::create(const DoutPrefixProvider *dpp,
- RGWUserCtl* const user_ctl,
+int RGWAccessControlPolicy_SWIFT::create(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore* store,
const rgw_user& id,
const std::string& name,
const char* read_list,
return r;
}
- r = add_grants(dpp, user_ctl, uids, SWIFT_PERM_READ);
+ r = add_grants(dpp, store, uids, SWIFT_PERM_READ);
if (r < 0) {
ldout(cct, 0) << "ERROR: add_grants for read returned r="
<< r << dendl;
return r;
}
- r = add_grants(dpp, user_ctl, uids, SWIFT_PERM_WRITE);
+ r = add_grants(dpp, store, uids, SWIFT_PERM_WRITE);
if (r < 0) {
ldout(cct, 0) << "ERROR: add_grants for write returned r="
<< r << dendl;
}
}
-void RGWAccessControlPolicy_SWIFTAcct::add_grants(const DoutPrefixProvider *dpp,
- RGWUserCtl * const user_ctl,
+void RGWAccessControlPolicy_SWIFTAcct::add_grants(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore* store,
const std::vector<std::string>& uids,
const uint32_t perm)
{
for (const auto& uid : uids) {
ACLGrant grant;
- RGWUserInfo grant_user;
if (uid_is_public(uid)) {
grant.set_group(ACL_GROUP_ALL_USERS, perm);
acl.add_grant(&grant);
} else {
- rgw_user user(uid);
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(rgw_user(uid));
- if (user_ctl->get_info_by_uid(dpp, user, &grant_user, null_yield) < 0) {
+ if (user->load_by_id(dpp, null_yield) < 0) {
ldout(cct, 10) << "grant user does not exist:" << uid << dendl;
/* skipping silently */
- grant.set_canon(user, std::string(), perm);
+ grant.set_canon(user->get_id(), std::string(), perm);
acl.add_grant(&grant);
} else {
- grant.set_canon(user, grant_user.display_name, perm);
+ grant.set_canon(user->get_id(), user->get_display_name(), perm);
acl.add_grant(&grant);
}
}
}
}
-bool RGWAccessControlPolicy_SWIFTAcct::create(const DoutPrefixProvider *dpp,
- RGWUserCtl * const user_ctl,
+bool RGWAccessControlPolicy_SWIFTAcct::create(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore* store,
const rgw_user& id,
const std::string& name,
const std::string& acl_str)
decode_json_obj(admin, *iter);
ldout(cct, 0) << "admins: " << admin << dendl;
- add_grants(dpp, user_ctl, admin, SWIFT_PERM_ADMIN);
+ add_grants(dpp, store, admin, SWIFT_PERM_ADMIN);
}
iter = parser.find_first("read-write");
decode_json_obj(readwrite, *iter);
ldout(cct, 0) << "read-write: " << readwrite << dendl;
- add_grants(dpp, user_ctl, readwrite, SWIFT_PERM_RWRT);
+ add_grants(dpp, store, readwrite, SWIFT_PERM_RWRT);
}
iter = parser.find_first("read-only");
decode_json_obj(readonly, *iter);
ldout(cct, 0) << "read-only: " << readonly << dendl;
- add_grants(dpp, user_ctl, readonly, SWIFT_PERM_READ);
+ add_grants(dpp, store, readonly, SWIFT_PERM_READ);
}
return true;
class RGWAccessControlPolicy_SWIFT : public RGWAccessControlPolicy
{
- int add_grants(const DoutPrefixProvider *dpp, RGWUserCtl *user_ctl,
+ int add_grants(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store,
const std::vector<std::string>& uids,
uint32_t perm);
}
~RGWAccessControlPolicy_SWIFT() override = default;
- int create(const DoutPrefixProvider *dpp,
- RGWUserCtl *user_ctl,
+ int create(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore* store,
const rgw_user& id,
const std::string& name,
const char* read_list,
}
~RGWAccessControlPolicy_SWIFTAcct() override {}
- void add_grants(const DoutPrefixProvider *dpp,
- RGWUserCtl *user_ctl,
+ void add_grants(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore* store,
const std::vector<std::string>& uids,
uint32_t perm);
- bool create(const DoutPrefixProvider *dpp,
- RGWUserCtl *user_ctl,
+ bool create(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore* store,
const rgw_user& id,
const std::string& name,
const std::string& acl_str);
#define SECRET_KEY_LEN 40
#define PUBLIC_ID_LEN 20
-static rgw::sal::RGWRadosStore *store = NULL;
+static rgw::sal::RGWStore *store = NULL;
static const DoutPrefixProvider* dpp() {
struct GlobalPrefix : public DoutPrefixProvider {
}
class StoreDestructor {
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
public:
explicit StoreDestructor(rgw::sal::RGWRadosStore *_s) : store(_s) {}
~StoreDestructor() {
}
};
-static int init_bucket(const string& tenant_name,
- const string& bucket_name,
- const string& bucket_id,
- RGWBucketInfo& bucket_info,
- rgw_bucket& bucket,
- map<string, bufferlist> *pattrs = nullptr)
+static int init_bucket(rgw::sal::RGWUser* user, const rgw_bucket& b,
+ std::unique_ptr<rgw::sal::RGWBucket>* bucket)
{
- if (!bucket_name.empty()) {
- auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
- int r;
- if (bucket_id.empty()) {
- r = store->getRados()->get_bucket_info(store->svc(), tenant_name, bucket_name, bucket_info, nullptr, null_yield, dpp(), pattrs);
- } else {
- string bucket_instance_id = bucket_name + ":" + bucket_id;
- r = store->getRados()->get_bucket_instance_info(obj_ctx, bucket_instance_id, bucket_info, NULL, pattrs, null_yield, dpp());
- }
- if (r < 0) {
- cerr << "could not get bucket info for bucket=" << bucket_name << std::endl;
- return r;
- }
- bucket = bucket_info.bucket;
- }
- return 0;
+ return store->get_bucket(dpp(), nullptr, b, bucket, null_yield);
}
-static int init_bucket(const rgw_bucket& b,
- RGWBucketInfo& bucket_info,
- rgw_bucket& bucket,
- map<string, bufferlist> *pattrs = nullptr)
+static int init_bucket(rgw::sal::RGWUser* user,
+ const string& tenant_name,
+ const string& bucket_name,
+ const string& bucket_id,
+ std::unique_ptr<rgw::sal::RGWBucket>* bucket)
{
- return init_bucket(b.tenant, b.name, b.bucket_id,
- bucket_info, bucket, pattrs);
+ rgw_bucket b;
+ b.tenant = tenant_name;
+ b.name = bucket_name;
+ if (!bucket_id.empty()) {
+ b.bucket_id = bucket_name + ":" + bucket_id;
+ }
+ return init_bucket(user, b, bucket);
}
static int read_input(const string& infile, bufferlist& bl)
}
}
-int set_bucket_quota(rgw::sal::RGWRadosStore *store, OPT opt_cmd,
+int set_bucket_quota(rgw::sal::RGWStore *store, OPT opt_cmd,
const string& tenant_name, const string& bucket_name,
int64_t max_size, int64_t max_objects,
bool have_max_size, bool have_max_objects)
{
- RGWBucketInfo bucket_info;
- map<string, bufferlist> attrs;
- int r = store->getRados()->get_bucket_info(store->svc(), tenant_name, bucket_name, bucket_info, NULL, null_yield, dpp(), &attrs);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ int r = store->get_bucket(dpp(), nullptr, tenant_name, bucket_name, &bucket, null_yield);
if (r < 0) {
cerr << "could not get bucket info for bucket=" << bucket_name << ": " << cpp_strerror(-r) << std::endl;
return -r;
}
- set_quota_info(bucket_info.quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects);
+ set_quota_info(bucket->get_info().quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects);
- r = store->getRados()->put_bucket_instance_info(bucket_info, false, real_time(), &attrs, dpp());
+ r = bucket->put_instance_info(dpp(), false, real_time());
if (r < 0) {
cerr << "ERROR: failed writing bucket instance info: " << cpp_strerror(-r) << std::endl;
return -r;
return 0;
}
-int check_min_obj_stripe_size(rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info, rgw::sal::RGWObject* obj, uint64_t min_stripe_size, bool *need_rewrite)
+int check_min_obj_stripe_size(rgw::sal::RGWStore *store, rgw::sal::RGWObject* obj, uint64_t min_stripe_size, bool *need_rewrite)
{
RGWObjectCtx obj_ctx(store);
int ret = obj->get_obj_attrs(&obj_ctx, null_yield, dpp());
}
-int check_obj_locator_underscore(RGWBucketInfo& bucket_info, rgw_obj& obj, rgw_obj_key& key, bool fix, bool remove_bad, Formatter *f) {
+int check_obj_locator_underscore(rgw::sal::RGWObject* obj, bool fix, bool remove_bad, Formatter *f) {
f->open_object_section("object");
f->open_object_section("key");
f->dump_string("type", "head");
- f->dump_string("name", key.name);
- f->dump_string("instance", key.instance);
+ f->dump_string("name", obj->get_name());
+ f->dump_string("instance", obj->get_instance());
f->close_section();
string oid;
string locator;
- get_obj_bucket_and_oid_loc(obj, oid, locator);
+ get_obj_bucket_and_oid_loc(obj->get_obj(), oid, locator);
f->dump_string("oid", oid);
f->dump_string("locator", locator);
-
RGWObjectCtx obj_ctx(store);
+ std::unique_ptr<rgw::sal::RGWObject::ReadOp> read_op = obj->get_read_op(&obj_ctx);
- RGWRados::Object op_target(store->getRados(), bucket_info, obj_ctx, obj);
- RGWRados::Object::Read read_op(&op_target);
-
- int ret = read_op.prepare(null_yield, dpp());
+ int ret = read_op->prepare(null_yield, dpp());
bool needs_fixing = (ret == -ENOENT);
f->dump_bool("needs_fixing", needs_fixing);
string status = (needs_fixing ? "needs_fixing" : "ok");
if ((needs_fixing || remove_bad) && fix) {
- ret = store->getRados()->fix_head_obj_locator(bucket_info, needs_fixing, remove_bad, key);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->fix_head_obj_locator(obj->get_bucket()->get_info(), needs_fixing, remove_bad, obj->get_key());
if (ret < 0) {
cerr << "ERROR: fix_head_object_locator() returned ret=" << ret << std::endl;
goto done;
return 0;
}
-int check_obj_tail_locator_underscore(RGWBucketInfo& bucket_info, rgw_obj& obj, rgw_obj_key& key, bool fix, Formatter *f) {
+int check_obj_tail_locator_underscore(RGWBucketInfo& bucket_info, rgw_obj_key& key, bool fix, Formatter *f) {
f->open_object_section("object");
f->open_object_section("key");
f->dump_string("type", "tail");
bool needs_fixing;
string status;
- int ret = store->getRados()->fix_tail_obj_locator(dpp(), bucket_info, key, fix, &needs_fixing, null_yield);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->fix_tail_obj_locator(dpp(), bucket_info, key, fix, &needs_fixing, null_yield);
if (ret < 0) {
cerr << "ERROR: fix_tail_object_locator_underscore() returned ret=" << ret << std::endl;
status = "failed";
return -EINVAL;
}
- RGWBucketInfo bucket_info;
- rgw_bucket bucket;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
string bucket_id;
f->open_object_section("bucket");
f->dump_string("bucket", bucket_name);
- int ret = init_bucket(tenant_name, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(nullptr, tenant_name, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return ret;
}
- bool truncated;
int count = 0;
int max_entries = 1000;
string prefix;
string delim;
+ string marker;
vector<rgw_bucket_dir_entry> result;
- map<string, bool> common_prefixes;
string ns;
- RGWRados::Bucket target(store->getRados(), bucket_info);
- RGWRados::Bucket::List list_op(&target);
-
- string marker;
+ rgw::sal::RGWBucket::ListParams params;
+ rgw::sal::RGWBucket::ListResults results;
- list_op.params.prefix = prefix;
- list_op.params.delim = delim;
- list_op.params.marker = rgw_obj_key(marker);
- list_op.params.ns = ns;
- list_op.params.enforce_ns = true;
- list_op.params.list_versions = true;
+ params.prefix = prefix;
+ params.delim = delim;
+ params.marker = rgw_obj_key(marker);
+ params.ns = ns;
+ params.enforce_ns = true;
+ params.list_versions = true;
f->open_array_section("check_objects");
do {
- ret = list_op.list_objects(dpp(), max_entries - count, &result, &common_prefixes, &truncated, null_yield);
+ ret = bucket->list(dpp(), params, max_entries - count, results, null_yield);
if (ret < 0) {
cerr << "ERROR: store->list_objects(): " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- count += result.size();
+ count += results.objs.size();
- 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);
+ for (vector<rgw_bucket_dir_entry>::iterator iter = results.objs.begin(); iter != results.objs.end(); ++iter) {
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(iter->key);
- if (key.name[0] == '_') {
- ret = check_obj_locator_underscore(bucket_info, obj, key, fix, remove_bad, f);
+ if (obj->get_name()[0] == '_') {
+ ret = check_obj_locator_underscore(obj.get(), fix, remove_bad, f);
if (ret >= 0) {
- ret = check_obj_tail_locator_underscore(bucket_info, obj, key, fix, f);
+ ret = check_obj_tail_locator_underscore(bucket->get_info(), obj->get_key(), fix, f);
if (ret < 0) {
cerr << "ERROR: check_obj_tail_locator_underscore(): " << cpp_strerror(-ret) << std::endl;
return -ret;
}
}
f->flush(cout);
- } while (truncated && count < max_entries);
+ } while (results.is_truncated && count < max_entries);
f->close_section();
f->close_section();
return -EINVAL;
}
// are we the period's master zone?
- if (store->svc()->zone->zone_id() == master_zone) {
+ if (store->get_zone_id() == master_zone) {
// read the current period
RGWPeriod current_period;
int ret = current_period.init(g_ceph_context,
- store->svc()->sysobj, realm.get_id(),
+ static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, realm.get_id(),
null_yield);
if (ret < 0) {
cerr << "Error initializing current period: "
boost::optional<RGWRESTConn> conn;
RGWRESTConn *remote_conn = nullptr;
if (!remote.empty()) {
- conn = get_remote_conn(store, period.get_map(), remote);
+ conn = get_remote_conn(static_cast<rgw::sal::RGWRadosStore*>(store), period.get_map(), remote);
if (!conn) {
cerr << "failed to find a zone or zonegroup for remote "
<< remote << std::endl;
Formatter *formatter, bool force)
{
RGWRealm realm(realm_id, realm_name);
- int ret = realm.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0 ) {
cerr << "Error initializing realm " << cpp_strerror(-ret) << std::endl;
return ret;
epoch = atoi(period_epoch.c_str());
}
RGWPeriod period(period_id, epoch);
- ret = period.init(g_ceph_context, store->svc()->sysobj, realm.get_id(), null_yield);
+ ret = period.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, realm.get_id(), null_yield);
if (ret < 0) {
cerr << "period init failed: " << cpp_strerror(-ret) << std::endl;
return ret;
return 0;
}
-static int init_bucket_for_sync(const string& tenant, const string& bucket_name,
- const string& bucket_id, rgw_bucket& bucket)
+static int init_bucket_for_sync(rgw::sal::RGWUser* user,
+ const string& tenant, const string& bucket_name,
+ const string& bucket_id,
+ std::unique_ptr<rgw::sal::RGWBucket>* bucket)
{
- RGWBucketInfo bucket_info;
-
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user, tenant, bucket_name, bucket_id, bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return ret;
cerr << "request failed: " << cpp_strerror(-ret) << std::endl;
return ret;
}
- ret = period->init(g_ceph_context, store->svc()->sysobj, null_yield, false);
+ ret = period->init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield, false);
if (ret < 0) {
cerr << "faile to init period " << cpp_strerror(-ret) << std::endl;
return ret;
static void get_md_sync_status(list<string>& status)
{
- RGWMetaSyncStatusManager sync(store, store->svc()->rados->get_async_processor());
+ RGWMetaSyncStatusManager sync(static_cast<rgw::sal::RGWRadosStore*>(store), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->rados->get_async_processor());
int ret = sync.init();
if (ret < 0) {
push_ss(ss, status) << "incremental sync: " << num_inc << "/" << total_shards << " shards";
map<int, RGWMetadataLogInfo> master_shards_info;
- string master_period = store->svc()->zone->get_current_period_id();
+ string master_period = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_current_period_id();
ret = sync.read_master_log_shards_info(master_period, &master_shards_info);
if (ret < 0) {
RGWZone *sz;
- if (!store->svc()->zone->find_zone(source_zone, &sz)) {
+ if (!static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->find_zone(source_zone, &sz)) {
push_ss(ss, status, tab) << string("zone not found");
flush_ss(ss, status);
return;
}
- if (!store->svc()->zone->zone_syncs_from(store->svc()->zone->get_zone(), *sz)) {
+ if (!static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->zone_syncs_from(static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_zone(), *sz)) {
push_ss(ss, status, tab) << string("not syncing from zone");
flush_ss(ss, status);
return;
}
- RGWDataSyncStatusManager sync(store, store->svc()->rados->get_async_processor(), source_zone, nullptr);
+ RGWDataSyncStatusManager sync(static_cast<rgw::sal::RGWRadosStore*>(store), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->rados->get_async_processor(), source_zone, nullptr);
int ret = sync.init();
if (ret < 0) {
static void sync_status(Formatter *formatter)
{
- const RGWRealm& realm = store->svc()->zone->get_realm();
- const RGWZoneGroup& zonegroup = store->svc()->zone->get_zonegroup();
- const RGWZone& zone = store->svc()->zone->get_zone();
+ const RGWRealm& realm = store->get_realm();
+ const RGWZoneGroup& zonegroup = store->get_zonegroup();
+ const RGWZone& zone = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_zone();
int width = 15;
list<string> md_status;
- if (store->svc()->zone->is_meta_master()) {
+ if (store->is_meta_master()) {
md_status.push_back("no sync (zone is master)");
} else {
get_md_sync_status(md_status);
list<string> data_status;
- auto& zone_conn_map = store->svc()->zone->get_zone_conn_map();
+ auto& zone_conn_map = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_zone_conn_map();
for (auto iter : zone_conn_map) {
const rgw_zone_id& source_id = iter.first;
string source_str = "source: ";
string s = source_str + source_id.id;
RGWZone *sz;
- if (store->svc()->zone->find_zone(source_id, &sz)) {
+ if (static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->find_zone(source_id, &sz)) {
s += string(" (") + sz->name + ")";
}
data_status.push_back(s);
return -EINVAL;
}
- RGWBucketInfo source_bucket_info;
- rgw_bucket source_bucket;
- int r = init_bucket(*pipe.source.bucket, source_bucket_info, source_bucket);
+ std::unique_ptr<rgw::sal::RGWBucket> source_bucket;
+ int r = init_bucket(nullptr, *pipe.source.bucket, &source_bucket);
if (r < 0) {
lderr(store->ctx()) << "failed to read source bucket info: " << cpp_strerror(r) << dendl;
return r;
}
- pipe.source.bucket = source_bucket;
+ pipe.source.bucket = source_bucket->get_key();
pipe.dest.bucket = bucket_info.bucket;
std::vector<rgw_bucket_shard_sync_info> status;
- r = rgw_bucket_sync_status(dpp(), store, pipe, bucket_info, &source_bucket_info, &status);
+ r = rgw_bucket_sync_status(dpp(), store, pipe, bucket_info, &source_bucket->get_info(), &status);
if (r < 0) {
lderr(store->ctx()) << "failed to read bucket sync status: " << cpp_strerror(r) << dendl;
return r;
}
- out << indented{width, "source bucket"} << source_bucket_info.bucket.get_key() << std::endl;
+ out << indented{width, "source bucket"} << source_bucket << std::endl;
int num_full = 0;
int num_inc = 0;
out << indented{width} << "incremental sync: " << num_inc << "/" << total_shards << " shards\n";
BucketIndexShardsManager remote_markers;
- r = rgw_read_remote_bilog_info(conn, source_bucket, remote_markers, null_yield);
+ r = rgw_read_remote_bilog_info(conn, source_bucket->get_key(), remote_markers, null_yield);
if (r < 0) {
lderr(store->ctx()) << "failed to read remote log: " << cpp_strerror(r) << dendl;
return r;
{
for (auto& zone_id : zones) {
for (auto& b : buckets) {
- RGWBucketInfo hint_bucket_info;
- rgw_bucket hint_bucket;
- int ret = init_bucket(b, hint_bucket_info, hint_bucket);
+ std::unique_ptr<rgw::sal::RGWBucket> hint_bucket;
+ int ret = init_bucket(nullptr, b, &hint_bucket);
if (ret < 0) {
ldpp_dout(dpp(), 20) << "could not init bucket info for hint bucket=" << b << " ... skipping" << dendl;
continue;
}
- hint_entities->insert(rgw_sync_bucket_entity(zone_id, hint_bucket));
+ hint_entities->insert(rgw_sync_bucket_entity(zone_id, hint_bucket->get_key()));
}
}
}
rgw_zone_id result;
RGWZone *zone;
- if (store->svc()->zone->find_zone(s, &zone)) {
+ if (static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->find_zone(s, &zone)) {
return rgw_zone_id(s);
}
- if (store->svc()->zone->find_zone_id_by_name(s, &result)) {
+ if (static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->find_zone_id_by_name(s, &result)) {
return result;
}
return rgw_zone_id(s);
static int sync_info(std::optional<rgw_zone_id> opt_target_zone, std::optional<rgw_bucket> opt_bucket, Formatter *formatter)
{
- rgw_zone_id zone_id = opt_target_zone.value_or(store->svc()->zone->zone_id());
+ rgw_zone_id zone_id = opt_target_zone.value_or(store->get_zone_id());
- auto zone_policy_handler = store->svc()->zone->get_sync_policy_handler(zone_id);
+ auto zone_policy_handler = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_sync_policy_handler(zone_id);
RGWBucketSyncPolicyHandlerRef bucket_handler;
auto handler = zone_policy_handler;
if (eff_bucket) {
- rgw_bucket bucket;
- RGWBucketInfo bucket_info;
- map<string, bufferlist> bucket_attrs;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
- int ret = init_bucket(*eff_bucket, bucket_info, bucket, &bucket_attrs);
+ int ret = init_bucket(nullptr, *eff_bucket, &bucket);
if (ret < 0 && ret != -ENOENT) {
cerr << "ERROR: init_bucket failed: " << cpp_strerror(-ret) << std::endl;
return ret;
}
if (ret >= 0) {
- bucket_handler.reset(handler->alloc_child(bucket_info, std::move(bucket_attrs)));
+ rgw::sal::RGWAttrs attrs = bucket->get_attrs();
+ bucket_handler.reset(handler->alloc_child(bucket->get_info(), std::move(attrs)));
} else {
cerr << "WARNING: bucket not found, simulating result" << std::endl;
bucket_handler.reset(handler->alloc_child(*eff_bucket, nullopt));
auto& hint_bucket = *hint_entity.bucket;
RGWBucketSyncPolicyHandlerRef hint_bucket_handler;
- int r = store->ctl()->bucket->get_sync_policy_handler(zid, hint_bucket, &hint_bucket_handler, null_yield, dpp());
+ int r = store->get_sync_policy_handler(dpp(), zid, hint_bucket, &hint_bucket_handler, null_yield);
if (r < 0) {
ldpp_dout(dpp(), 20) << "could not get bucket sync policy handler for hint bucket=" << hint_bucket << " ... skipping" << dendl;
continue;
static int bucket_sync_info(rgw::sal::RGWRadosStore *store, const RGWBucketInfo& info,
std::ostream& out)
{
- const RGWRealm& realm = store->svc()->zone->get_realm();
- const RGWZoneGroup& zonegroup = store->svc()->zone->get_zonegroup();
+ const RGWRealm& realm = store->get_realm();
+ const RGWZoneGroup& zonegroup = store->get_zonegroup();
const RGWZone& zone = store->svc()->zone->get_zone();
constexpr int width = 15;
out << indented{width, "zone"} << zone.id << " (" << zone.name << ")\n";
out << indented{width, "bucket"} << info.bucket << "\n\n";
- if (!store->ctl()->bucket->bucket_imports_data(info.bucket, null_yield, dpp())) {
+ if (!static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->bucket->bucket_imports_data(info.bucket, null_yield, dpp())) {
out << "Sync is disabled for bucket " << info.bucket.name << '\n';
return 0;
}
RGWBucketSyncPolicyHandlerRef handler;
- int r = store->ctl()->bucket->get_sync_policy_handler(std::nullopt, info.bucket, &handler, null_yield, dpp());
+ int r = store->get_sync_policy_handler(dpp(), std::nullopt, info.bucket, &handler, null_yield);
if (r < 0) {
lderr(store->ctx()) << "ERROR: failed to get policy handler for bucket (" << info.bucket << "): r=" << r << ": " << cpp_strerror(-r) << dendl;
return r;
std::optional<rgw_bucket>& opt_source_bucket,
std::ostream& out)
{
- const RGWRealm& realm = store->svc()->zone->get_realm();
- const RGWZoneGroup& zonegroup = store->svc()->zone->get_zonegroup();
- const RGWZone& zone = store->svc()->zone->get_zone();
+ const RGWRealm& realm = store->get_realm();
+ const RGWZoneGroup& zonegroup = store->get_zonegroup();
+ const RGWZone& zone = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_zone();
constexpr int width = 15;
out << indented{width, "realm"} << realm.get_id() << " (" << realm.get_name() << ")\n";
out << indented{width, "zone"} << zone.id << " (" << zone.name << ")\n";
out << indented{width, "bucket"} << info.bucket << "\n\n";
- if (!store->ctl()->bucket->bucket_imports_data(info.bucket, null_yield, dpp())) {
+ if (!static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->bucket->bucket_imports_data(info.bucket, null_yield, dpp())) {
out << "Sync is disabled for bucket " << info.bucket.name << " or bucket has no sync sources" << std::endl;
return 0;
}
RGWBucketSyncPolicyHandlerRef handler;
- int r = store->ctl()->bucket->get_sync_policy_handler(std::nullopt, info.bucket, &handler, null_yield, dpp());
+ int r = store->get_sync_policy_handler(dpp(), std::nullopt, info.bucket, &handler, null_yield);
if (r < 0) {
lderr(store->ctx()) << "ERROR: failed to get policy handler for bucket (" << info.bucket << "): r=" << r << ": " << cpp_strerror(-r) << dendl;
return r;
auto sources = handler->get_all_sources();
- auto& zone_conn_map = store->svc()->zone->get_zone_conn_map();
+ auto& zone_conn_map = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_zone_conn_map();
set<rgw_zone_id> zone_ids;
if (!source_zone_id.empty()) {
static int check_pool_support_omap(const rgw_pool& pool)
{
librados::IoCtx io_ctx;
- int ret = store->getRados()->get_rados_handle()->ioctx_create(pool.to_str().c_str(), io_ctx);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_rados_handle()->ioctx_create(pool.to_str().c_str(), io_ctx);
if (ret < 0) {
// the pool may not exist at this moment, we have no way to check if it supports omap.
return 0;
bool num_shards_specified,
int num_shards,
int yes_i_really_mean_it,
- rgw_bucket& bucket,
- RGWBucketInfo& bucket_info,
- map<string, bufferlist>& attrs)
+ std::unique_ptr<rgw::sal::RGWBucket>* bucket)
{
if (bucket_name.empty()) {
cerr << "ERROR: bucket not specified" << std::endl;
return -EINVAL;
}
- if (num_shards > (int)store->getRados()->get_max_bucket_shards()) {
- cerr << "ERROR: num_shards too high, max value: " << store->getRados()->get_max_bucket_shards() << std::endl;
+ if (num_shards > (int)static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_max_bucket_shards()) {
+ cerr << "ERROR: num_shards too high, max value: " << static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_max_bucket_shards() << std::endl;
return -EINVAL;
}
return -EINVAL;
}
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket, &attrs);
+ int ret = init_bucket(nullptr, tenant, bucket_name, bucket_id, bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return ret;
}
- if (bucket_info.reshard_status != cls_rgw_reshard_status::NOT_RESHARDING) {
+ if ((*bucket)->get_info().reshard_status != cls_rgw_reshard_status::NOT_RESHARDING) {
// if in_progress or done then we have an old BucketInfo
cerr << "ERROR: the bucket is currently undergoing resharding and "
"cannot be added to the reshard list at this time" << std::endl;
return -EBUSY;
}
- int num_source_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
+ int num_source_shards = ((*bucket)->get_info().layout.current_index.layout.normal.num_shards > 0 ? (*bucket)->get_info().layout.current_index.layout.normal.num_shards : 1);
if (num_shards <= num_source_shards && !yes_i_really_mean_it) {
cerr << "num shards is less or equal to current shards count" << std::endl
shard_id);
// call cls_log_trim() until it returns -ENODATA
for (;;) {
- int ret = store->svc()->cls->timelog.trim(oid, {}, {}, {}, marker, nullptr,
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls->timelog.trim(oid, {}, {}, {}, marker, nullptr,
null_yield);
if (ret == -ENODATA) {
return 0;
{
RGWZoneGroup zonegroup;
- std::optional<rgw_bucket> bucket;
- RGWBucketInfo bucket_info;
- map<string, bufferlist> bucket_attrs;
+ std::optional<rgw_bucket> b;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
rgw_sync_policy_info *policy{nullptr};
SyncPolicyContext(const string& zonegroup_id,
const string& zonegroup_name,
std::optional<rgw_bucket> _bucket) : zonegroup(zonegroup_id, zonegroup_name),
- bucket(_bucket) {}
+ b(_bucket) {}
int init() {
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
return ret;
}
- if (!bucket) {
+ if (!b) {
policy = &zonegroup.sync_policy;
return 0;
}
- ret = init_bucket(*bucket, bucket_info, *bucket, &bucket_attrs);
+ ret = init_bucket(nullptr, *b, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return ret;
}
- owner = bucket_info.owner;
+ owner = bucket->get_info().owner;
- if (!bucket_info.sync_policy) {
+ if (!bucket->get_info().sync_policy) {
rgw_sync_policy_info new_policy;
- bucket_info.set_sync_policy(std::move(new_policy));
+ bucket->get_info().set_sync_policy(std::move(new_policy));
}
- policy = &(*bucket_info.sync_policy);
+ policy = &(*bucket->get_info().sync_policy);
return 0;
}
int write_policy() {
- if (!bucket) {
+ if (!b) {
int ret = zonegroup.update(null_yield);
if (ret < 0) {
cerr << "failed to update zonegroup: " << cpp_strerror(-ret) << std::endl;
return 0;
}
- int ret = store->getRados()->put_bucket_instance_info(bucket_info, false, real_time(), &bucket_attrs, dpp());
+ int ret = bucket->put_instance_info(dpp(), false, real_time());
if (ret < 0) {
cerr << "failed to store bucket info: " << cpp_strerror(-ret) << std::endl;
return -ret;
return;
}
zone_id.emplace();
- if (!store->svc()->zone->find_zone_id_by_name(*zone_name, &(*zone_id))) {
+ if (!static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->find_zone_id_by_name(*zone_name, &(*zone_id))) {
cerr << "WARNING: cannot find source zone id for name=" << *zone_name << std::endl;
zone_id = rgw_zone_id(*zone_name);
}
ids.emplace();
for (auto& name : *names) {
rgw_zone_id zid;
- if (!store->svc()->zone->find_zone_id_by_name(name, &zid)) {
+ if (!static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->find_zone_id_by_name(name, &zid)) {
cerr << "WARNING: cannot find source zone id for name=" << name << std::endl;
zid = rgw_zone_id(name);
}
auto zone_id = *(static_cast<const rgw_zone_id *>(pval));
string zone_name;
RGWZone *zone;
- if (store->svc()->zone->find_zone(zone_id, &zone)) {
+ if (static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->find_zone(zone_id, &zone)) {
zone_name = zone->name;
} else {
cerr << "WARNING: cannot find zone name for id=" << zone_id << std::endl;
common_init_finish(g_ceph_context);
- rgw_user user_id;
+ std::unique_ptr<rgw::sal::RGWUser> user;
string tenant;
string user_ns;
rgw_user new_user_id;
int commit = false;
int staging = false;
int key_type = KEY_TYPE_UNDEFINED;
- rgw_bucket bucket;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
uint32_t perm_mask = 0;
RGWUserInfo info;
OPT opt_cmd = OPT::NO_CMD;
if (ceph_argparse_double_dash(args, i)) {
break;
} else if (ceph_argparse_witharg(args, i, &val, "-i", "--uid", (char*)NULL)) {
+ rgw_user user_id;
user_id.from_str(val);
- if (user_id.empty()) {
+ if (!user) {
cerr << "no value for uid" << std::endl;
exit(1);
}
+ user = store->get_user(user_id);
} else if (ceph_argparse_witharg(args, i, &val, "-i", "--new-uid", (char*)NULL)) {
new_user_id.from_str(val);
} else if (ceph_argparse_witharg(args, i, &val, "--tenant", (char*)NULL)) {
opt_dest_bucket_name, opt_dest_bucket_id);
if (tenant.empty()) {
- tenant = user_id.tenant;
+ tenant = user->get_tenant();
} else {
- if (user_id.empty() && opt_cmd != OPT::ROLE_CREATE
+ if (!user && opt_cmd != OPT::ROLE_CREATE
&& opt_cmd != OPT::ROLE_DELETE
&& opt_cmd != OPT::ROLE_GET
&& opt_cmd != OPT::ROLE_MODIFY
cerr << "ERROR: --tenant is set, but there's no user ID" << std::endl;
return EINVAL;
}
- user_id.tenant = tenant;
+ user->set_tenant(tenant);
}
if (user_ns.empty()) {
- user_ns = user_id.ns;
+ user_ns = user->get_id().ns;
} else {
- user_id.ns = user_ns;
+ user->set_ns(user_ns);
}
if (!new_user_id.empty() && !tenant.empty()) {
bool need_cache = readonly_ops_list.find(opt_cmd) == readonly_ops_list.end();
if (raw_storage_op) {
- store = RGWStoreManager::get_raw_storage(dpp(), g_ceph_context);
+ store = RGWStoreManager::get_raw_storage(dpp(), g_ceph_context, "rados");
} else {
- store = RGWStoreManager::get_storage(dpp(), g_ceph_context, false, false, false, false, false,
+ store = RGWStoreManager::get_storage(dpp(), g_ceph_context, "rados", false, false, false, false, false,
need_cache && g_conf()->rgw_cache_enabled);
}
if (!store) {
}
if (!source_zone_name.empty()) {
- if (!store->svc()->zone->find_zone_id_by_name(source_zone_name, &source_zone)) {
+ if (!static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->find_zone_id_by_name(source_zone_name, &source_zone)) {
cerr << "WARNING: cannot find source zone id for name=" << source_zone_name << std::endl;
source_zone = source_zone_name;
}
oath_init();
- StoreDestructor store_destructor(store);
+ StoreDestructor store_destructor(static_cast<rgw::sal::RGWRadosStore*>(store));
if (raw_storage_op) {
switch (opt_cmd) {
return EINVAL;
}
RGWPeriod period(period_id);
- int ret = period.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = period.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "period.init failed: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
if (staging) {
RGWRealm realm(realm_id, realm_name);
- int ret = realm.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0 ) {
cerr << "Error initializing realm " << cpp_strerror(-ret) << std::endl;
return -ret;
epoch = 1;
}
RGWPeriod period(period_id, epoch);
- int ret = period.init(g_ceph_context, store->svc()->sysobj, realm_id,
+ int ret = period.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, realm_id,
null_yield, realm_name);
if (ret < 0) {
cerr << "period init failed: " << cpp_strerror(-ret) << std::endl;
break;
case OPT::PERIOD_GET_CURRENT:
{
- int ret = read_current_period_id(store, realm_id, realm_name, &period_id);
+ int ret = read_current_period_id(static_cast<rgw::sal::RGWRadosStore*>(store), realm_id, realm_name, &period_id);
if (ret < 0) {
return -ret;
}
case OPT::PERIOD_LIST:
{
list<string> periods;
- int ret = store->svc()->zone->list_periods(periods);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->list_periods(periods);
if (ret < 0) {
cerr << "failed to list periods: " << cpp_strerror(-ret) << std::endl;
return -ret;
if (url.empty()) {
// load current period for endpoints
RGWRealm realm(realm_id, realm_name);
- int ret = realm.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWPeriod current_period(realm.get_current_period());
- ret = current_period.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ ret = current_period.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init current period: " << cpp_strerror(-ret) << std::endl;
return -ret;
// use realm master zone as remote
remote = current_period.get_master_zone().id;
}
- conn = get_remote_conn(store, current_period.get_map(), remote);
+ conn = get_remote_conn(static_cast<rgw::sal::RGWRadosStore*>(store), current_period.get_map(), remote);
if (!conn) {
cerr << "failed to find a zone or zonegroup for remote "
<< remote << std::endl;
case OPT::GLOBAL_QUOTA_DISABLE:
{
if (realm_id.empty()) {
- RGWRealm realm(g_ceph_context, store->svc()->sysobj);
+ RGWRealm realm(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj);
if (!realm_name.empty()) {
// look up realm_id for the given realm_name
int ret = realm.read_id(realm_name, realm_id, null_yield);
}
RGWPeriodConfig period_config;
- int ret = period_config.read(store->svc()->sysobj, realm_id, null_yield);
+ int ret = period_config.read(static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, realm_id, null_yield);
if (ret < 0 && ret != -ENOENT) {
cerr << "ERROR: failed to read period config: "
<< cpp_strerror(-ret) << std::endl;
if (opt_cmd != OPT::GLOBAL_QUOTA_GET) {
// write the modified period config
- ret = period_config.write(store->svc()->sysobj, realm_id, null_yield);
+ ret = period_config.write(static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, realm_id, null_yield);
if (ret < 0) {
cerr << "ERROR: failed to write period config: "
<< cpp_strerror(-ret) << std::endl;
return EINVAL;
}
- RGWRealm realm(realm_name, g_ceph_context, store->svc()->sysobj);
+ RGWRealm realm(realm_name, g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj);
int ret = realm.create(dpp(), null_yield);
if (ret < 0) {
cerr << "ERROR: couldn't create realm " << realm_name << ": " << cpp_strerror(-ret) << std::endl;
cerr << "missing realm name or id" << std::endl;
return EINVAL;
}
- int ret = realm.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "realm.init failed: " << cpp_strerror(-ret) << std::endl;
return -ret;
case OPT::REALM_GET:
{
RGWRealm realm(realm_id, realm_name);
- int ret = realm.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
if (ret == -ENOENT && realm_name.empty() && realm_id.empty()) {
cerr << "missing realm name or id, or default realm not found" << std::endl;
break;
case OPT::REALM_GET_DEFAULT:
{
- RGWRealm realm(g_ceph_context, store->svc()->sysobj);
+ RGWRealm realm(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj);
string default_id;
int ret = realm.read_default_id(default_id, null_yield);
if (ret == -ENOENT) {
break;
case OPT::REALM_LIST:
{
- RGWRealm realm(g_ceph_context, store->svc()->sysobj);
+ RGWRealm realm(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj);
string default_id;
int ret = realm.read_default_id(default_id, null_yield);
if (ret < 0 && ret != -ENOENT) {
cerr << "could not determine default realm: " << cpp_strerror(-ret) << std::endl;
}
list<string> realms;
- ret = store->svc()->zone->list_realms(realms);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->list_realms(realms);
if (ret < 0) {
cerr << "failed to list realms: " << cpp_strerror(-ret) << std::endl;
return -ret;
break;
case OPT::REALM_LIST_PERIODS:
{
- int ret = read_current_period_id(store, realm_id, realm_name, &period_id);
+ int ret = read_current_period_id(static_cast<rgw::sal::RGWRadosStore*>(store), realm_id, realm_name, &period_id);
if (ret < 0) {
return -ret;
}
list<string> periods;
- ret = store->svc()->zone->list_periods(period_id, periods, null_yield);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->list_periods(period_id, periods, null_yield);
if (ret < 0) {
cerr << "list periods failed: " << cpp_strerror(-ret) << std::endl;
return -ret;
cerr << "missing realm name or id" << std::endl;
return EINVAL;
}
- int ret = realm.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "realm.init failed: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWRealm realm(realm_id, realm_name);
bool new_realm = false;
- int ret = realm.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0 && ret != -ENOENT) {
cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl;
return -ret;
case OPT::REALM_DEFAULT:
{
RGWRealm realm(realm_id, realm_name);
- int ret = realm.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl;
return -ret;
return -ret;
}
RGWRealm realm;
- realm.init(g_ceph_context, store->svc()->sysobj, null_yield, false);
+ realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield, false);
try {
decode_json_obj(realm, &p);
} catch (const JSONDecoder::err& e) {
}
RGWZoneGroup zonegroup(zonegroup_id,zonegroup_name);
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to initialize zonegroup " << zonegroup_name << " id " << zonegroup_id << " :"
<< cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWZoneParams zone(zone_id, zone_name);
- ret = zone.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ ret = zone.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl;
return -ret;
endpoints, ptier_type,
psync_from_all, sync_from, sync_from_rm,
predirect_zone, bucket_index_max_shards,
- store->svc()->sync_modules->get_manager(),
+ static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sync_modules->get_manager(),
null_yield);
if (ret < 0) {
cerr << "failed to add zone " << zone_name << " to zonegroup " << zonegroup.get_name() << ": "
return EINVAL;
}
RGWRealm realm(realm_id, realm_name);
- int ret = realm.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- RGWZoneGroup zonegroup(zonegroup_name, is_master, g_ceph_context, store->svc()->sysobj, realm.get_id(), endpoints);
+ RGWZoneGroup zonegroup(zonegroup_name, is_master, g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, realm.get_id(), endpoints);
zonegroup.api_name = (api_name.empty() ? zonegroup_name : api_name);
ret = zonegroup.create(dpp(), null_yield);
if (ret < 0) {
}
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
return -ret;
return EINVAL;
}
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj,
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj,
null_yield);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
case OPT::ZONEGROUP_GET:
{
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
return -ret;
case OPT::ZONEGROUP_LIST:
{
RGWZoneGroup zonegroup;
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj,
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj,
null_yield, false);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
}
list<string> zonegroups;
- ret = store->svc()->zone->list_zonegroups(zonegroups);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->list_zonegroups(zonegroups);
if (ret < 0) {
cerr << "failed to list zonegroups: " << cpp_strerror(-ret) << std::endl;
return -ret;
case OPT::ZONEGROUP_MODIFY:
{
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
return -ret;
need_update = true;
} else if (!realm_name.empty()) {
// get realm id from name
- RGWRealm realm{g_ceph_context, store->svc()->sysobj};
+ RGWRealm realm{g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj};
ret = realm.read_id(realm_name, zonegroup.realm_id, null_yield);
if (ret < 0) {
cerr << "failed to find realm by name " << realm_name << std::endl;
case OPT::ZONEGROUP_SET:
{
RGWRealm realm(realm_id, realm_name);
- int ret = realm.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
bool default_realm_not_exist = (ret == -ENOENT && realm_id.empty() && realm_name.empty());
if (ret < 0 && !default_realm_not_exist ) {
}
RGWZoneGroup zonegroup;
- ret = zonegroup.init(g_ceph_context, store->svc()->sysobj,
+ ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj,
null_yield, false);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
case OPT::ZONEGROUP_REMOVE:
{
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
return -ret;
return EINVAL;
}
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
return -ret;
case OPT::ZONEGROUP_PLACEMENT_LIST:
{
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj,
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj,
null_yield);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
}
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
return -ret;
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
/* if the user didn't provide zonegroup info , create stand alone zone */
if (!zonegroup_id.empty() || !zonegroup_name.empty()) {
- ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "unable to initialize zonegroup " << zonegroup_name << ": " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWZoneParams zone(zone_id, zone_name);
- ret = zone.init(g_ceph_context, store->svc()->sysobj, null_yield, false);
+ ret = zone.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield, false);
if (ret < 0) {
cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl;
return -ret;
psync_from_all,
sync_from, sync_from_rm,
predirect_zone, bucket_index_max_shards,
- store->svc()->sync_modules->get_manager(),
+ static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sync_modules->get_manager(),
null_yield);
if (ret < 0) {
cerr << "failed to add zone " << zone_name << " to zonegroup " << zonegroup.get_name()
case OPT::ZONE_DEFAULT:
{
RGWZoneGroup zonegroup(zonegroup_id,zonegroup_name);
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "WARNING: failed to initialize zonegroup " << zonegroup_name << std::endl;
}
return EINVAL;
}
RGWZoneParams zone(zone_id, zone_name);
- ret = zone.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ ret = zone.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl;
return -ret;
return EINVAL;
}
RGWZoneParams zone(zone_id, zone_name);
- int ret = zone.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zone.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
list<string> zonegroups;
- ret = store->svc()->zone->list_zonegroups(zonegroups);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->list_zonegroups(zonegroups);
if (ret < 0) {
cerr << "failed to list zonegroups: " << cpp_strerror(-ret) << std::endl;
return -ret;
for (list<string>::iterator iter = zonegroups.begin(); iter != zonegroups.end(); ++iter) {
RGWZoneGroup zonegroup(string(), *iter);
- int ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "WARNING: failed to initialize zonegroup " << zonegroup_name << std::endl;
continue;
case OPT::ZONE_GET:
{
RGWZoneParams zone(zone_id, zone_name);
- int ret = zone.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zone.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl;
return -ret;
case OPT::ZONE_SET:
{
RGWZoneParams zone(zone_name);
- int ret = zone.init(g_ceph_context, store->svc()->sysobj, null_yield,
+ int ret = zone.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield,
false);
if (ret < 0) {
return -ret;
if(zone.realm_id.empty()) {
RGWRealm realm(realm_id, realm_name);
- int ret = realm.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0 && ret != -ENOENT) {
cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl;
return -ret;
case OPT::ZONE_LIST:
{
list<string> zones;
- int ret = store->svc()->zone->list_zones(zones);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->list_zones(zones);
if (ret < 0) {
cerr << "failed to list zones: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWZoneParams zone;
- ret = zone.init(g_ceph_context, store->svc()->sysobj, null_yield, false);
+ ret = zone.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield, false);
if (ret < 0) {
cerr << "failed to init zone: " << cpp_strerror(-ret) << std::endl;
return -ret;
case OPT::ZONE_MODIFY:
{
RGWZoneParams zone(zone_id, zone_name);
- int ret = zone.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zone.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init zone: " << cpp_strerror(-ret) << std::endl;
return -ret;
need_zone_update = true;
} else if (!realm_name.empty()) {
// get realm id from name
- RGWRealm realm{g_ceph_context, store->svc()->sysobj};
+ RGWRealm realm{g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj};
ret = realm.read_id(realm_name, zone.realm_id, null_yield);
if (ret < 0) {
cerr << "failed to find realm by name " << realm_name << std::endl;
}
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
- ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
return -ret;
endpoints, ptier_type,
psync_from_all, sync_from, sync_from_rm,
predirect_zone, bucket_index_max_shards,
- store->svc()->sync_modules->get_manager(),
+ static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sync_modules->get_manager(),
null_yield);
if (ret < 0) {
cerr << "failed to update zonegroup: " << cpp_strerror(-ret) << std::endl;
return EINVAL;
}
RGWZoneParams zone(zone_id,zone_name);
- int ret = zone.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zone.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl;
return -ret;
return -ret;
}
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
- ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "WARNING: failed to initialize zonegroup " << zonegroup_name << std::endl;
} else {
}
RGWZoneParams zone(zone_id, zone_name);
- int ret = zone.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zone.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init zone: " << cpp_strerror(-ret) << std::endl;
return -ret;
if (opt_cmd == OPT::ZONE_PLACEMENT_ADD ||
opt_cmd == OPT::ZONE_PLACEMENT_MODIFY) {
RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
- ret = zonegroup.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ ret = zonegroup.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
return -ret;
case OPT::ZONE_PLACEMENT_LIST:
{
RGWZoneParams zone(zone_id, zone_name);
- int ret = zone.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zone.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWZoneParams zone(zone_id, zone_name);
- int ret = zone.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = zone.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl;
return -ret;
resolve_zone_ids_opt(opt_source_zone_names, opt_source_zone_ids);
resolve_zone_ids_opt(opt_dest_zone_names, opt_dest_zone_ids);
- bool non_master_cmd = (!store->svc()->zone->is_meta_master() && !yes_i_really_mean_it);
+ bool non_master_cmd = (!store->is_meta_master() && !yes_i_really_mean_it);
std::set<OPT> non_master_ops_list = {OPT::USER_CREATE, OPT::USER_RM,
OPT::USER_MODIFY, OPT::USER_ENABLE,
OPT::USER_SUSPEND, OPT::SUBUSER_CREATE,
return EINVAL;
}
- if (!user_id.empty()) {
- user_op.set_user_id(user_id);
- bucket_op.set_user_id(user_id);
+ if (user) {
+ user_op.set_user_id(user->get_id());
+ bucket_op.set_user_id(user->get_id());
}
if (!display_name.empty())
if (!user_email.empty())
user_op.set_user_email(user_email);
- if (!user_id.empty()) {
+ if (!new_user_id.empty()) {
user_op.set_new_user_id(new_user_id);
}
rgw_placement_rule target_rule;
target_rule.name = placement_id;
target_rule.storage_class = *opt_storage_class;
- if (!store->svc()->zone->get_zone_params().valid_placement(target_rule)) {
+ if (!store->get_zone_params().valid_placement(target_rule)) {
cerr << "NOTICE: invalid dest placement: " << target_rule.to_str() << std::endl;
return EINVAL;
}
}
// RGWUser to use for user operations
- RGWUser user;
+ RGWUser ruser;
int ret = 0;
- if (!(user_id.empty() && access_key.empty()) || !subuser.empty()) {
- ret = user.init(dpp(), store, user_op, null_yield);
+ if (!(!user && access_key.empty()) || !subuser.empty()) {
+ ret = ruser.init(dpp(), store, user_op, null_yield);
if (ret < 0) {
cerr << "user.init failed: " << cpp_strerror(-ret) << std::endl;
return -ret;
switch (opt_cmd) {
case OPT::USER_INFO:
- if (user_id.empty() && access_key.empty()) {
+ if (!user && access_key.empty()) {
cerr << "ERROR: --uid or --access-key required" << std::endl;
return EINVAL;
}
if (!user_op.has_existing_user()) {
user_op.set_generate_key(); // generate a new key by default
}
- ret = user.add(dpp(), user_op, null_yield, &err_msg);
+ ret = ruser.add(dpp(), user_op, null_yield, &err_msg);
if (ret < 0) {
cerr << "could not create user: " << err_msg << std::endl;
if (ret == -ERR_INVALID_TENANT_NAME)
return -ret;
}
if (!subuser.empty()) {
- ret = user.subusers.add(dpp(), user_op, null_yield, &err_msg);
+ ret = ruser.subusers.add(dpp(),user_op, null_yield, &err_msg);
if (ret < 0) {
cerr << "could not create subuser: " << err_msg << std::endl;
return -ret;
}
break;
case OPT::USER_RM:
- ret = user.remove(dpp(), user_op, null_yield, &err_msg);
+ ret = ruser.remove(dpp(), user_op, null_yield, &err_msg);
if (ret < 0) {
cerr << "could not remove user: " << err_msg << std::endl;
return -ret;
if (yes_i_really_mean_it) {
user_op.set_overwrite_new_user(true);
}
- ret = user.rename(user_op, null_yield, dpp(), &err_msg);
+ ret = ruser.rename(user_op, null_yield, dpp(), &err_msg);
if (ret < 0) {
if (ret == -EEXIST) {
err_msg += ". to overwrite this user, add --yes-i-really-mean-it";
case OPT::USER_ENABLE:
case OPT::USER_SUSPEND:
case OPT::USER_MODIFY:
- ret = user.modify(dpp(), user_op, null_yield, &err_msg);
+ ret = ruser.modify(dpp(), user_op, null_yield, &err_msg);
if (ret < 0) {
cerr << "could not modify user: " << err_msg << std::endl;
return -ret;
break;
case OPT::SUBUSER_CREATE:
- ret = user.subusers.add(dpp(), user_op, null_yield, &err_msg);
+ ret = ruser.subusers.add(dpp(), user_op, null_yield, &err_msg);
if (ret < 0) {
cerr << "could not create subuser: " << err_msg << std::endl;
return -ret;
break;
case OPT::SUBUSER_MODIFY:
- ret = user.subusers.modify(dpp(), user_op, null_yield, &err_msg);
+ ret = ruser.subusers.modify(dpp(), user_op, null_yield, &err_msg);
if (ret < 0) {
cerr << "could not modify subuser: " << err_msg << std::endl;
return -ret;
break;
case OPT::SUBUSER_RM:
- ret = user.subusers.remove(dpp(), user_op, null_yield, &err_msg);
+ ret = ruser.subusers.remove(dpp(), user_op, null_yield, &err_msg);
if (ret < 0) {
cerr << "could not remove subuser: " << err_msg << std::endl;
return -ret;
break;
case OPT::CAPS_ADD:
- ret = user.caps.add(dpp(), user_op, null_yield, &err_msg);
+ ret = ruser.caps.add(dpp(), user_op, null_yield, &err_msg);
if (ret < 0) {
cerr << "could not add caps: " << err_msg << std::endl;
return -ret;
break;
case OPT::CAPS_RM:
- ret = user.caps.remove(dpp(), user_op, null_yield, &err_msg);
+ ret = ruser.caps.remove(dpp(), user_op, null_yield, &err_msg);
if (ret < 0) {
cerr << "could not remove caps: " << err_msg << std::endl;
return -ret;
break;
case OPT::KEY_CREATE:
- ret = user.keys.add(dpp(), user_op, null_yield, &err_msg);
+ ret = ruser.keys.add(dpp(), user_op, null_yield, &err_msg);
if (ret < 0) {
cerr << "could not create key: " << err_msg << std::endl;
return -ret;
break;
case OPT::KEY_RM:
- ret = user.keys.remove(dpp(), user_op, null_yield, &err_msg);
+ ret = ruser.keys.remove(dpp(), user_op, null_yield, &err_msg);
if (ret < 0) {
cerr << "could not remove key: " << err_msg << std::endl;
return -ret;
// load the period
RGWPeriod period(period_id);
- int ret = period.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = period.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "period init failed: " << cpp_strerror(-ret) << std::endl;
return -ret;
{
// read realm and staging period
RGWRealm realm(realm_id, realm_name);
- int ret = realm.init(g_ceph_context, store->svc()->sysobj, null_yield);
+ int ret = realm.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, null_yield);
if (ret < 0) {
cerr << "Error initializing realm: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWPeriod period(RGWPeriod::get_staging_id(realm.get_id()), 1);
- ret = period.init(g_ceph_context, store->svc()->sysobj, realm.get_id(), null_yield);
+ ret = period.init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, realm.get_id(), null_yield);
if (ret < 0) {
cerr << "period init failed: " << cpp_strerror(-ret) << std::endl;
return -ret;
cerr << "failed to parse policy: " << e.what() << std::endl;
return -EINVAL;
}
- RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, path, assume_role_doc, tenant);
+ RGWRole role(g_ceph_context, store->get_ctl(), role_name, path, assume_role_doc, tenant);
ret = role.create(dpp(), true, null_yield);
if (ret < 0) {
return -ret;
cerr << "ERROR: empty role name" << std::endl;
return -EINVAL;
}
- RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
+ RGWRole role(g_ceph_context, store->get_ctl(), role_name, tenant);
ret = role.delete_obj(dpp(), null_yield);
if (ret < 0) {
return -ret;
cerr << "ERROR: empty role name" << std::endl;
return -EINVAL;
}
- RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
+ RGWRole role(g_ceph_context, store->get_ctl(), role_name, tenant);
ret = role.get(dpp(), null_yield);
if (ret < 0) {
return -ret;
return -EINVAL;
}
- RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
+ RGWRole role(g_ceph_context, store->get_ctl(), role_name, tenant);
ret = role.get(dpp(), null_yield);
if (ret < 0) {
return -ret;
case OPT::ROLE_LIST:
{
vector<RGWRole> result;
- ret = RGWRole::get_roles_by_path_prefix(dpp(), store->getRados(), g_ceph_context, path_prefix, tenant, result, null_yield);
+ ret = RGWRole::get_roles_by_path_prefix(dpp(), store, g_ceph_context, path_prefix, tenant, result, null_yield);
if (ret < 0) {
return -ret;
}
return -EINVAL;
}
- RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
+ RGWRole role(g_ceph_context, store->get_ctl(), role_name, tenant);
ret = role.get(dpp(), null_yield);
if (ret < 0) {
return -ret;
cerr << "ERROR: Role name is empty" << std::endl;
return -EINVAL;
}
- RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
+ RGWRole role(g_ceph_context, store->get_ctl(), role_name, tenant);
ret = role.get(dpp(), null_yield);
if (ret < 0) {
return -ret;
cerr << "ERROR: policy name is empty" << std::endl;
return -EINVAL;
}
- RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
+ RGWRole role(g_ceph_context, store->get_ctl(), role_name, tenant);
int ret = role.get(dpp(), null_yield);
if (ret < 0) {
return -ret;
cerr << "ERROR: policy name is empty" << std::endl;
return -EINVAL;
}
- RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
+ RGWRole role(g_ceph_context, store->get_ctl(), role_name, tenant);
ret = role.get(dpp(), null_yield);
if (ret < 0) {
return -ret;
// output the result of a user operation
if (output_user_info) {
- ret = user.info(info, &err_msg);
+ ret = ruser.info(info, &err_msg);
if (ret < 0) {
cerr << "could not fetch user info: " << err_msg << std::endl;
return -ret;
bool truncated;
- if (! user_id.empty()) {
- user_ids.push_back(user_id.id);
+ if (user) {
+ user_ids.push_back(user->get_id().id);
ret =
RGWBucketAdminOp::limit_check(store, bucket_op, user_ids, f,
null_yield, dpp(), warnings_only);
} else {
/* list users in groups of max-keys, then perform user-bucket
* limit-check on each group */
- ret = store->ctl()->meta.mgr->list_keys_init(metadata_key, &handle);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init(metadata_key, &handle);
if (ret < 0) {
cerr << "ERROR: buckets limit check can't get user metadata_key: "
<< cpp_strerror(-ret) << std::endl;
}
do {
- ret = store->ctl()->meta.mgr->list_keys_next(handle, max, user_ids,
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, max, user_ids,
&truncated);
if (ret < 0 && ret != -ENOENT) {
cerr << "ERROR: buckets limit check lists_keys_next(): "
}
user_ids.clear();
} while (truncated);
- store->ctl()->meta.mgr->list_keys_complete(handle);
+ static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
}
return -ret;
} /* OPT::BUCKET_LIMIT_CHECK */
if (opt_cmd == OPT::BUCKETS_LIST) {
if (bucket_name.empty()) {
- if (!user_id.empty()) {
+ if (user) {
if (!user_op.has_existing_user()) {
- cerr << "ERROR: could not find user: " << user_id << std::endl;
+ cerr << "ERROR: could not find user: " << user << std::endl;
return -ENOENT;
}
}
RGWBucketAdminOp::info(store, bucket_op, f, null_yield, dpp());
} else {
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
formatter->open_array_section("entries");
- bool truncated = false;
int count = 0;
static constexpr int MAX_PAGINATE_SIZE = 10000;
string prefix;
string delim;
- vector<rgw_bucket_dir_entry> result;
- map<string, bool> common_prefixes;
string ns;
- RGWRados::Bucket target(store->getRados(), bucket_info);
- RGWRados::Bucket::List list_op(&target);
+ rgw::sal::RGWBucket::ListParams params;
+ rgw::sal::RGWBucket::ListResults results;
- list_op.params.prefix = prefix;
- list_op.params.delim = delim;
- list_op.params.marker = rgw_obj_key(marker);
- list_op.params.ns = ns;
- list_op.params.enforce_ns = false;
- list_op.params.list_versions = true;
- list_op.params.allow_unordered = bool(allow_unordered);
+ params.prefix = prefix;
+ params.delim = delim;
+ params.marker = rgw_obj_key(marker);
+ params.ns = ns;
+ params.enforce_ns = false;
+ params.list_versions = true;
+ params.allow_unordered = bool(allow_unordered);
do {
const int remaining = max_entries - count;
- ret = list_op.list_objects(dpp(), std::min(remaining, paginate_size),
- &result, &common_prefixes, &truncated,
- null_yield);
+ ret = bucket->list(dpp(), params, std::min(remaining, paginate_size), results,
+ null_yield);
if (ret < 0) {
cerr << "ERROR: store->list_objects(): " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- count += result.size();
+ count += results.objs.size();
- for (const auto& entry : result) {
+ for (const auto& entry : results.objs) {
encode_json("entry", entry, formatter.get());
}
formatter->flush(cout);
- } while (truncated && count < max_entries);
+ } while (results.is_truncated && count < max_entries);
formatter->close_section();
formatter->flush(cout);
if (opt_cmd == OPT::BUCKET_STATS) {
if (bucket_name.empty() && !bucket_id.empty()) {
rgw_bucket bucket;
- if (!rgw_find_bucket_by_id(store->ctx(), store->ctl()->meta.mgr, marker, bucket_id, &bucket)) {
+ if (!rgw_find_bucket_by_id(store->ctx(), static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr, marker, bucket_id, &bucket)) {
cerr << "failure: no such bucket id" << std::endl;
return -ENOENT;
}
formatter->reset();
formatter->open_array_section("logs");
RGWAccessHandle h;
- int r = store->getRados()->log_list_init(date, &h);
+ int r = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->log_list_init(date, &h);
if (r == -ENOENT) {
// no logs.
} else {
}
while (true) {
string name;
- int r = store->getRados()->log_list_next(h, &name);
+ int r = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->log_list_next(h, &name);
if (r == -ENOENT)
break;
if (r < 0) {
if (opt_cmd == OPT::LOG_SHOW) {
RGWAccessHandle h;
- int r = store->getRados()->log_show_init(oid, &h);
+ int r = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->log_show_init(oid, &h);
if (r < 0) {
cerr << "error opening log " << oid << ": " << cpp_strerror(-r) << std::endl;
return -r;
struct rgw_log_entry entry;
// peek at first entry to get bucket metadata
- r = store->getRados()->log_show_next(h, &entry);
+ r = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->log_show_next(h, &entry);
if (r < 0) {
cerr << "error reading log " << oid << ": " << cpp_strerror(-r) << std::endl;
return -r;
formatter->flush(cout);
}
next:
- r = store->getRados()->log_show_next(h, &entry);
+ r = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->log_show_next(h, &entry);
} while (r > 0);
if (r < 0) {
cout << std::endl;
}
if (opt_cmd == OPT::LOG_RM) {
- int r = store->getRados()->log_remove(oid);
+ int r = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->log_remove(oid);
if (r < 0) {
cerr << "error removing log " << oid << ": " << cpp_strerror(-r) << std::endl;
return -r;
exit(1);
}
- int ret = store->svc()->zone->add_bucket_placement(pool, null_yield);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->add_bucket_placement(pool, null_yield);
if (ret < 0)
cerr << "failed to add bucket placement: " << cpp_strerror(-ret) << std::endl;
}
exit(1);
}
- int ret = store->svc()->zone->remove_bucket_placement(pool, null_yield);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->remove_bucket_placement(pool, null_yield);
if (ret < 0)
cerr << "failed to remove bucket placement: " << cpp_strerror(-ret) << std::endl;
}
if (opt_cmd == OPT::POOLS_LIST) {
set<rgw_pool> pools;
- int ret = store->svc()->zone->list_placement_set(pools, null_yield);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->list_placement_set(pools, null_yield);
if (ret < 0) {
cerr << "could not list placement set: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- ret = RGWUsage::show(store->getRados(), user_id, bucket_name, start_epoch, end_epoch,
- show_log_entries, show_log_sum, &categories,
+ if (!bucket_name.empty()) {
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
+ if (ret < 0) {
+ cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
+ return -ret;
+ }
+ }
+ ret = RGWUsage::show(dpp(), store, user.get(), bucket.get(), start_epoch,
+ end_epoch, show_log_entries, show_log_sum, &categories,
f);
if (ret < 0) {
cerr << "ERROR: failed to show usage" << std::endl;
}
if (opt_cmd == OPT::USAGE_TRIM) {
- if (user_id.empty() && bucket_name.empty() &&
+ if (!user && bucket_name.empty() &&
start_date.empty() && end_date.empty() && !yes_i_really_mean_it) {
cerr << "usage trim without user/date/bucket specified will remove *all* users data" << std::endl;
cerr << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl;
}
}
- ret = RGWUsage::trim(store->getRados(), user_id, bucket_name, start_epoch, end_epoch);
+ if (!bucket_name.empty()) {
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
+ if (ret < 0) {
+ cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
+ return -ret;
+ }
+ }
+ ret = RGWUsage::trim(dpp(), store, user.get(), bucket.get(), start_epoch, end_epoch);
if (ret < 0) {
cerr << "ERROR: read_usage() returned ret=" << ret << std::endl;
return 1;
return 1;
}
- ret = RGWUsage::clear(store->getRados());
+ ret = RGWUsage::clear(store);
if (ret < 0) {
return ret;
}
}
if (opt_cmd == OPT::OLH_GET) {
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWOLHInfo olh;
- rgw_obj obj(bucket, object);
- ret = store->getRados()->get_olh(bucket_info, obj, &olh);
+ rgw_obj obj(bucket->get_key(), object);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_olh(bucket->get_info(), obj, &olh);
if (ret < 0) {
cerr << "ERROR: failed reading olh: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
if (opt_cmd == OPT::OLH_READLOG) {
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
bool is_truncated;
RGWObjectCtx rctx(store);
- rgw_obj obj(bucket, object);
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(object);
RGWObjState *state;
- ret = store->getRados()->get_obj_state(dpp(), &rctx, bucket_info, obj, &state, false, null_yield); /* don't follow olh */
+ ret = obj->get_obj_state(dpp(), &rctx, &state, null_yield);
if (ret < 0) {
return -ret;
}
- ret = store->getRados()->bucket_index_read_olh_log(dpp(), bucket_info, *state, obj, 0, &log, &is_truncated);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->bucket_index_read_olh_log(dpp(), bucket->get_info(), *state, obj->get_obj(), 0, &log, &is_truncated);
if (ret < 0) {
cerr << "ERROR: failed reading olh: " << cpp_strerror(-ret) << std::endl;
return -ret;
cerr << "ERROR: object not specified" << std::endl;
return EINVAL;
}
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- rgw_obj obj(bucket, object);
+ rgw_obj obj(bucket->get_key(), object);
if (!object_version.empty()) {
obj.key.set_instance(object_version);
}
rgw_cls_bi_entry entry;
- ret = store->getRados()->bi_get(bucket_info, obj, bi_index_type, &entry);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->bi_get(bucket->get_info(), obj, bi_index_type, &entry);
if (ret < 0) {
cerr << "ERROR: bi_get(): " << cpp_strerror(-ret) << std::endl;
return -ret;
cerr << "ERROR: bucket name not specified" << std::endl;
return EINVAL;
}
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
return 1;
}
- rgw_obj obj(bucket, key);
+ rgw_obj obj(bucket->get_key(), key);
- ret = store->getRados()->bi_put(dpp(), bucket, obj, entry);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->bi_put(dpp(), bucket->get_key(), obj, entry);
if (ret < 0) {
cerr << "ERROR: bi_put(): " << cpp_strerror(-ret) << std::endl;
return -ret;
cerr << "ERROR: bucket name not specified" << std::endl;
return EINVAL;
}
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
max_entries = 1000;
}
- int max_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
+ int max_shards = (bucket->get_info().layout.current_index.layout.normal.num_shards > 0 ? bucket->get_info().layout.current_index.layout.normal.num_shards : 1);
formatter->open_array_section("entries");
int i = (specified_shard_id ? shard_id : 0);
for (; i < max_shards; i++) {
- RGWRados::BucketShard bs(store->getRados());
- int shard_id = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? i : -1);
+ RGWRados::BucketShard bs(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados());
+ int shard_id = (bucket->get_info().layout.current_index.layout.normal.num_shards > 0 ? i : -1);
- int ret = bs.init(bucket, shard_id, bucket_info.layout.current_index, nullptr /* no RGWBucketInfo */, dpp());
+ int ret = bs.init(bucket->get_key(), shard_id, bucket->get_info().layout.current_index, nullptr /* no RGWBucketInfo */, dpp());
marker.clear();
if (ret < 0) {
do {
entries.clear();
- ret = store->getRados()->bi_list(bs, object, marker, max_entries, &entries, &is_truncated);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->bi_list(bs, object, marker, max_entries, &entries, &is_truncated);
if (ret < 0) {
cerr << "ERROR: bi_list(): " << cpp_strerror(-ret) << std::endl;
return -ret;
cerr << "ERROR: bucket name not specified" << std::endl;
return EINVAL;
}
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- RGWBucketInfo cur_bucket_info;
- rgw_bucket cur_bucket;
- ret = init_bucket(tenant, bucket_name, string(), cur_bucket_info, cur_bucket);
+ std::unique_ptr<rgw::sal::RGWBucket> cur_bucket;
+ ret = init_bucket(user.get(), tenant, bucket_name, string(), &cur_bucket);
if (ret < 0) {
cerr << "ERROR: could not init current bucket info for bucket_name=" << bucket_name << ": " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- if (cur_bucket_info.bucket.bucket_id == bucket_info.bucket.bucket_id && !yes_i_really_mean_it) {
+ if (cur_bucket->get_bucket_id() == bucket->get_bucket_id() && !yes_i_really_mean_it) {
cerr << "specified bucket instance points to a current bucket instance" << std::endl;
cerr << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl;
return EINVAL;
}
- int max_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
-
- for (int i = 0; i < max_shards; i++) {
- RGWRados::BucketShard bs(store->getRados());
- int shard_id = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? i : -1);
- int ret = bs.init(bucket, shard_id, bucket_info.layout.current_index, nullptr /* no RGWBucketInfo */, dpp());
- if (ret < 0) {
- cerr << "ERROR: bs.init(bucket=" << bucket << ", shard=" << shard_id << "): " << cpp_strerror(-ret) << std::endl;
- return -ret;
- }
-
- ret = store->getRados()->bi_remove(bs);
- if (ret < 0) {
- cerr << "ERROR: failed to remove bucket index object: " << cpp_strerror(-ret) << std::endl;
- return -ret;
- }
+ ret = bucket->purge_instance(dpp());
+ if (ret < 0) {
+ return -ret;
}
}
}
if (opt_cmd == OPT::OBJECT_RM) {
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
rgw_obj_key key(object, object_version);
- ret = rgw_remove_object(dpp(), store, bucket_info, bucket, key);
+ ret = rgw_remove_object(dpp(), store, bucket.get(), key);
if (ret < 0) {
cerr << "ERROR: object remove returned: " << cpp_strerror(-ret) << std::endl;
return EINVAL;
}
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- rgw::sal::RGWRadosBucket rbucket(store, bucket);
- rgw::sal::RGWRadosObject obj(store, object, &rbucket);
- obj.set_instance(object_version);
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(object);
+ obj->set_instance(object_version);
bool need_rewrite = true;
if (min_rewrite_stripe_size > 0) {
- ret = check_min_obj_stripe_size(store, bucket_info, &obj, min_rewrite_stripe_size, &need_rewrite);
+ ret = check_min_obj_stripe_size(store, obj.get(), min_rewrite_stripe_size, &need_rewrite);
if (ret < 0) {
ldpp_dout(dpp(), 0) << "WARNING: check_min_obj_stripe_size failed, r=" << ret << dendl;
}
}
if (need_rewrite) {
- ret = store->getRados()->rewrite_obj(bucket_info, &obj, dpp(), null_yield);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->rewrite_obj(bucket->get_info(), obj.get(), dpp(), null_yield);
if (ret < 0) {
cerr << "ERROR: object rewrite returned: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
if (opt_cmd == OPT::OBJECTS_EXPIRE) {
- if (!store->getRados()->process_expire_objects(dpp())) {
+ if (!static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->process_expire_objects(dpp())) {
cerr << "ERROR: process_expire_objects() processing returned error." << std::endl;
return 1;
}
return EINVAL;
}
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
RGWRados::ent_map_t result;
result.reserve(NUM_ENTRIES);
- int r = store->getRados()->cls_bucket_list_ordered(
- dpp(), bucket_info, RGW_NO_SHARD,
+ int r = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->cls_bucket_list_ordered(
+ dpp(), bucket->get_info(), RGW_NO_SHARD,
marker, empty_prefix, empty_delimiter,
NUM_ENTRIES, true, expansion_factor,
result, &is_truncated, &cls_filtered, &marker,
(end_epoch > 0 && end_epoch < (uint64_t)ut.sec())) {
formatter->dump_string("status", "Skipped");
} else {
- rgw::sal::RGWRadosBucket rbucket(store, bucket);
- rgw::sal::RGWRadosObject obj(store, key, &rbucket);
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(key);
bool need_rewrite = true;
if (min_rewrite_stripe_size > 0) {
- r = check_min_obj_stripe_size(store, bucket_info, &obj, min_rewrite_stripe_size, &need_rewrite);
+ r = check_min_obj_stripe_size(store, obj.get(), min_rewrite_stripe_size, &need_rewrite);
if (r < 0) {
ldpp_dout(dpp(), 0) << "WARNING: check_min_obj_stripe_size failed, r=" << r << dendl;
}
if (!need_rewrite) {
formatter->dump_string("status", "Skipped");
} else {
- r = store->getRados()->rewrite_obj(bucket_info, &obj, dpp(), null_yield);
+ r = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->rewrite_obj(bucket->get_info(), obj.get(), dpp(), null_yield);
if (r == 0) {
formatter->dump_string("status", "Success");
} else {
}
if (opt_cmd == OPT::BUCKET_RESHARD) {
- rgw_bucket bucket;
- RGWBucketInfo bucket_info;
- map<string, bufferlist> attrs;
-
- int ret = check_reshard_bucket_params(store,
+ int ret = check_reshard_bucket_params(static_cast<rgw::sal::RGWRadosStore*>(store),
bucket_name,
tenant,
bucket_id,
num_shards_specified,
num_shards,
yes_i_really_mean_it,
- bucket,
- bucket_info,
- attrs);
+ &bucket);
if (ret < 0) {
return ret;
}
- RGWBucketReshard br(store, bucket_info, attrs, nullptr /* no callback */);
+ RGWBucketReshard br(static_cast<rgw::sal::RGWRadosStore*>(store), bucket->get_info(), bucket->get_attrs(), nullptr /* no callback */);
#define DEFAULT_RESHARD_MAX_ENTRIES 1000
if (max_entries < 1) {
}
if (opt_cmd == OPT::RESHARD_ADD) {
- rgw_bucket bucket;
- RGWBucketInfo bucket_info;
- map<string, bufferlist> attrs;
-
- int ret = check_reshard_bucket_params(store,
+ int ret = check_reshard_bucket_params(static_cast<rgw::sal::RGWRadosStore*>(store),
bucket_name,
tenant,
bucket_id,
num_shards_specified,
num_shards,
yes_i_really_mean_it,
- bucket,
- bucket_info,
- attrs);
+ &bucket);
if (ret < 0) {
return ret;
}
- int num_source_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
+ int num_source_shards = (bucket->get_info().layout.current_index.layout.normal.num_shards > 0 ? bucket->get_info().layout.current_index.layout.normal.num_shards : 1);
- RGWReshard reshard(store, dpp());
+ RGWReshard reshard(static_cast<rgw::sal::RGWRadosStore*>(store), dpp());
cls_rgw_reshard_entry entry;
entry.time = real_clock::now();
entry.tenant = tenant;
entry.bucket_name = bucket_name;
- entry.bucket_id = bucket_info.bucket.bucket_id;
+ entry.bucket_id = bucket->get_info().bucket.bucket_id;
entry.old_num_shards = num_source_shards;
entry.new_num_shards = num_shards;
int num_logshards =
store->ctx()->_conf.get_val<uint64_t>("rgw_reshard_num_logs");
- RGWReshard reshard(store, dpp());
+ RGWReshard reshard(static_cast<rgw::sal::RGWRadosStore*>(store), dpp());
formatter->open_array_section("reshard");
for (int i = 0; i < num_logshards; i++) {
return EINVAL;
}
- rgw_bucket bucket;
- RGWBucketInfo bucket_info;
- map<string, bufferlist> attrs;
- ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket, &attrs);
+ ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- RGWBucketReshard br(store, bucket_info, attrs, nullptr /* no callback */);
+ RGWBucketReshard br(static_cast<rgw::sal::RGWRadosStore*>(store), bucket->get_info(), bucket->get_attrs(), nullptr /* no callback */);
list<cls_rgw_bucket_instance_entry> status;
int r = br.get_status(&status);
if (r < 0) {
}
if (opt_cmd == OPT::RESHARD_PROCESS) {
- RGWReshard reshard(store, true, &cout);
+ RGWReshard reshard(static_cast<rgw::sal::RGWRadosStore*>(store), true, &cout);
int ret = reshard.process_all_logshards(dpp());
if (ret < 0) {
return EINVAL;
}
- rgw_bucket bucket;
- RGWBucketInfo bucket_info;
- map<string, bufferlist> attrs;
bool bucket_initable = true;
- ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket,
- &attrs);
+ ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
if (yes_i_really_mean_it) {
bucket_initable = false;
if (bucket_initable) {
// we did not encounter an error, so let's work with the bucket
- RGWBucketReshard br(store, bucket_info, attrs,
+ RGWBucketReshard br(static_cast<rgw::sal::RGWRadosStore*>(store), bucket->get_info(), bucket->get_attrs(),
nullptr /* no callback */);
int ret = br.cancel();
if (ret < 0) {
}
}
- RGWReshard reshard(store, dpp());
+ RGWReshard reshard(static_cast<rgw::sal::RGWRadosStore*>(store), dpp());
cls_rgw_reshard_entry entry;
entry.tenant = tenant;
} // OPT_RESHARD_CANCEL
if (opt_cmd == OPT::OBJECT_UNLINK) {
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
rgw_obj_index_key index_key;
key.get_index_key(&index_key);
oid_list.push_back(index_key);
- ret = store->getRados()->remove_objs_from_index(bucket_info, oid_list);
+ ret = bucket->remove_objs_from_index(oid_list);
if (ret < 0) {
cerr << "ERROR: remove_obj_from_index() returned error: " << cpp_strerror(-ret) << std::endl;
return 1;
}
if (opt_cmd == OPT::OBJECT_STAT) {
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- rgw_obj obj(bucket, object);
- obj.key.set_instance(object_version);
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(object);
+ obj->set_instance(object_version);
- uint64_t obj_size;
- map<string, bufferlist> attrs;
RGWObjectCtx obj_ctx(store);
- RGWRados::Object op_target(store->getRados(), bucket_info, obj_ctx, obj);
- RGWRados::Object::Read read_op(&op_target);
-
- read_op.params.attrs = &attrs;
- read_op.params.obj_size = &obj_size;
- ret = read_op.prepare(null_yield, dpp());
+ ret = obj->get_obj_attrs(&obj_ctx, null_yield, dpp());
if (ret < 0) {
cerr << "ERROR: failed to stat object, returned error: " << cpp_strerror(-ret) << std::endl;
return 1;
}
formatter->open_object_section("object_metadata");
formatter->dump_string("name", object);
- formatter->dump_unsigned("size", obj_size);
+ formatter->dump_unsigned("size", obj->get_obj_size());
map<string, bufferlist>::iterator iter;
map<string, bufferlist> other_attrs;
- for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
+ for (iter = obj->get_attrs().begin(); iter != obj->get_attrs().end(); ++iter) {
bufferlist& bl = iter->second;
bool handled = false;
if (iter->first == RGW_ATTR_MANIFEST) {
do {
list<cls_rgw_gc_obj_info> result;
- int ret = store->getRados()->list_gc_objs(&index, marker, 1000, !include_all, result, &truncated, processing_queue);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->list_gc_objs(&index, marker, 1000, !include_all, result, &truncated, processing_queue);
if (ret < 0) {
cerr << "ERROR: failed to list objs: " << cpp_strerror(-ret) << std::endl;
return 1;
}
if (opt_cmd == OPT::GC_PROCESS) {
- int ret = store->getRados()->process_gc(!include_all);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->process_gc(!include_all);
if (ret < 0) {
cerr << "ERROR: gc processing returned error: " << cpp_strerror(-ret) << std::endl;
return 1;
max_entries = MAX_LC_LIST_ENTRIES;
}
do {
- int ret = store->getRados()->list_lc_progress(marker, max_entries,
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->list_lc_progress(marker, max_entries,
bucket_lc_map, index);
if (ret < 0) {
cerr << "ERROR: failed to list objs: " << cpp_strerror(-ret)
return EINVAL;
}
- rgw_bucket bucket;
- RGWBucketInfo bucket_info;
- map<string, bufferlist> attrs;
RGWLifecycleConfiguration config;
- ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket, &attrs);
+ ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- auto aiter = attrs.find(RGW_ATTR_LC);
- if (aiter == attrs.end()) {
+ auto aiter = bucket->get_attrs().find(RGW_ATTR_LC);
+ if (aiter == bucket->get_attrs().end()) {
return -ENOENT;
}
}
if (opt_cmd == OPT::LC_PROCESS) {
- int ret = store->getRados()->process_lc();
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->process_lc();
if (ret < 0) {
cerr << "ERROR: lc processing returned error: " << cpp_strerror(-ret) << std::endl;
return 1;
}
if (opt_cmd == OPT::USER_CHECK) {
- check_bad_user_bucket_mapping(store, user_id, fix, null_yield, dpp());
+ check_bad_user_bucket_mapping(store, user.get(), fix, null_yield, dpp());
}
if (opt_cmd == OPT::USER_STATS) {
- if (user_id.empty()) {
+ if (!user) {
cerr << "ERROR: uid not specified" << std::endl;
return EINVAL;
}
-
if (reset_stats) {
if (!bucket_name.empty()) {
cerr << "ERROR: --reset-stats does not work on buckets and "
"so at most one of the two should be specified" << std::endl;
return EINVAL;
}
- ret = store->ctl()->user->reset_stats(user_id, null_yield);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->user->reset_stats(user->get_id(), null_yield);
if (ret < 0) {
cerr << "ERROR: could not reset user stats: " << cpp_strerror(-ret) <<
std::endl;
if (sync_stats) {
if (!bucket_name.empty()) {
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- ret = store->ctl()->bucket->sync_user_stats(user_id, bucket_info, null_yield);
+ ret = bucket->sync_user_stats(null_yield);
if (ret < 0) {
cerr << "ERROR: could not sync bucket stats: " <<
cpp_strerror(-ret) << std::endl;
return -ret;
}
} else {
- int ret = rgw_user_sync_all_stats(dpp(), store, user_id, null_yield);
+ int ret = rgw_user_sync_all_stats(dpp(), store, user.get(), null_yield);
if (ret < 0) {
cerr << "ERROR: could not sync user stats: " <<
cpp_strerror(-ret) << std::endl;
RGWStorageStats stats;
ceph::real_time last_stats_sync;
ceph::real_time last_stats_update;
- int ret = store->ctl()->user->read_stats(user_id, &stats, null_yield,
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->user->read_stats(user->get_id(), &stats, null_yield,
&last_stats_sync,
&last_stats_update);
if (ret < 0) {
}
if (opt_cmd == OPT::METADATA_GET) {
- int ret = store->ctl()->meta.mgr->get(metadata_key, formatter.get(), null_yield, dpp());
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->get(metadata_key, formatter.get(), null_yield, dpp());
if (ret < 0) {
cerr << "ERROR: can't get key: " << cpp_strerror(-ret) << std::endl;
return -ret;
cerr << "ERROR: failed to read input: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- ret = store->ctl()->meta.mgr->put(metadata_key, bl, null_yield, dpp(), RGWMDLogSyncType::APPLY_ALWAYS, false);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->put(metadata_key, bl, null_yield, dpp(), RGWMDLogSyncType::APPLY_ALWAYS, false);
if (ret < 0) {
cerr << "ERROR: can't put key: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
if (opt_cmd == OPT::METADATA_RM) {
- int ret = store->ctl()->meta.mgr->remove(metadata_key, null_yield, dpp());
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->remove(metadata_key, null_yield, dpp());
if (ret < 0) {
cerr << "ERROR: can't remove key: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
void *handle;
int max = 1000;
- int ret = store->ctl()->meta.mgr->list_keys_init(metadata_key, marker, &handle);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init(metadata_key, marker, &handle);
if (ret < 0) {
cerr << "ERROR: can't get key: " << cpp_strerror(-ret) << std::endl;
return -ret;
do {
list<string> keys;
left = (max_entries_specified ? max_entries - count : max);
- ret = store->ctl()->meta.mgr->list_keys_next(handle, left, keys, &truncated);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, left, keys, &truncated);
if (ret < 0 && ret != -ENOENT) {
cerr << "ERROR: lists_keys_next(): " << cpp_strerror(-ret) << std::endl;
return -ret;
encode_json("truncated", truncated, formatter.get());
encode_json("count", count, formatter.get());
if (truncated) {
- encode_json("marker", store->ctl()->meta.mgr->get_marker(handle), formatter.get());
+ encode_json("marker", static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->get_marker(handle), formatter.get());
}
formatter->close_section();
}
formatter->flush(cout);
- store->ctl()->meta.mgr->list_keys_complete(handle);
+ static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
}
if (opt_cmd == OPT::MDLOG_LIST) {
int i = (specified_shard_id ? shard_id : 0);
if (period_id.empty()) {
- int ret = read_current_period_id(store, realm_id, realm_name, &period_id);
+ int ret = read_current_period_id(static_cast<rgw::sal::RGWRadosStore*>(store), realm_id, realm_name, &period_id);
if (ret < 0) {
return -ret;
}
std::cerr << "No --period given, using current period="
<< period_id << std::endl;
}
- RGWMetadataLog *meta_log = store->svc()->mdlog->get_log(period_id);
+ RGWMetadataLog *meta_log = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->mdlog->get_log(period_id);
formatter->open_array_section("entries");
for (; i < g_ceph_context->_conf->rgw_md_log_max_shards; i++) {
for (list<cls_log_entry>::iterator iter = entries.begin(); iter != entries.end(); ++iter) {
cls_log_entry& entry = *iter;
- store->ctl()->meta.mgr->dump_log_entry(entry, formatter.get());
+ static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->dump_log_entry(entry, formatter.get());
}
formatter->flush(cout);
} while (truncated);
int i = (specified_shard_id ? shard_id : 0);
if (period_id.empty()) {
- int ret = read_current_period_id(store, realm_id, realm_name, &period_id);
+ int ret = read_current_period_id(static_cast<rgw::sal::RGWRadosStore*>(store), realm_id, realm_name, &period_id);
if (ret < 0) {
return -ret;
}
std::cerr << "No --period given, using current period="
<< period_id << std::endl;
}
- RGWMetadataLog *meta_log = store->svc()->mdlog->get_log(period_id);
+ RGWMetadataLog *meta_log = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->mdlog->get_log(period_id);
formatter->open_array_section("entries");
if (opt_cmd == OPT::MDLOG_AUTOTRIM) {
// need a full history for purging old mdlog periods
- store->svc()->mdlog->init_oldest_log_period(null_yield, dpp());
+ static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->mdlog->init_oldest_log_period(null_yield, dpp());
- RGWCoroutinesManager crs(store->ctx(), store->getRados()->get_cr_registry());
+ RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry());
RGWHTTPManager http(store->ctx(), crs.get_completion_mgr());
int ret = http.start();
if (ret < 0) {
}
auto num_shards = g_conf()->rgw_md_log_max_shards;
- ret = crs.run(create_admin_meta_log_trim_cr(dpp(), store, &http, num_shards));
+ ret = crs.run(create_admin_meta_log_trim_cr(dpp(), static_cast<rgw::sal::RGWRadosStore*>(store), &http, num_shards));
if (ret < 0) {
cerr << "automated mdlog trim failed with " << cpp_strerror(ret) << std::endl;
return -ret;
std::cerr << "missing --period argument" << std::endl;
return EINVAL;
}
- RGWMetadataLog *meta_log = store->svc()->mdlog->get_log(period_id);
+ RGWMetadataLog *meta_log = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->mdlog->get_log(period_id);
// trim until -ENODATA
do {
}
if (opt_cmd == OPT::METADATA_SYNC_STATUS) {
- RGWMetaSyncStatusManager sync(store, store->svc()->rados->get_async_processor());
+ RGWMetaSyncStatusManager sync(static_cast<rgw::sal::RGWRadosStore*>(store), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->rados->get_async_processor());
int ret = sync.init();
if (ret < 0) {
}
if (opt_cmd == OPT::METADATA_SYNC_INIT) {
- RGWMetaSyncStatusManager sync(store, store->svc()->rados->get_async_processor());
+ RGWMetaSyncStatusManager sync(static_cast<rgw::sal::RGWRadosStore*>(store), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->rados->get_async_processor());
int ret = sync.init();
if (ret < 0) {
if (opt_cmd == OPT::METADATA_SYNC_RUN) {
- RGWMetaSyncStatusManager sync(store, store->svc()->rados->get_async_processor());
+ RGWMetaSyncStatusManager sync(static_cast<rgw::sal::RGWRadosStore*>(store), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->rados->get_async_processor());
int ret = sync.init();
if (ret < 0) {
cerr << "ERROR: source zone not specified" << std::endl;
return EINVAL;
}
- RGWDataSyncStatusManager sync(store, store->svc()->rados->get_async_processor(), source_zone, nullptr);
+ RGWDataSyncStatusManager sync(static_cast<rgw::sal::RGWRadosStore*>(store), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->rados->get_async_processor(), source_zone, nullptr);
int ret = sync.init();
if (ret < 0) {
return EINVAL;
}
- RGWDataSyncStatusManager sync(store, store->svc()->rados->get_async_processor(), source_zone, nullptr);
+ RGWDataSyncStatusManager sync(static_cast<rgw::sal::RGWRadosStore*>(store), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->rados->get_async_processor(), source_zone, nullptr);
int ret = sync.init();
if (ret < 0) {
}
RGWSyncModuleInstanceRef sync_module;
- int ret = store->svc()->sync_modules->get_manager()->create_instance(g_ceph_context, store->svc()->zone->get_zone().tier_type,
- store->svc()->zone->get_zone_params().tier_config, &sync_module);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sync_modules->get_manager()->create_instance(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_zone().tier_type,
+ store->get_zone_params().tier_config, &sync_module);
if (ret < 0) {
lderr(cct) << "ERROR: failed to init sync module instance, ret=" << ret << dendl;
return ret;
}
- RGWDataSyncStatusManager sync(store, store->svc()->rados->get_async_processor(), source_zone, nullptr, sync_module);
+ RGWDataSyncStatusManager sync(static_cast<rgw::sal::RGWRadosStore*>(store), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->rados->get_async_processor(), source_zone, nullptr, sync_module);
ret = sync.init();
if (ret < 0) {
cerr << "ERROR: bucket not specified" << std::endl;
return EINVAL;
}
- rgw_bucket bucket;
- int ret = init_bucket_for_sync(tenant, bucket_name, bucket_id, bucket);
+ int ret = init_bucket_for_sync(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
return -ret;
}
auto opt_sb = opt_source_bucket;
if (opt_sb && opt_sb->bucket_id.empty()) {
string sbid;
- rgw_bucket sbuck;
- int ret = init_bucket_for_sync(opt_sb->tenant, opt_sb->name, sbid, sbuck);
+ std::unique_ptr<rgw::sal::RGWBucket> sbuck;
+ int ret = init_bucket_for_sync(user.get(), opt_sb->tenant, opt_sb->name, sbid, &sbuck);
if (ret < 0) {
return -ret;
}
- opt_sb = sbuck;
+ opt_sb = sbuck->get_key();
}
- RGWBucketPipeSyncStatusManager sync(store, source_zone, opt_sb, bucket);
+ RGWBucketPipeSyncStatusManager sync(static_cast<rgw::sal::RGWRadosStore*>(store), source_zone, opt_sb, bucket->get_key());
ret = sync.init();
if (ret < 0) {
cerr << "ERROR: bucket not specified" << std::endl;
return EINVAL;
}
- RGWBucketInfo bucket_info;
- rgw_bucket bucket;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
return -ret;
}
- if (!store->ctl()->bucket->bucket_imports_data(bucket_info.bucket, null_yield, dpp())) {
+ if (!static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->bucket->bucket_imports_data(bucket->get_key(), null_yield, dpp())) {
std::cout << "Sync is disabled for bucket " << bucket_name << std::endl;
return 0;
}
RGWBucketSyncPolicyHandlerRef handler;
- ret = store->ctl()->bucket->get_sync_policy_handler(std::nullopt, bucket, &handler, null_yield, dpp());
+ ret = store->get_sync_policy_handler(dpp(), std::nullopt, bucket->get_key(), &handler, null_yield);
if (ret < 0) {
std::cerr << "ERROR: failed to get policy handler for bucket ("
- << bucket_info.bucket << "): r=" << ret << ": " << cpp_strerror(-ret) << std::endl;
+ << bucket << "): r=" << ret << ": " << cpp_strerror(-ret) << std::endl;
return -ret;
}
auto timeout_at = ceph::coarse_mono_clock::now() + opt_timeout_sec;
- ret = rgw_bucket_sync_checkpoint(dpp(), store, *handler, bucket_info,
+ ret = rgw_bucket_sync_checkpoint(dpp(), static_cast<rgw::sal::RGWRadosStore*>(store), *handler, bucket->get_info(),
opt_source_zone, opt_source_bucket,
opt_retry_delay_ms, timeout_at);
if (ret < 0) {
cerr << "ERROR: bucket not specified" << std::endl;
return EINVAL;
}
- RGWBucketInfo bucket_info;
- rgw_bucket bucket;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
return -ret;
}
- bucket_sync_info(store, bucket_info, std::cout);
+ bucket_sync_info(static_cast<rgw::sal::RGWRadosStore*>(store), bucket->get_info(), std::cout);
}
if (opt_cmd == OPT::BUCKET_SYNC_STATUS) {
cerr << "ERROR: bucket not specified" << std::endl;
return EINVAL;
}
- RGWBucketInfo bucket_info;
- rgw_bucket bucket;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
return -ret;
}
- bucket_sync_status(store, bucket_info, source_zone, opt_source_bucket, std::cout);
+ bucket_sync_status(static_cast<rgw::sal::RGWRadosStore*>(store), bucket->get_info(), source_zone, opt_source_bucket, std::cout);
}
if (opt_cmd == OPT::BUCKET_SYNC_MARKERS) {
cerr << "ERROR: bucket not specified" << std::endl;
return EINVAL;
}
- rgw_bucket bucket;
- int ret = init_bucket_for_sync(tenant, bucket_name, bucket_id, bucket);
+ int ret = init_bucket_for_sync(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
return -ret;
}
- RGWBucketPipeSyncStatusManager sync(store, source_zone, opt_source_bucket, bucket);
+ RGWBucketPipeSyncStatusManager sync(static_cast<rgw::sal::RGWRadosStore*>(store), source_zone, opt_source_bucket, bucket->get_key());
ret = sync.init();
if (ret < 0) {
cerr << "ERROR: bucket not specified" << std::endl;
return EINVAL;
}
- rgw_bucket bucket;
- int ret = init_bucket_for_sync(tenant, bucket_name, bucket_id, bucket);
+ int ret = init_bucket_for_sync(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
return -ret;
}
- RGWBucketPipeSyncStatusManager sync(store, source_zone, opt_source_bucket, bucket);
+ RGWBucketPipeSyncStatusManager sync(static_cast<rgw::sal::RGWRadosStore*>(store), source_zone, opt_source_bucket, bucket->get_key());
ret = sync.init();
if (ret < 0) {
cerr << "ERROR: bucket not specified" << std::endl;
return EINVAL;
}
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
do {
list<rgw_bi_log_entry> entries;
- ret = store->svc()->bilog_rados->log_list(bucket_info, shard_id, marker, max_entries - count, entries, &truncated);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->bilog_rados->log_list(bucket->get_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;
do {
list<cls_log_entry> entries;
- ret = store->svc()->cls->timelog.list(oid, {}, {}, max_entries - count, entries, marker, &marker, &truncated,
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls->timelog.list(oid, {}, {}, max_entries - count, entries, marker, &marker, &truncated,
null_yield);
if (ret == -ENOENT) {
break;
}
}
- if (!user_id.empty()) {
- pipe->params.user = user_id;
+ if (user) {
+ pipe->params.user = user->get_id();
} else if (pipe->params.user.empty()) {
auto owner = sync_policy_ctx.get_owner();
if (owner) {
cerr << "ERROR: bucket not specified" << std::endl;
return EINVAL;
}
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- ret = store->svc()->bilog_rados->log_trim(bucket_info, shard_id, start_marker, end_marker);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->bilog_rados->log_trim(bucket->get_info(), shard_id, start_marker, end_marker);
if (ret < 0) {
cerr << "ERROR: trim_bi_log_entries(): " << cpp_strerror(-ret) << std::endl;
return -ret;
cerr << "ERROR: bucket not specified" << std::endl;
return EINVAL;
}
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
map<int, string> markers;
- ret = store->svc()->bilog_rados->get_log_status(bucket_info, shard_id,
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->bilog_rados->get_log_status(bucket->get_info(), shard_id,
&markers, null_yield);
if (ret < 0) {
cerr << "ERROR: get_bi_log_status(): " << cpp_strerror(-ret) << std::endl;
}
if (opt_cmd == OPT::BILOG_AUTOTRIM) {
- RGWCoroutinesManager crs(store->ctx(), store->getRados()->get_cr_registry());
+ RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry());
RGWHTTPManager http(store->ctx(), crs.get_completion_mgr());
int ret = http.start();
if (ret < 0) {
rgw::BucketTrimConfig config;
configure_bucket_trim(store->ctx(), config);
- rgw::BucketTrimManager trim(store, config);
+ rgw::BucketTrimManager trim(static_cast<rgw::sal::RGWRadosStore*>(store), config);
ret = trim.init();
if (ret < 0) {
cerr << "trim manager init failed with " << cpp_strerror(ret) << std::endl;
}
}
- auto datalog_svc = store->svc()->datalog_rados;
+ auto datalog_svc = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->datalog_rados;
RGWDataChangesLog::LogMarker log_marker;
do {
list<cls_log_entry> entries;
RGWDataChangesLogInfo info;
- store->svc()->datalog_rados->get_info(i, &info);
+ static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->datalog_rados->get_info(i, &info);
::encode_json("info", info, formatter.get());
}
if (opt_cmd == OPT::DATALOG_AUTOTRIM) {
- RGWCoroutinesManager crs(store->ctx(), store->getRados()->get_cr_registry());
+ RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry());
RGWHTTPManager http(store->ctx(), crs.get_completion_mgr());
int ret = http.start();
if (ret < 0) {
auto num_shards = g_conf()->rgw_data_log_num_shards;
std::vector<std::string> markers(num_shards);
- ret = crs.run(create_admin_data_log_trim_cr(store, &http, num_shards, markers));
+ ret = crs.run(create_admin_data_log_trim_cr(static_cast<rgw::sal::RGWRadosStore*>(store), &http, num_shards, markers));
if (ret < 0) {
cerr << "automated datalog trim failed with " << cpp_strerror(ret) << std::endl;
return -ret;
// loop until -ENODATA
do {
- auto datalog = store->svc()->datalog_rados;
+ auto datalog = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->datalog_rados;
ret = datalog->trim_entries(shard_id, marker);
} while (ret == 0);
bool quota_op = (opt_cmd == OPT::QUOTA_SET || opt_cmd == OPT::QUOTA_ENABLE || opt_cmd == OPT::QUOTA_DISABLE);
if (quota_op) {
- if (bucket_name.empty() && user_id.empty()) {
+ if (bucket_name.empty() && !user) {
cerr << "ERROR: bucket name or uid is required for quota operation" << std::endl;
return EINVAL;
}
}
set_bucket_quota(store, opt_cmd, tenant, bucket_name,
max_size, max_objects, have_max_size, have_max_objects);
- } else if (!user_id.empty()) {
+ } else if (user) {
if (quota_scope == "bucket") {
- return set_user_bucket_quota(opt_cmd, user, user_op, max_size, max_objects, have_max_size, have_max_objects);
+ return set_user_bucket_quota(opt_cmd, ruser, user_op, max_size, max_objects, have_max_size, have_max_objects);
} else if (quota_scope == "user") {
- return set_user_quota(opt_cmd, user, user_op, max_size, max_objects, have_max_size, have_max_objects);
+ return set_user_quota(opt_cmd, ruser, user_op, max_size, max_objects, have_max_size, have_max_objects);
} else {
cerr << "ERROR: invalid quota scope specification. Please specify either --quota-scope=bucket, or --quota-scope=user" << std::endl;
return EINVAL;
if (opt_cmd == OPT::MFA_CREATE) {
rados::cls::otp::otp_info_t config;
- if (user_id.empty()) {
+ if (!user) {
cerr << "ERROR: user id was not provided (via --uid)" << std::endl;
return EINVAL;
}
}
real_time mtime = real_clock::now();
- string oid = store->svc()->cls->mfa.get_mfa_oid(user_id);
+ string oid = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls->mfa.get_mfa_oid(user->get_id());
- int ret = store->ctl()->meta.mgr->mutate(RGWSI_MetaBackend_OTP::get_meta_key(user_id),
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->mutate(RGWSI_MetaBackend_OTP::get_meta_key(user->get_id()),
mtime, &objv_tracker,
null_yield, dpp(),
MDLOG_STATUS_WRITE,
[&] {
- return store->svc()->cls->mfa.create_mfa(user_id, config, &objv_tracker, mtime, null_yield);
+ return static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls->mfa.create_mfa(user->get_id(), config, &objv_tracker, mtime, null_yield);
});
if (ret < 0) {
cerr << "MFA creation failed, error: " << cpp_strerror(-ret) << std::endl;
user_info.mfa_ids.insert(totp_serial);
user_op.set_mfa_ids(user_info.mfa_ids);
string err;
- ret = user.modify(dpp(), user_op, null_yield, &err);
+ ret = ruser.modify(dpp(), user_op, null_yield, &err);
if (ret < 0) {
cerr << "ERROR: failed storing user info, error: " << err << std::endl;
return -ret;
}
if (opt_cmd == OPT::MFA_REMOVE) {
- if (user_id.empty()) {
+ if (!user) {
cerr << "ERROR: user id was not provided (via --uid)" << std::endl;
return EINVAL;
}
real_time mtime = real_clock::now();
- int ret = store->ctl()->meta.mgr->mutate(RGWSI_MetaBackend_OTP::get_meta_key(user_id),
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->mutate(RGWSI_MetaBackend_OTP::get_meta_key(user->get_id()),
mtime, &objv_tracker,
null_yield, dpp(),
MDLOG_STATUS_WRITE,
[&] {
- return store->svc()->cls->mfa.remove_mfa(user_id, totp_serial, &objv_tracker, mtime, null_yield);
+ return static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls->mfa.remove_mfa(user->get_id(), totp_serial, &objv_tracker, mtime, null_yield);
});
if (ret < 0) {
cerr << "MFA removal failed, error: " << cpp_strerror(-ret) << std::endl;
user_info.mfa_ids.erase(totp_serial);
user_op.set_mfa_ids(user_info.mfa_ids);
string err;
- ret = user.modify(dpp(), user_op, null_yield, &err);
+ ret = ruser.modify(dpp(), user_op, null_yield, &err);
if (ret < 0) {
cerr << "ERROR: failed storing user info, error: " << err << std::endl;
return -ret;
}
if (opt_cmd == OPT::MFA_GET) {
- if (user_id.empty()) {
+ if (!user) {
cerr << "ERROR: user id was not provided (via --uid)" << std::endl;
return EINVAL;
}
}
rados::cls::otp::otp_info_t result;
- int ret = store->svc()->cls->mfa.get_mfa(user_id, totp_serial, &result, null_yield);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls->mfa.get_mfa(user->get_id(), totp_serial, &result, null_yield);
if (ret < 0) {
if (ret == -ENOENT || ret == -ENODATA) {
cerr << "MFA serial id not found" << std::endl;
}
if (opt_cmd == OPT::MFA_LIST) {
- if (user_id.empty()) {
+ if (!user) {
cerr << "ERROR: user id was not provided (via --uid)" << std::endl;
return EINVAL;
}
list<rados::cls::otp::otp_info_t> result;
- int ret = store->svc()->cls->mfa.list_mfa(user_id, &result, null_yield);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls->mfa.list_mfa(user->get_id(), &result, null_yield);
if (ret < 0) {
cerr << "MFA listing failed, error: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
if (opt_cmd == OPT::MFA_CHECK) {
- if (user_id.empty()) {
+ if (!user) {
cerr << "ERROR: user id was not provided (via --uid)" << std::endl;
return EINVAL;
}
}
list<rados::cls::otp::otp_info_t> result;
- int ret = store->svc()->cls->mfa.check_mfa(user_id, totp_serial, totp_pin.front(), null_yield);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls->mfa.check_mfa(user->get_id(), totp_serial, totp_pin.front(), null_yield);
if (ret < 0) {
cerr << "MFA check failed, error: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
if (opt_cmd == OPT::MFA_RESYNC) {
- if (user_id.empty()) {
+ if (!user) {
cerr << "ERROR: user id was not provided (via --uid)" << std::endl;
return EINVAL;
}
}
rados::cls::otp::otp_info_t config;
- int ret = store->svc()->cls->mfa.get_mfa(user_id, totp_serial, &config, null_yield);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls->mfa.get_mfa(user->get_id(), totp_serial, &config, null_yield);
if (ret < 0) {
if (ret == -ENOENT || ret == -ENODATA) {
cerr << "MFA serial id not found" << std::endl;
ceph::real_time now;
- ret = store->svc()->cls->mfa.otp_get_current_time(user_id, &now, null_yield);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls->mfa.otp_get_current_time(user->get_id(), &now, null_yield);
if (ret < 0) {
cerr << "ERROR: failed to fetch current time from osd: " << cpp_strerror(-ret) << std::endl;
return -ret;
/* now update the backend */
real_time mtime = real_clock::now();
- ret = store->ctl()->meta.mgr->mutate(RGWSI_MetaBackend_OTP::get_meta_key(user_id),
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->mutate(RGWSI_MetaBackend_OTP::get_meta_key(user->get_id()),
mtime, &objv_tracker,
null_yield, dpp(),
MDLOG_STATUS_WRITE,
[&] {
- return store->svc()->cls->mfa.create_mfa(user_id, config, &objv_tracker, mtime, null_yield);
+ return static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls->mfa.create_mfa(user->get_id(), config, &objv_tracker, mtime, null_yield);
});
if (ret < 0) {
cerr << "MFA update failed, error: " << cpp_strerror(-ret) << std::endl;
}
if (opt_cmd == OPT::RESHARD_STALE_INSTANCES_LIST) {
- if (!store->svc()->zone->can_reshard() && !yes_i_really_mean_it) {
+ if (!static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->can_reshard() && !yes_i_really_mean_it) {
cerr << "Resharding disabled in a multisite env, stale instances unlikely from resharding" << std::endl;
cerr << "These instances may not be safe to delete." << std::endl;
cerr << "Use --yes-i-really-mean-it to force displaying these instances." << std::endl;
}
if (opt_cmd == OPT::RESHARD_STALE_INSTANCES_DELETE) {
- if (!store->svc()->zone->can_reshard()) {
+ if (!static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->can_reshard()) {
cerr << "Resharding disabled in a multisite env. Stale instances are not safe to be deleted." << std::endl;
return EINVAL;
}
if (opt_cmd == OPT::PUBSUB_TOPICS_LIST) {
- RGWPubSub ps(store, tenant);
-
- rgw_bucket bucket;
+ RGWPubSub ps(static_cast<rgw::sal::RGWRadosStore*>(store), tenant);
if (!bucket_name.empty()) {
rgw_pubsub_bucket_topics result;
- RGWBucketInfo bucket_info;
- int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
+ int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- auto b = ps.get_bucket(bucket_info.bucket);
+ auto b = ps.get_bucket(bucket->get_key());
ret = b->get_topics(&result);
if (ret < 0) {
cerr << "ERROR: could not get topics: " << cpp_strerror(-ret) << std::endl;
return EINVAL;
}
- RGWPubSub ps(store, tenant);
+ RGWPubSub ps(static_cast<rgw::sal::RGWRadosStore*>(store), tenant);
rgw_pubsub_topic_subs topic;
ret = ps.get_topic(topic_name, &topic);
return EINVAL;
}
- RGWPubSub ps(store, tenant);
+ RGWPubSub ps(static_cast<rgw::sal::RGWRadosStore*>(store), tenant);
ret = ps.remove_topic(topic_name, null_yield);
if (ret < 0) {
}
if (opt_cmd == OPT::PUBSUB_SUB_GET) {
- if (get_tier_type(store) != "pubsub") {
+ if (get_tier_type(static_cast<rgw::sal::RGWRadosStore*>(store)) != "pubsub") {
cerr << "ERROR: only pubsub tier type supports this command" << std::endl;
return EINVAL;
}
return EINVAL;
}
- RGWPubSub ps(store, tenant);
+ RGWPubSub ps(static_cast<rgw::sal::RGWRadosStore*>(store), tenant);
rgw_pubsub_sub_config sub_conf;
}
if (opt_cmd == OPT::PUBSUB_SUB_RM) {
- if (get_tier_type(store) != "pubsub") {
+ if (get_tier_type(static_cast<rgw::sal::RGWRadosStore*>(store)) != "pubsub") {
cerr << "ERROR: only pubsub tier type supports this command" << std::endl;
return EINVAL;
}
return EINVAL;
}
- RGWPubSub ps(store, tenant);
+ RGWPubSub ps(static_cast<rgw::sal::RGWRadosStore*>(store), tenant);
auto sub = ps.get_sub(sub_name);
ret = sub->unsubscribe(topic_name, null_yield);
}
if (opt_cmd == OPT::PUBSUB_SUB_PULL) {
- if (get_tier_type(store) != "pubsub") {
+ if (get_tier_type(static_cast<rgw::sal::RGWRadosStore*>(store)) != "pubsub") {
cerr << "ERROR: only pubsub tier type supports this command" << std::endl;
return EINVAL;
}
return EINVAL;
}
- RGWPubSub ps(store, tenant);
+ RGWPubSub ps(static_cast<rgw::sal::RGWRadosStore*>(store), tenant);
if (!max_entries_specified) {
max_entries = RGWPubSub::Sub::DEFAULT_MAX_EVENTS;
}
if (opt_cmd == OPT::PUBSUB_EVENT_RM) {
- if (get_tier_type(store) != "pubsub") {
+ if (get_tier_type(static_cast<rgw::sal::RGWRadosStore*>(store)) != "pubsub") {
cerr << "ERROR: only pubsub tier type supports this command" << std::endl;
return EINVAL;
}
return EINVAL;
}
- RGWPubSub ps(store, tenant);
+ RGWPubSub ps(static_cast<rgw::sal::RGWRadosStore*>(store), tenant);
auto sub = ps.get_sub_with_events(sub_name);
ret = sub->remove_event(dpp(), event_id);
class RGWLibAdmin
{
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
boost::intrusive_ptr<CephContext> cct;
public:
- rgw::sal::RGWRadosStore* get_store()
+ rgw::sal::RGWStore* get_store()
{
return store;
}
}
// process the request
- RGWRequest req{env.store->getRados()->get_new_req_id()};
+ RGWRequest req{env.store->get_new_req_id()};
auto& socket = get_lowest_layer(stream).socket();
const auto& remote_endpoint = socket.remote_endpoint(ec);
void stop();
void join();
void pause();
- void unpause(rgw::sal::RGWRadosStore* store, rgw_auth_registry_ptr_t);
+ void unpause(rgw::sal::RGWStore* store, rgw_auth_registry_ptr_t);
};
unsigned short parse_port(const char *input, boost::system::error_code& ec)
return -EINVAL;
}
- auto svc = env.store->svc()->config_key;
- int r = svc->get(name, true, pbl);
+ int r = env.store->get_config_key_val(name, pbl);
if (r < 0) {
lderr(ctx()) << type << " was not found: " << name << dendl;
return r;
key_is_cert = true;
}
- ExpandMetaVar emv(env.store->svc()->zone);
+ ExpandMetaVar emv(static_cast<rgw::sal::RGWRadosStore*>(env.store)->svc()->zone);
cert = emv.process_str(*cert);
key = emv.process_str(*key);
}
}
-void AsioFrontend::unpause(rgw::sal::RGWRadosStore* const store,
+void AsioFrontend::unpause(rgw::sal::RGWStore* const store,
rgw_auth_registry_ptr_t auth_registry)
{
env.store = store;
}
void RGWAsioFrontend::unpause_with_new_config(
- rgw::sal::RGWRadosStore* const store,
+ rgw::sal::RGWStore* const store,
rgw_auth_registry_ptr_t auth_registry
) {
impl->unpause(store, std::move(auth_registry));
void join() override;
void pause_for_new_config() override;
- void unpause_with_new_config(rgw::sal::RGWRadosStore *store,
+ void unpause_with_new_config(rgw::sal::RGWStore *store,
rgw_auth_registry_ptr_t auth_registry) override;
};
// cppcheck-suppress noExplicitConstructor
explicit rgw_bucket(const rgw_user& u, const cls_user_bucket& b);
+ rgw_bucket(const std::string& _tenant,
+ const std::string& _name,
+ const std::string& _bucket_id) : tenant(_tenant),
+ name(_name),
+ bucket_id(_bucket_id) {}
rgw_bucket(const rgw_bucket_key& bk) : tenant(bk.tenant),
name(bk.name),
bucket_id(bk.bucket_id) {}
#include "cls/user/cls_user_types.h"
-#include "rgw_sal.h"
#include "rgw_sal_rados.h"
#define dout_context g_ceph_context
}
}
-/**
- * Get all the buckets owned by a user and fill up an RGWUserBuckets with them.
- * Returns: 0 on success, -ERR# on failure.
- */
-int rgw_read_user_buckets(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore * store,
- const rgw_user& user_id,
- rgw::sal::RGWBucketList& buckets,
- const string& marker,
- const string& end_marker,
- uint64_t max,
- bool need_stats,
- optional_yield y)
-{
- rgw::sal::RGWRadosUser user(store, user_id);
- return user.list_buckets(dpp, marker, end_marker, max, need_stats, buckets, y);
-}
-
int rgw_bucket_parse_bucket_instance(const string& bucket_instance, string *bucket_name, string *bucket_id, int *shard_id)
{
auto pos = bucket_instance.rfind(':');
}
}
-void check_bad_user_bucket_mapping(rgw::sal::RGWRadosStore *store, const rgw_user& user_id,
+void check_bad_user_bucket_mapping(rgw::sal::RGWStore *store, rgw::sal::RGWUser* user,
bool fix,
optional_yield y,
const DoutPrefixProvider *dpp)
{
rgw::sal::RGWBucketList user_buckets;
- rgw::sal::RGWRadosUser user(store, user_id);
string marker;
CephContext *cct = store->ctx();
size_t max_entries = cct->_conf->rgw_list_buckets_max_chunk;
do {
- int ret = user.list_buckets(dpp, marker, string(), max_entries, false, user_buckets, y);
+ int ret = user->list_buckets(dpp, marker, string(), max_entries, false, user_buckets, y);
if (ret < 0) {
ldout(store->ctx(), 0) << "failed to read user buckets: "
<< cpp_strerror(-ret) << dendl;
auto& bucket = i->second;
- RGWBucketInfo bucket_info;
- real_time mtime;
- int r = store->getRados()->get_bucket_info(store->svc(), user_id.tenant, bucket->get_name(), bucket_info, &mtime, null_yield, dpp);
+ std::unique_ptr<rgw::sal::RGWBucket> actual_bucket;
+ int r = store->get_bucket(dpp, user, user->get_tenant(), bucket->get_name(), &actual_bucket, null_yield);
if (r < 0) {
ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket << dendl;
continue;
}
- rgw_bucket& actual_bucket = bucket_info.bucket;
-
- if (actual_bucket.name.compare(bucket->get_name()) != 0 ||
- actual_bucket.tenant.compare(bucket->get_tenant()) != 0 ||
- actual_bucket.marker.compare(bucket->get_marker()) != 0 ||
- actual_bucket.bucket_id.compare(bucket->get_bucket_id()) != 0) {
+ if (actual_bucket->get_name().compare(bucket->get_name()) != 0 ||
+ actual_bucket->get_tenant().compare(bucket->get_tenant()) != 0 ||
+ actual_bucket->get_marker().compare(bucket->get_marker()) != 0 ||
+ actual_bucket->get_bucket_id().compare(bucket->get_bucket_id()) != 0) {
cout << "bucket info mismatch: expected " << actual_bucket << " got " << bucket << std::endl;
if (fix) {
cout << "fixing" << std::endl;
- r = store->ctl()->bucket->link_bucket(user_id, actual_bucket,
- bucket_info.creation_time,
- null_yield, dpp);
+ r = actual_bucket->link(dpp, user, null_yield);
if (r < 0) {
cerr << "failed to fix bucket: " << cpp_strerror(-r) << std::endl;
}
return rgw_obj_key::oid_to_key_in_ns(oid, &key, ns);
}
-int rgw_remove_object(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, const RGWBucketInfo& bucket_info, const rgw_bucket& bucket, rgw_obj_key& key)
+int rgw_remove_object(const DoutPrefixProvider *dpp, rgw::sal::RGWStore *store, rgw::sal::RGWBucket* bucket, rgw_obj_key& key)
{
RGWObjectCtx rctx(store);
key.instance = "null";
}
- rgw_obj obj(bucket, key);
-
- return store->getRados()->delete_obj(dpp, rctx, bucket_info, obj, bucket_info.versioning_status());
-}
-
-static int aio_wait(librados::AioCompletion *handle)
-{
- librados::AioCompletion *c = (librados::AioCompletion *)handle;
- c->wait_for_complete();
- int ret = c->get_return_value();
- c->release();
- return ret;
-}
+ std::unique_ptr<rgw::sal::RGWObject> object = bucket->get_object(key);
-static int drain_handles(list<librados::AioCompletion *>& pending)
-{
- int ret = 0;
- while (!pending.empty()) {
- librados::AioCompletion *handle = pending.front();
- pending.pop_front();
- int r = aio_wait(handle);
- if (r < 0) {
- ret = r;
- }
- }
- return ret;
+ return object->delete_object(dpp, &rctx, null_yield);
}
-int rgw_remove_bucket_bypass_gc(rgw::sal::RGWRadosStore *store, rgw_bucket& bucket,
+int rgw_remove_bucket_bypass_gc(rgw::sal::RGWStore *store, rgw::sal::RGWBucket* bucket,
int concurrent_max, bool keep_index_consistent,
optional_yield y,
const DoutPrefixProvider *dpp)
{
int ret;
map<RGWObjCategory, RGWStorageStats> stats;
- std::vector<rgw_bucket_dir_entry> objs;
map<string, bool> common_prefixes;
- RGWBucketInfo info;
RGWObjectCtx obj_ctx(store);
CephContext *cct = store->ctx();
string bucket_ver, master_ver;
- ret = store->getRados()->get_bucket_info(store->svc(), bucket.tenant, bucket.name, info, NULL, null_yield, dpp);
+ ret = bucket->get_bucket_info(dpp, null_yield);
if (ret < 0)
return ret;
- ret = store->getRados()->get_bucket_stats(info, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, NULL);
+ ret = bucket->get_bucket_stats(RGW_NO_SHARD, &bucket_ver, &master_ver, stats, NULL);
if (ret < 0)
return ret;
string prefix, delimiter;
- ret = abort_bucket_multiparts(dpp, store, cct, info, prefix, delimiter);
+ ret = abort_bucket_multiparts(dpp, store, cct, bucket, prefix, delimiter);
if (ret < 0) {
return ret;
}
- RGWRados::Bucket target(store->getRados(), info);
- RGWRados::Bucket::List list_op(&target);
+ rgw::sal::RGWBucket::ListParams params;
+ rgw::sal::RGWBucket::ListResults results;
- list_op.params.list_versions = true;
- list_op.params.allow_unordered = true;
+ params.list_versions = true;
+ params.allow_unordered = true;
- std::list<librados::AioCompletion*> handles;
+ std::unique_ptr<rgw::sal::Completions> handles = store->get_completions();
int max_aio = concurrent_max;
- bool is_truncated = true;
+ results.is_truncated = true;
- while (is_truncated) {
- objs.clear();
- ret = list_op.list_objects(dpp, listing_max_entries, &objs, &common_prefixes,
- &is_truncated, null_yield);
+ while (results.is_truncated) {
+ ret = bucket->list(dpp, params, listing_max_entries, results, null_yield);
if (ret < 0)
return ret;
- std::vector<rgw_bucket_dir_entry>::iterator it = objs.begin();
- for (; it != objs.end(); ++it) {
+ std::vector<rgw_bucket_dir_entry>::iterator it = results.objs.begin();
+ for (; it != results.objs.end(); ++it) {
RGWObjState *astate = NULL;
- rgw_obj obj(bucket, (*it).key);
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object((*it).key);
- ret = store->getRados()->get_obj_state(dpp, &obj_ctx, info, obj, &astate, false, y);
+ ret = obj->get_obj_state(dpp, &obj_ctx, &astate, y, false);
if (ret == -ENOENT) {
- dout(1) << "WARNING: cannot find obj state for obj " << obj.get_oid() << dendl;
+ dout(1) << "WARNING: cannot find obj state for obj " << obj << dendl;
continue;
}
if (ret < 0) {
if (astate->manifest) {
RGWObjManifest& manifest = *astate->manifest;
RGWObjManifest::obj_iterator miter = manifest.obj_begin();
- rgw_obj head_obj = manifest.get_obj();
+ std::unique_ptr<rgw::sal::RGWObject> head_obj = bucket->get_object(manifest.get_obj().key);
rgw_raw_obj raw_head_obj;
- store->getRados()->obj_to_raw(info.placement_rule, head_obj, &raw_head_obj);
-
+ head_obj->get_raw_obj(&raw_head_obj);
for (; miter != manifest.obj_end() && max_aio--; ++miter) {
if (!max_aio) {
- ret = drain_handles(handles);
+ ret = handles->drain();
if (ret < 0) {
lderr(store->ctx()) << "ERROR: could not drain handles as aio completion returned with " << ret << dendl;
return ret;
continue;
}
- ret = store->getRados()->delete_raw_obj_aio(last_obj, handles);
+ ret = store->delete_raw_obj_aio(last_obj, handles.get());
if (ret < 0) {
lderr(store->ctx()) << "ERROR: delete obj aio failed with " << ret << dendl;
return ret;
}
} // for all shadow objs
- ret = store->getRados()->delete_obj_aio(dpp, head_obj, info, astate, handles, keep_index_consistent, null_yield);
+ ret = head_obj->delete_obj_aio(dpp, astate, handles.get(), keep_index_consistent, null_yield);
if (ret < 0) {
lderr(store->ctx()) << "ERROR: delete obj aio failed with " << ret << dendl;
return ret;
}
if (!max_aio) {
- ret = drain_handles(handles);
+ ret = handles->drain();
if (ret < 0) {
lderr(store->ctx()) << "ERROR: could not drain handles as aio completion returned with " << ret << dendl;
return ret;
}
max_aio = concurrent_max;
}
- obj_ctx.invalidate(obj);
+ obj_ctx.invalidate(obj->get_obj());
} // for all RGW objects
}
- ret = drain_handles(handles);
+ ret = handles->drain();
if (ret < 0) {
lderr(store->ctx()) << "ERROR: could not drain handles as aio completion returned with " << ret << dendl;
return ret;
}
- ret = store->ctl()->bucket->sync_user_stats(info.owner, info, y);
+ bucket->sync_user_stats(y);
if (ret < 0) {
dout(1) << "WARNING: failed sync user stats before bucket delete. ret=" << ret << dendl;
}
// this function can only be run if caller wanted children to be
// deleted, so we can ignore the check for children as any that
// remain are detritus from a prior bug
- ret = store->getRados()->delete_bucket(info, objv_tracker, y, dpp, false);
+ ret = bucket->remove_bucket(dpp, true, std::string(), std::string(), false, nullptr, y);
if (ret < 0) {
- lderr(store->ctx()) << "ERROR: could not remove bucket " << bucket.name << dendl;
+ lderr(store->ctx()) << "ERROR: could not remove bucket " << bucket << dendl;
return ret;
}
- ret = store->ctl()->bucket->unlink_bucket(info.owner, bucket, null_yield, dpp, false);
- if (ret < 0) {
- lderr(store->ctx()) << "ERROR: unable to remove user bucket information" << dendl;
- }
-
return ret;
}
*sink = msg;
}
-int RGWBucket::init(rgw::sal::RGWRadosStore *storage, RGWBucketAdminOpState& op_state,
- optional_yield y, const DoutPrefixProvider *dpp, std::string *err_msg,
- map<string, bufferlist> *pattrs)
+int RGWBucket::init(rgw::sal::RGWStore *_store, RGWBucketAdminOpState& op_state,
+ optional_yield y, const DoutPrefixProvider *dpp, std::string *err_msg)
{
- if (!storage) {
+ if (!_store) {
set_err_msg(err_msg, "no storage!");
return -EINVAL;
}
- store = storage;
+ store = _store;
- rgw_user user_id = op_state.get_user_id();
- bucket.tenant = user_id.tenant;
- bucket.name = op_state.get_bucket_name();
+ std::string bucket_name = op_state.get_bucket_name();
- if (bucket.name.empty() && user_id.empty())
+ if (bucket_name.empty() && op_state.get_user_id().empty())
return -EINVAL;
-
+
+ user = store->get_user(op_state.get_user_id());
+ std::string tenant = user->get_tenant();
+
// split possible tenant/name
- auto pos = bucket.name.find('/');
+ auto pos = bucket_name.find('/');
if (pos != string::npos) {
- bucket.tenant = bucket.name.substr(0, pos);
- bucket.name = bucket.name.substr(pos + 1);
+ tenant = bucket_name.substr(0, pos);
+ bucket_name = bucket_name.substr(pos + 1);
}
- if (!bucket.name.empty()) {
- int r = store->ctl()->bucket->read_bucket_info(
- bucket, &bucket_info, y, dpp,
- RGWBucketCtl::BucketInstance::GetParams().set_attrs(pattrs),
- &ep_objv);
- if (r < 0) {
- set_err_msg(err_msg, "failed to fetch bucket info for bucket=" + bucket.name);
+ int r = store->get_bucket(dpp, user.get(), tenant, bucket_name, &bucket, y);
+ if (r < 0) {
+ set_err_msg(err_msg, "failed to fetch bucket info for bucket=" + bucket_name);
return r;
- }
-
- op_state.set_bucket(bucket_info.bucket);
}
- if (!user_id.empty()) {
- int r = store->ctl()->user->get_info_by_uid(dpp, user_id, &user_info, y);
+ op_state.set_bucket(bucket->clone());
+
+ if (!rgw::sal::RGWUser::empty(user.get())) {
+ r = user->load_by_id(dpp, y);
if (r < 0) {
set_err_msg(err_msg, "failed to fetch user info");
return r;
}
-
- op_state.display_name = user_info.display_name;
}
+ op_state.display_name = user->get_display_name();
+
clear_failure();
return 0;
}
}
int RGWBucket::link(RGWBucketAdminOpState& op_state, optional_yield y, const DoutPrefixProvider *dpp,
- map<string, bufferlist>& attrs, std::string *err_msg)
+ std::string *err_msg)
{
if (!op_state.is_user_op()) {
set_err_msg(err_msg, "empty user id");
}
string bucket_id = op_state.get_bucket_id();
-
std::string display_name = op_state.get_user_display_name();
- rgw_bucket& bucket = op_state.get_bucket();
- if (!bucket_id.empty() && bucket_id != bucket.bucket_id) {
+ std::unique_ptr<rgw::sal::RGWBucket> loc_bucket;
+ std::unique_ptr<rgw::sal::RGWBucket> old_bucket;
+
+ loc_bucket = op_state.get_bucket()->clone();
+
+ if (!bucket_id.empty() && bucket_id != loc_bucket->get_bucket_id()) {
set_err_msg(err_msg,
- "specified bucket id does not match " + bucket.bucket_id);
+ "specified bucket id does not match " + loc_bucket->get_bucket_id());
return -EINVAL;
}
- rgw_bucket old_bucket = bucket;
- rgw_user user_id = op_state.get_user_id();
- bucket.tenant = user_id.tenant;
+
+ old_bucket = loc_bucket->clone();
+
+ loc_bucket->get_key().tenant = op_state.get_user_id().tenant;
+
if (!op_state.new_bucket_name.empty()) {
auto pos = op_state.new_bucket_name.find('/');
if (pos != string::npos) {
- bucket.tenant = op_state.new_bucket_name.substr(0, pos);
- bucket.name = op_state.new_bucket_name.substr(pos + 1);
+ loc_bucket->get_key().tenant = op_state.new_bucket_name.substr(0, pos);
+ loc_bucket->get_key().name = op_state.new_bucket_name.substr(pos + 1);
} else {
- bucket.name = op_state.new_bucket_name;
+ loc_bucket->get_key().name = op_state.new_bucket_name;
}
}
RGWObjVersionTracker objv_tracker;
- RGWObjVersionTracker old_version = bucket_info.objv_tracker;
+ RGWObjVersionTracker old_version = loc_bucket->get_info().objv_tracker;
- map<string, bufferlist>::iterator aiter = attrs.find(RGW_ATTR_ACL);
- if (aiter == attrs.end()) {
+ map<string, bufferlist>::iterator aiter = loc_bucket->get_attrs().find(RGW_ATTR_ACL);
+ if (aiter == loc_bucket->get_attrs().end()) {
// should never happen; only pre-argonaut buckets lacked this.
- ldpp_dout(dpp, 0) << "WARNING: can't bucket link because no acl on bucket=" << old_bucket.name << dendl;
+ ldpp_dout(dpp, 0) << "WARNING: can't bucket link because no acl on bucket=" << old_bucket << dendl;
set_err_msg(err_msg,
"While crossing the Anavros you have displeased the goddess Hera."
- " You must sacrifice your ancient bucket " + bucket.bucket_id);
+ " You must sacrifice your ancient bucket " + loc_bucket->get_bucket_id());
return -EINVAL;
}
bufferlist& aclbl = aiter->second;
return -EIO;
}
- auto bucket_ctl = store->ctl()->bucket;
- int r = bucket_ctl->unlink_bucket(owner.get_id(), old_bucket, y, dpp, false);
+ std::unique_ptr<rgw::sal::RGWUser> owner_user = store->get_user(owner.get_id());
+
+ int r = old_bucket->unlink(dpp, owner_user.get(), y, false);
if (r < 0) {
- set_err_msg(err_msg, "could not unlink policy from user " + owner.get_id().to_str());
+ set_err_msg(err_msg, "could not unlink policy from user " + owner_user->get_id().to_str());
return r;
}
// now update the user for the bucket...
if (display_name.empty()) {
- ldpp_dout(dpp, 0) << "WARNING: user " << user_info.user_id << " has no display name set" << dendl;
+ ldpp_dout(dpp, 0) << "WARNING: user " << user << " has no display name set" << dendl;
}
RGWAccessControlPolicy policy_instance;
- policy_instance.create_default(user_info.user_id, display_name);
+ policy_instance.create_default(user->get_id(), display_name);
owner = policy_instance.get_owner();
aclbl.clear();
policy_instance.encode(aclbl);
- auto instance_params = RGWBucketCtl::BucketInstance::PutParams().set_attrs(&attrs);
-
- bucket_info.owner = user_info.user_id;
- if (bucket != old_bucket) {
- bucket_info.bucket = bucket;
- bucket_info.objv_tracker.version_for_read()->ver = 0;
- instance_params.set_exclusive(true);
+ bool exclusive = false;
+ loc_bucket->get_info().owner = user->get_id();
+ if (*loc_bucket != *old_bucket) {
+ ldpp_dout(dpp, 20) << "Lando 10" << dendl;
+ loc_bucket->get_info().bucket = loc_bucket->get_key();
+ loc_bucket->get_info().objv_tracker.version_for_read()->ver = 0;
+ exclusive = true;
}
- r = bucket_ctl->store_bucket_instance_info(bucket, bucket_info, y, dpp, instance_params);
+ ldpp_dout(dpp, 20) << "Lando 11" << dendl;
+ r = loc_bucket->put_instance_info(dpp, exclusive, ceph::real_time());
+ ldpp_dout(dpp, 20) << "Lando 12 r=" << r << dendl;
if (r < 0) {
set_err_msg(err_msg, "ERROR: failed writing bucket instance info: " + cpp_strerror(-r));
return r;
}
- RGWBucketEntryPoint ep;
- ep.bucket = bucket_info.bucket;
- ep.owner = user_info.user_id;
- ep.creation_time = bucket_info.creation_time;
- ep.linked = true;
- map<string, bufferlist> ep_attrs;
- rgw_ep_info ep_data{ep, ep_attrs};
+ RGWObjVersionTracker objv;
/* link to user */
- r = store->ctl()->bucket->link_bucket(user_info.user_id,
- bucket_info.bucket,
- ep.creation_time,
- y, dpp, true, &ep_data);
+ ldpp_dout(dpp, 20) << "Lando 13" << dendl;
+ r = loc_bucket->link(dpp, user.get(), y, true, &objv);
+ ldpp_dout(dpp, 20) << "Lando 14 r=" << r << dendl;
if (r < 0) {
set_err_msg(err_msg, "failed to relink bucket");
return r;
}
- if (bucket != old_bucket) {
+ if (*loc_bucket != *old_bucket) {
// like RGWRados::delete_bucket -- excepting no bucket_index work.
- r = bucket_ctl->remove_bucket_entrypoint_info(old_bucket, y, dpp,
- RGWBucketCtl::Bucket::RemoveParams()
- .set_objv_tracker(&ep_data.ep_objv));
+ r = old_bucket->remove_entrypoint(dpp, &objv, y);
if (r < 0) {
- set_err_msg(err_msg, "failed to unlink old bucket endpoint " + old_bucket.tenant + "/" + old_bucket.name);
+ set_err_msg(err_msg, "failed to unlink old bucket endpoint " + old_bucket->get_tenant() + "/" + old_bucket->get_name());
return r;
}
- r = bucket_ctl->remove_bucket_instance_info(old_bucket, bucket_info, y, dpp,
- RGWBucketCtl::BucketInstance::RemoveParams()
- .set_objv_tracker(&old_version));
+ r = old_bucket->remove_instance_info(dpp, &old_version, y);
if (r < 0) {
set_err_msg(err_msg, "failed to unlink old bucket info");
return r;
int RGWBucket::chown(RGWBucketAdminOpState& op_state, const string& marker,
optional_yield y, const DoutPrefixProvider *dpp, std::string *err_msg)
{
- int ret = store->ctl()->bucket->chown(store, bucket_info, user_info.user_id,
- user_info.display_name, marker, y, dpp);
+ int ret = bucket->chown(dpp, user.get(), user.get(), y, &marker);
if (ret < 0) {
set_err_msg(err_msg, "Failed to change object ownership: " + cpp_strerror(-ret));
}
int RGWBucket::unlink(RGWBucketAdminOpState& op_state, optional_yield y, const DoutPrefixProvider *dpp, std::string *err_msg)
{
- rgw_bucket bucket = op_state.get_bucket();
-
+ bucket = op_state.get_bucket()->clone();
if (!op_state.is_user_op()) {
set_err_msg(err_msg, "could not fetch user or user bucket info");
return -EINVAL;
}
- int r = store->ctl()->bucket->unlink_bucket(user_info.user_id, bucket, y, dpp);
+ int r = bucket->unlink(dpp, user.get(), y);
if (r < 0) {
set_err_msg(err_msg, "error unlinking bucket" + cpp_strerror(-r));
}
int RGWBucket::set_quota(RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, std::string *err_msg)
{
- rgw_bucket bucket = op_state.get_bucket();
- RGWBucketInfo bucket_info;
- map<string, bufferlist> attrs;
- int r = store->getRados()->get_bucket_info(store->svc(), bucket.tenant, bucket.name, bucket_info, NULL, null_yield, dpp, &attrs);
- if (r < 0) {
- set_err_msg(err_msg, "could not get bucket info for bucket=" + bucket.name + ": " + cpp_strerror(-r));
- return r;
- }
+ bucket = op_state.get_bucket()->clone();
- bucket_info.quota = op_state.quota;
- r = store->getRados()->put_bucket_instance_info(bucket_info, false, real_time(), &attrs, dpp);
+ bucket->get_info().quota = op_state.quota;
+ int r = bucket->put_instance_info(dpp, false, real_time());
if (r < 0) {
set_err_msg(err_msg, "ERROR: failed writing bucket instance info: " + cpp_strerror(-r));
return r;
int RGWBucket::remove_object(const DoutPrefixProvider *dpp, RGWBucketAdminOpState& op_state, std::string *err_msg)
{
- rgw_bucket bucket = op_state.get_bucket();
std::string object_name = op_state.get_object_name();
rgw_obj_key key(object_name);
- int ret = rgw_remove_object(dpp, store, bucket_info, bucket, key);
+ bucket = op_state.get_bucket()->clone();
+
+ int ret = rgw_remove_object(dpp, store, bucket.get(), key);
if (ret < 0) {
set_err_msg(err_msg, "unable to remove object" + cpp_strerror(-ret));
return ret;
return 0;
}
-static void dump_bucket_index(const RGWRados::ent_map_t& result, Formatter *f)
+static void dump_bucket_index(const vector<rgw_bucket_dir_entry>& objs, Formatter *f)
{
- for (auto iter = result.begin(); iter != result.end(); ++iter) {
- f->dump_string("object", iter->first);
+ for (auto iter = objs.begin(); iter != objs.end(); ++iter) {
+ f->dump_string("object", iter->key.name);
}
}
const DoutPrefixProvider *dpp, std::string *err_msg)
{
bool fix_index = op_state.will_fix_index();
- rgw_bucket bucket = op_state.get_bucket();
-
- map<string, bool> common_prefixes;
bool is_truncated;
map<string, bool> meta_objs;
map<rgw_obj_index_key, string> all_objs;
- RGWBucketInfo bucket_info;
- auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
- int r = store->getRados()->get_bucket_instance_info(obj_ctx, bucket, bucket_info, nullptr, nullptr, null_yield, dpp);
- if (r < 0) {
- ldout(store->ctx(), 0) << "ERROR: " << __func__ << "(): get_bucket_instance_info(bucket=" << bucket << ") returned r=" << r << dendl;
- return r;
- }
+ bucket = op_state.get_bucket()->clone();
- RGWRados::Bucket target(store->getRados(), bucket_info);
- RGWRados::Bucket::List list_op(&target);
+ rgw::sal::RGWBucket::ListParams params;
- list_op.params.list_versions = true;
- list_op.params.ns = RGW_OBJ_NS_MULTIPART;
+ params.list_versions = true;
+ params.ns = RGW_OBJ_NS_MULTIPART;
do {
- vector<rgw_bucket_dir_entry> result;
- int r = list_op.list_objects(dpp, listing_max_entries, &result,
- &common_prefixes, &is_truncated, null_yield);
+ rgw::sal::RGWBucket::ListResults results;
+ int r = bucket->list(dpp, params, listing_max_entries, results, null_yield);
if (r < 0) {
- set_err_msg(err_msg, "failed to list objects in bucket=" + bucket.name +
+ set_err_msg(err_msg, "failed to list objects in bucket=" + bucket->get_name() +
" err=" + cpp_strerror(-r));
return r;
}
+ is_truncated = results.is_truncated;
vector<rgw_bucket_dir_entry>::iterator iter;
- for (iter = result.begin(); iter != result.end(); ++iter) {
+ for (iter = results.objs.begin(); iter != results.objs.end(); ++iter) {
rgw_obj_index_key key = iter->key;
- rgw_obj obj(bucket, key);
+ rgw_obj obj(bucket->get_key(), key);
string oid = obj.get_oid();
int pos = oid.find_last_of('.');
if (objs_to_unlink.size() > listing_max_entries) {
if (fix_index) {
- int r = store->getRados()->remove_objs_from_index(bucket_info, objs_to_unlink);
+ int r = bucket->remove_objs_from_index(objs_to_unlink);
if (r < 0) {
set_err_msg(err_msg, "ERROR: remove_obj_from_index() returned error: " +
cpp_strerror(-r));
}
if (fix_index) {
- int r = store->getRados()->remove_objs_from_index(bucket_info, objs_to_unlink);
+ int r = bucket->remove_objs_from_index(objs_to_unlink);
if (r < 0) {
set_err_msg(err_msg, "ERROR: remove_obj_from_index() returned error: " +
cpp_strerror(-r));
return -EINVAL;
}
- store->getRados()->cls_obj_set_bucket_tag_timeout(bucket_info, BUCKET_TAG_TIMEOUT);
+ bucket->set_tag_timeout(BUCKET_TAG_TIMEOUT);
string prefix;
string empty_delimiter;
- rgw_obj_index_key marker;
- bool is_truncated = true;
- bool cls_filtered = true;
+ rgw::sal::RGWBucket::ListResults results;
+ results.is_truncated = true;
Formatter *formatter = flusher.get_formatter();
formatter->open_object_section("objects");
- uint16_t expansion_factor = 1;
- while (is_truncated) {
- RGWRados::ent_map_t result;
- result.reserve(listing_max_entries);
-
- int r = store->getRados()->cls_bucket_list_ordered(
- dpp, bucket_info, RGW_NO_SHARD, marker, prefix, empty_delimiter,
- listing_max_entries, true, expansion_factor,
- result, &is_truncated, &cls_filtered, &marker,
- y, rgw_bucket_object_check_filter);
+ while (results.is_truncated) {
+ rgw::sal::RGWBucket::ListParams params;
+
+ params.marker = results.next_marker;
+ params.prefix = prefix;
+
+ int r = bucket->list(dpp, params, listing_max_entries, results, y);
+
if (r == -ENOENT) {
break;
} else if (r < 0 && r != -ENOENT) {
set_err_msg(err_msg, "ERROR: failed operation r=" + cpp_strerror(-r));
}
- if (result.size() < listing_max_entries / 8) {
- ++expansion_factor;
- } else if (result.size() > listing_max_entries * 7 / 8 &&
- expansion_factor > 1) {
- --expansion_factor;
- }
-
- dump_bucket_index(result, formatter);
+ dump_bucket_index(results.objs, formatter);
flusher.flush();
}
formatter->close_section();
- store->getRados()->cls_obj_set_bucket_tag_timeout(bucket_info, 0);
+ bucket->set_tag_timeout(0);
return 0;
}
{
bool fix_index = op_state.will_fix_index();
- int r = store->getRados()->bucket_check_index(bucket_info, &existing_stats, &calculated_stats);
+ int r = bucket->check_index(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->getRados()->bucket_rebuild_index(bucket_info);
+ r = bucket->rebuild_index();
if (r < 0) {
set_err_msg(err_msg, "failed to rebuild index err=" + cpp_strerror(-r));
return r;
return 0;
}
-int RGWBucket::sync(RGWBucketAdminOpState& op_state, map<string, bufferlist> *attrs, const DoutPrefixProvider *dpp, std::string *err_msg)
+int RGWBucket::sync(RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, std::string *err_msg)
{
- if (!store->svc()->zone->is_meta_master()) {
+ if (!store->is_meta_master()) {
set_err_msg(err_msg, "ERROR: failed to update bucket sync: only allowed on meta master zone");
return EINVAL;
}
bool sync = op_state.will_sync_bucket();
if (sync) {
- bucket_info.flags &= ~BUCKET_DATASYNC_DISABLED;
+ bucket->get_info().flags &= ~BUCKET_DATASYNC_DISABLED;
} else {
- bucket_info.flags |= BUCKET_DATASYNC_DISABLED;
+ bucket->get_info().flags |= BUCKET_DATASYNC_DISABLED;
}
- int r = store->getRados()->put_bucket_instance_info(bucket_info, false, real_time(), attrs, dpp);
+ int r = bucket->put_instance_info(dpp, false, real_time());
if (r < 0) {
set_err_msg(err_msg, "ERROR: failed writing bucket instance info:" + cpp_strerror(-r));
return r;
}
- int shards_num = bucket_info.layout.current_index.layout.normal.num_shards? bucket_info.layout.current_index.layout.normal.num_shards : 1;
- int shard_id = bucket_info.layout.current_index.layout.normal.num_shards? 0 : -1;
+ int shards_num = bucket->get_info().layout.current_index.layout.normal.num_shards? bucket->get_info().layout.current_index.layout.normal.num_shards : 1;
+ int shard_id = bucket->get_info().layout.current_index.layout.normal.num_shards? 0 : -1;
if (!sync) {
- r = store->svc()->bilog_rados->log_stop(bucket_info, -1);
+ r = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->bilog_rados->log_stop(bucket->get_info(), -1);
if (r < 0) {
set_err_msg(err_msg, "ERROR: failed writing stop bilog:" + cpp_strerror(-r));
return r;
}
} else {
- r = store->svc()->bilog_rados->log_start(bucket_info, -1);
+ r = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->bilog_rados->log_start(bucket->get_info(), -1);
if (r < 0) {
set_err_msg(err_msg, "ERROR: failed writing resync bilog:" + cpp_strerror(-r));
return r;
}
for (int i = 0; i < shards_num; ++i, ++shard_id) {
- r = store->svc()->datalog_rados->add_entry(dpp, bucket_info, shard_id);
+ r = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->datalog_rados->add_entry(dpp, bucket->get_info(), shard_id);
if (r < 0) {
set_err_msg(err_msg, "ERROR: failed writing data log:" + cpp_strerror(-r));
return r;
return 0;
}
-int rgw_object_get_attr(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore* store, const RGWBucketInfo& bucket_info,
- const rgw_obj& obj, const char* attr_name,
- bufferlist& out_bl, optional_yield y)
+int rgw_object_get_attr(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore* store, rgw::sal::RGWObject* obj,
+ const char* attr_name, bufferlist& out_bl, optional_yield y)
{
RGWObjectCtx obj_ctx(store);
- RGWRados::Object op_target(store->getRados(), bucket_info, obj_ctx, obj);
- RGWRados::Object::Read rop(&op_target);
+ std::unique_ptr<rgw::sal::RGWObject::ReadOp> rop = obj->get_read_op(&obj_ctx);
- return rop.get_attr(dpp, attr_name, out_bl, y);
+ return rop->get_attr(dpp, attr_name, out_bl, y);
}
int RGWBucket::get_policy(RGWBucketAdminOpState& op_state, RGWAccessControlPolicy& policy, optional_yield y, const DoutPrefixProvider *dpp)
{
+ int ret;
std::string object_name = op_state.get_object_name();
- rgw_bucket bucket = op_state.get_bucket();
- RGWBucketInfo bucket_info;
- map<string, bufferlist> attrs;
- int ret = store->getRados()->get_bucket_info(store->svc(), bucket.tenant, bucket.name, bucket_info, NULL, null_yield, dpp, &attrs);
- if (ret < 0) {
- return ret;
- }
+ bucket = op_state.get_bucket()->clone();
if (!object_name.empty()) {
bufferlist bl;
- rgw_obj obj(bucket, object_name);
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(rgw_obj_key(object_name));
- ret = rgw_object_get_attr(dpp, store, bucket_info, obj, RGW_ATTR_ACL, bl, y);
+ ret = rgw_object_get_attr(dpp, store, obj.get(), RGW_ATTR_ACL, bl, y);
if (ret < 0){
return ret;
}
return ret;
}
- map<string, bufferlist>::iterator aiter = attrs.find(RGW_ATTR_ACL);
- if (aiter == attrs.end()) {
+ map<string, bufferlist>::iterator aiter = bucket->get_attrs().find(RGW_ATTR_ACL);
+ if (aiter == bucket->get_attrs().end()) {
return -ENOENT;
}
}
-int RGWBucketAdminOp::get_policy(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+int RGWBucketAdminOp::get_policy(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
RGWAccessControlPolicy& policy, const DoutPrefixProvider *dpp)
{
RGWBucket bucket;
/* Wrappers to facilitate RESTful interface */
-int RGWBucketAdminOp::get_policy(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+int RGWBucketAdminOp::get_policy(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp)
{
RGWAccessControlPolicy policy(store->ctx());
return 0;
}
-int RGWBucketAdminOp::dump_s3_policy(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+int RGWBucketAdminOp::dump_s3_policy(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
ostream& os, const DoutPrefixProvider *dpp)
{
RGWAccessControlPolicy_S3 policy(store->ctx());
return 0;
}
-int RGWBucketAdminOp::unlink(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp)
+int RGWBucketAdminOp::unlink(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp)
{
RGWBucket bucket;
return bucket.unlink(op_state, null_yield, dpp);
}
-int RGWBucketAdminOp::link(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, string *err)
+int RGWBucketAdminOp::link(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, string *err)
{
RGWBucket bucket;
- map<string, bufferlist> attrs;
-
- int ret = bucket.init(store, op_state, null_yield, dpp, err, &attrs);
+ int ret = bucket.init(store, op_state, null_yield, dpp, err);
if (ret < 0)
return ret;
- return bucket.link(op_state, null_yield, dpp, attrs, err);
+ return bucket.link(op_state, null_yield, dpp, err);
}
-int RGWBucketAdminOp::chown(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const string& marker, const DoutPrefixProvider *dpp, string *err)
+int RGWBucketAdminOp::chown(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, const string& marker, const DoutPrefixProvider *dpp, string *err)
{
RGWBucket bucket;
- map<string, bufferlist> attrs;
- int ret = bucket.init(store, op_state, null_yield, dpp, err, &attrs);
+ int ret = bucket.init(store, op_state, null_yield, dpp, err);
if (ret < 0)
return ret;
- ret = bucket.link(op_state, null_yield, dpp, attrs, err);
+ ret = bucket.link(op_state, null_yield, dpp, err);
if (ret < 0)
return ret;
}
-int RGWBucketAdminOp::check_index(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+int RGWBucketAdminOp::check_index(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher, optional_yield y, const DoutPrefixProvider *dpp)
{
int ret;
return 0;
}
-int RGWBucketAdminOp::remove_bucket(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+int RGWBucketAdminOp::remove_bucket(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
optional_yield y, const DoutPrefixProvider *dpp,
bool bypass_gc, bool keep_index_consistent)
{
return ret;
if (bypass_gc)
- ret = rgw_remove_bucket_bypass_gc(store, bucket->get_key(), op_state.get_max_aio(), keep_index_consistent, y, dpp);
+ ret = rgw_remove_bucket_bypass_gc(store, bucket.get(), op_state.get_max_aio(), keep_index_consistent, y, dpp);
else
ret = bucket->remove_bucket(dpp, op_state.will_delete_children(), string(), string(),
false, nullptr, y);
return ret;
}
-int RGWBucketAdminOp::remove_object(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp)
+int RGWBucketAdminOp::remove_object(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp)
{
RGWBucket bucket;
return bucket.remove_object(dpp, op_state);
}
-int RGWBucketAdminOp::sync_bucket(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, string *err_msg)
+int RGWBucketAdminOp::sync_bucket(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, string *err_msg)
{
RGWBucket bucket;
- map<string, bufferlist> attrs;
- int ret = bucket.init(store, op_state, null_yield, dpp, err_msg, &attrs);
+ int ret = bucket.init(store, op_state, null_yield, dpp, err_msg);
if (ret < 0)
{
return ret;
}
- return bucket.sync(op_state, &attrs, dpp, err_msg);
+ return bucket.sync(op_state, dpp, err_msg);
}
-static int bucket_stats(rgw::sal::RGWRadosStore *store,
+static int bucket_stats(rgw::sal::RGWStore *store,
const std::string& tenant_name,
const std::string& bucket_name,
Formatter *formatter,
const DoutPrefixProvider *dpp)
{
- RGWBucketInfo bucket_info;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
map<RGWObjCategory, RGWStorageStats> stats;
- map<string, bufferlist> attrs;
real_time mtime;
- int r = store->getRados()->get_bucket_info(store->svc(),
- tenant_name, bucket_name, bucket_info,
- &mtime, null_yield, dpp, &attrs);
- if (r < 0) {
- return r;
+ int ret = store->get_bucket(dpp, nullptr, tenant_name, bucket_name, &bucket, null_yield);
+ if (ret < 0) {
+ return ret;
}
- rgw_bucket& bucket = bucket_info.bucket;
-
string bucket_ver, master_ver;
string max_marker;
- int ret = store->getRados()->get_bucket_stats(bucket_info, RGW_NO_SHARD,
- &bucket_ver, &master_ver, stats,
- &max_marker);
+ ret = bucket->get_bucket_stats(RGW_NO_SHARD, &bucket_ver, &master_ver, stats, &max_marker);
if (ret < 0) {
- cerr << "error getting bucket stats bucket=" << bucket.name << " ret=" << ret << std::endl;
+ cerr << "error getting bucket stats bucket=" << bucket->get_name() << " ret=" << ret << std::endl;
return ret;
}
utime_t ut(mtime);
- utime_t ctime_ut(bucket_info.creation_time);
+ utime_t ctime_ut(bucket->get_creation_time());
formatter->open_object_section("stats");
- formatter->dump_string("bucket", bucket.name);
+ formatter->dump_string("bucket", bucket->get_name());
formatter->dump_int("num_shards",
- bucket_info.layout.current_index.layout.normal.num_shards);
- formatter->dump_string("tenant", bucket.tenant);
- formatter->dump_string("zonegroup", bucket_info.zonegroup);
- formatter->dump_string("placement_rule", bucket_info.placement_rule.to_str());
- ::encode_json("explicit_placement", bucket.explicit_placement, formatter);
- formatter->dump_string("id", bucket.bucket_id);
- formatter->dump_string("marker", bucket.marker);
- formatter->dump_stream("index_type") << bucket_info.layout.current_index.layout.type;
- ::encode_json("owner", bucket_info.owner, formatter);
+ bucket->get_info().layout.current_index.layout.normal.num_shards);
+ formatter->dump_string("tenant", bucket->get_tenant());
+ formatter->dump_string("zonegroup", bucket->get_info().zonegroup);
+ formatter->dump_string("placement_rule", bucket->get_info().placement_rule.to_str());
+ ::encode_json("explicit_placement", bucket->get_key().explicit_placement, formatter);
+ formatter->dump_string("id", bucket->get_bucket_id());
+ formatter->dump_string("marker", bucket->get_marker());
+ formatter->dump_stream("index_type") << bucket->get_info().layout.current_index.layout.type;
+ ::encode_json("owner", bucket->get_info().owner, formatter);
formatter->dump_string("ver", bucket_ver);
formatter->dump_string("master_ver", master_ver);
ut.gmtime(formatter->dump_stream("mtime"));
ctime_ut.gmtime(formatter->dump_stream("creation_time"));
formatter->dump_string("max_marker", max_marker);
dump_bucket_usage(stats, formatter);
- encode_json("bucket_quota", bucket_info.quota, formatter);
+ encode_json("bucket_quota", bucket->get_info().quota, formatter);
// bucket tags
- auto iter = attrs.find(RGW_ATTR_TAGS);
- if (iter != attrs.end()) {
+ auto iter = bucket->get_attrs().find(RGW_ATTR_TAGS);
+ if (iter != bucket->get_attrs().end()) {
RGWObjTagSet_S3 tagset;
bufferlist::const_iterator piter{&iter->second};
try {
return 0;
}
-int RGWBucketAdminOp::limit_check(rgw::sal::RGWRadosStore *store,
+int RGWBucketAdminOp::limit_check(rgw::sal::RGWStore *store,
RGWBucketAdminOpState& op_state,
const std::list<std::string>& user_ids,
RGWFormatterFlusher& flusher, optional_yield y,
string marker;
rgw::sal::RGWBucketList buckets;
do {
- rgw::sal::RGWRadosUser user(store, rgw_user(user_id));
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(rgw_user(user_id));
- ret = user.list_buckets(dpp, marker, string(), max_entries, false, buckets, y);
+ ret = user->list_buckets(dpp, marker, string(), max_entries, false, buckets, y);
if (ret < 0)
return ret;
uint32_t num_shards = 1;
uint64_t num_objects = 0;
- /* need info for num_shards */
- RGWBucketInfo info;
-
marker = bucket->get_name(); /* Casey's location for marker update,
* as we may now not reach the end of
* the loop body */
- ret = store->getRados()->get_bucket_info(store->svc(), bucket->get_tenant(),
- bucket->get_name(), info, nullptr,
- null_yield, dpp);
+ ret = bucket->get_bucket_info(dpp, null_yield);
if (ret < 0)
continue;
/* need stats for num_entries */
string bucket_ver, master_ver;
std::map<RGWObjCategory, RGWStorageStats> stats;
- ret = store->getRados()->get_bucket_stats(info, RGW_NO_SHARD, &bucket_ver,
- &master_ver, stats, nullptr);
+ ret = bucket->get_bucket_stats(RGW_NO_SHARD, &bucket_ver, &master_ver, stats, nullptr);
if (ret < 0)
continue;
num_objects += s.second.num_objects;
}
- num_shards = info.layout.current_index.layout.normal.num_shards;
+ num_shards = bucket->get_info().layout.current_index.layout.normal.num_shards;
uint64_t objs_per_shard =
(num_shards) ? num_objects/num_shards : num_objects;
{
return ret;
} /* RGWBucketAdminOp::limit_check */
-int RGWBucketAdminOp::info(rgw::sal::RGWRadosStore *store,
+int RGWBucketAdminOp::info(rgw::sal::RGWStore *store,
RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher,
optional_yield y,
formatter->open_array_section("buckets");
rgw::sal::RGWBucketList buckets;
- rgw::sal::RGWRadosUser user(store, op_state.get_user_id());
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(op_state.get_user_id());
std::string marker;
const std::string empty_end_marker;
constexpr bool no_need_stats = false; // set need_stats to false
do {
- ret = user.list_buckets(dpp, marker, empty_end_marker, max_entries,
+ ret = user->list_buckets(dpp, marker, empty_end_marker, max_entries,
no_need_stats, buckets, y);
if (ret < 0) {
return ret;
bool truncated = true;
formatter->open_array_section("buckets");
- ret = store->ctl()->meta.mgr->list_keys_init("bucket", &handle);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init("bucket", &handle);
while (ret == 0 && truncated) {
std::list<std::string> buckets;
constexpr int max_keys = 1000;
- ret = store->ctl()->meta.mgr->list_keys_next(handle, max_keys, buckets,
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, max_keys, buckets,
&truncated);
for (auto& bucket_name : buckets) {
if (show_stats) {
}
}
}
- store->ctl()->meta.mgr->list_keys_complete(handle);
+ static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
formatter->close_section();
}
return 0;
}
-int RGWBucketAdminOp::set_quota(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp)
+int RGWBucketAdminOp::set_quota(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp)
{
RGWBucket bucket;
return bucket.set_quota(op_state, dpp);
}
-static int purge_bucket_instance(rgw::sal::RGWRadosStore *store, const RGWBucketInfo& bucket_info, const DoutPrefixProvider *dpp)
+static int purge_bucket_instance(rgw::sal::RGWStore *store, const RGWBucketInfo& bucket_info, const DoutPrefixProvider *dpp)
{
- int max_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
- for (int i = 0; i < max_shards; i++) {
- RGWRados::BucketShard bs(store->getRados());
- int shard_id = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? i : -1);
- int ret = bs.init(bucket_info.bucket, shard_id, bucket_info.layout.current_index, nullptr, dpp);
- if (ret < 0) {
- cerr << "ERROR: bs.init(bucket=" << bucket_info.bucket << ", shard=" << shard_id
- << "): " << cpp_strerror(-ret) << std::endl;
- return ret;
- }
- ret = store->getRados()->bi_remove(bs);
- if (ret < 0) {
- cerr << "ERROR: failed to remove bucket index object: "
- << cpp_strerror(-ret) << std::endl;
- return ret;
- }
- }
- return 0;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ int ret = store->get_bucket(nullptr, bucket_info, &bucket);
+ if (ret < 0)
+ return ret;
+
+ return bucket->purge_instance(dpp);
}
inline auto split_tenant(const std::string& bucket_name){
}
using bucket_instance_ls = std::vector<RGWBucketInfo>;
-void get_stale_instances(rgw::sal::RGWRadosStore *store, const std::string& bucket_name,
+void get_stale_instances(rgw::sal::RGWStore *store, const std::string& bucket_name,
const vector<std::string>& lst,
bucket_instance_ls& stale_instances,
const DoutPrefixProvider *dpp)
{
- auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
-
bucket_instance_ls other_instances;
// first iterate over the entries, and pick up the done buckets; these
// are guaranteed to be stale
for (const auto& bucket_instance : lst){
RGWBucketInfo binfo;
- int r = store->getRados()->get_bucket_instance_info(obj_ctx, bucket_instance,
- binfo, nullptr,nullptr, null_yield, dpp);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ rgw_bucket rbucket;
+ rgw_bucket_parse_bucket_key(store->ctx(), bucket_instance, &rbucket, nullptr);
+ int r = store->get_bucket(dpp, nullptr, rbucket, &bucket, null_yield);
if (r < 0){
// this can only happen if someone deletes us right when we're processing
lderr(store->ctx()) << "Bucket instance is invalid: " << bucket_instance
<< cpp_strerror(-r) << dendl;
continue;
}
+ binfo = bucket->get_info();
if (binfo.reshard_status == cls_rgw_reshard_status::DONE)
stale_instances.emplace_back(std::move(binfo));
else {
// Read the cur bucket info, if the bucket doesn't exist we can simply return
// all the instances
- auto [tenant, bucket] = split_tenant(bucket_name);
+ auto [tenant, bname] = split_tenant(bucket_name);
RGWBucketInfo cur_bucket_info;
- int r = store->getRados()->get_bucket_info(store->svc(), tenant, bucket, cur_bucket_info, nullptr, null_yield, dpp);
+ std::unique_ptr<rgw::sal::RGWBucket> cur_bucket;
+ int r = store->get_bucket(dpp, nullptr, tenant, bname, &cur_bucket, null_yield);
if (r < 0) {
if (r == -ENOENT) {
// bucket doesn't exist, everything is stale then
} else {
// all bets are off if we can't read the bucket, just return the sureshot stale instances
ldpp_dout(dpp, -1) << "error: reading bucket info for bucket: "
- << bucket << cpp_strerror(-r) << dendl;
+ << bname << cpp_strerror(-r) << dendl;
}
return;
}
// Don't process further in this round if bucket is resharding
+ cur_bucket_info = cur_bucket->get_info();
if (cur_bucket_info.reshard_status == cls_rgw_reshard_status::IN_PROGRESS)
return;
// bucket and walk through these instances to make sure no one else interferes
// with these
{
- RGWBucketReshardLock reshard_lock(store, cur_bucket_info, true);
+ RGWBucketReshardLock reshard_lock(static_cast<rgw::sal::RGWRadosStore*>(store), cur_bucket->get_info(), true);
r = reshard_lock.lock();
if (r < 0) {
// most likely bucket is under reshard, return the sureshot stale instances
return;
}
-static int process_stale_instances(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+static int process_stale_instances(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher,
const DoutPrefixProvider *dpp,
std::function<void(const bucket_instance_ls&,
Formatter *,
- rgw::sal::RGWRadosStore*)> process_f)
+ rgw::sal::RGWStore*)> process_f)
{
std::string marker;
void *handle;
Formatter *formatter = flusher.get_formatter();
static constexpr auto default_max_keys = 1000;
- int ret = store->ctl()->meta.mgr->list_keys_init("bucket.instance", marker, &handle);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init("bucket.instance", marker, &handle);
if (ret < 0) {
cerr << "ERROR: can't get key: " << cpp_strerror(-ret) << std::endl;
return ret;
formatter->open_array_section("keys");
auto g = make_scope_guard([&store, &handle, &formatter]() {
- store->ctl()->meta.mgr->list_keys_complete(handle);
+ static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
formatter->close_section(); // keys
formatter->flush(cout);
});
do {
list<std::string> keys;
- ret = store->ctl()->meta.mgr->list_keys_next(handle, default_max_keys, keys, &truncated);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, default_max_keys, keys, &truncated);
if (ret < 0 && ret != -ENOENT) {
cerr << "ERROR: lists_keys_next(): " << cpp_strerror(-ret) << std::endl;
return ret;
return 0;
}
-int RGWBucketAdminOp::list_stale_instances(rgw::sal::RGWRadosStore *store,
+int RGWBucketAdminOp::list_stale_instances(rgw::sal::RGWStore *store,
RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher,
const DoutPrefixProvider *dpp)
{
auto process_f = [](const bucket_instance_ls& lst,
Formatter *formatter,
- rgw::sal::RGWRadosStore*){
+ rgw::sal::RGWStore*){
for (const auto& binfo: lst)
formatter->dump_string("key", binfo.bucket.get_key());
};
}
-int RGWBucketAdminOp::clear_stale_instances(rgw::sal::RGWRadosStore *store,
+int RGWBucketAdminOp::clear_stale_instances(rgw::sal::RGWStore *store,
RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher,
const DoutPrefixProvider *dpp)
{
auto process_f = [dpp](const bucket_instance_ls& lst,
Formatter *formatter,
- rgw::sal::RGWRadosStore *store) {
+ rgw::sal::RGWStore *store){
for (const auto &binfo: lst) {
int ret = purge_bucket_instance(store, binfo, dpp);
if (ret == 0){
auto md_key = "bucket.instance:" + binfo.bucket.get_key();
- ret = store->ctl()->meta.mgr->remove(md_key, null_yield, dpp);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->remove(md_key, null_yield, dpp);
}
formatter->open_object_section("delete_status");
formatter->dump_string("bucket_instance", binfo.bucket.get_key());
return process_stale_instances(store, op_state, flusher, dpp, process_f);
}
-static int fix_single_bucket_lc(rgw::sal::RGWRadosStore *store,
+static int fix_single_bucket_lc(rgw::sal::RGWStore *store,
const std::string& tenant_name,
const std::string& bucket_name,
const DoutPrefixProvider *dpp)
{
- RGWBucketInfo bucket_info;
- map <std::string, bufferlist> bucket_attrs;
- int ret = store->getRados()->get_bucket_info(store->svc(), tenant_name, bucket_name,
- bucket_info, nullptr, null_yield, dpp, &bucket_attrs);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ int ret = store->get_bucket(dpp, nullptr, tenant_name, bucket_name, &bucket, null_yield);
if (ret < 0) {
// TODO: Should we handle the case where the bucket could've been removed between
// listing and fetching?
return ret;
}
- return rgw::lc::fix_lc_shard_entry(store, store->get_rgwlc()->get_lc(), bucket_info,
- bucket_attrs);
+ return rgw::lc::fix_lc_shard_entry(store, store->get_rgwlc()->get_lc(), bucket.get());
}
static void format_lc_status(Formatter* formatter,
formatter->close_section(); // bucket_entry
}
-static void process_single_lc_entry(rgw::sal::RGWRadosStore *store,
+static void process_single_lc_entry(rgw::sal::RGWStore *store,
Formatter *formatter,
const std::string& tenant_name,
const std::string& bucket_name,
format_lc_status(formatter, tenant_name, bucket_name, -ret);
}
-int RGWBucketAdminOp::fix_lc_shards(rgw::sal::RGWRadosStore *store,
+int RGWBucketAdminOp::fix_lc_shards(rgw::sal::RGWStore *store,
RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher,
const DoutPrefixProvider *dpp)
process_single_lc_entry(store, formatter, user_id.tenant, bucket_name, dpp);
formatter->flush(cout);
} else {
- int ret = store->ctl()->meta.mgr->list_keys_init("bucket", marker, &handle);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init("bucket", marker, &handle);
if (ret < 0) {
std::cerr << "ERROR: can't get key: " << cpp_strerror(-ret) << std::endl;
return ret;
{
formatter->open_array_section("lc_fix_status");
auto sg = make_scope_guard([&store, &handle, &formatter](){
- store->ctl()->meta.mgr->list_keys_complete(handle);
+ static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
formatter->close_section(); // lc_fix_status
formatter->flush(cout);
});
do {
list<std::string> keys;
- ret = store->ctl()->meta.mgr->list_keys_next(handle, default_max_keys, keys, &truncated);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, default_max_keys, keys, &truncated);
if (ret < 0 && ret != -ENOENT) {
std::cerr << "ERROR: lists_keys_next(): " << cpp_strerror(-ret) << std::endl;
return ret;
}
-static bool has_object_expired(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
- const RGWBucketInfo& bucket_info,
+static bool has_object_expired(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
+ rgw::sal::RGWBucket* bucket,
const rgw_obj_key& key, utime_t& delete_at)
{
- rgw_obj obj(bucket_info.bucket, key);
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(key);
bufferlist delete_at_bl;
- int ret = rgw_object_get_attr(dpp, store, bucket_info, obj, RGW_ATTR_DELETE_AT, delete_at_bl, null_yield);
+ int ret = rgw_object_get_attr(dpp, store, obj.get(), RGW_ATTR_DELETE_AT, delete_at_bl, null_yield);
if (ret < 0) {
return false; // no delete at attr, proceed
}
return false;
}
-static int fix_bucket_obj_expiry(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
- const RGWBucketInfo& bucket_info,
+static int fix_bucket_obj_expiry(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
+ rgw::sal::RGWBucket* bucket,
RGWFormatterFlusher& flusher, bool dry_run)
{
- if (bucket_info.bucket.bucket_id == bucket_info.bucket.marker) {
+ if (bucket->get_key().bucket_id == bucket->get_key().marker) {
ldpp_dout(dpp, -1) << "Not a resharded bucket skipping" << dendl;
return 0; // not a resharded bucket, move along
}
formatter->flush(std::cout);
});
- RGWRados::Bucket target(store->getRados(), bucket_info);
- RGWRados::Bucket::List list_op(&target);
+ rgw::sal::RGWBucket::ListParams params;
+ rgw::sal::RGWBucket::ListResults results;
- list_op.params.list_versions = bucket_info.versioned();
- list_op.params.allow_unordered = true;
+ params.list_versions = bucket->versioned();
+ params.allow_unordered = true;
- bool is_truncated {false};
do {
- std::vector<rgw_bucket_dir_entry> objs;
-
- int ret = list_op.list_objects(dpp, listing_max_entries, &objs, nullptr,
- &is_truncated, null_yield);
+ int ret = bucket->list(dpp, params, listing_max_entries, results, null_yield);
if (ret < 0) {
lderr(store->ctx()) << "ERROR failed to list objects in the bucket" << dendl;
return ret;
}
- for (const auto& obj : objs) {
+ for (const auto& obj : results.objs) {
rgw_obj_key key(obj.key);
utime_t delete_at;
- if (has_object_expired(dpp, store, bucket_info, key, delete_at)) {
+ if (has_object_expired(dpp, store, bucket, key, delete_at)) {
formatter->open_object_section("object_status");
formatter->dump_string("object", key.name);
formatter->dump_stream("delete_at") << delete_at;
if (!dry_run) {
- ret = rgw_remove_object(dpp, store, bucket_info, bucket_info.bucket, key);
+ ret = rgw_remove_object(dpp, store, bucket, key);
formatter->dump_int("status", ret);
}
}
}
formatter->flush(cout); // regularly flush every 1k entries
- } while (is_truncated);
+ } while (results.is_truncated);
return 0;
}
-int RGWBucketAdminOp::fix_obj_expiry(rgw::sal::RGWRadosStore *store,
+int RGWBucketAdminOp::fix_obj_expiry(rgw::sal::RGWStore *store,
RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher,
const DoutPrefixProvider *dpp, bool dry_run)
lderr(store->ctx()) << "failed to initialize bucket" << dendl;
return ret;
}
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ ret = store->get_bucket(nullptr, admin_bucket.get_bucket_info(), &bucket);
+ if (ret < 0) {
+ return ret;
+ }
- return fix_bucket_obj_expiry(dpp, store, admin_bucket.get_bucket_info(), flusher, dry_run);
+ return fix_bucket_obj_expiry(dpp, store, bucket.get(), flusher, dry_run);
}
void RGWBucketCompleteInfo::dump(Formatter *f) const {
}
// TODO: remove RGWRados dependency for bucket listing
-int RGWBucketCtl::chown(rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info,
+int RGWBucketCtl::chown(rgw::sal::RGWStore *store, rgw::sal::RGWBucket* bucket,
const rgw_user& user_id, const std::string& display_name,
const std::string& marker, optional_yield y, const DoutPrefixProvider *dpp)
{
RGWObjectCtx obj_ctx(store);
- std::vector<rgw_bucket_dir_entry> objs;
map<string, bool> common_prefixes;
- RGWRados::Bucket target(store->getRados(), bucket_info);
- RGWRados::Bucket::List list_op(&target);
+ rgw::sal::RGWBucket::ListParams params;
+ rgw::sal::RGWBucket::ListResults results;
- list_op.params.list_versions = true;
- list_op.params.allow_unordered = true;
- list_op.params.marker = marker;
+ params.list_versions = true;
+ params.allow_unordered = true;
+ params.marker = marker;
- bool is_truncated = false;
int count = 0;
int max_entries = 1000;
//Loop through objects and update object acls to point to bucket owner
do {
- objs.clear();
- int ret = list_op.list_objects(dpp, max_entries, &objs, &common_prefixes, &is_truncated, y);
+ results.objs.clear();
+ int ret = bucket->list(dpp, params, max_entries, results, y);
if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR: list objects failed: " << cpp_strerror(-ret) << dendl;
return ret;
}
- list_op.params.marker = list_op.get_next_marker();
- count += objs.size();
-
- for (const auto& obj : objs) {
+ params.marker = results.next_marker;
+ count += results.objs.size();
- rgw_obj r_obj(bucket_info.bucket, obj.key);
- RGWRados::Object op_target(store->getRados(), bucket_info, obj_ctx, r_obj);
- RGWRados::Object::Read read_op(&op_target);
+ for (const auto& obj : results.objs) {
+ std::unique_ptr<rgw::sal::RGWObject> r_obj = bucket->get_object(obj.key);
- map<string, bufferlist> attrs;
- read_op.params.attrs = &attrs;
- ret = read_op.prepare(y, dpp);
+ ret = r_obj->get_obj_attrs(&obj_ctx, y, dpp);
if (ret < 0){
ldout(store->ctx(), 0) << "ERROR: failed to read object " << obj.key.name << cpp_strerror(-ret) << dendl;
continue;
}
- const auto& aiter = attrs.find(RGW_ATTR_ACL);
- if (aiter == attrs.end()) {
+ const auto& aiter = r_obj->get_attrs().find(RGW_ATTR_ACL);
+ if (aiter == r_obj->get_attrs().end()) {
ldpp_dout(dpp, 0) << "ERROR: no acls found for object " << obj.key.name << " .Continuing with next object." << dendl;
continue;
} else {
bl.clear();
encode(policy, bl);
- obj_ctx.set_atomic(r_obj);
- ret = store->getRados()->set_attr(dpp, &obj_ctx, bucket_info, r_obj, RGW_ATTR_ACL, bl);
+ r_obj->set_atomic(&obj_ctx);
+ map<string, bufferlist> attrs;
+ attrs[RGW_ATTR_ACL] = bl;
+ ret = r_obj->set_obj_attrs(dpp, &obj_ctx, &attrs, nullptr, y);
if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR: modify attr failed " << cpp_strerror(-ret) << dendl;
return ret;
}
}
}
- cerr << count << " objects processed in " << bucket_info.bucket.name
- << ". Next marker " << list_op.params.marker.name << std::endl;
- } while(is_truncated);
+ cerr << count << " objects processed in " << bucket
+ << ". Next marker " << params.marker.name << std::endl;
+ } while(results.is_truncated);
return 0;
}
#include "rgw_metadata.h"
#include "rgw_string.h"
+#include "rgw_sal.h"
#include "common/Formatter.h"
#include "common/lru_map.h"
class RGWBucketCtl;
class RGWZone;
struct RGWZoneParams;
-namespace rgw { namespace sal {
- class RGWRadosStore;
- class RGWBucketList;
-} }
extern int rgw_bucket_parse_bucket_instance(const string& bucket_instance, string *bucket_name, string *bucket_id, int *shard_id);
extern int rgw_bucket_parse_bucket_key(CephContext *cct, const string& key,
static RGWBucketInstanceMetadataHandlerBase *alloc();
};
-/**
- * Get all the buckets owned by a user and fill up an RGWUserBuckets with them.
- * Returns: 0 on success, -ERR# on failure.
- */
-extern int rgw_read_user_buckets(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
- const rgw_user& user_id,
- rgw::sal::RGWBucketList& buckets,
- const string& marker,
- const string& end_marker,
- uint64_t max,
- bool need_stats,
- optional_yield y);
-
-extern int rgw_remove_object(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, const RGWBucketInfo& bucket_info, const rgw_bucket& bucket, rgw_obj_key& key);
-extern int rgw_remove_bucket_bypass_gc(rgw::sal::RGWRadosStore *store, rgw_bucket& bucket, int concurrent_max, optional_yield y);
+extern int rgw_remove_object(const DoutPrefixProvider *dpp, rgw::sal::RGWStore *store, rgw::sal::RGWBucket* bucket, rgw_obj_key& key);
+extern int rgw_remove_bucket_bypass_gc(rgw::sal::RGWStore *store, rgw::sal::RGWBucket* bucket, int concurrent_max, optional_yield y);
-extern int rgw_object_get_attr(rgw::sal::RGWRadosStore* store, const RGWBucketInfo& bucket_info,
- const rgw_obj& obj, const char* attr_name,
- bufferlist& out_bl, optional_yield y);
+extern int rgw_object_get_attr(rgw::sal::RGWStore* store, rgw::sal::RGWObject* obj,
+ const char* attr_name, bufferlist& out_bl,
+ optional_yield y);
-extern void check_bad_user_bucket_mapping(rgw::sal::RGWRadosStore *store, const rgw_user& user_id, bool fix, optional_yield y, const DoutPrefixProvider *dpp);
+extern void check_bad_user_bucket_mapping(rgw::sal::RGWStore *store, rgw::sal::RGWUser* user, bool fix, optional_yield y, const DoutPrefixProvider *dpp);
struct RGWBucketAdminOpState {
rgw_user uid;
bool sync_bucket;
int max_aio = 0;
- rgw_bucket bucket;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
RGWQuotaInfo quota;
std::string& get_object_name() { return object_name; }
std::string& get_tenant() { return uid.tenant; }
- rgw_bucket& get_bucket() { return bucket; }
- void set_bucket(rgw_bucket& _bucket) {
- bucket = _bucket;
+ rgw::sal::RGWBucket* get_bucket() { return bucket.get(); }
+ void set_bucket(std::unique_ptr<rgw::sal::RGWBucket> _bucket) {
+ bucket = std::move(_bucket);
bucket_stored = true;
}
class RGWBucket
{
RGWUserBuckets buckets;
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
RGWAccessHandle handle;
- RGWUserInfo user_info;
- rgw_bucket bucket;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ std::unique_ptr<rgw::sal::RGWUser> user;
bool failure;
- RGWBucketInfo bucket_info;
RGWObjVersionTracker ep_objv; // entrypoint object version
public:
RGWBucket() : store(NULL), handle(NULL), failure(false) {}
- int init(rgw::sal::RGWRadosStore *storage, RGWBucketAdminOpState& op_state, optional_yield y,
- const DoutPrefixProvider *dpp, std::string *err_msg = NULL, map<string, bufferlist> *pattrs = NULL);
+ int init(rgw::sal::RGWStore *storage, RGWBucketAdminOpState& op_state, optional_yield y,
+ const DoutPrefixProvider *dpp, std::string *err_msg = NULL);
int check_bad_index_multipart(RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher,
std::string *err_msg = NULL);
int link(RGWBucketAdminOpState& op_state, optional_yield y, const DoutPrefixProvider *dpp,
- map<string, bufferlist>& attrs, std::string *err_msg = NULL);
+ std::string *err_msg = NULL);
int chown(RGWBucketAdminOpState& op_state, const string& marker,
optional_yield y, const DoutPrefixProvider *dpp, std::string *err_msg = NULL);
int unlink(RGWBucketAdminOpState& op_state, optional_yield y, const DoutPrefixProvider *dpp, std::string *err_msg = NULL);
int remove_object(const DoutPrefixProvider *dpp, RGWBucketAdminOpState& op_state, std::string *err_msg = NULL);
int policy_bl_to_stream(bufferlist& bl, ostream& o);
int get_policy(RGWBucketAdminOpState& op_state, RGWAccessControlPolicy& policy, optional_yield y, const DoutPrefixProvider *dpp);
- int sync(RGWBucketAdminOpState& op_state, map<string, bufferlist> *attrs, const DoutPrefixProvider *dpp, std::string *err_msg = NULL);
+ int sync(RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, std::string *err_msg = NULL);
void clear_failure() { failure = false; }
- const RGWBucketInfo& get_bucket_info() const { return bucket_info; }
+ const RGWBucketInfo& get_bucket_info() const { return bucket->get_info(); }
};
class RGWBucketAdminOp
{
public:
- static int get_policy(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+ static int get_policy(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp);
- static int get_policy(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+ static int get_policy(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
RGWAccessControlPolicy& policy, const DoutPrefixProvider *dpp);
- static int dump_s3_policy(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+ static int dump_s3_policy(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
ostream& os, const DoutPrefixProvider *dpp);
- static int unlink(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp);
- static int link(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, string *err_msg = NULL);
- static int chown(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const string& marker, const DoutPrefixProvider *dpp, string *err_msg = NULL);
+ static int unlink(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp);
+ static int link(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, string *err_msg = NULL);
+ static int chown(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, const string& marker, const DoutPrefixProvider *dpp, string *err_msg = NULL);
- static int check_index(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+ static int check_index(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher, optional_yield y, const DoutPrefixProvider *dpp);
- static int remove_bucket(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, optional_yield y,
- const DoutPrefixProvider *dpp, bool bypass_gc = false, bool keep_index_consistent = true);
- static int remove_object(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp);
- static int info(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, RGWFormatterFlusher& flusher, optional_yield y, const DoutPrefixProvider *dpp);
- static int limit_check(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+ static int remove_bucket(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, optional_yield y,
+ const DoutPrefixProvider *dpp, bool bypass_gc = false, bool keep_index_consistent = true);
+ static int remove_object(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp);
+ static int info(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, RGWFormatterFlusher& flusher, optional_yield y, const DoutPrefixProvider *dpp);
+ static int limit_check(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
const std::list<std::string>& user_ids,
RGWFormatterFlusher& flusher, optional_yield y,
const DoutPrefixProvider *dpp,
bool warnings_only = false);
- static int set_quota(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp);
+ static int set_quota(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp);
- static int list_stale_instances(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+ static int list_stale_instances(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp);
- static int clear_stale_instances(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+ static int clear_stale_instances(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp);
- static int fix_lc_shards(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+ static int fix_lc_shards(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp);
- static int fix_obj_expiry(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
+ static int fix_obj_expiry(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp, bool dry_run = false);
- static int sync_bucket(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, string *err_msg = NULL);
+ static int sync_bucket(rgw::sal::RGWStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, string *err_msg = NULL);
};
struct rgw_ep_info {
const DoutPrefixProvider *dpp,
bool update_entrypoint = true);
- int chown(rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info,
+ int chown(rgw::sal::RGWStore *store, rgw::sal::RGWBucket* bucket,
const rgw_user& user_id, const std::string& display_name,
const std::string& marker, optional_yield y, const DoutPrefixProvider *dpp);
&cw_client))));
RGWRestfulIO client_io(dout_context, &real_client_io);
- RGWRequest req(env.store->getRados()->get_new_req_id());
+ RGWRequest req(env.store->get_new_req_id());
int http_ret = 0;
//assert (scheduler != nullptr);
int ret = process_request(env.store, env.rest, &req, env.uri_prefix,
template<>
int RGWGetBucketInfoCR::Request::_send_request()
{
- return store->getRados()->get_bucket_info(store->svc(), params.tenant, params.bucket_name,
- result->bucket_info, &result->mtime, null_yield, dpp, &result->attrs);
+ return store->get_bucket(dpp, nullptr, params.tenant, params.bucket_name, &result->bucket, null_yield);
}
template<>
return -EIO;
}
- int ret = lc->set_bucket_config(params.bucket_info,
+ int ret = lc->set_bucket_config(params.bucket,
params.bucket_attrs,
¶ms.config);
if (ret < 0) {
};
struct rgw_get_bucket_info_result {
- ceph::real_time mtime;
- RGWBucketInfo bucket_info;
- map<string, bufferlist> attrs;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
};
using RGWGetBucketInfoCR = RGWSimpleAsyncCR<rgw_get_bucket_info_params, rgw_get_bucket_info_result>;
struct rgw_bucket_lifecycle_config_params {
- RGWBucketInfo bucket_info;
- map<string, bufferlist> bucket_attrs;
+ rgw::sal::RGWBucket* bucket;
+ rgw::sal::RGWAttrs bucket_attrs;
RGWLifecycleConfiguration config;
};
#include "rgw_coroutine.h"
#include "rgw_http_client.h"
-#include "rgw_sal.h"
+#include "rgw_sal_rados.h"
#include "rgw_datalog.h"
#include "rgw_sync_module.h"
{
LookupFHResult fhr{nullptr, 0};
std::string bucket_name{path};
- RGWStatBucketRequest req(cct, rgwlib.get_store()->get_user(user.user_id), bucket_name, bs);
+ RGWStatBucketRequest req(cct, user->clone(), bucket_name, bs);
int rc = rgwlib.get_fe()->execute_req(&req);
if ((rc == 0) &&
if (type == RGW_FS_TYPE_DIRECTORY)
continue;
- RGWStatObjRequest req(cct, rgwlib.get_store()->get_user(user.user_id),
+ RGWStatObjRequest req(cct, user->clone(),
parent->bucket_name(), obj_path,
RGWStatObjRequest::FLAG_NONE);
int rc = rgwlib.get_fe()->execute_req(&req);
continue;
obj_path += "/";
- RGWStatObjRequest req(cct, rgwlib.get_store()->get_user(user.user_id),
+ RGWStatObjRequest req(cct, user->clone(),
parent->bucket_name(), obj_path,
RGWStatObjRequest::FLAG_NONE);
int rc = rgwlib.get_fe()->execute_req(&req);
case 2:
{
std::string object_name{path};
- RGWStatLeafRequest req(cct, rgwlib.get_store()->get_user(user.user_id),
+ RGWStatLeafRequest req(cct, user->clone(),
parent, object_name);
int rc = rgwlib.get_fe()->execute_req(&req);
if ((rc == 0) &&
if (rgw_fh->deleted())
return -ESTALE;
- RGWReadRequest req(get_context(), rgwlib.get_store()->get_user(user.user_id),
- rgw_fh, offset, length, buffer);
+ RGWReadRequest req(get_context(), user->clone(), rgw_fh, offset, length, buffer);
int rc = rgwlib.get_fe()->execute_req(&req);
if ((rc == 0) &&
if (rgw_fh->deleted())
return -ESTALE;
- RGWReadRequest req(get_context(), rgwlib.get_store()->get_user(user.user_id),
- rgw_fh, offset, length, buffer);
+ RGWReadRequest req(get_context(), user->clone(), rgw_fh, offset, length, buffer);
int rc = rgwlib.get_fe()->execute_req(&req);
if ((rc == 0) &&
} else {
/* delete object w/key "<bucket>/" (uxattrs), if any */
string oname{"/"};
- RGWDeleteObjRequest req(cct, rgwlib.get_store()->get_user(user.user_id),
- bkt_fh->bucket_name(), oname);
+ RGWDeleteObjRequest req(cct, user->clone(), bkt_fh->bucket_name(), oname);
rc = rgwlib.get_fe()->execute_req(&req);
/* don't care if ENOENT */
unref(bkt_fh);
}
string bname{name};
- RGWDeleteBucketRequest req(cct, rgwlib.get_store()->get_user(user.user_id), bname);
+ RGWDeleteBucketRequest req(cct, user->clone(), bname);
rc = rgwlib.get_fe()->execute_req(&req);
if (! rc) {
rc = req.get_ret();
}
oname += "/";
}
- RGWDeleteObjRequest req(cct, rgwlib.get_store()->get_user(user.user_id), parent->bucket_name(),
- oname);
+ RGWDeleteObjRequest req(cct, user->clone(), parent->bucket_name(), oname);
rc = rgwlib.get_fe()->execute_req(&req);
if (! rc) {
rc = req.get_ret();
switch (ix) {
case 0:
{
- RGWCopyObjRequest req(cct, rgwlib.get_store()->get_user(user.user_id),
- src_fh, dst_fh, src_name, dst_name);
+ RGWCopyObjRequest req(cct, user->clone(), src_fh, dst_fh, src_name, dst_name);
int rc = rgwlib.get_fe()->execute_req(&req);
if ((rc != 0) ||
((rc = req.get_ret()) != 0)) {
return mkr;
}
- RGWCreateBucketRequest req(get_context(),
- rgwlib.get_store()->get_user(user.user_id), bname);
+ RGWCreateBucketRequest req(get_context(), user->clone(), bname);
/* save attrs */
req.emplace_attr(RGW_ATTR_UNIX_KEY1, std::move(ux_key));
return mkr;
}
- RGWPutObjRequest req(get_context(), rgwlib.get_store()->get_user(user.user_id),
- parent->bucket_name(), dir_name, bl);
+ RGWPutObjRequest req(get_context(), user->clone(), parent->bucket_name(), dir_name, bl);
/* save attrs */
req.emplace_attr(RGW_ATTR_UNIX_KEY1, std::move(ux_key));
/* create it */
buffer::list bl;
- RGWPutObjRequest req(cct, rgwlib.get_store()->get_user(user.user_id),
- parent->bucket_name(), obj_name, bl);
+ RGWPutObjRequest req(cct, user->clone(), parent->bucket_name(), obj_name, bl);
MkObjResult mkr{nullptr, -EINVAL};
rc = rgwlib.get_fe()->execute_req(&req);
buffer::copy(link_path, strlen(link_path)));
#endif
- RGWPutObjRequest req(get_context(), rgwlib.get_store()->get_user(user.user_id),
- parent->bucket_name(), obj_name, bl);
+ RGWPutObjRequest req(get_context(), user->clone(), parent->bucket_name(), obj_name, bl);
/* save attrs */
req.emplace_attr(RGW_ATTR_UNIX_KEY1, std::move(ux_key));
obj_name += "/";
}
- RGWSetAttrsRequest req(cct, rgwlib.get_store()->get_user(user.user_id),
- rgw_fh->bucket_name(), obj_name);
+ RGWSetAttrsRequest req(cct, user->clone(), rgw_fh->bucket_name(), obj_name);
rgw_fh->create_stat(st, mask);
rgw_fh->encode_attrs(ux_key, ux_attrs);
if (rc == -ENOENT) {
/* special case: materialize placeholder dir */
buffer::list bl;
- RGWPutObjRequest req(get_context(), rgwlib.get_store()->get_user(user.user_id), rgw_fh->bucket_name(),
- obj_name, bl);
+ RGWPutObjRequest req(get_context(), user->clone(), rgw_fh->bucket_name(), obj_name, bl);
rgw_fh->encode_attrs(ux_key, ux_attrs); /* because std::moved */
int rc, rc2, rc3;
string obj_name{rgw_fh->relative_object_name2()};
- RGWGetAttrsRequest req(cct, rgwlib.get_store()->get_user(user.user_id),
- rgw_fh->bucket_name(), obj_name);
+ RGWGetAttrsRequest req(cct, user->clone(), rgw_fh->bucket_name(), obj_name);
for (uint32_t ix = 0; ix < attrs->xattr_cnt; ++ix) {
auto& xattr = attrs->xattrs[ix];
int rc, rc2, rc3;
string obj_name{rgw_fh->relative_object_name2()};
- RGWGetAttrsRequest req(cct, rgwlib.get_store()->get_user(user.user_id),
- rgw_fh->bucket_name(), obj_name);
+ RGWGetAttrsRequest req(cct, user->clone(), rgw_fh->bucket_name(), obj_name);
rc = rgwlib.get_fe()->execute_req(&req);
rc2 = req.get_ret();
int rc, rc2;
string obj_name{rgw_fh->relative_object_name2()};
- RGWSetAttrsRequest req(cct, rgwlib.get_store()->get_user(user.user_id),
- rgw_fh->bucket_name(), obj_name);
+ RGWSetAttrsRequest req(cct, user->clone(), rgw_fh->bucket_name(), obj_name);
for (uint32_t ix = 0; ix < attrs->xattr_cnt; ++ix) {
auto& xattr = attrs->xattrs[ix];
int rc, rc2;
string obj_name{rgw_fh->relative_object_name2()};
- RGWRMAttrsRequest req(cct, rgwlib.get_store()->get_user(user.user_id),
- rgw_fh->bucket_name(), obj_name);
+ RGWRMAttrsRequest req(cct, user->clone(), rgw_fh->bucket_name(), obj_name);
for (uint32_t ix = 0; ix < attrs->xattr_cnt; ++ix) {
auto& xattr = attrs->xattrs[ix];
<< " update old versioned fh : " << obj_name
<< dendl;
- RGWSetAttrsRequest req(cct, rgwlib.get_store()->get_user(user.user_id),
- rgw_fh->bucket_name(), obj_name);
+ RGWSetAttrsRequest req(cct, user->clone(), rgw_fh->bucket_name(), obj_name);
rgw_fh->encode_attrs(ux_key, ux_attrs);
state->object->set_bucket(state->bucket.get());
auto compression_type =
- get_store()->svc()->zone->get_zone_params().get_compression_type(
+ get_store()->get_zone_params().get_compression_type(
state->bucket->get_placement_rule());
/* not obviously supportable */
std::string uid; // should match user.user_id, iiuc
- RGWUserInfo user;
+ std::unique_ptr<rgw::sal::RGWUser> user;
RGWAccessKey key; // XXXX acc_key
static std::atomic<uint32_t> fs_inst_counter;
(void) fh_lru.unref(fh, cohort::lru::FLAG_NONE);
}
- int authorize(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store) {
- int ret = store->ctl()->user->get_info_by_access_key(dpp, key.id, &user, null_yield);
+ int authorize(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store) {
+ int ret = store->get_user(dpp, key, null_yield, &user);
if (ret == 0) {
- RGWAccessKey* k = user.get_key(key.id);
+ RGWAccessKey* k = user->get_info().get_key(key.id);
if (!k || (k->key != key.key))
return -EINVAL;
- if (user.suspended)
+ if (user->get_info().suspended)
return -ERR_USER_SUSPENDED;
} else {
/* try external authenticators (ldap for now) */
}
if (token.valid() && (ldh->auth(token.id, token.key) == 0)) {
/* try to store user if it doesn't already exist */
- if (store->ctl()->user->get_info_by_uid(dpp, rgw_user(token.id), &user, null_yield) < 0) {
- int ret = store->ctl()->user->store_info(dpp, user, null_yield,
- RGWUserCtl::PutParams()
+ if (user->load_by_id(dpp, null_yield) < 0) {
+ int ret = user->store_info(dpp, null_yield, RGWUserCtl::PutParams()
.set_exclusive(true));
if (ret < 0) {
lsubdout(get_context(), rgw, 10)
uint64_t get_fsid() { return root_fh.state.dev; }
- RGWUserInfo* get_user() { return &user; }
+ RGWUserInfo* get_user() { return &user->get_info(); }
void update_user(const DoutPrefixProvider *dpp) {
- RGWUserInfo _user = user;
- auto user_ctl = rgwlib.get_store()->ctl()->user;
- int ret = user_ctl->get_info_by_access_key(dpp, key.id, &user, null_yield);
- if (ret != 0)
- user = _user;
+ (void) rgwlib.get_store()->get_user(dpp, key, null_yield, &user);
}
void close();
size_t bytes_written;
bool eio;
- RGWWriteRequest(rgw::sal::RGWRadosStore* store,
+ RGWWriteRequest(rgw::sal::RGWStore* store,
std::unique_ptr<rgw::sal::RGWUser> _user,
RGWFileHandle* _fh, const std::string& _bname,
const std::string& _oname)
virtual void join() = 0;
virtual void pause_for_new_config() = 0;
- virtual void unpause_with_new_config(rgw::sal::RGWRadosStore* store,
+ virtual void unpause_with_new_config(rgw::sal::RGWStore* store,
rgw_auth_registry_ptr_t auth_registry) = 0;
};
env.mutex.get_write();
}
- void unpause_with_new_config(rgw::sal::RGWRadosStore* const store,
+ void unpause_with_new_config(rgw::sal::RGWStore* const store,
rgw_auth_registry_ptr_t auth_registry) override {
env.store = store;
env.auth_registry = std::move(auth_registry);
pprocess->pause();
}
- void unpause_with_new_config(rgw::sal::RGWRadosStore* const store,
+ void unpause_with_new_config(rgw::sal::RGWStore* const store,
rgw_auth_registry_ptr_t auth_registry) override {
env.store = store;
env.auth_registry = auth_registry;
}
rgw_user uid(uid_str);
+ std::unique_ptr<rgw::sal::RGWUser> user = env.store->get_user(uid);
- RGWUserInfo user_info;
- int ret = env.store->ctl()->user->get_info_by_uid(this, uid, &user_info, null_yield);
+ int ret = user->load_by_id(this, null_yield);
if (ret < 0) {
derr << "ERROR: failed reading user info: uid=" << uid << " ret="
<< ret << dendl;
return ret;
}
- map<string, RGWAccessKey>::iterator aiter = user_info.access_keys.begin();
- if (aiter == user_info.access_keys.end()) {
+ map<string, RGWAccessKey>::iterator aiter = user->get_info().access_keys.begin();
+ if (aiter == user->get_info().access_keys.end()) {
derr << "ERROR: user has no S3 access keys set" << dendl;
return -EINVAL;
}
if (pauser)
pauser->pause();
}
- void resume(rgw::sal::RGWRadosStore *store) override {
+ void resume(rgw::sal::RGWStore *store) override {
/* Initialize the registry of auth strategies which will coordinate
* the dynamic reconfiguration. */
auto auth_registry = \
- rgw::auth::StrategyRegistry::create(g_ceph_context, implicit_tenants, store->getRados()->pctl);
+ rgw::auth::StrategyRegistry::create(g_ceph_context, implicit_tenants, store->get_ctl());
for (auto frontend : frontends)
frontend->unpause_with_new_config(store, auth_registry);
#include "rgw_string.h"
#include "rgw_multi.h"
#include "rgw_sal.h"
-#include "rgw_sal_rados.h"
+#include "rgw_sal.h"
// this seems safe to use, at least for now--arguably, we should
// prefer header-only fmt, in general
return NULL;
}
-void RGWLC::initialize(CephContext *_cct, rgw::sal::RGWRadosStore *_store) {
+void RGWLC::initialize(CephContext *_cct, rgw::sal::RGWStore *_store) {
cct = _cct;
store = _store;
sal_lc = store->get_lifecycle();
using LCWorker = RGWLC::LCWorker;
lc_op op;
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
LCWorker* worker;
rgw::sal::RGWBucket* bucket;
LCObjsLister& ol;
- op_env(lc_op& _op, rgw::sal::RGWRadosStore *_store, LCWorker* _worker,
+ op_env(lc_op& _op, rgw::sal::RGWStore *_store, LCWorker* _worker,
rgw::sal::RGWBucket* _bucket, LCObjsLister& _ol)
: op(_op), store(_store), worker(_worker), bucket(_bucket),
ol(_ol) {}
boost::optional<std::string> next_key_name;
ceph::real_time effective_mtime;
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
rgw::sal::RGWBucket* bucket;
lc_op& op; // ok--refers to expanded env.op
LCObjsLister& ol;
}
obj = bucket->get_object(obj_key);
+ std::unique_ptr<rgw::sal::RGWObject::DeleteOp> del_op = obj->get_delete_op(&oc.rctx);
- ACLOwner obj_owner;
- obj_owner.set_id(rgw_user {meta.owner});
- obj_owner.set_name(meta.owner_display_name);
- ACLOwner bucket_owner;
- bucket_owner.set_id(bucket_info.owner);
+ del_op->params.versioning_status = obj->get_bucket()->get_info().versioning_status();
+ del_op->params.obj_owner.set_id(rgw_user {meta.owner});
+ del_op->params.obj_owner.set_name(meta.owner_display_name);
+ del_op->params.bucket_owner.set_id(bucket_info.owner);
+ del_op->params.unmod_since = meta.mtime;
+ del_op->params.marker_version_id = version_id;
- return obj->delete_object(dpp, &oc.rctx, obj_owner, bucket_owner, meta.mtime, false, 0,
- version_id, null_yield);
+ return del_op->delete_obj(dpp, null_yield);
} /* remove_expired_obj */
class LCOpAction {
return;
}
RGWObjectCtx rctx(store);
- int ret = abort_multipart_upload(this, store, cct, &rctx, target->get_info(), mp_obj);
+ int ret = abort_multipart_upload(this, store, cct, &rctx, target, mp_obj);
if (ret == 0) {
if (perfcounter) {
perfcounter->inc(l_rgw_lc_abort_mpu, 1);
target_placement.inherit_from(oc.bucket->get_placement_rule());
target_placement.storage_class = transition.storage_class;
- if (!oc.store->svc()->zone->get_zone_params().
+ if (!oc.store->get_zone_params().
valid_placement(target_placement)) {
ldpp_dout(oc.dpp, 0) << "ERROR: non existent dest placement: "
<< target_placement
}
template<typename F>
-static int guard_lc_modify(rgw::sal::RGWRadosStore* store,
+static int guard_lc_modify(rgw::sal::RGWStore* store,
rgw::sal::Lifecycle* sal_lc,
const rgw_bucket& bucket, const string& cookie,
const F& f) {
return ret;
}
-int RGWLC::set_bucket_config(RGWBucketInfo& bucket_info,
- const map<string, bufferlist>& bucket_attrs,
+int RGWLC::set_bucket_config(rgw::sal::RGWBucket* bucket,
+ const rgw::sal::RGWAttrs& bucket_attrs,
RGWLifecycleConfiguration *config)
{
- map<string, bufferlist> attrs = bucket_attrs;
+ rgw::sal::RGWAttrs attrs = bucket_attrs;
bufferlist lc_bl;
config->encode(lc_bl);
attrs[RGW_ATTR_LC] = std::move(lc_bl);
int ret =
- store->ctl()->bucket->set_bucket_instance_attrs(
- bucket_info, attrs, &bucket_info.objv_tracker, null_yield, this);
+ bucket->set_instance_attrs(this, attrs, null_yield);
if (ret < 0)
return ret;
- rgw_bucket& bucket = bucket_info.bucket;
+ rgw_bucket& b = bucket->get_key();
- ret = guard_lc_modify(store, sal_lc.get(), bucket, cookie,
+ ret = guard_lc_modify(store, sal_lc.get(), b, cookie,
[&](rgw::sal::Lifecycle* sal_lc, const string& oid,
const rgw::sal::Lifecycle::LCEntry& entry) {
return sal_lc->set_entry(oid, entry);
return ret;
}
-int RGWLC::remove_bucket_config(RGWBucketInfo& bucket_info,
- const map<string, bufferlist>& bucket_attrs)
+int RGWLC::remove_bucket_config(rgw::sal::RGWBucket* bucket,
+ const rgw::sal::RGWAttrs& bucket_attrs)
{
- map<string, bufferlist> attrs = bucket_attrs;
+ rgw::sal::RGWAttrs attrs = bucket_attrs;
attrs.erase(RGW_ATTR_LC);
- int ret =
- store->ctl()->bucket->set_bucket_instance_attrs(
- bucket_info, attrs, &bucket_info.objv_tracker, null_yield, this);
+ int ret = bucket->set_instance_attrs(this, attrs, null_yield);
- rgw_bucket& bucket = bucket_info.bucket;
+ rgw_bucket& b = bucket->get_key();
if (ret < 0) {
ldout(cct, 0) << "RGWLC::RGWDeleteLC() failed to set attrs on bucket="
- << bucket.name << " returned err=" << ret << dendl;
+ << b.name << " returned err=" << ret << dendl;
return ret;
}
- ret = guard_lc_modify(store, sal_lc.get(), bucket, cookie,
+ ret = guard_lc_modify(store, sal_lc.get(), b, cookie,
[&](rgw::sal::Lifecycle* sal_lc, const string& oid,
const rgw::sal::Lifecycle::LCEntry& entry) {
return sal_lc->rm_entry(oid, entry);
namespace rgw::lc {
-int fix_lc_shard_entry(rgw::sal::RGWRadosStore* store,
+int fix_lc_shard_entry(rgw::sal::RGWStore* store,
rgw::sal::Lifecycle* sal_lc,
- const RGWBucketInfo& bucket_info,
- const map<std::string,bufferlist>& battrs)
+ rgw::sal::RGWBucket* bucket)
{
- if (auto aiter = battrs.find(RGW_ATTR_LC);
- aiter == battrs.end()) {
+ if (auto aiter = bucket->get_attrs().find(RGW_ATTR_LC);
+ aiter == bucket->get_attrs().end()) {
return 0; // No entry, nothing to fix
}
- auto shard_name = get_lc_shard_name(bucket_info.bucket);
+ auto shard_name = get_lc_shard_name(bucket->get_key());
std::string lc_oid;
get_lc_oid(store->ctx(), shard_name, &lc_oid);
}
ldout(store->ctx(), 5) << "lc_get_entry errored ret code=" << ret << dendl;
if (ret == -ENOENT) {
- ldout(store->ctx(), 1) << "No entry for bucket=" << bucket_info.bucket.name
+ ldout(store->ctx(), 1) << "No entry for bucket=" << bucket
<< " creating " << dendl;
// TODO: we have too many ppl making cookies like this!
char cookie_buf[COOKIE_LEN + 1];
std::string cookie = cookie_buf;
ret = guard_lc_modify(
- store, sal_lc, bucket_info.bucket, cookie,
+ store, sal_lc, bucket->get_key(), cookie,
[&lc_oid](rgw::sal::Lifecycle* slc,
const string& oid,
const rgw::sal::Lifecycle::LCEntry& entry) {
class RGWLC : public DoutPrefixProvider {
CephContext *cct;
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
std::unique_ptr<rgw::sal::Lifecycle> sal_lc;
int max_objs{0};
string *obj_names{nullptr};
RGWLC() : cct(nullptr), store(nullptr) {}
~RGWLC();
- void initialize(CephContext *_cct, rgw::sal::RGWRadosStore *_store);
+ void initialize(CephContext *_cct, rgw::sal::RGWStore *_store);
void finalize();
int process(LCWorker* worker, bool once);
bool going_down();
void start_processor();
void stop_processor();
- int set_bucket_config(RGWBucketInfo& bucket_info,
- const map<string, bufferlist>& bucket_attrs,
+ int set_bucket_config(rgw::sal::RGWBucket* bucket,
+ const rgw::sal::RGWAttrs& bucket_attrs,
RGWLifecycleConfiguration *config);
- int remove_bucket_config(RGWBucketInfo& bucket_info,
- const map<string, bufferlist>& bucket_attrs);
+ int remove_bucket_config(rgw::sal::RGWBucket* bucket,
+ const rgw::sal::RGWAttrs& bucket_attrs);
CephContext *get_cct() const override { return cct; }
rgw::sal::Lifecycle *get_lc() const { return sal_lc.get(); }
namespace rgw::lc {
-int fix_lc_shard_entry(rgw::sal::RGWRadosStore *store,
+int fix_lc_shard_entry(rgw::sal::RGWStore *store,
rgw::sal::Lifecycle* sal_lc,
- const RGWBucketInfo& bucket_info,
- const map<std::string,bufferlist>& battrs);
+ rgw::sal::RGWBucket* bucket);
std::string s3_expiration_header(
DoutPrefixProvider* dpp,
OpsLogSocket* olog;
rgw::LDAPHelper* ldh{nullptr};
RGWREST rest; // XXX needed for RGWProcessEnv
- rgw::sal::RGWRadosStore* store;
+ rgw::sal::RGWStore* store;
boost::intrusive_ptr<CephContext> cct;
public:
{}
~RGWLib() {}
- rgw::sal::RGWRadosStore* get_store() { return store; }
+ rgw::sal::RGWStore* get_store() { return store; }
RGWLibFrontend* get_fe() { return fe; }
return user_info;
}
- int set_uid(rgw::sal::RGWRadosStore* store, const rgw_user& uid);
+ int set_uid(rgw::sal::RGWStore* store, const rgw_user& uid);
int write_data(const char *buf, int len);
int read_data(char *buf, int len);
RGWHandler_Lib() {}
~RGWHandler_Lib() override {}
- static int init_from_header(rgw::sal::RGWRadosStore *store,
+ static int init_from_header(rgw::sal::RGWStore *store,
struct req_state *s);
}; /* RGWHandler_Lib */
inline struct req_state* get_state() { return this->RGWRequest::s; }
RGWLibRequest(CephContext* _cct, std::unique_ptr<rgw::sal::RGWUser> _user)
- : RGWRequest(rgwlib.get_store()->getRados()->get_new_req_id()),
+ : RGWRequest(rgwlib.get_store()->get_new_req_id()),
tuser(std::move(_user)), cct(_cct)
{}
RGWRequest::init_state(_s);
RGWHandler::init(rados_ctx->get_store(), _s, io);
- sysobj_ctx.emplace(store->svc()->sysobj);
+ sysobj_ctx.emplace(static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj);
get_state()->obj_ctx = rados_ctx;
get_state()->sysobj_ctx = &(sysobj_ctx.get());
- get_state()->req_id = store->svc()->zone_utils->unique_id(id);
- get_state()->trans_id = store->svc()->zone_utils->unique_trans_id(id);
+ get_state()->req_id = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone_utils->unique_id(id);
+ get_state()->trans_id = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone_utils->unique_trans_id(id);
get_state()->bucket_tenant = tuser->get_tenant();
get_state()->set_user(tuser);
RGWRequest::init_state(&rstate);
RGWHandler::init(rados_ctx.get_store(), &rstate, &io_ctx);
- sysobj_ctx.emplace(store->svc()->sysobj);
+ sysobj_ctx.emplace(static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj);
get_state()->cio = &io_ctx;
get_state()->obj_ctx = &rados_ctx;
get_state()->sysobj_ctx = &(sysobj_ctx.get());
- get_state()->req_id = store->svc()->zone_utils->unique_id(id);
- get_state()->trans_id = store->svc()->zone_utils->unique_trans_id(id);
+ get_state()->req_id = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone_utils->unique_id(id);
+ get_state()->trans_id = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone_utils->unique_trans_id(id);
ldpp_dout(get_state(), 2) << "initializing for trans_id = "
<< get_state()->trans_id.c_str() << dendl;
}
- inline rgw::sal::RGWRadosStore* get_store() { return store; }
+ inline rgw::sal::RGWStore* get_store() { return store; }
inline RGWLibIO& get_io() { return io_ctx; }
inline RGWObjectCtx& get_octx() { return rados_ctx; }
int content_length, std::atomic<bool>* fail_flag)
{
RGWLoadGenRequest* req =
- new RGWLoadGenRequest(store->getRados()->get_new_req_id(), method, resource,
+ new RGWLoadGenRequest(store->get_new_req_id(), method, resource,
content_length, fail_flag);
dout(10) << "allocated request req=" << hex << req << dec << dendl;
req_throttle.get(1);
/* usage logger */
class UsageLogger {
CephContext *cct;
- RGWRados *store;
+ rgw::sal::RGWStore *store;
map<rgw_user_bucket, RGWUsageBatch> usage_map;
ceph::mutex lock = ceph::make_mutex("UsageLogger");
int32_t num_entries;
}
public:
- UsageLogger(CephContext *_cct, RGWRados *_store) : cct(_cct), store(_store), num_entries(0), timer(cct, timer_lock) {
+ UsageLogger(CephContext *_cct, rgw::sal::RGWStore *_store) : cct(_cct), store(_store), num_entries(0), timer(cct, timer_lock) {
timer.init();
std::lock_guard l{timer_lock};
set_timer();
static UsageLogger *usage_logger = NULL;
-void rgw_log_usage_init(CephContext *cct, RGWRados *store)
+void rgw_log_usage_init(CephContext *cct, rgw::sal::RGWStore *store)
{
usage_logger = new UsageLogger(cct, store);
}
append_output(bl);
}
-int rgw_log_op(RGWRados *store, RGWREST* const rest, struct req_state *s,
+int rgw_log_op(rgw::sal::RGWStore *store, RGWREST* const rest, struct req_state *s,
const string& op_name, OpsLogSocket *olog)
{
struct rgw_log_entry entry;
if (s->cct->_conf->rgw_ops_log_rados) {
string oid = render_log_object_name(s->cct->_conf->rgw_log_object_name, &bdt,
entry.bucket_id, entry.bucket);
-
- rgw_raw_obj obj(store->svc.zone->get_zone_params().log_pool, oid);
-
- ret = store->append_async(obj, bl.length(), bl);
- if (ret == -ENOENT) {
- ret = store->create_pool(store->svc.zone->get_zone_params().log_pool);
- if (ret < 0)
- goto done;
- // retry
- ret = store->append_async(obj, bl.length(), bl);
- }
+ ret = store->log_op(oid, bl);
}
if (olog) {
olog->log(entry);
}
-done:
if (ret < 0)
ldout(s->cct, 0) << "ERROR: failed to log entry" << dendl;
#include "rgw_common.h"
#include "common/OutputDataSocket.h"
-class RGWRados;
+namespace rgw { namespace sal {
+ class RGWStore;
+} }
struct rgw_log_entry {
class RGWREST;
-int rgw_log_op(RGWRados *store, RGWREST* const rest, struct req_state *s,
- const string& op_name, OpsLogSocket *olog);
-void rgw_log_usage_init(CephContext *cct, RGWRados *store);
+int rgw_log_op(rgw::sal::RGWStore* store, RGWREST* const rest, struct req_state* s,
+ const string& op_name, OpsLogSocket* olog);
+void rgw_log_usage_init(CephContext* cct, rgw::sal::RGWStore* store);
void rgw_log_usage_finalize();
void rgw_format_ops_log_entry(struct rgw_log_entry& entry,
ceph::Formatter *formatter);
}
-int read_script(rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx, std::string& script)
+int read_script(rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx, std::string& script)
{
- RGWSysObjectCtx obj_ctx(store->svc()->sysobj->init_obj_ctx());
+ RGWSysObjectCtx obj_ctx(static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj->init_obj_ctx());
RGWObjVersionTracker objv_tracker;
- rgw_raw_obj obj(store->svc()->zone->get_zone_params().log_pool, script_oid(ctx, tenant));
+ rgw_raw_obj obj(store->get_zone_params().log_pool, script_oid(ctx, tenant));
bufferlist bl;
return 0;
}
-int write_script(rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx, const std::string& script)
+int write_script(rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx, const std::string& script)
{
- RGWSysObjectCtx obj_ctx(store->svc()->sysobj->init_obj_ctx());
+ RGWSysObjectCtx obj_ctx(static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj->init_obj_ctx());
RGWObjVersionTracker objv_tracker;
- rgw_raw_obj obj(store->svc()->zone->get_zone_params().log_pool, script_oid(ctx, tenant));
+ rgw_raw_obj obj(store->get_zone_params().log_pool, script_oid(ctx, tenant));
bufferlist bl;
ceph::encode(script, bl);
return 0;
}
-int delete_script(rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx)
+int delete_script(rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx)
{
RGWObjVersionTracker objv_tracker;
- rgw_raw_obj obj(store->svc()->zone->get_zone_params().log_pool, script_oid(ctx, tenant));
+ rgw_raw_obj obj(store->get_zone_params().log_pool, script_oid(ctx, tenant));
const auto rc = rgw_delete_system_obj(
- store->svc()->sysobj,
+ static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj,
obj.pool,
obj.oid,
&objv_tracker,
namespace bp = boost::process;
-int add_package(rgw::sal::RGWRadosStore* store, optional_yield y, const std::string& package_name, bool allow_compilation) {
+int add_package(rgw::sal::RGWStore* store, optional_yield y, const std::string& package_name, bool allow_compilation) {
// verify that luarocks can load this oackage
const auto p = bp::search_path("luarocks");
if (p.empty()) {
std::map<std::string, bufferlist> new_package{{package_name, empty_bl}};
librados::ObjectWriteOperation op;
op.omap_set(new_package);
- ret = rgw_rados_operate(*(store->getRados()->get_lc_pool_ctx()),
+ ret = rgw_rados_operate(*(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_lc_pool_ctx()),
PACKAGE_LIST_OBJECT_NAME, &op, y);
if (ret < 0) {
return 0;
}
-int remove_package(rgw::sal::RGWRadosStore* store, optional_yield y, const std::string& package_name) {
+int remove_package(rgw::sal::RGWStore* store, optional_yield y, const std::string& package_name) {
librados::ObjectWriteOperation op;
op.omap_rm_keys(std::set<std::string>({package_name}));
- const auto ret = rgw_rados_operate(*(store->getRados()->get_lc_pool_ctx()),
+ const auto ret = rgw_rados_operate(*(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_lc_pool_ctx()),
PACKAGE_LIST_OBJECT_NAME, &op, y);
if (ret < 0) {
return 0;
}
-int list_packages(rgw::sal::RGWRadosStore* store, optional_yield y, packages_t& packages) {
+int list_packages(rgw::sal::RGWStore* store, optional_yield y, packages_t& packages) {
constexpr auto max_chunk = 1024U;
std::string start_after;
bool more = true;
librados::ObjectReadOperation op;
packages_t packages_chunk;
op.omap_get_keys2(start_after, max_chunk, &packages_chunk, &more, &rval);
- const auto ret = rgw_rados_operate(*(store->getRados()->get_lc_pool_ctx()),
+ const auto ret = rgw_rados_operate(*(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_lc_pool_ctx()),
PACKAGE_LIST_OBJECT_NAME, &op, nullptr, y);
if (ret < 0) {
return 0;
}
-int install_packages(rgw::sal::RGWRadosStore* store, optional_yield y, packages_t& failed_packages, std::string& output) {
+int install_packages(rgw::sal::RGWStore* store, optional_yield y, packages_t& failed_packages, std::string& output) {
// luarocks directory cleanup
boost::system::error_code ec;
const auto& luarocks_path = store->get_luarocks_path();
class lua_State;
class rgw_user;
namespace rgw::sal {
- class RGWRadosStore;
+ class RGWStore;
}
namespace rgw::lua {
bool verify(const std::string& script, std::string& err_msg);
// store a lua script in a context
-int write_script(rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx, const std::string& script);
+int write_script(rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx, const std::string& script);
// read the stored lua script from a context
-int read_script(rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx, std::string& script);
+int read_script(rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx, std::string& script);
// delete the stored lua script from a context
-int delete_script(rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx);
+int delete_script(rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx);
#ifdef WITH_RADOSGW_LUA_PACKAGES
#include <set>
using packages_t = std::set<std::string>;
// add a lua package to the allowlist
-int add_package(rgw::sal::RGWRadosStore* store, optional_yield y, const std::string& package_name, bool allow_compilation);
+int add_package(rgw::sal::RGWStore* store, optional_yield y, const std::string& package_name, bool allow_compilation);
// remove a lua package from the allowlist
-int remove_package(rgw::sal::RGWRadosStore* store, optional_yield y, const std::string& package_name);
+int remove_package(rgw::sal::RGWStore* store, optional_yield y, const std::string& package_name);
// list lua packages in the allowlist
-int list_packages(rgw::sal::RGWRadosStore* store, optional_yield y, packages_t& packages);
+int list_packages(rgw::sal::RGWStore* store, optional_yield y, packages_t& packages);
// install all packages from the allowlist
// return the list of packages that failed to install and the output of the install command
-int install_packages(rgw::sal::RGWRadosStore* store, optional_yield y, packages_t& failed_packages, std::string& output);
+int install_packages(rgw::sal::RGWStore* store, optional_yield y, packages_t& failed_packages, std::string& output);
#endif
}
const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(4)));
const std::string op_name(reinterpret_cast<const char*>(lua_touserdata(L, lua_upvalueindex(5))));
if (store && s) {
- const auto rc = rgw_log_op(store->getRados(), rest, s, op_name, olog);
+ const auto rc = rgw_log_op(store, rest, s, op_name, olog);
lua_pushinteger(L, rc);
} else {
ldout(s->cct, 1) << "Lua ERROR: missing rados store, cannot use ops log" << dendl;
};
int execute(
- rgw::sal::RGWRadosStore* store,
+ rgw::sal::RGWStore* store,
RGWREST* rest,
OpsLogSocket* olog,
req_state* s,
class RGWREST;
class OpsLogSocket;
namespace rgw::sal {
- class RGWRadosStore;
+ class RGWStore;
}
namespace rgw::lua::request {
// execute a lua script in the Request context
int execute(
- rgw::sal::RGWRadosStore* store,
+ rgw::sal::RGWStore* store,
RGWREST* rest,
OpsLogSocket* olog,
req_state *s,
#endif
const DoutPrefix dp(cct.get(), dout_subsys, "rgw main: ");
- rgw::sal::RGWRadosStore *store =
+ rgw::sal::RGWStore *store =
RGWStoreManager::get_storage(&dp, g_ceph_context,
+ "rados",
g_conf()->rgw_enable_gc_threads,
g_conf()->rgw_enable_lc_threads,
g_conf()->rgw_enable_quota_threads,
return -r;
}
- rgw_rest_init(g_ceph_context, store->svc()->zone->get_zonegroup());
+ rgw_rest_init(g_ceph_context, store->get_zonegroup());
mutex.lock();
init_timer.cancel_all_events();
init_timer.shutdown();
mutex.unlock();
- rgw_log_usage_init(g_ceph_context, store->getRados());
+ rgw_log_usage_init(g_ceph_context, store);
RGWREST rest;
const bool swift_at_root = g_conf()->rgw_swift_url_prefix == "/";
if (apis_map.count("s3") > 0 || s3website_enabled) {
if (! swift_at_root) {
- rest.register_default_mgr(set_logging(rest_filter(store->getRados(), RGW_REST_S3,
+ rest.register_default_mgr(set_logging(rest_filter(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados(), RGW_REST_S3,
new RGWRESTMgr_S3(s3website_enabled, sts_enabled, iam_enabled, pubsub_enabled))));
} else {
derr << "Cannot have the S3 or S3 Website enabled together with "
if (! swift_at_root) {
rest.register_resource(g_conf()->rgw_swift_url_prefix,
- set_logging(rest_filter(store->getRados(), RGW_REST_SWIFT,
+ set_logging(rest_filter(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados(), RGW_REST_SWIFT,
swift_resource)));
} else {
- if (store->svc()->zone->get_zonegroup().zones.size() > 1) {
+ if (store->get_zonegroup().zones.size() > 1) {
derr << "Placing Swift API in the root of URL hierarchy while running"
<< " multi-site configuration requires another instance of RadosGW"
<< " with S3 API enabled!" << dendl;
rgw::auth::ImplicitTenants implicit_tenant_context{g_conf()};
g_conf().add_observer(&implicit_tenant_context);
auto auth_registry = \
- rgw::auth::StrategyRegistry::create(g_ceph_context, implicit_tenant_context, store->getRados()->pctl);
+ rgw::auth::StrategyRegistry::create(g_ceph_context, implicit_tenant_context, store->get_ctl());
/* Header custom behavior */
rest.register_x_headers(g_conf()->rgw_log_http_headers);
fes.push_back(fe);
}
- r = store->getRados()->register_to_service_map("rgw", service_map_meta);
+ r = store->register_to_service_map("rgw", service_map_meta);
if (r < 0) {
derr << "ERROR: failed to register to service map: " << cpp_strerror(-r) << dendl;
auto reloader = std::make_unique<RGWRealmReloader>(store,
service_map_meta, &pauser);
- RGWRealmWatcher realm_watcher(g_ceph_context, store->svc()->zone->get_realm());
+ RGWRealmWatcher realm_watcher(g_ceph_context, store->get_realm());
realm_watcher.add_watcher(RGWRealmNotify::Reload, *reloader);
realm_watcher.add_watcher(RGWRealmNotify::ZonesNeedPeriod, pusher);
namespace rgw { namespace sal {
-class RGWRadosStore;
+class RGWStore;
} }
class RGWCoroutine;
class JSONObj;
(strncmp(uid, MULTIPART_UPLOAD_ID_PREFIX_LEGACY, sizeof(MULTIPART_UPLOAD_ID_PREFIX_LEGACY) - 1) == 0);
}
-int list_multipart_parts(rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info,
+int list_multipart_parts(rgw::sal::RGWBucket* bucket,
CephContext *cct,
const string& upload_id,
const string& meta_oid, int num_parts,
map<string, bufferlist> parts_map;
map<string, bufferlist>::iterator iter;
- rgw_obj obj;
- obj.init_ns(bucket_info.bucket, meta_oid, RGW_OBJ_NS_MULTIPART);
- obj.set_in_extra_data(true);
-
- rgw_raw_obj raw_obj;
- store->getRados()->obj_to_raw(bucket_info.placement_rule, obj, &raw_obj);
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(
+ rgw_obj_key(meta_oid, std::string(), RGW_OBJ_NS_MULTIPART));
+ obj->set_in_extra_data(true);
bool sorted_omap = is_v2_upload_id(upload_id) && !assume_unsorted;
parts.clear();
- auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
- auto sysobj = obj_ctx.get_obj(raw_obj);
int ret;
if (sorted_omap) {
string p;
snprintf(buf, sizeof(buf), "%08d", marker);
p.append(buf);
- ret = sysobj.omap().get_vals(p, num_parts + 1, &parts_map,
+ ret = obj->omap_get_vals(p, num_parts + 1, &parts_map,
nullptr, null_yield);
} else {
- ret = sysobj.omap().get_all(&parts_map, null_yield);
+ ret = obj->omap_get_all(&parts_map, null_yield);
}
if (ret < 0) {
return ret;
* where one gateway doesn't support correctly sorted omap
* keys for multipart upload just assume data is unsorted.
*/
- return list_multipart_parts(store, bucket_info, cct, upload_id,
+ return list_multipart_parts(bucket, cct, upload_id,
meta_oid, num_parts, marker, parts,
next_marker, truncated, true);
}
return 0;
}
-int list_multipart_parts(rgw::sal::RGWRadosStore *store, struct req_state *s,
+int list_multipart_parts(struct req_state *s,
const string& upload_id,
const string& meta_oid, int num_parts,
int marker, map<uint32_t, RGWUploadPartInfo>& parts,
int *next_marker, bool *truncated,
bool assume_unsorted)
{
- return list_multipart_parts(store, s->bucket->get_info(), s->cct, upload_id,
+ return list_multipart_parts(s->bucket.get(), s->cct, upload_id,
meta_oid, num_parts, marker, parts,
next_marker, truncated, assume_unsorted);
}
int abort_multipart_upload(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store, CephContext *cct,
- RGWObjectCtx *obj_ctx, RGWBucketInfo& bucket_info,
+ rgw::sal::RGWStore *store, CephContext *cct,
+ RGWObjectCtx *obj_ctx, rgw::sal::RGWBucket* bucket,
RGWMPObj& mp_obj)
{
- rgw_obj meta_obj;
- meta_obj.init_ns(bucket_info.bucket, mp_obj.get_meta(), RGW_OBJ_NS_MULTIPART);
- meta_obj.set_in_extra_data(true);
- meta_obj.index_hash_source = mp_obj.get_key();
- cls_rgw_obj_chain chain;
+ std::unique_ptr<rgw::sal::RGWObject> meta_obj = bucket->get_object(
+ rgw_obj_key(mp_obj.get_meta(), std::string(), RGW_OBJ_NS_MULTIPART));
+ meta_obj->set_in_extra_data(true);
+ meta_obj->set_hash_source(mp_obj.get_key());
+ std::unique_ptr<rgw::sal::GCChain> chain = store->get_gc_chain(meta_obj.get());
list<rgw_obj_index_key> remove_objs;
map<uint32_t, RGWUploadPartInfo> obj_parts;
bool truncated;
uint64_t parts_accounted_size = 0;
do {
- ret = list_multipart_parts(store, bucket_info, cct,
+ ret = list_multipart_parts(bucket, cct,
mp_obj.get_upload_id(), mp_obj.get_meta(),
1000, marker, obj_parts, &marker, &truncated);
if (ret < 0) {
obj_iter != obj_parts.end();
++obj_iter) {
RGWUploadPartInfo& obj_part = obj_iter->second;
- rgw_obj obj;
if (obj_part.manifest.empty()) {
string oid = mp_obj.get_part(obj_iter->second.num);
- obj.init_ns(bucket_info.bucket, oid, RGW_OBJ_NS_MULTIPART);
- obj.index_hash_source = mp_obj.get_key();
- ret = store->getRados()->delete_obj(dpp, *obj_ctx, bucket_info, obj, 0);
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(
+ rgw_obj_key(oid, std::string(), RGW_OBJ_NS_MULTIPART));
+ obj->set_hash_source(mp_obj.get_key());
+ ret = obj->delete_object(dpp, obj_ctx, null_yield);
if (ret < 0 && ret != -ENOENT)
return ret;
} else {
- store->getRados()->update_gc_chain(meta_obj, obj_part.manifest, &chain);
+ chain->update(&obj_part.manifest);
RGWObjManifest::obj_iterator oiter = obj_part.manifest.obj_begin();
if (oiter != obj_part.manifest.obj_end()) {
- rgw_obj head;
+ std::unique_ptr<rgw::sal::RGWObject> head = bucket->get_object(rgw_obj_key());
rgw_raw_obj raw_head = oiter.get_location().get_raw_obj(store);
- RGWSI_Tier_RADOS::raw_obj_to_obj(bucket_info.bucket, raw_head, &head);
+ head->raw_obj_to_obj(raw_head);
rgw_obj_index_key key;
- head.key.get_index_key(&key);
+ head->get_key().get_index_key(&key);
remove_objs.push_back(key);
}
}
} while (truncated);
/* use upload id as tag and do it synchronously */
- ret = store->getRados()->send_chain_to_gc(chain, mp_obj.get_upload_id());
+ ret = chain->send(mp_obj.get_upload_id());
if (ret < 0) {
ldpp_dout(dpp, 5) << __func__ << ": gc->send_chain() returned " << ret << dendl;
if (ret == -ENOENT) {
return -ERR_NO_SUCH_UPLOAD;
}
//Delete objects inline if send chain to gc fails
- store->getRados()->delete_objs_inline(chain, mp_obj.get_upload_id());
+ chain->delete_inline(mp_obj.get_upload_id());
}
- RGWRados::Object del_target(store->getRados(), bucket_info, *obj_ctx, meta_obj);
- RGWRados::Object::Delete del_op(&del_target);
- del_op.params.bucket_owner = bucket_info.owner;
- del_op.params.versioning_status = 0;
+ std::unique_ptr<rgw::sal::RGWObject::DeleteOp> del_op = meta_obj->get_delete_op(obj_ctx);
+ del_op->params.bucket_owner = bucket->get_acl_owner();
+ del_op->params.versioning_status = 0;
if (!remove_objs.empty()) {
- del_op.params.remove_objs = &remove_objs;
+ del_op->params.remove_objs = &remove_objs;
}
- del_op.params.abortmp = true;
- del_op.params.parts_accounted_size = parts_accounted_size;
+ del_op->params.abortmp = true;
+ del_op->params.parts_accounted_size = parts_accounted_size;
// and also remove the metadata obj
- ret = del_op.delete_obj(null_yield, dpp);
+ ret = del_op->delete_obj(dpp, null_yield);
if (ret < 0) {
ldpp_dout(dpp, 20) << __func__ << ": del_op.delete_obj returned " <<
ret << dendl;
return (ret == -ENOENT) ? -ERR_NO_SUCH_UPLOAD : ret;
}
-int list_bucket_multiparts(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info,
+int list_bucket_multiparts(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWBucket* bucket,
const string& prefix, const string& marker,
const string& delim,
const int& max_uploads,
vector<rgw_bucket_dir_entry> *objs,
map<string, bool> *common_prefixes, bool *is_truncated)
{
- RGWRados::Bucket target(store->getRados(), bucket_info);
- RGWRados::Bucket::List list_op(&target);
+ rgw::sal::RGWBucket::ListParams params;
+ rgw::sal::RGWBucket::ListResults results;
MultipartMetaFilter mp_filter;
- list_op.params.prefix = prefix;
- list_op.params.delim = delim;
- list_op.params.marker = marker;
- list_op.params.ns = RGW_OBJ_NS_MULTIPART;
- list_op.params.filter = &mp_filter;
+ params.prefix = prefix;
+ params.delim = delim;
+ params.marker = marker;
+ params.ns = RGW_OBJ_NS_MULTIPART;
+ params.filter = &mp_filter;
+
+ int ret = bucket->list(dpp, params, max_uploads, results, null_yield);
+
+ if (ret < 0)
+ return ret;
+
+ *objs = std::move(results.objs);
+ *common_prefixes = std::move(results.common_prefixes);
+ *is_truncated = results.is_truncated;
- return(list_op.list_objects(dpp, max_uploads, objs, common_prefixes, is_truncated, null_yield));
+ return ret;
}
-int abort_bucket_multiparts(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store, CephContext *cct,
- RGWBucketInfo& bucket_info, string& prefix, string& delim)
+int abort_bucket_multiparts(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store, CephContext *cct,
+ rgw::sal::RGWBucket* bucket, string& prefix, string& delim)
{
constexpr int max = 1000;
int ret, num_deleted = 0;
bool is_truncated;
do {
- ret = list_bucket_multiparts(dpp, store, bucket_info, prefix, marker, delim,
+ ret = list_bucket_multiparts(dpp, bucket, prefix, marker, delim,
max, &objs, nullptr, &is_truncated);
if (ret < 0) {
ldpp_dout(dpp, 0) << __func__ <<
" ERROR : calling list_bucket_multiparts; ret=" << ret <<
- "; bucket=\"" << bucket_info.bucket << "\"; prefix=\"" <<
+ "; bucket=\"" << bucket << "\"; prefix=\"" <<
prefix << "\"; delim=\"" << delim << "\"" << dendl;
return ret;
}
ldpp_dout(dpp, 20) << __func__ <<
" INFO: aborting and cleaning up multipart upload(s); bucket=\"" <<
- bucket_info.bucket << "\"; objs.size()=" << objs.size() <<
+ bucket << "\"; objs.size()=" << objs.size() <<
"; is_truncated=" << is_truncated << dendl;
if (!objs.empty()) {
rgw_obj_key key(obj.key);
if (!mp.from_meta(key.name))
continue;
- ret = abort_multipart_upload(dpp, store, cct, &obj_ctx, bucket_info, mp);
+ ret = abort_multipart_upload(dpp, store, cct, &obj_ctx, bucket, mp);
if (ret < 0) {
// we're doing a best-effort; if something cannot be found,
// log it and keep moving forward
#include "rgw_compression_types.h"
namespace rgw { namespace sal {
- class RGWRadosStore;
+ class RGWStore;
} }
#define MULTIPART_UPLOAD_ID_PREFIX_LEGACY "2/"
extern bool is_v2_upload_id(const string& upload_id);
-extern int list_multipart_parts(rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info,
+extern int list_multipart_parts(rgw::sal::RGWBucket* bucket,
CephContext *cct,
const string& upload_id,
const string& meta_oid, int num_parts,
int *next_marker, bool *truncated,
bool assume_unsorted = false);
-extern int list_multipart_parts(rgw::sal::RGWRadosStore *store, struct req_state *s,
+extern int list_multipart_parts(struct req_state *s,
const string& upload_id,
const string& meta_oid, int num_parts,
int marker, map<uint32_t, RGWUploadPartInfo>& parts,
int *next_marker, bool *truncated,
bool assume_unsorted = false);
-extern int abort_multipart_upload(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, CephContext *cct, RGWObjectCtx *obj_ctx,
- RGWBucketInfo& bucket_info, RGWMPObj& mp_obj);
+extern int abort_multipart_upload(const DoutPrefixProvider *dpp, rgw::sal::RGWStore *store,
+ CephContext *cct, RGWObjectCtx *obj_ctx,
+ rgw::sal::RGWBucket* bucket, RGWMPObj& mp_obj);
-extern int list_bucket_multiparts(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info,
+extern int list_bucket_multiparts(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWBucket* bucket,
const string& prefix,
const string& marker,
const string& delim,
vector<rgw_bucket_dir_entry> *objs,
map<string, bool> *common_prefixes, bool *is_truncated);
-extern int abort_bucket_multiparts(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, CephContext *cct, RGWBucketInfo& bucket_info,
- string& prefix, string& delim);
+extern int abort_bucket_multiparts(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store, CephContext *cct,
+ rgw::sal::RGWBucket* bucket,
+ string& prefix, string& delim);
#endif
#include <boost/algorithm/hex.hpp>
#include <boost/context/protected_fixedsize_stack.hpp>
#include <spawn/spawn.hpp>
+#include "rgw_sal_rados.h"
#include "rgw_pubsub.h"
#include "rgw_pubsub_push.h"
#include "rgw_perf_counters.h"
-#include "rgw_sal_rados.h"
#include "common/dout.h"
#include <chrono>
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
+// vim: ts=8 sw=2 smarttab ft=cpp
#pragma once
#define dout_subsys ceph_subsys_rgw
-static rgw::sal::RGWRadosStore *store = NULL;
+static rgw::sal::RGWStore *store = NULL;
class StoreDestructor {
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
public:
- explicit StoreDestructor(rgw::sal::RGWRadosStore *_s) : store(_s) {}
+ explicit StoreDestructor(rgw::sal::RGWStore *_s) : store(_s) {}
~StoreDestructor() {
if (store) {
RGWStoreManager::close_storage(store);
common_init_finish(g_ceph_context);
const DoutPrefix dp(cct.get(), dout_subsys, "rgw object expirer: ");
- store = RGWStoreManager::get_storage(&dp, g_ceph_context, false, false, false, false, false);
+ store = RGWStoreManager::get_storage(&dp, g_ceph_context, "rados", false, false, false, false, false);
if (!store) {
std::cerr << "couldn't init storage provider" << std::endl;
return EIO;
return 0;
}
-int RGWObjectExpirer::init_bucket_info(const string& tenant_name,
- const string& bucket_name,
- const string& bucket_id,
- RGWBucketInfo& bucket_info)
-{
- /*
- * XXX Here's where it gets tricky. We went to all the trouble of
- * punching the tenant through the objexp_hint_entry, but now we
- * find that our instances do not actually have tenants. They are
- * unique thanks to IDs. So the tenant string is not needed...
-
- * XXX reloaded: it turns out tenants were needed after all since bucket ids
- * are ephemeral, good call encoding tenant info!
- */
-
- return store->getRados()->get_bucket_info(store->svc(), tenant_name, bucket_name,
- bucket_info, nullptr, null_yield, nullptr);
-
-}
-
int RGWObjectExpirer::garbage_single_object(const DoutPrefixProvider *dpp, objexp_hint_entry& hint)
{
RGWBucketInfo bucket_info;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
- int ret = init_bucket_info(hint.tenant, hint.bucket_name,
- hint.bucket_id, bucket_info);
+ int ret = store->get_bucket(dpp, nullptr, rgw_bucket(hint.tenant, hint.bucket_name, hint.bucket_id), &bucket, null_yield);
if (-ENOENT == ret) {
ldpp_dout(dpp, 15) << "NOTICE: cannot find bucket = " \
<< hint.bucket_name << ". The object must be already removed" << dendl;
key.instance = "null";
}
- rgw_obj obj(bucket_info.bucket, key);
- store->getRados()->set_atomic(&rctx, obj);
- ret = store->getRados()->delete_obj(dpp, rctx, bucket_info, obj,
- bucket_info.versioning_status(), 0, hint.exp_time);
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(key);
+ obj->set_atomic(&rctx);
+ ret = obj->delete_object(dpp, &rctx, null_yield);
return ret;
}
ldpp_dout(dpp, 15) << "got removal hint for: " << iter->key_ts.sec() \
<< " - " << iter->key_ext << dendl;
- int ret = objexp_hint_parse(store->getRados()->ctx(), *iter, &hint);
+ int ret = objexp_hint_parse(store->ctx(), *iter, &hint);
if (ret < 0) {
ldpp_dout(dpp, 1) << "cannot parse removal hint for " << hint.obj_key << dendl;
continue;
utime_t time(max_secs, 0);
l.set_duration(time);
- int ret = l.lock_exclusive(&store->getRados()->objexp_pool_ctx, shard);
+ int ret = l.lock_exclusive(&static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->objexp_pool_ctx, shard);
if (ret == -EBUSY) { /* already locked by another processor */
ldpp_dout(dpp, 5) << __func__ << "(): failed to acquire lock on " << shard << dendl;
return false;
marker = out_marker;
} while (truncated);
- l.unlock(&store->getRados()->objexp_pool_ctx, shard);
+ l.unlock(&static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->objexp_pool_ctx, shard);
return done;
}
class RGWObjectExpirer {
protected:
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
RGWObjExpStore exp_store;
- int init_bucket_info(const std::string& tenant_name,
- const std::string& bucket_name,
- const std::string& bucket_id,
- RGWBucketInfo& bucket_info);
-
class OEWorker : public Thread, public DoutPrefixProvider {
CephContext *cct;
RGWObjectExpirer *oe;
std::atomic<bool> down_flag = { false };
public:
- explicit RGWObjectExpirer(rgw::sal::RGWRadosStore *_store)
+ explicit RGWObjectExpirer(rgw::sal::RGWStore *_store)
: store(_store),
- exp_store(_store->getRados()->ctx(), _store->svc()->rados, _store->svc()->zone),
+ exp_store(_store->ctx(), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->rados, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone),
worker(NULL) {
}
~RGWObjectExpirer() {
return true;
}
-int RGWOIDCProvider::get_providers(const DoutPrefixProvider *dpp, RGWRados *store,
- const string& tenant,
- vector<RGWOIDCProvider>& providers)
+int RGWOIDCProvider::get_providers(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore* store,
+ const string& tenant,
+ vector<RGWOIDCProvider>& providers)
{
- auto ctl = store->pctl;
+ auto ctl = store->get_ctl();
auto svc = ctl->svc;
- auto pool = store->svc.zone->get_zone_params().oidc_pool;
+ auto pool = store->get_zone_params().oidc_pool;
string prefix = tenant + oidc_url_oid_prefix;
//Get the filtered objects
return r;
}
for (const auto& iter : oids) {
- RGWOIDCProvider provider(ctl->cct, store->pctl);
+ RGWOIDCProvider provider(ctl->cct, store->get_ctl());
bufferlist bl;
auto obj_ctx = svc->sysobj->init_obj_ctx();
#include "common/ceph_context.h"
#include "common/ceph_json.h"
-#include "rgw/rgw_rados.h"
+#include "rgw/rgw_sal.h"
class RGWCtl;
void decode_json(JSONObj *obj);
static const string& get_url_oid_prefix();
- static int get_providers(const DoutPrefixProvider *dpp, RGWRados *store,
- const string& tenant,
- vector<RGWOIDCProvider>& providers);
+ static int get_providers(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore* store,
+ const string& tenant,
+ vector<RGWOIDCProvider>& providers);
};
WRITE_CLASS_ENCODER(RGWOIDCProvider)
#endif /* CEPH_RGW_OIDC_PROVIDER_H */
#include "rgw_perf_counters.h"
#include "rgw_notify.h"
#include "rgw_notify_event_type.h"
+#include "rgw_sal.h"
#include "rgw_sal_rados.h"
#include "services/svc_zone.h"
static int get_user_policy_from_attr(CephContext * const cct,
- rgw::sal::RGWRadosStore * const store,
map<string, bufferlist>& attrs,
RGWAccessControlPolicy& policy /* out */)
{
}
vector<Policy> get_iam_user_policy_from_attr(CephContext* cct,
- rgw::sal::RGWRadosStore* store,
map<string, bufferlist>& attrs,
const string& tenant) {
vector<Policy> policies;
* only_bucket: If true, reads the user and bucket ACLs rather than the object ACL.
* Returns: 0 on success, -ERR# otherwise.
*/
-int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, struct req_state* s, optional_yield y)
+int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store, struct req_state* s, optional_yield y)
{
int ret = 0;
- auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
string bi = s->info.args.get(RGW_SYS_PARAM_PREFIX "bucket-instance");
if (!bi.empty()) {
/* check if copy source is within the current domain */
if (!s->src_bucket_name.empty()) {
std::unique_ptr<rgw::sal::RGWBucket> src_bucket;
- ret = store->get_bucket(dpp, nullptr, s->src_tenant_name, s->src_bucket_name, &src_bucket, y);
- if (ret == 0) {
- ret = src_bucket->load_by_name(dpp, s->src_tenant_name, s->src_bucket_name,
- s->bucket_instance_id, &obj_ctx, s->yield);
- }
+ ret = store->get_bucket(dpp, nullptr,
+ rgw_bucket(s->src_tenant_name,
+ s->src_bucket_name,
+ s->bucket_instance_id),
+ &src_bucket, y);
if (ret == 0) {
string& zonegroup = src_bucket->get_info().zonegroup;
s->local_source = store->get_zonegroup().equals(zonegroup);
s->dest_placement.storage_class = s->info.storage_class;
s->dest_placement.inherit_from(s->bucket->get_placement_rule());
- if (!store->svc()->zone->get_zone_params().valid_placement(s->dest_placement)) {
+ if (!store->get_zone_params().valid_placement(s->dest_placement)) {
ldpp_dout(dpp, 0) << "NOTICE: invalid dest placement: " << s->dest_placement.to_str() << dendl;
return -EINVAL;
}
/* handle user ACL only for those APIs which support it */
if (s->user_acl) {
- map<string, bufferlist> uattrs;
- ret = store->ctl()->user->get_attrs_by_uid(dpp, acct_acl_user.uid, &uattrs, s->yield);
+ rgw::sal::RGWAttrs uattrs;
+ std::unique_ptr<rgw::sal::RGWUser> acl_user = store->get_user(acct_acl_user.uid);
+
+ ret = acl_user->read_attrs(dpp, y, &uattrs);
if (!ret) {
- ret = get_user_policy_from_attr(s->cct, store, uattrs, *s->user_acl);
+ ret = get_user_policy_from_attr(s->cct, uattrs, *s->user_acl);
}
if (-ENOENT == ret) {
/* In already existing clusters users won't have ACL. In such case
// hence the check for user type
if (! s->user->get_id().empty() && s->auth.identity->get_identity_type() != TYPE_ROLE) {
try {
- map<string, bufferlist> uattrs;
- if (ret = store->ctl()->user->get_attrs_by_uid(dpp, s->user->get_id(), &uattrs, s->yield); ! ret) {
- auto user_policies = get_iam_user_policy_from_attr(s->cct, store, uattrs, s->user->get_tenant());
+ rgw::sal::RGWAttrs uattrs;
+ ret = s->user->read_attrs(dpp, y, &uattrs);
+ if (ret == 0) {
+ auto user_policies = get_iam_user_policy_from_attr(s->cct, uattrs, s->user->get_tenant());
s->iam_user_policies.insert(s->iam_user_policies.end(),
std::make_move_iterator(user_policies.begin()),
std::make_move_iterator(user_policies.end()));
ret = -EACCES;
}
- bool success = store->svc()->zone->get_redirect_zone_endpoint(&s->redirect_zone_endpoint);
+ bool success = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_redirect_zone_endpoint(&s->redirect_zone_endpoint);
if (success) {
ldpp_dout(dpp, 20) << "redirect_zone_endpoint=" << s->redirect_zone_endpoint << dendl;
}
* only_bucket: If true, reads the bucket ACL rather than the object ACL.
* Returns: 0 on success, -ERR# otherwise.
*/
-int rgw_build_object_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, struct req_state *s,
- bool prefetch_data, optional_yield y)
+int rgw_build_object_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWStore *store,
+ struct req_state *s, bool prefetch_data, optional_yield y)
{
int ret = 0;
return 0;
}
-static int rgw_iam_add_existing_objtags(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, struct req_state* s, std::uint64_t action) {
+static int rgw_iam_add_existing_objtags(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store, struct req_state* s, std::uint64_t action) {
s->object->set_atomic(s->obj_ctx);
int op_ret = s->object->get_obj_attrs(s->obj_ctx, s->yield, dpp);
if (op_ret < 0)
}
}
-void rgw_build_iam_environment(rgw::sal::RGWRadosStore* store,
+void rgw_build_iam_environment(rgw::sal::RGWStore* store,
struct req_state* s)
{
const auto& m = s->info.env->get_map();
return -EPERM;
}
- if (!s->system_request && (required_mask & RGW_OP_TYPE_MODIFY) && !store->svc()->zone->zone_is_writeable()) {
+ if (!s->system_request && (required_mask & RGW_OP_TYPE_MODIFY) && !static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->zone_is_writeable()) {
ldpp_dout(this, 5) << "NOTICE: modify request to a read-only zone by a "
"non-system user, permission denied" << dendl;
return -EPERM;
return 0;
}
- rgw::sal::RGWRadosUser owner_user(store, s->bucket->get_info().owner);
+ std::unique_ptr<rgw::sal::RGWUser> owner_user =
+ store->get_user(s->bucket->get_info().owner);
rgw::sal::RGWUser* user;
if (s->user->get_id() == s->bucket_owner.get_id()) {
user = s->user.get();
} else {
- int r = owner_user.load_by_id(this, s->yield);
+ int r = owner_user->load_by_id(this, s->yield);
if (r < 0)
return r;
- user = &owner_user;
+ user = owner_user.get();
}
+ store->get_quota(bucket_quota, user_quota);
+
if (s->bucket->get_info().quota.enabled) {
bucket_quota = s->bucket->get_info().quota;
} else if (user->get_info().bucket_quota.enabled) {
bucket_quota = user->get_info().bucket_quota;
- } else {
- bucket_quota = store->svc()->quota->get_bucket_quota();
}
if (user->get_info().user_quota.enabled) {
user_quota = user->get_info().user_quota;
- } else {
- user_quota = store->svc()->quota->get_user_quota();
}
return 0;
RGWAccessControlPolicy& _bucket_acl = allocated_acls.back();
std::unique_ptr<rgw::sal::RGWBucket> tmp_bucket;
- auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
int r = store->get_bucket(this, s->user.get(), s->user->get_tenant(), bucket_name, &tmp_bucket, y);
if (r < 0) {
ldpp_dout(this, 0) << "could not get bucket info for bucket="
}
if (supports_account_metadata()) {
- op_ret = store->ctl()->user->get_attrs_by_uid(this, s->user->get_id(), &attrs, s->yield);
+ op_ret = s->user->read_attrs(this, s->yield, &attrs);
if (op_ret < 0) {
goto send_end;
}
}
}
- op_ret = rgw_user_sync_all_stats(this, store, s->user->get_id(), y);
+ op_ret = rgw_user_sync_all_stats(this, store, s->user.get(), y);
if (op_ret < 0) {
ldpp_dout(this, 0) << "ERROR: failed to sync user stats" << dendl;
return;
}
- op_ret = rgw_user_get_all_buckets_stats(this, store, s->user->get_id(), buckets_usage, y);
+ op_ret = rgw_user_get_all_buckets_stats(this, store, s->user.get(), buckets_usage, y);
if (op_ret < 0) {
ldpp_dout(this, 0) << "ERROR: failed to get user's buckets stats" << dendl;
return;
}
- op_ret = store->ctl()->user->read_stats(s->user->get_id(), &stats, y);
+ op_ret = s->user->read_stats(y, &stats);
if (op_ret < 0) {
ldpp_dout(this, 0) << "ERROR: can't read user header" << dendl;
return;
do {
lastmarker = nullptr;
- op_ret = rgw_read_user_buckets(this, store, s->user->get_id(), buckets, marker,
- string(), max_buckets, true, y);
+ op_ret = s->user->list_buckets(this, marker, string(), max_buckets, true, buckets, y);
if (op_ret < 0) {
/* hmm.. something wrong here.. the user was authenticated, so it
should exist */
- ldpp_dout(this, 10) << "WARNING: failed on rgw_read_user_buckets uid="
+ ldpp_dout(this, 10) << "WARNING: failed on list_buckets uid="
<< s->user->get_id() << " ret=" << op_ret << dendl;
break;
} else {
if (s->user->get_max_buckets()) {
rgw::sal::RGWBucketList buckets;
string marker;
- op_ret = rgw_read_user_buckets(this, store, s->user->get_id(), buckets,
- marker, string(), s->user->get_max_buckets(),
- false, y);
+ op_ret = s->user->list_buckets(this, marker, string(), s->user->get_max_buckets(),
+ false, buckets, y);
if (op_ret < 0) {
return op_ret;
}
buffer::list aclbl;
buffer::list corsbl;
string bucket_name = rgw_make_bucket_entry_name(s->bucket_tenant, s->bucket_name);
- rgw_raw_obj obj(store->svc()->zone->get_zone_params().domain_root, bucket_name);
+ rgw_raw_obj obj(store->get_zone_params().domain_root, bucket_name);
op_ret = get_params(y);
if (op_ret < 0)
if (!relaxed_region_enforcement &&
!location_constraint.empty() &&
- !store->svc()->zone->has_zonegroup_api(location_constraint)) {
+ !static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->has_zonegroup_api(location_constraint)) {
ldpp_dout(this, 0) << "location constraint (" << location_constraint << ")"
<< " can't be found." << dendl;
op_ret = -ERR_INVALID_LOCATION_CONSTRAINT;
if (s->bucket_exists) {
if (!s->system_request &&
- store->svc()->zone->get_zonegroup().get_id() != s->bucket->get_info().zonegroup) {
+ store->get_zonegroup().get_id() != s->bucket->get_info().zonegroup) {
op_ret = -EEXIST;
return;
}
}
}
- op_ret = store->ctl()->bucket->link_bucket(s->user->get_id(), s->bucket->get_key(),
- s->bucket->get_creation_time(), y, s, false);
+ op_ret = s->bucket->link(this, s->user.get(), y, false);
if (op_ret && !existed && op_ret != -EEXIST) {
/* if it exists (or previously existed), don't remove it! */
- op_ret = store->ctl()->bucket->unlink_bucket(s->user->get_id(), s->bucket->get_key(), y, this);
+ op_ret = s->bucket->unlink(this, s->user.get(), y);
if (op_ret < 0) {
ldpp_dout(this, 0) << "WARNING: failed to unlink bucket: ret=" << op_ret
<< dendl;
s->bucket->get_info().has_website = !s->bucket->get_info().website_conf.is_empty();
/* This will also set the quota on the bucket. */
- op_ret = store->ctl()->bucket->set_bucket_instance_attrs(s->bucket->get_info(), attrs,
- &s->bucket->get_info().objv_tracker,
- y, this);
+ op_ret = s->bucket->set_instance_attrs(this, attrs, y);
} while (op_ret == -ECANCELED && tries++ < 20);
/* Restore the proper return code. */
}
// make reservation for notification if needed
- rgw::notify::reservation_t res(store, s, s->object.get());
- const auto event_type = rgw::notify::ObjectCreatedPut;
- op_ret = rgw::notify::publish_reserve(event_type, res, obj_tags.get());
+ std::unique_ptr<rgw::sal::Notification> res = store->get_notification(s->object.get(),
+ s, rgw::notify::ObjectCreatedPut);
+ op_ret = res->publish_reserve(obj_tags.get());
if (op_ret < 0) {
return;
}
}
if ((! copy_source.empty()) && !copy_source_range) {
- rgw::sal::RGWRadosObject obj(store, rgw_obj_key(copy_source_object_name, copy_source_version_id));
- rgw::sal::RGWRadosBucket bucket(store, copy_source_bucket_info);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ op_ret = store->get_bucket(nullptr, copy_source_bucket_info, &bucket);
+ if (op_ret < 0) {
+ ldpp_dout(this, 0) << "ERROR: failed to get bucket with error" << op_ret << dendl;
+ return;
+ }
+ std::unique_ptr<rgw::sal::RGWObject> obj =
+ bucket->get_object(rgw_obj_key(copy_source_object_name, copy_source_version_id));
RGWObjState *astate;
- op_ret = obj.get_obj_state(this, &obj_ctx, bucket, &astate, s->yield);
+ op_ret = obj->get_obj_state(this, &obj_ctx, &astate, s->yield);
if (op_ret < 0) {
ldpp_dout(this, 0) << "ERROR: get copy source obj state returned with error" << op_ret << dendl;
return;
// no filters by default
DataProcessor *filter = processor.get();
- const auto& compression_type = store->svc()->zone->get_zone_params().get_compression_type(*pdest_placement);
+ const auto& compression_type = store->get_zone_params().get_compression_type(*pdest_placement);
CompressorRef plugin;
boost::optional<RGWPutObj_Compress> compressor;
}
// send request to notification manager
- const auto ret = rgw::notify::publish_commit(s->object.get(), s->obj_size, mtime, etag, event_type, res, this);
+ int ret = res->publish_commit(this, s->obj_size, mtime, etag);
if (ret < 0) {
ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl;
// too late to rollback operation, hence op_ret is not set here
}
// make reservation for notification if needed
- rgw::notify::reservation_t res(store, s, s->object.get());
- const auto event_type = rgw::notify::ObjectCreatedPost;
- op_ret = rgw::notify::publish_reserve(event_type, res, nullptr);
+ std::unique_ptr<rgw::sal::Notification> res = store->get_notification(s->object.get(), s, rgw::notify::ObjectCreatedPost);
+ op_ret = res->publish_reserve();
if (op_ret < 0) {
return;
}
if (encrypt != nullptr) {
filter = encrypt.get();
} else {
- const auto& compression_type = store->svc()->zone->get_zone_params().get_compression_type(
+ const auto& compression_type = store->get_zone_params().get_compression_type(
s->dest_placement);
if (compression_type != "none") {
plugin = Compressor::create(s->cct, compression_type);
} while (is_next_file_to_upload());
// send request to notification manager
- const auto ret = rgw::notify::publish_commit(s->object.get(), ofs, ceph::real_clock::now(), etag, event_type, res, this);
+ int ret = res->publish_commit(this, ofs, ceph::real_clock::now(), etag);
if (ret < 0) {
ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl;
// too late to rollback operation, hence op_ret is not set here
return op_ret;
}
- op_ret = store->ctl()->user->get_attrs_by_uid(this, s->user->get_id(), &orig_attrs,
- s->yield,
- &acct_op_tracker);
+ op_ret = s->user->read_attrs(this, y, &orig_attrs, &acct_op_tracker);
if (op_ret < 0) {
return op_ret;
}
void RGWPutMetadataAccount::execute(optional_yield y)
{
/* Params have been extracted earlier. See init_processing(). */
- RGWUserInfo new_uinfo;
- op_ret = store->ctl()->user->get_info_by_uid(this, s->user->get_id(), &new_uinfo, s->yield,
- RGWUserCtl::GetParams()
- .set_objv_tracker(&acct_op_tracker));
+ op_ret = s->user->load_by_id(this, y, RGWUserCtl::GetParams().set_objv_tracker(&acct_op_tracker));
if (op_ret < 0) {
return;
}
/* Handle the TempURL-related stuff. */
if (!temp_url_keys.empty()) {
for (auto& pair : temp_url_keys) {
- new_uinfo.temp_url_keys[pair.first] = std::move(pair.second);
+ s->user->get_info().temp_url_keys[pair.first] = std::move(pair.second);
}
}
/* Handle the quota extracted at the verify_permission step. */
if (new_quota_extracted) {
- new_uinfo.user_quota = std::move(new_quota);
+ s->user->get_info().user_quota = std::move(new_quota);
}
/* We are passing here the current (old) user info to allow the function
* optimize-out some operations. */
- op_ret = store->ctl()->user->store_info(this, new_uinfo, s->yield,
- RGWUserCtl::PutParams()
- .set_old_info(&s->user->get_info())
- .set_objv_tracker(&acct_op_tracker)
- .set_attrs(&attrs));
+ op_ret = s->user->store_info(this, y, RGWUserCtl::PutParams()
+ .set_old_info(&s->user->get_info())
+ .set_objv_tracker(&acct_op_tracker)
+ .set_attrs(&attrs));
}
int RGWPutMetadataBucket::verify_permission(optional_yield y)
}
// make reservation for notification if needed
- rgw::notify::reservation_t res(store, s, s->object.get());
const auto versioned_object = s->bucket->versioning_enabled();
const auto event_type = versioned_object && s->object->get_instance().empty() ?
rgw::notify::ObjectRemovedDeleteMarkerCreated : rgw::notify::ObjectRemovedDelete;
- op_ret = rgw::notify::publish_reserve(event_type, res, nullptr);
+ std::unique_ptr<rgw::sal::Notification> res = store->get_notification(s->object.get(),
+ s, event_type);
+ op_ret = res->publish_reserve();
if (op_ret < 0) {
return;
}
return;
}
- op_ret = s->object->delete_object(this, obj_ctx, s->owner, s->bucket_owner, unmod_since,
- s->system_request, epoch, version_id, s->yield);
+ std::unique_ptr<rgw::sal::RGWObject::DeleteOp> del_op = s->object->get_delete_op(obj_ctx);
+ del_op->params.obj_owner = s->owner;
+ del_op->params.bucket_owner = s->bucket_owner;
+ del_op->params.versioning_status = s->bucket->get_info().versioning_status();
+ del_op->params.unmod_since = unmod_since;
+ del_op->params.high_precision_time = s->system_request;
+ del_op->params.olh_epoch = epoch;
+ del_op->params.marker_version_id = version_id;
+
+ op_ret = del_op->delete_obj(this, y);
if (op_ret >= 0) {
- delete_marker = s->object->get_delete_marker();
+ delete_marker = del_op->result.delete_marker;
+ version_id = del_op->result.version_id;
}
/* Check whether the object has expired. Swift API documentation
const auto obj_state = obj_ctx->get_state(s->object->get_obj());
// send request to notification manager
- const auto ret = rgw::notify::publish_commit(s->object.get(), obj_state->size, obj_state->mtime, attrs[RGW_ATTR_ETAG].to_str(), event_type, res, this);
+ int ret = res->publish_commit(this, obj_state->size, obj_state->mtime, attrs[RGW_ATTR_ETAG].to_str());
if (ret < 0) {
ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl;
// too late to rollback operation, hence op_ret is not set here
return op_ret;
}
- /* This is a bit of a hack; create an empty bucket, then load it below. */
- op_ret = store->get_bucket(s->user.get(), RGWBucketInfo(), &src_bucket);
- if (op_ret < 0) {
- if (op_ret == -ENOENT) {
- op_ret = -ERR_NO_SUCH_BUCKET;
- }
- return op_ret;
- }
-
- op_ret = src_bucket->load_by_name(this, src_tenant_name, src_bucket_name, s->bucket_instance_id,
- s->sysobj_ctx, s->yield);
+ op_ret = store->get_bucket(this, s->user.get(),
+ rgw_bucket(src_tenant_name,
+ src_bucket_name,
+ s->bucket_instance_id),
+ &src_bucket, y);
if (op_ret < 0) {
if (op_ret == -ENOENT) {
op_ret = -ERR_NO_SUCH_BUCKET;
or intra region sync */
dest_bucket = src_bucket->clone();
} else {
- op_ret = store->get_bucket(s->user.get(), RGWBucketInfo(), &dest_bucket);
+ op_ret = store->get_bucket(this, s->user.get(), dest_tenant_name, dest_bucket_name, &dest_bucket, y);
if (op_ret < 0) {
if (op_ret == -ENOENT) {
op_ret = -ERR_NO_SUCH_BUCKET;
}
return op_ret;
}
- op_ret = dest_bucket->load_by_name(this, dest_tenant_name, dest_bucket_name, std::string(),
- s->sysobj_ctx, s->yield);
- if (op_ret < 0) {
- if (op_ret == -ENOENT) {
- op_ret = -ERR_NO_SUCH_BUCKET;
- }
- return op_ret;
- }
}
dest_object = store->get_object(rgw_obj_key(dest_obj_name));
}
// make reservation for notification if needed
- rgw::notify::reservation_t res(store, s, s->object.get());
- const auto event_type = rgw::notify::ObjectCreatedCopy;
- op_ret = rgw::notify::publish_reserve(event_type, res, nullptr);
+ std::unique_ptr<rgw::sal::Notification> res = store->get_notification(s->object.get(),
+ s, rgw::notify::ObjectCreatedPost);
+ op_ret = res->publish_reserve();
if (op_ret < 0) {
return;
}
if (!s->system_request) { // no quota enforcement for system requests
// get src object size (cached in obj_ctx from verify_permission())
RGWObjState* astate = nullptr;
- op_ret = src_object->get_obj_state(this, s->obj_ctx, *src_bucket, &astate,
- s->yield, true);
+ op_ret = src_object->get_obj_state(this, s->obj_ctx, &astate, s->yield, true);
if (op_ret < 0) {
return;
}
s->yield);
// send request to notification manager
- const auto ret = rgw::notify::publish_commit(s->object.get(), s->obj_size, mtime, etag, event_type, res, this);
+ int ret = res->publish_commit(this, s->obj_size, mtime, etag);
if (ret < 0) {
ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl;
// too late to rollback operation, hence op_ret is not set here
*_dout << dendl;
}
- op_ret = policy->rebuild(this, store->ctl()->user, &owner, new_policy, s->err.message);
+ op_ret = policy->rebuild(this, store, &owner, new_policy, s->err.message);
if (op_ret < 0)
return;
} else {
map<string,bufferlist> attrs = s->bucket_attrs;
attrs[RGW_ATTR_ACL] = bl;
- op_ret = store->ctl()->bucket->set_bucket_instance_attrs(s->bucket->get_info(), attrs,
- &s->bucket->get_info().objv_tracker,
- s->yield, this);
+ op_ret = s->bucket->set_instance_attrs(this, attrs, y);
}
if (op_ret == -ECANCELED) {
op_ret = 0; /* lost a race, but it's ok because acls are immutable */
return;
}
- op_ret = store->get_rgwlc()->set_bucket_config(s->bucket->get_info(), s->bucket_attrs, &new_config);
+ op_ret = store->get_rgwlc()->set_bucket_config(s->bucket.get(), s->bucket_attrs, &new_config);
if (op_ret < 0) {
return;
}
return;
}
- op_ret = store->get_rgwlc()->remove_bucket_config(s->bucket->get_info(), s->bucket_attrs);
+ op_ret = store->get_rgwlc()->remove_bucket_config(s->bucket.get(), s->bucket_attrs);
if (op_ret < 0) {
return;
}
}
// make reservation for notification if needed
- rgw::notify::reservation_t res(store, s, s->object.get());
- const auto event_type = rgw::notify::ObjectCreatedPost;
- op_ret = rgw::notify::publish_reserve(event_type, res, nullptr);
+ std::unique_ptr<rgw::sal::Notification> res = store->get_notification(s->object.get(),
+ s, rgw::notify::ObjectCreatedCompleteMultipartUpload);
+ op_ret = res->publish_reserve();
if (op_ret < 0) {
return;
}
} while (op_ret == -EEXIST);
// send request to notification manager
- const auto ret = rgw::notify::publish_commit(s->object.get(), s->obj_size, ceph::real_clock::now(), attrs[RGW_ATTR_ETAG].to_str(), event_type, res, this);
+ int ret = res->publish_commit(this, s->obj_size, ceph::real_clock::now(), attrs[RGW_ATTR_ETAG].to_str());
if (ret < 0) {
ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl;
// too late to rollback operation, hence op_ret is not set here
mp.init(s->object->get_name(), upload_id);
// make reservation for notification if needed
- rgw::notify::reservation_t res(store, s, s->object.get());
- const auto event_type = rgw::notify::ObjectCreatedCompleteMultipartUpload;
- op_ret = rgw::notify::publish_reserve(event_type, res, nullptr);
+ std::unique_ptr<rgw::sal::Notification> res = store->get_notification(s->object.get(),
+ s, rgw::notify::ObjectCreatedCompleteMultipartUpload);
+ op_ret = res->publish_reserve();
if (op_ret < 0) {
return;
}
attrs = meta_obj->get_attrs();
do {
- op_ret = list_multipart_parts(store, s, upload_id, meta_oid, max_parts,
+ op_ret = list_multipart_parts(s, upload_id, meta_oid, max_parts,
marker, obj_parts, &marker, &truncated);
if (op_ret == -ENOENT) {
op_ret = -ERR_NO_SUCH_UPLOAD;
op_ret = -ERR_INVALID_PART;
return;
} else {
- manifest.append(obj_part.manifest, store->svc()->zone);
+ manifest.append(obj_part.manifest, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone);
}
bool part_compressed = (obj_part.cs_info.compression_type != "none");
return;
// remove the upload obj
- string version_id;
- int r = meta_obj->delete_object(this, s->obj_ctx, ACLOwner(), ACLOwner(), ceph::real_time(), false, 0, version_id, null_yield);
+ int r = meta_obj->delete_object(this, s->obj_ctx, y);
if (r >= 0) {
/* serializer's exclusive lock is released */
serializer->clear_locked();
}
// send request to notification manager
- const auto ret = rgw::notify::publish_commit(s->object.get(), ofs, ceph::real_clock::now(), final_etag_str, event_type, res, this);
+ int ret = res->publish_commit(this, ofs, ceph::real_clock::now(), final_etag_str);
if (ret < 0) {
ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl;
// too late to rollback operation, hence op_ret is not set here
return;
RGWObjectCtx *obj_ctx = static_cast<RGWObjectCtx *>(s->obj_ctx);
- op_ret = abort_multipart_upload(this, store, s->cct, obj_ctx, s->bucket->get_info(), mp);
+ op_ret = abort_multipart_upload(this, store, s->cct, obj_ctx, s->bucket.get(), mp);
}
int RGWListMultipart::verify_permission(optional_yield y)
if (op_ret < 0)
return;
- op_ret = list_multipart_parts(store, s, upload_id, meta_oid, max_parts,
+ op_ret = list_multipart_parts(s, upload_id, meta_oid, max_parts,
marker, parts, NULL, &truncated);
}
}
marker_meta = marker.get_meta();
- op_ret = list_bucket_multiparts(this, store, s->bucket->get_info(), prefix, marker_meta, delimiter,
+ op_ret = list_bucket_multiparts(this, s->bucket.get(), prefix, marker_meta, delimiter,
max_uploads, &objs, &common_prefixes, &is_truncated);
if (op_ret < 0) {
return;
}
// make reservation for notification if needed
const auto versioned_object = s->bucket->versioning_enabled();
- rgw::notify::reservation_t res(store, s, obj.get());
const auto event_type = versioned_object && obj->get_instance().empty() ?
rgw::notify::ObjectRemovedDeleteMarkerCreated : rgw::notify::ObjectRemovedDelete;
- op_ret = rgw::notify::publish_reserve(event_type, res, nullptr);
+ std::unique_ptr<rgw::sal::Notification> res = store->get_notification(obj.get(),
+ s, event_type);
+ op_ret = res->publish_reserve();
if (op_ret < 0) {
send_partial_response(*iter, false, "", op_ret);
continue;
obj->set_atomic(obj_ctx);
- op_ret = obj->delete_object(this, obj_ctx, s->owner, s->bucket_owner, ceph::real_time(),
- false, 0, version_id, s->yield);
+ std::unique_ptr<rgw::sal::RGWObject::DeleteOp> del_op = obj->get_delete_op(obj_ctx);
+ del_op->params.versioning_status = obj->get_bucket()->get_info().versioning_status();
+ del_op->params.obj_owner = s->owner;
+ del_op->params.bucket_owner = s->bucket_owner;
+ del_op->params.marker_version_id = version_id;
+
+ op_ret = del_op->delete_obj(this, y);
if (op_ret == -ENOENT) {
op_ret = 0;
}
- send_partial_response(*iter, obj->get_delete_marker(), version_id, op_ret);
+ send_partial_response(*iter, obj->get_delete_marker(), del_op->result.version_id, op_ret);
const auto obj_state = obj_ctx->get_state(obj->get_obj());
bufferlist etag_bl;
const auto etag = obj_state->get_attr(RGW_ATTR_ETAG, etag_bl) ? etag_bl.to_str() : "";
// send request to notification manager
- const auto ret = rgw::notify::publish_commit(obj.get(), obj_state->size, obj_state->mtime, etag, event_type, res, this);
+ int ret = res->publish_commit(this, obj_state->size, obj_state->mtime, etag);
if (ret < 0) {
ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl;
// too late to rollback operation, hence op_ret is not set here
if (!path.obj_key.empty()) {
ACLOwner bucket_owner;
- std::string version_id;
bucket_owner.set_id(bucket->get_info().owner);
std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(path.obj_key);
obj->set_atomic(s->obj_ctx);
- ret = obj->delete_object(dpp, s->obj_ctx, bowner, bucket_owner, ceph::real_time(), false, 0, version_id, s->yield);
+ std::unique_ptr<rgw::sal::RGWObject::DeleteOp> del_op = obj->get_delete_op(s->obj_ctx);
+ del_op->params.versioning_status = obj->get_bucket()->get_info().versioning_status();
+ del_op->params.obj_owner = bowner;
+ del_op->params.bucket_owner = bucket_owner;
+
+ ret = del_op->delete_obj(dpp, y);
if (ret < 0) {
goto delop_fail;
}
if (s->user->get_max_buckets() > 0) {
rgw::sal::RGWBucketList buckets;
std::string marker;
- op_ret = rgw_read_user_buckets(this, store, s->user->get_user(), buckets,
- marker, std::string(), s->user->get_max_buckets(),
- false, y);
+ op_ret = s->user->list_buckets(this, marker, std::string(), s->user->get_max_buckets(),
+ false, buckets, y);
if (op_ret < 0) {
return op_ret;
}
info.effective_uri = "/" + bucket_name;
}
-void RGWBulkUploadOp::init(rgw::sal::RGWRadosStore* const store,
+void RGWBulkUploadOp::init(rgw::sal::RGWStore* const store,
struct req_state* const s,
RGWHandler* const h)
{
RGWOp::init(store, s, h);
- dir_ctx.emplace(store->svc()->sysobj->init_obj_ctx());
}
int RGWBulkUploadOp::handle_dir(const std::string_view path, optional_yield y)
rgw_obj_key object_junk;
std::tie(bucket_name, object_junk) = *parse_path(path);
- rgw_raw_obj obj(store->svc()->zone->get_zone_params().domain_root,
+ rgw_raw_obj obj(store->get_zone_params().domain_root,
rgw_make_bucket_entry_name(s->bucket_tenant, bucket_name));
/* we need to make sure we read bucket info, it's not read before for this
ldpp_dout(this, 20) << "conflicting bucket name" << dendl;
return op_ret;
}
- new_bucket = out_info.bucket;
}
- op_ret = store->ctl()->bucket->link_bucket(s->user->get_id(), new_bucket,
- out_info.creation_time,
- s->yield, s, false);
+ op_ret = bucket->link(this, s->user.get(), y, false);
if (op_ret && !existed && op_ret != -EEXIST) {
/* if it exists (or previously existed), don't remove it! */
- op_ret = store->ctl()->bucket->unlink_bucket(s->user->get_id(), new_bucket, s->yield, this);
+ op_ret = bucket->unlink(this, s->user.get(), y);
if (op_ret < 0) {
ldpp_dout(this, 0) << "WARNING: failed to unlink bucket: ret=" << op_ret << dendl;
}
/* No filters by default. */
DataProcessor *filter = &processor;
- const auto& compression_type = store->svc()->zone->get_zone_params().get_compression_type(
+ const auto& compression_type = store->get_zone_params().get_compression_type(
dest_placement);
CompressorRef plugin;
boost::optional<RGWPutObj_Compress> compressor;
for (auto& iter : attrs) {
s->bucket_attrs[iter.first] = std::move(iter.second);
}
- op_ret = store->ctl()->bucket->set_bucket_instance_attrs(
- s->bucket->get_info(), attrs, &s->bucket->get_info().objv_tracker,
- s->yield, this);
+ op_ret = s->bucket->set_instance_attrs(this, attrs, y);
}
} /* RGWSetAttrs::execute() */
{
}
-int RGWHandler::init(rgw::sal::RGWRadosStore *_store,
+int RGWHandler::init(rgw::sal::RGWStore *_store,
struct req_state *_s,
rgw::io::BasicClient *cio)
{
class RGWHandler {
protected:
- rgw::sal::RGWRadosStore* store{nullptr};
+ rgw::sal::RGWStore* store{nullptr};
struct req_state *s{nullptr};
int do_init_permissions(const DoutPrefixProvider *dpp, optional_yield y);
RGWHandler() {}
virtual ~RGWHandler();
- virtual int init(rgw::sal::RGWRadosStore* store,
+ virtual int init(rgw::sal::RGWStore* store,
struct req_state* _s,
rgw::io::BasicClient* cio);
protected:
struct req_state *s;
RGWHandler *dialect_handler;
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
RGWCORSConfiguration bucket_cors;
bool cors_exist;
RGWQuotaInfo bucket_quota;
return 0;
}
- virtual void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *dialect_handler) {
+ virtual void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *dialect_handler) {
this->store = store;
this->s = s;
this->dialect_handler = dialect_handler;
unsigned int num_unfound;
std::list<fail_desc_t> failures;
- rgw::sal::RGWRadosStore * const store;
+ rgw::sal::RGWStore * const store;
req_state * const s;
public:
- Deleter(const DoutPrefixProvider* dpp, rgw::sal::RGWRadosStore * const str, req_state * const s)
+ Deleter(const DoutPrefixProvider* dpp, rgw::sal::RGWStore * const str, req_state * const s)
: dpp(dpp),
num_deleted(0),
num_unfound(0),
class RGWBulkUploadOp : public RGWOp {
- boost::optional<RGWSysObjectCtx> dir_ctx;
-
protected:
class fail_desc_t {
public:
: num_created(0) {
}
- void init(rgw::sal::RGWRadosStore* const store,
+ void init(rgw::sal::RGWStore* const store,
struct req_state* const s,
RGWHandler* const h) override;
std::string end_marker;
int64_t limit;
uint64_t limit_max;
- std::map<std::string, ceph::bufferlist> attrs;
+ rgw::sal::RGWAttrs attrs;
bool is_truncated;
RGWUsageStats global_stats;
void pre_exec() override;
void execute(optional_yield y) override;
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWOp::init(store, s, h);
}
virtual int get_params(optional_yield y) = 0;
int verify_permission(optional_yield y) override;
void pre_exec() override;
void execute(optional_yield y) override;
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWOp::init(store, s, h);
policy.set_ctx(s->cct);
relaxed_region_enforcement =
delete obj_legal_hold;
}
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWOp::init(store, s, h);
policy.set_ctx(s->cct);
}
attrs.emplace(std::move(key), std::move(bl)); /* key and bl are r-value refs */
}
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWOp::init(store, s, h);
policy.set_ctx(s->cct);
}
has_policy(false) {
}
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWOp::init(store, s, h);
policy.set_ctx(s->cct);
}
attrs.emplace(std::move(key), std::move(bl)); /* key and bl are r-value refs */
}
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWOp::init(store, s, h);
policy.set_ctx(s->cct);
}
: dlo_manifest(NULL)
{}
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWOp::init(store, s, h);
policy.set_ctx(s->cct);
}
attrs.emplace(std::move(key), std::move(bl));
}
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWOp::init(store, s, h);
dest_policy.set_ctx(s->cct);
}
void pre_exec() override;
void execute(optional_yield y) override;
- virtual int get_policy_from_state(rgw::sal::RGWRadosStore *store, struct req_state *s, stringstream& ss) { return 0; }
+ virtual int get_policy_from_state(rgw::sal::RGWStore *store, struct req_state *s, stringstream& ss) { return 0; }
virtual int get_params(optional_yield y) = 0;
void send_response() override = 0;
const char* name() const override { return "put_acls"; }
}
~RGWPutLC() override {}
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *dialect_handler) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *dialect_handler) override {
#define COOKIE_LEN 16
char buf[COOKIE_LEN + 1];
public:
RGWInitMultipart() {}
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWOp::init(store, s, h);
policy.set_ctx(s->cct);
}
truncated = false;
}
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWOp::init(store, s, h);
policy = RGWAccessControlPolicy(s->cct);
}
default_max = 0;
}
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWOp::init(store, s, h);
max_uploads = default_max;
}
uint32_t op_mask() override { return RGW_OP_TYPE_READ; }
};
-extern int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, struct req_state* s, optional_yield y);
-extern int rgw_build_object_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, struct req_state *s,
- bool prefetch_data, optional_yield y);
-extern void rgw_build_iam_environment(rgw::sal::RGWRadosStore* store,
- struct req_state* s);
+extern int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store,
+ struct req_state* s, optional_yield y);
+extern int rgw_build_object_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWStore *store,
+ struct req_state *s, bool prefetch_data, optional_yield y);
+extern void rgw_build_iam_environment(rgw::sal::RGWStore* store,
+ struct req_state* s);
extern vector<rgw::IAM::Policy> get_iam_user_policy_from_attr(CephContext* cct,
- rgw::sal::RGWRadosStore* store,
map<string, bufferlist>& attrs,
const string& tenant);
public:
RGWGetClusterStat() {}
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWOp::init(store, s, h);
}
int verify_permission(optional_yield) override {return 0;}
int RGWOrphanStore::init()
{
- const rgw_pool& log_pool = store->svc()->zone->get_zone_params().log_pool;
- int r = rgw_init_ioctx(store->getRados()->get_rados_handle(), log_pool, ioctx);
+ const rgw_pool& log_pool = store->get_zone_params().log_pool;
+ int r = rgw_init_ioctx(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_rados_handle(), log_pool, ioctx);
if (r < 0) {
cerr << "ERROR: failed to open log pool (" << log_pool << " ret=" << r << std::endl;
return r;
{
librados::IoCtx ioctx;
- int ret = rgw_init_ioctx(store->getRados()->get_rados_handle(), search_info.pool, ioctx);
+ int ret = rgw_init_ioctx(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_rados_handle(), search_info.pool, ioctx);
if (ret < 0) {
lderr(store->ctx()) << __func__ << ": rgw_init_ioctx() returned ret=" << ret << dendl;
return ret;
void *handle;
int max = 1000;
string section = "bucket.instance";
- int ret = store->ctl()->meta.mgr->list_keys_init(section, &handle);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init(section, &handle);
if (ret < 0) {
lderr(store->ctx()) << "ERROR: can't get key: " << cpp_strerror(-ret) << dendl;
return ret;
do {
list<string> keys;
- ret = store->ctl()->meta.mgr->list_keys_next(handle, max, keys, &truncated);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, max, keys, &truncated);
if (ret < 0) {
lderr(store->ctx()) << "ERROR: lists_keys_next(): " << cpp_strerror(-ret) << dendl;
return ret;
lderr(store->ctx()) << __func__ << ": ERROR: log_oids() returned ret=" << ret << dendl;
return ret;
}
- store->ctl()->meta.mgr->list_keys_complete(handle);
+ static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
return 0;
}
-int RGWOrphanSearch::handle_stat_result(map<int, list<string> >& oids, RGWRados::Object::Stat::Result& result)
+int RGWOrphanSearch::handle_stat_result(map<int, list<string> >& oids, rgw::sal::RGWObject::StatOp::Result& result)
{
set<string> obj_oids;
- rgw_bucket& bucket = result.obj.bucket;
+ rgw::sal::RGWBucket* bucket = result.obj->get_bucket();
if (!result.manifest) { /* a very very old object, or part of a multipart upload during upload */
- const string loc = bucket.bucket_id + "_" + result.obj.get_oid();
+ const string loc = bucket->get_bucket_id() + "_" + result.obj->get_oid();
obj_oids.insert(obj_fingerprint(loc));
/*
return 0;
}
-int RGWOrphanSearch::pop_and_handle_stat_op(map<int, list<string> >& oids, std::deque<RGWRados::Object::Stat>& ops)
+int RGWOrphanSearch::pop_and_handle_stat_op(map<int, list<string> >& oids, std::deque<std::unique_ptr<rgw::sal::RGWObject::StatOp>>& ops)
{
- RGWRados::Object::Stat& front_op = ops.front();
+ rgw::sal::RGWObject::StatOp* front_op = ops.front().get();
- int ret = front_op.wait();
+ int ret = front_op->wait();
if (ret < 0) {
if (ret != -ENOENT) {
lderr(store->ctx()) << "ERROR: stat_async() returned error: " << cpp_strerror(-ret) << dendl;
}
goto done;
}
- ret = handle_stat_result(oids, front_op.result);
+ ret = handle_stat_result(oids, front_op->result);
if (ret < 0) {
lderr(store->ctx()) << "ERROR: handle_stat_response() returned error: " << cpp_strerror(-ret) << dendl;
}
int RGWOrphanSearch::build_linked_oids_for_bucket(const DoutPrefixProvider *dpp, const string& bucket_instance_id, map<int, list<string> >& oids)
{
RGWObjectCtx obj_ctx(store);
- auto sysobj_ctx = store->svc()->sysobj->init_obj_ctx();
-
rgw_bucket orphan_bucket;
int shard_id;
int ret = rgw_bucket_parse_bucket_key(store->ctx(), bucket_instance_id,
return ret;
}
- RGWBucketInfo cur_bucket_info;
- ret = store->getRados()->get_bucket_info(store->svc(), orphan_bucket.tenant,
- orphan_bucket.name, cur_bucket_info, nullptr, null_yield, dpp);
+ std::unique_ptr<rgw::sal::RGWBucket> cur_bucket;
+ ret = store->get_bucket(dpp, nullptr, orphan_bucket, &cur_bucket, null_yield);
if (ret < 0) {
if (ret == -ENOENT) {
/* probably raced with bucket removal */
return ret;
}
- if (cur_bucket_info.bucket.bucket_id != orphan_bucket.bucket_id) {
+ if (cur_bucket->get_bucket_id() != orphan_bucket.bucket_id) {
ldpp_dout(dpp, 0) << __func__ << ": Skipping stale bucket instance: "
<< orphan_bucket.name << ": "
<< orphan_bucket.bucket_id << dendl;
return 0;
}
- if (cur_bucket_info.reshard_status == cls_rgw_reshard_status::IN_PROGRESS) {
+ if (cur_bucket->get_info().reshard_status == cls_rgw_reshard_status::IN_PROGRESS) {
ldpp_dout(dpp, 0) << __func__ << ": reshard in progress. Skipping "
<< orphan_bucket.name << ": "
<< orphan_bucket.bucket_id << dendl;
return 0;
}
- RGWBucketInfo bucket_info;
- ret = store->getRados()->get_bucket_instance_info(sysobj_ctx, bucket_instance_id, bucket_info, nullptr, nullptr, null_yield, dpp);
+ rgw_bucket b;
+ rgw_bucket_parse_bucket_key(store->ctx(), bucket_instance_id, &b, nullptr);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ ret = store->get_bucket(dpp, nullptr, b, &bucket, null_yield);
if (ret < 0) {
if (ret == -ENOENT) {
/* probably raced with bucket removal */
}
ldpp_dout(dpp, 10) << "building linked oids for bucket instance: " << bucket_instance_id << dendl;
- RGWRados::Bucket target(store->getRados(), bucket_info);
- RGWRados::Bucket::List list_op(&target);
+ rgw::sal::RGWBucket::ListParams params;
+ rgw::sal::RGWBucket::ListResults results;
string marker;
- list_op.params.marker = rgw_obj_key(marker);
- list_op.params.list_versions = true;
- list_op.params.enforce_ns = false;
-
- bool truncated;
+ params.marker = rgw_obj_key(marker);
+ params.list_versions = true;
+ params.enforce_ns = false;
- deque<RGWRados::Object::Stat> stat_ops;
+ std::deque<std::unique_ptr<rgw::sal::RGWObject>> objs;
+ std::deque<std::unique_ptr<rgw::sal::RGWObject::StatOp>> stat_ops;
do {
- vector<rgw_bucket_dir_entry> result;
-
- ret = list_op.list_objects(dpp, max_list_bucket_entries,
- &result, nullptr, &truncated, null_yield);
+ ret = bucket->list(dpp, params, max_list_bucket_entries, results, null_yield);
if (ret < 0) {
cerr << "ERROR: store->list_objects(): " << cpp_strerror(-ret) << std::endl;
return ret;
}
- for (vector<rgw_bucket_dir_entry>::iterator iter = result.begin(); iter != result.end(); ++iter) {
+ for (vector<rgw_bucket_dir_entry>::iterator iter = results.objs.begin(); iter != results.objs.end(); ++iter) {
rgw_bucket_dir_entry& entry = *iter;
if (entry.key.instance.empty()) {
ldpp_dout(dpp, 20) << "obj entry: " << entry.key.name << dendl;
continue;
}
- rgw_obj obj(bucket_info.bucket, entry.key);
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(entry.key);
+ std::unique_ptr<rgw::sal::RGWObject::StatOp> stat_op = obj->get_stat_op(&obj_ctx);
+ rgw::sal::RGWObject::StatOp* op = stat_op.get();
- RGWRados::Object op_target(store->getRados(), bucket_info, obj_ctx, obj);
+ objs.push_back(std::move(obj));
+ stat_ops.push_back(std::move(stat_op));
- stat_ops.push_back(RGWRados::Object::Stat(&op_target));
- RGWRados::Object::Stat& op = stat_ops.back();
-
- ret = op.stat_async();
+ ret = op->stat_async();
if (ret < 0) {
lderr(store->ctx()) << "ERROR: stat_async() returned error: " << cpp_strerror(-ret) << dendl;
return ret;
oids.clear();
}
}
- } while (truncated);
+ } while (results.is_truncated);
while (!stat_ops.empty()) {
ret = pop_and_handle_stat_op(oids, stat_ops);
librados::IoCtx data_ioctx;
- int ret = rgw_init_ioctx(store->getRados()->get_rados_handle(), search_info.pool, data_ioctx);
+ int ret = rgw_init_ioctx(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_rados_handle(), search_info.pool, data_ioctx);
if (ret < 0) {
lderr(store->ctx()) << __func__ << ": rgw_init_ioctx() returned ret=" << ret << dendl;
return ret;
}
-int RGWRadosList::handle_stat_result(RGWRados::Object::Stat::Result& result,
+int RGWRadosList::handle_stat_result(rgw::sal::RGWObject::StatOp::Result& result,
std::string& bucket_name,
rgw_obj_key& obj_key,
std::set<string>& obj_oids)
{
obj_oids.clear();
- rgw_bucket& bucket = result.obj.bucket;
+ rgw::sal::RGWBucket* bucket = result.obj->get_bucket();
ldout(store->ctx(), 20) << "RGWRadosList::" << __func__ <<
" bucket=" << bucket <<
- ", has_manifest=" << result.manifest.has_value() <<
+ ", has_manifest=" << !!result.manifest <<
dendl;
// iterator to store result of dlo/slo attribute find
- decltype(result.attrs)::iterator attr_it = result.attrs.end();
- const std::string oid = bucket.marker + "_" + result.obj.get_oid();
+ auto attr_it = result.obj->get_attrs().end();
+ const std::string oid = bucket->get_marker() + "_" + result.obj->get_oid();
ldout(store->ctx(), 20) << "radoslist processing object=\"" <<
oid << "\"" << dendl;
if (visited_oids.find(oid) != visited_oids.end()) {
return 0;
}
- bucket_name = bucket.name;
- obj_key = result.obj.key;
+ bucket_name = bucket->get_name();
+ obj_key = result.obj->get_key();
if (!result.manifest) {
/* a very very old object, or part of a multipart upload during upload */
* object; we'll process them in
* RGWRadosList::do_incomplete_multipart
*/
- } else if ((attr_it = result.attrs.find(RGW_ATTR_USER_MANIFEST)) !=
- result.attrs.end()) {
+ } else if ((attr_it = result.obj->get_attrs().find(RGW_ATTR_USER_MANIFEST)) !=
+ result.obj->get_attrs().end()) {
// *** handle DLO object ***
obj_oids.insert(oid);
ldout(store->ctx(), 25) << "radoslist DLO oid=\"" << oid <<
"\" added bucket=\"" << bucket_name << "\" prefix=\"" <<
prefix << "\" to process list" << dendl;
- } else if ((attr_it = result.attrs.find(RGW_ATTR_SLO_MANIFEST)) !=
- result.attrs.end()) {
+ } else if ((attr_it = result.obj->get_attrs().find(RGW_ATTR_SLO_MANIFEST)) !=
+ result.obj->get_attrs().end()) {
// *** handle SLO object ***
obj_oids.insert(oid);
int RGWRadosList::pop_and_handle_stat_op(
RGWObjectCtx& obj_ctx,
- std::deque<RGWRados::Object::Stat>& ops)
+ std::deque<std::unique_ptr<rgw::sal::RGWObject::StatOp>>& ops)
{
std::string bucket_name;
rgw_obj_key obj_key;
std::set<std::string> obj_oids;
- RGWRados::Object::Stat& front_op = ops.front();
+ std::unique_ptr<rgw::sal::RGWObject::StatOp> front_op = std::move(ops.front());
- int ret = front_op.wait();
+ int ret = front_op->wait();
if (ret < 0) {
if (ret != -ENOENT) {
lderr(store->ctx()) << "ERROR: stat_async() returned error: " <<
goto done;
}
- ret = handle_stat_result(front_op.result, bucket_name, obj_key, obj_oids);
+ ret = handle_stat_result(front_op->result, bucket_name, obj_key, obj_oids);
if (ret < 0) {
lderr(store->ctx()) << "ERROR: handle_stat_result() returned error: " <<
cpp_strerror(-ret) << dendl;
// invalidate object context for this object to avoid memory leak
// (see pr https://github.com/ceph/ceph/pull/30174)
- obj_ctx.invalidate(front_op.result.obj);
+ obj_ctx.invalidate(front_op->result.obj->get_obj());
ops.pop_front();
return ret;
", prefix=" << prefix <<
", entries_filter.size=" << entries_filter.size() << dendl;
- RGWBucketInfo bucket_info;
- RGWSysObjectCtx sys_obj_ctx = store->svc()->sysobj->init_obj_ctx();
- int ret = store->getRados()->get_bucket_instance_info(sys_obj_ctx,
- bucket_instance_id,
- bucket_info,
- nullptr,
- nullptr,
- null_yield,
- dpp);
+ rgw_bucket b;
+ rgw_bucket_parse_bucket_key(store->ctx(), bucket_instance_id, &b, nullptr);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ int ret = store->get_bucket(dpp, nullptr, b, &bucket, null_yield);
if (ret < 0) {
if (ret == -ENOENT) {
// probably raced with bucket removal
return ret;
}
- RGWRados::Bucket target(store->getRados(), bucket_info);
- RGWRados::Bucket::List list_op(&target);
+ rgw::sal::RGWBucket::ListParams params;
+ rgw::sal::RGWBucket::ListResults results;
std::string marker;
- list_op.params.marker = rgw_obj_key(marker);
- list_op.params.list_versions = true;
- list_op.params.enforce_ns = false;
- list_op.params.allow_unordered = false;
- list_op.params.prefix = prefix;
-
- bool truncated;
-
- std::deque<RGWRados::Object::Stat> stat_ops;
+ params.marker = rgw_obj_key(marker);
+ params.list_versions = true;
+ params.enforce_ns = false;
+ params.allow_unordered = false;
+ params.prefix = prefix;
+
+ std::deque<std::unique_ptr<rgw::sal::RGWObject>> objs;
+ std::deque<std::unique_ptr<rgw::sal::RGWObject::StatOp>> stat_ops;
std::string prev_versioned_key_name = "";
RGWObjectCtx obj_ctx(store);
do {
- std::vector<rgw_bucket_dir_entry> result;
-
constexpr int64_t LIST_OBJS_MAX_ENTRIES = 100;
- ret = list_op.list_objects(dpp, LIST_OBJS_MAX_ENTRIES, &result,
- NULL, &truncated, null_yield);
+ ret = bucket->list(dpp, params, LIST_OBJS_MAX_ENTRIES, results, null_yield);
if (ret == -ENOENT) {
// race with bucket delete?
ret = 0;
return ret;
}
- for (std::vector<rgw_bucket_dir_entry>::iterator iter = result.begin();
- iter != result.end();
+ for (std::vector<rgw_bucket_dir_entry>::iterator iter = results.objs.begin();
+ iter != results.objs.end();
++iter) {
rgw_bucket_dir_entry& entry = *iter;
[&](const rgw_obj_key& key) -> int {
int ret;
- rgw_obj obj(bucket_info.bucket, key);
+ std::unique_ptr<rgw::sal::RGWObject> obj = bucket->get_object(key);
+ std::unique_ptr<rgw::sal::RGWObject::StatOp> stat_op = obj->get_stat_op(&obj_ctx);
+ rgw::sal::RGWObject::StatOp* op = stat_op.get();
- RGWRados::Object op_target(store->getRados(), bucket_info,
- obj_ctx, obj);
+ objs.push_back(std::move(obj));
+ stat_ops.push_back(std::move(stat_op));
- stat_ops.push_back(RGWRados::Object::Stat(&op_target));
- RGWRados::Object::Stat& op = stat_ops.back();
-
- ret = op.stat_async();
+ ret = op->stat_async();
if (ret < 0) {
lderr(store->ctx()) << "ERROR: stat_async() returned error: " <<
cpp_strerror(-ret) << dendl;
return ret;
}
} // for iter loop
- } while (truncated);
+ } while (results.is_truncated);
while (!stat_ops.empty()) {
ret = pop_and_handle_stat_op(obj_ctx, stat_ops);
int ret;
void* handle = nullptr;
- ret = store->ctl()->meta.mgr->list_keys_init("bucket", &handle);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init("bucket", &handle);
if (ret < 0) {
lderr(store->ctx()) << "RGWRadosList::" << __func__ <<
" ERROR: list_keys_init returned " <<
do {
std::list<std::string> buckets;
- ret = store->ctl()->meta.mgr->list_keys_next(handle, max_keys,
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, max_keys,
buckets, &truncated);
for (std::string& bucket_id : buckets) {
int RGWRadosList::run(const DoutPrefixProvider *dpp, const std::string& start_bucket_name)
{
- RGWSysObjectCtx sys_obj_ctx = store->svc()->sysobj->init_obj_ctx();
RGWObjectCtx obj_ctx(store);
- RGWBucketInfo bucket_info;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
int ret;
add_bucket_entire(start_bucket_name);
std::swap(process, front->second);
bucket_process_map.erase(front);
- RGWBucketInfo bucket_info;
- ret = store->getRados()->get_bucket_info(store->svc(),
- tenant_name,
- bucket_name,
- bucket_info,
- nullptr,
- null_yield,
- dpp);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ ret = store->get_bucket(dpp, nullptr, tenant_name, bucket_name, &bucket, null_yield);
if (ret == -ENOENT) {
std::cerr << "WARNING: bucket " << bucket_name <<
" does not exist; could it have been deleted very recently?" <<
return ret;
}
- const std::string bucket_id = bucket_info.bucket.get_key();
+ const std::string bucket_id = bucket->get_key().get_key();
static const std::set<rgw_obj_key> empty_filter;
static const std::string empty_prefix;
// now handle incomplete multipart uploads by going back to the
// initial bucket
- ret = store->getRados()->get_bucket_info(store->svc(),
- tenant_name,
- start_bucket_name,
- bucket_info,
- nullptr,
- null_yield,
- dpp);
+ ret = store->get_bucket(dpp, nullptr, tenant_name, start_bucket_name, &bucket, null_yield);
if (ret == -ENOENT) {
// bucket deletion race?
return 0;
return ret;
}
- ret = do_incomplete_multipart(dpp, store, bucket_info);
+ ret = do_incomplete_multipart(dpp, bucket.get());
if (ret < 0) {
lderr(store->ctx()) << "RGWRadosList::" << __func__ <<
": ERROR: do_incomplete_multipart returned ret=" << ret << dendl;
} // RGWRadosList::run(string)
-int RGWRadosList::do_incomplete_multipart(
- const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore* store,
- RGWBucketInfo& bucket_info)
+int RGWRadosList::do_incomplete_multipart(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWBucket* bucket)
{
constexpr int max_uploads = 1000;
constexpr int max_parts = 1000;
int ret;
- RGWRados::Bucket target(store->getRados(), bucket_info);
- RGWRados::Bucket::List list_op(&target);
- list_op.params.ns = mp_ns;
- list_op.params.filter = &mp_filter;
- // use empty string for initial list_op.params.marker
- // use empty strings for list_op.params.{prefix,delim}
+ rgw::sal::RGWBucket::ListParams params;
+ rgw::sal::RGWBucket::ListResults results;
- bool is_listing_truncated;
+ params.ns = mp_ns;
+ params.filter = &mp_filter;
+ // use empty string for initial params.marker
+ // use empty strings for params.{prefix,delim}
do {
- std::vector<rgw_bucket_dir_entry> objs;
- std::map<string, bool> common_prefixes;
- ret = list_op.list_objects(dpp, max_uploads, &objs, &common_prefixes,
- &is_listing_truncated, null_yield);
+ ret = bucket->list(dpp, params, max_uploads, results, null_yield);
if (ret == -ENOENT) {
// could bucket have been removed while this is running?
ldpp_dout(dpp, 20) << "RGWRadosList::" << __func__ <<
return ret;
}
- if (!objs.empty()) {
+ if (!results.objs.empty()) {
std::vector<RGWMultipartUploadEntry> uploads;
RGWMultipartUploadEntry entry;
- for (const rgw_bucket_dir_entry& obj : objs) {
+ for (const rgw_bucket_dir_entry& obj : results.objs) {
const rgw_obj_key& key = obj.key;
if (!entry.mp.from_meta(key.name)) {
// we only want the meta objects, so skip all the components
for (const auto& upload : uploads) {
const RGWMPObj& mp = upload.mp;
- ret = list_multipart_parts(store, bucket_info, store->ctx(),
+ ret = list_multipart_parts(bucket, store->ctx(),
mp.get_upload_id(), mp.get_meta(),
max_parts,
parts_marker, parts, NULL, &is_parts_truncated);
}
}
} while (is_parts_truncated);
- } // if objs not empty
- } while (is_listing_truncated);
+ } // if results.objs not empty
+ } while (results.is_truncated);
return 0;
} // RGWRadosList::do_incomplete_multipart
WRITE_CLASS_ENCODER(RGWOrphanSearchState)
class RGWOrphanStore {
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
librados::IoCtx ioctx;
string oid;
public:
- explicit RGWOrphanStore(rgw::sal::RGWRadosStore *_store) : store(_store), oid(RGW_ORPHAN_INDEX_OID) {}
+ explicit RGWOrphanStore(rgw::sal::RGWStore *_store) : store(_store), oid(RGW_ORPHAN_INDEX_OID) {}
librados::IoCtx& get_ioctx() { return ioctx; }
class RGWOrphanSearch {
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
RGWOrphanStore orphan_store;
return ceph_str_hash_linux(str.c_str(), str.size()) % RGW_ORPHANSEARCH_HASH_PRIME % search_info.num_shards;
}
- int handle_stat_result(map<int, list<string> >& oids, RGWRados::Object::Stat::Result& result);
- int pop_and_handle_stat_op(map<int, list<string> >& oids, std::deque<RGWRados::Object::Stat>& ops);
+ int handle_stat_result(map<int, list<string> >& oids, rgw::sal::RGWObject::StatOp::Result& result);
+ int pop_and_handle_stat_op(map<int, list<string> >& oids, std::deque<std::unique_ptr<rgw::sal::RGWObject::StatOp>>& ops);
int remove_index(map<int, string>& index);
public:
- RGWOrphanSearch(rgw::sal::RGWRadosStore *_store, int _max_ios, uint64_t _stale_secs) : store(_store), orphan_store(store), max_concurrent_ios(_max_ios), stale_secs(_stale_secs) {}
+ RGWOrphanSearch(rgw::sal::RGWStore *_store, int _max_ios, uint64_t _stale_secs) : store(_store), orphan_store(store), max_concurrent_ios(_max_ios), stale_secs(_stale_secs) {}
int save_state() {
RGWOrphanSearchState state;
p.first->second.filter_keys.insert(obj_key);
}
- rgw::sal::RGWRadosStore* store;
+ rgw::sal::RGWStore* store;
uint16_t max_concurrent_ios;
uint64_t stale_secs;
bool include_rgw_obj_name;
std::string field_separator;
- int handle_stat_result(RGWRados::Object::Stat::Result& result,
+ int handle_stat_result(rgw::sal::RGWObject::StatOp::Result& result,
std::string& bucket_name,
rgw_obj_key& obj_key,
std::set<string>& obj_oids);
int pop_and_handle_stat_op(RGWObjectCtx& obj_ctx,
- std::deque<RGWRados::Object::Stat>& ops);
+ std::deque<std::unique_ptr<rgw::sal::RGWObject::StatOp>>& ops);
public:
- RGWRadosList(rgw::sal::RGWRadosStore* _store,
+ RGWRadosList(rgw::sal::RGWStore* _store,
int _max_ios,
uint64_t _stale_secs,
const std::string& _tenant_name) :
const std::string& prefix,
const std::set<rgw_obj_key>& entries_filter);
- int do_incomplete_multipart(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore* store,
- RGWBucketInfo& bucket_info);
+ int do_incomplete_multipart(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWBucket* bucket);
int build_linked_oids_index();
namespace rgw {
/* static */
- int RGWHandler_Lib::init_from_header(rgw::sal::RGWRadosStore *store,
+ int RGWHandler_Lib::init_from_header(rgw::sal::RGWStore *store,
struct req_state *s)
{
string req;
#define CEPH_RGW_OTP_H
namespace rgw { namespace sal {
-class RGWRadosStore;
+class RGWStore;
} }
#include "cls/otp/cls_otp_types.h"
};
-RGWPeriodPusher::RGWPeriodPusher(rgw::sal::RGWRadosStore* store,
+RGWPeriodPusher::RGWPeriodPusher(rgw::sal::RGWStore* store,
optional_yield y)
: cct(store->ctx()), store(store)
{
- const auto& realm = store->svc()->zone->get_realm();
+ const auto& realm = store->get_realm();
auto& realm_id = realm.get_id();
if (realm_id.empty()) // no realm configuration
return;
// always send out the current period on startup
RGWPeriod period;
- int r = period.init(cct, store->svc()->sysobj, realm_id, y, realm.get_name());
+ // XXX dang
+ int r = period.init(cct, static_cast<rgw::sal::RGWRadosStore *>(store)->svc()->sysobj, realm_id, y, realm.get_name());
if (r < 0) {
lderr(cct) << "failed to load period for realm " << realm_id << dendl;
return;
// find our zonegroup in the new period
auto& zonegroups = period.get_map().zonegroups;
- auto i = zonegroups.find(store->svc()->zone->get_zonegroup().get_id());
+ auto i = zonegroups.find(store->get_zonegroup().get_id());
if (i == zonegroups.end()) {
lderr(cct) << "The new period does not contain my zonegroup!" << dendl;
return;
auto& my_zonegroup = i->second;
// if we're not a master zone, we're not responsible for pushing any updates
- if (my_zonegroup.master_zone != store->svc()->zone->get_zone_params().get_id())
+ if (my_zonegroup.master_zone != store->get_zone_params().get_id())
return;
// construct a map of the zones that need this period. the map uses the same
auto hint = conns.end();
// are we the master zonegroup in this period?
- if (period.get_map().master_zonegroup == store->svc()->zone->get_zonegroup().get_id()) {
+ if (period.get_map().master_zonegroup == store->get_zonegroup().get_id()) {
// update other zonegroup endpoints
for (auto& zg : zonegroups) {
auto& zonegroup = zg.second;
- if (zonegroup.get_id() == store->svc()->zone->get_zonegroup().get_id())
+ if (zonegroup.get_id() == store->get_zonegroup().get_id())
continue;
if (zonegroup.endpoints.empty())
continue;
hint = conns.emplace_hint(
hint, std::piecewise_construct,
std::forward_as_tuple(zonegroup.get_id()),
- std::forward_as_tuple(cct, store->svc()->zone, zonegroup.get_id(), zonegroup.endpoints));
+ std::forward_as_tuple(cct, store, zonegroup.get_id(), zonegroup.endpoints));
}
}
// update other zone endpoints
for (auto& z : my_zonegroup.zones) {
auto& zone = z.second;
- if (zone.id == store->svc()->zone->get_zone_params().get_id())
+ if (zone.id == store->get_zone_params().get_id())
continue;
if (zone.endpoints.empty())
continue;
hint = conns.emplace_hint(
hint, std::piecewise_construct,
std::forward_as_tuple(zone.id),
- std::forward_as_tuple(cct, store->svc()->zone, zone.id, zone.endpoints));
+ std::forward_as_tuple(cct, store, zone.id, zone.endpoints));
}
if (conns.empty()) {
store = nullptr;
}
-void RGWPeriodPusher::resume(rgw::sal::RGWRadosStore* store)
+void RGWPeriodPusher::resume(rgw::sal::RGWStore* store)
{
std::lock_guard<std::mutex> lock(mutex);
this->store = store;
namespace rgw {
namespace sal {
-class RGWRadosStore;
+class RGWStore;
}
}
class RGWPeriodPusher final : public RGWRealmWatcher::Watcher,
public RGWRealmReloader::Pauser {
public:
- explicit RGWPeriodPusher(rgw::sal::RGWRadosStore* store, optional_yield y);
+ explicit RGWPeriodPusher(rgw::sal::RGWStore* store, optional_yield y);
~RGWPeriodPusher() override;
/// respond to realm notifications by pushing new periods to other zones
void pause() override;
/// continue processing notifications with a new RGWRados instance
- void resume(rgw::sal::RGWRadosStore* store) override;
+ void resume(rgw::sal::RGWStore* store) override;
private:
void handle_notify(RGWZonesNeedPeriod&& period);
CephContext *const cct;
- rgw::sal::RGWRadosStore* store;
+ rgw::sal::RGWStore* store;
std::mutex mutex;
epoch_t realm_epoch{0}; //< the current realm epoch being sent
return 0;
}
-int process_request(rgw::sal::RGWRadosStore* const store,
+int process_request(rgw::sal::RGWStore* const store,
RGWREST* const rest,
RGWRequest* const req,
const std::string& frontend_prefix,
RGWObjectCtx rados_ctx(store, s);
s->obj_ctx = &rados_ctx;
- auto sysobj_ctx = store->svc()->sysobj->init_obj_ctx();
+ auto sysobj_ctx = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj->init_obj_ctx();
s->sysobj_ctx = &sysobj_ctx;
if (ret < 0) {
return ret;
}
- s->req_id = store->svc()->zone_utils->unique_id(req->id);
- s->trans_id = store->svc()->zone_utils->unique_trans_id(req->id);
- s->host_id = store->getRados()->host_id;
+ s->req_id = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone_utils->unique_id(req->id);
+ s->trans_id = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone_utils->unique_trans_id(req->id);
+ s->host_id = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->host_id;
s->yield = yield;
ldpp_dout(s, 2) << "initializing for trans_id = " << s->trans_id << dendl;
}
if (should_log) {
- rgw_log_op(store->getRados(), rest, s, (op ? op->name() : "unknown"), olog);
+ rgw_log_op(store, rest, s, (op ? op->name() : "unknown"), olog);
}
if (http_ret != nullptr) {
}
struct RGWProcessEnv {
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
RGWREST *rest;
OpsLogSocket *olog;
int port;
deque<RGWRequest*> m_req_queue;
protected:
CephContext *cct;
- rgw::sal::RGWRadosStore* store;
+ rgw::sal::RGWStore* store;
rgw_auth_registry_ptr_t auth_registry;
OpsLogSocket* olog;
ThreadPool m_tp;
m_tp.pause();
}
- void unpause_with_new_config(rgw::sal::RGWRadosStore* const store,
+ void unpause_with_new_config(rgw::sal::RGWStore* const store,
rgw_auth_registry_ptr_t auth_registry) {
this->store = store;
this->auth_registry = std::move(auth_registry);
void set_access_key(RGWAccessKey& key) { access_key = key; }
};
/* process stream request */
-extern int process_request(rgw::sal::RGWRadosStore* store,
+extern int process_request(rgw::sal::RGWStore* store,
RGWREST* rest,
RGWRequest* req,
const std::string& frontend_prefix,
#ifndef CEPH_RGW_PUBSUB_H
#define CEPH_RGW_PUBSUB_H
-#include "rgw_sal.h"
#include "services/svc_sys_obj.h"
#include "rgw_tools.h"
#include "rgw_zone.h"
#include "rgw_notify_event_type.h"
#include <boost/container/flat_map.hpp>
+namespace rgw::sal { class RGWRadosStore; }
+
class XMLObj;
struct rgw_s3_key_filter {
class Pipe : public DataProcessor {
DataProcessor *next;
public:
+ explicit Pipe() : next(nullptr) {}
explicit Pipe(DataProcessor *next) : next(next) {}
// passes the data on to the next processor
uint64_t chunk_size;
bufferlist chunk; // leftover bytes from the last call to process()
public:
+ ChunkProcessor() {}
ChunkProcessor(DataProcessor *next, uint64_t chunk_size)
: Pipe(next), chunk_size(chunk_size)
{}
StripeGenerator *gen;
std::pair<uint64_t, uint64_t> bounds; // bounds of current stripe
public:
+ StripeProcessor() {}
StripeProcessor(DataProcessor *next, StripeGenerator *gen,
uint64_t first_stripe_size)
: Pipe(next), gen(gen), bounds(0, first_stripe_size)
return processor->process(std::move(data), write_offset);
}
-
-static int process_completed(const AioResultList& completed, RawObjSet *written)
-{
- std::optional<int> error;
- for (auto& r : completed) {
- if (r.result >= 0) {
- written->insert(r.obj.get_ref().obj);
- } else if (!error) { // record first error code
- error = r.result;
- }
- }
- return error.value_or(0);
-}
-
-int RadosWriter::set_stripe_obj(const rgw_raw_obj& raw_obj)
-{
- stripe_obj = store->svc()->rados->obj(raw_obj);
- return stripe_obj.open();
-}
-
-int RadosWriter::process(bufferlist&& bl, uint64_t offset)
-{
- bufferlist data = std::move(bl);
- const uint64_t cost = data.length();
- if (cost == 0) { // no empty writes, use aio directly for creates
- return 0;
- }
- librados::ObjectWriteOperation op;
- if (offset == 0) {
- op.write_full(data);
- } else {
- op.write(offset, data);
- }
- constexpr uint64_t id = 0; // unused
- auto c = aio->get(stripe_obj, Aio::librados_op(std::move(op), y), cost, id);
- return process_completed(c, &written);
-}
-
-int RadosWriter::write_exclusive(const bufferlist& data)
-{
- const uint64_t cost = data.length();
-
- librados::ObjectWriteOperation op;
- op.create(true); // exclusive create
- op.write_full(data);
-
- constexpr uint64_t id = 0; // unused
- auto c = aio->get(stripe_obj, Aio::librados_op(std::move(op), y), cost, id);
- auto d = aio->drain();
- c.splice(c.end(), d);
- return process_completed(c, &written);
-}
-
-int RadosWriter::drain()
-{
- return process_completed(aio->drain(), &written);
-}
-
-RadosWriter::~RadosWriter()
-{
- // wait on any outstanding aio completions
- process_completed(aio->drain(), &written);
-
- bool need_to_remove_head = false;
- std::optional<rgw_raw_obj> raw_head;
- if (!rgw::sal::RGWObject::empty(head_obj.get())) {
- raw_head.emplace();
- head_obj->get_raw_obj(&*raw_head);
- }
-
- /**
- * We should delete the object in the "multipart" namespace to avoid race condition.
- * Such race condition is caused by the fact that the multipart object is the gatekeeper of a multipart
- * upload, when it is deleted, a second upload would start with the same suffix("2/"), therefore, objects
- * written by the second upload may be deleted by the first upload.
- * details is describled on #11749
- *
- * The above comment still stands, but instead of searching for a specific object in the multipart
- * namespace, we just make sure that we remove the object that is marked as the head object after
- * we remove all the other raw objects. Note that we use different call to remove the head object,
- * as this one needs to go via the bucket index prepare/complete 2-phase commit scheme.
- */
- for (const auto& obj : written) {
- if (raw_head && obj == *raw_head) {
- ldpp_dout(dpp, 5) << "NOTE: we should not process the head object (" << obj << ") here" << dendl;
- need_to_remove_head = true;
- continue;
- }
-
- int r = store->delete_raw_obj(obj);
- if (r < 0 && r != -ENOENT) {
- ldpp_dout(dpp, 0) << "WARNING: failed to remove obj (" << obj << "), leaked" << dendl;
- }
- }
-
- if (need_to_remove_head) {
- std::string version_id;
- ldpp_dout(dpp, 5) << "NOTE: we are going to process the head obj (" << *raw_head << ")" << dendl;
- int r = head_obj->delete_object(dpp, &obj_ctx, ACLOwner(), bucket->get_acl_owner(), ceph::real_time(),
- false, 0, version_id, null_yield);
- if (r < 0 && r != -ENOENT) {
- ldpp_dout(dpp, 0) << "WARNING: failed to remove obj (" << *raw_head << "), leaked" << dendl;
- }
- }
-}
-
-
// advance to the next stripe
int ManifestObjectProcessor::next(uint64_t offset, uint64_t *pstripe_size)
{
if (r < 0) {
return r;
}
- r = writer.set_stripe_obj(stripe_obj);
+ r = writer->set_stripe_obj(stripe_obj);
if (r < 0) {
return r;
}
- chunk = ChunkProcessor(&writer, chunk_size);
+ chunk = ChunkProcessor(writer.get(), chunk_size);
*pstripe_size = manifest_gen.cur_stripe_max_size();
return 0;
}
rgw_raw_obj stripe_obj = manifest_gen.get_cur_obj(store);
- r = writer.set_stripe_obj(stripe_obj);
+ r = writer->set_stripe_obj(stripe_obj);
if (r < 0) {
return r;
}
set_head_chunk_size(head_max_size);
// initialize the processors
- chunk = ChunkProcessor(&writer, chunk_size);
+ chunk = ChunkProcessor(writer.get(), chunk_size);
stripe = StripeProcessor(&chunk, this, head_max_size);
return 0;
}
rgw_zone_set *zones_trace,
bool *pcanceled, optional_yield y)
{
- int r = writer.drain();
+ int r = writer->drain();
if (r < 0) {
return r;
}
}
if (!obj_op->params.canceled) {
// on success, clear the set of objects for deletion
- writer.clear_written();
+ writer->clear_written();
}
if (pcanceled) {
*pcanceled = obj_op->params.canceled;
{
// write the first chunk of the head object as part of an exclusive create,
// then drain to wait for the result in case of EEXIST
- int r = writer.write_exclusive(data);
+ int r = writer->write_exclusive(data);
if (r == -EEXIST) {
// randomize the oid prefix and reprepare the head/manifest
std::string oid_rand = gen_rand_alphanumeric(store->ctx(), 32);
return r;
}
// resubmit the write op on the new head object
- r = writer.write_exclusive(data);
+ r = writer->write_exclusive(data);
}
if (r < 0) {
return r;
head_obj->raw_obj_to_obj(stripe_obj);
head_obj->set_hash_source(target_obj->get_name());
- r = writer.set_stripe_obj(stripe_obj);
+ r = writer->set_stripe_obj(stripe_obj);
if (r < 0) {
return r;
}
stripe_size = manifest_gen.cur_stripe_max_size();
set_head_chunk_size(stripe_size);
- chunk = ChunkProcessor(&writer, chunk_size);
+ chunk = ChunkProcessor(writer.get(), chunk_size);
stripe = StripeProcessor(&chunk, this, stripe_size);
return 0;
}
rgw_zone_set *zones_trace,
bool *pcanceled, optional_yield y)
{
- int r = writer.drain();
+ int r = writer->drain();
if (r < 0) {
return r;
}
if (!obj_op->params.canceled) {
// on success, clear the set of objects for deletion
- writer.clear_written();
+ writer->clear_written();
}
if (pcanceled) {
*pcanceled = obj_op->params.canceled;
int AppendObjectProcessor::process_first_chunk(bufferlist &&data, rgw::putobj::DataProcessor **processor)
{
- int r = writer.write_exclusive(data);
+ int r = writer->write_exclusive(data);
if (r < 0) {
return r;
}
int AppendObjectProcessor::prepare(optional_yield y)
{
RGWObjState *astate;
- int r = head_obj->get_obj_state(dpp, &obj_ctx, *bucket, &astate, y);
+ int r = head_obj->get_obj_state(dpp, &obj_ctx, &astate, y);
if (r < 0) {
return r;
}
if (r < 0) {
return r;
}
- r = writer.set_stripe_obj(std::move(stripe_obj));
+ r = writer->set_stripe_obj(std::move(stripe_obj));
if (r < 0) {
return r;
}
set_head_chunk_size(max_head_size);
// initialize the processors
- chunk = ChunkProcessor(&writer, chunk_size);
+ chunk = ChunkProcessor(writer.get(), chunk_size);
stripe = StripeProcessor(&chunk, this, stripe_size);
return 0;
const string *user_data, rgw_zone_set *zones_trace, bool *pcanceled,
optional_yield y)
{
- int r = writer.drain();
+ int r = writer->drain();
if (r < 0)
return r;
const uint64_t actual_size = get_actual_size();
//For Append obj, disable versioning
obj_op->params.versioning_disabled = true;
if (cur_manifest) {
- cur_manifest->append(manifest, store->svc()->zone);
+ cur_manifest->append(manifest, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone);
obj_op->params.manifest = cur_manifest;
} else {
obj_op->params.manifest = &manifest;
}
if (!obj_op->params.canceled) {
// on success, clear the set of objects for deletion
- writer.clear_written();
+ writer->clear_written();
}
if (pcanceled) {
*pcanceled = obj_op->params.canceled;
};
-using RawObjSet = std::set<rgw_raw_obj>;
-
-// a data sink that writes to rados objects and deletes them on cancelation
-class RadosWriter : public DataProcessor {
- Aio *const aio;
- rgw::sal::RGWRadosStore *const store;
- rgw::sal::RGWBucket* bucket;
- RGWObjectCtx& obj_ctx;
- std::unique_ptr<rgw::sal::RGWObject> head_obj;
- RGWSI_RADOS::Obj stripe_obj; // current stripe object
- RawObjSet written; // set of written objects for deletion
- const DoutPrefixProvider *dpp;
- optional_yield y;
-
- public:
- RadosWriter(Aio *aio, rgw::sal::RGWRadosStore *store,
- rgw::sal::RGWBucket* bucket,
- RGWObjectCtx& obj_ctx, std::unique_ptr<rgw::sal::RGWObject> _head_obj,
- const DoutPrefixProvider *dpp, optional_yield y)
- : aio(aio), store(store), bucket(bucket),
- obj_ctx(obj_ctx), head_obj(std::move(_head_obj)), dpp(dpp), y(y)
- {}
- RadosWriter(RadosWriter&& r)
- : aio(r.aio), store(r.store), bucket(r.bucket),
- obj_ctx(r.obj_ctx), head_obj(std::move(r.head_obj)), dpp(r.dpp), y(r.y)
- {}
-
- ~RadosWriter();
-
- // change the current stripe object
- int set_stripe_obj(const rgw_raw_obj& obj);
-
- // write the data at the given offset of the current stripe object
- int process(bufferlist&& data, uint64_t stripe_offset) override;
-
- // write the data as an exclusive create and wait for it to complete
- int write_exclusive(const bufferlist& data);
-
- int drain();
-
- // when the operation completes successfully, clear the set of written objects
- // so they aren't deleted on destruction
- void clear_written() { written.clear(); }
-
-};
-
// a rados object processor that stripes according to RGWObjManifest
class ManifestObjectProcessor : public HeadObjectProcessor,
public StripeGenerator {
protected:
- rgw::sal::RGWRadosStore *const store;
+ rgw::sal::RGWStore *const store;
rgw::sal::RGWBucket* bucket;
rgw_placement_rule tail_placement_rule;
rgw_user owner;
RGWObjectCtx& obj_ctx;
std::unique_ptr<rgw::sal::RGWObject> head_obj;
- RadosWriter writer;
+ std::unique_ptr<rgw::sal::Writer> writer;
RGWObjManifest manifest;
RGWObjManifest::generator manifest_gen;
ChunkProcessor chunk;
int next(uint64_t offset, uint64_t *stripe_size) override;
public:
- ManifestObjectProcessor(Aio *aio, rgw::sal::RGWRadosStore *store,
+ ManifestObjectProcessor(Aio *aio, rgw::sal::RGWStore *store,
rgw::sal::RGWBucket* bucket,
const rgw_placement_rule *ptail_placement_rule,
const rgw_user& owner, RGWObjectCtx& obj_ctx,
store(store), bucket(bucket),
owner(owner),
obj_ctx(obj_ctx), head_obj(std::move(_head_obj)),
- writer(aio, store, bucket, obj_ctx, head_obj->clone(), dpp, y),
- chunk(&writer, 0), stripe(&chunk, this, 0), dpp(dpp) {
+ dpp(dpp) {
+ writer = store->get_writer(aio, bucket, obj_ctx, head_obj->clone(), dpp, y);
+ chunk = ChunkProcessor(writer.get(), 0);
+ stripe = StripeProcessor(&chunk, this, 0);
if (ptail_placement_rule) {
tail_placement_rule = *ptail_placement_rule;
}
int process_first_chunk(bufferlist&& data, DataProcessor **processor) override;
public:
- AtomicObjectProcessor(Aio *aio, rgw::sal::RGWRadosStore *store,
+ AtomicObjectProcessor(Aio *aio, rgw::sal::RGWStore *store,
rgw::sal::RGWBucket* bucket,
const rgw_placement_rule *ptail_placement_rule,
const rgw_user& owner,
// prepare the head stripe and manifest
int prepare_head();
public:
- MultipartObjectProcessor(Aio *aio, rgw::sal::RGWRadosStore *store,
+ MultipartObjectProcessor(Aio *aio, rgw::sal::RGWStore *store,
rgw::sal::RGWBucket* bucket,
const rgw_placement_rule *ptail_placement_rule,
const rgw_user& owner, RGWObjectCtx& obj_ctx,
int process_first_chunk(bufferlist&& data, DataProcessor **processor) override;
public:
- AppendObjectProcessor(Aio *aio, rgw::sal::RGWRadosStore *store,
+ AppendObjectProcessor(Aio *aio, rgw::sal::RGWStore *store,
rgw::sal::RGWBucket* bucket,
const rgw_placement_rule *ptail_placement_rule,
const rgw_user& owner, RGWObjectCtx& obj_ctx,
template<class T>
class RGWQuotaCache {
protected:
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
lru_map<T, RGWQuotaCacheStats> stats_map;
RefCountedWaitObject *async_refcount;
virtual void data_modified(const rgw_user& user, rgw_bucket& bucket) {}
public:
- RGWQuotaCache(rgw::sal::RGWRadosStore *_store, int size) : store(_store), stats_map(size) {
+ RGWQuotaCache(rgw::sal::RGWStore *_store, int size) : store(_store), stats_map(size) {
async_refcount = new RefCountedWaitObject;
}
virtual ~RGWQuotaCache() {
class AsyncRefreshHandler {
protected:
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
RGWQuotaCache<T> *cache;
public:
- AsyncRefreshHandler(rgw::sal::RGWRadosStore *_store, RGWQuotaCache<T> *_cache) : store(_store), cache(_cache) {}
+ AsyncRefreshHandler(rgw::sal::RGWStore *_store, RGWQuotaCache<T> *_cache) : store(_store), cache(_cache) {}
virtual ~AsyncRefreshHandler() {}
virtual int init_fetch() = 0;
public RGWGetBucketStats_CB {
rgw_user user;
public:
- BucketAsyncRefreshHandler(rgw::sal::RGWRadosStore *_store, RGWQuotaCache<rgw_bucket> *_cache,
+ BucketAsyncRefreshHandler(rgw::sal::RGWStore *_store, RGWQuotaCache<rgw_bucket> *_cache,
const rgw_user& _user, const rgw_bucket& _bucket) :
RGWQuotaCache<rgw_bucket>::AsyncRefreshHandler(_store, _cache),
RGWGetBucketStats_CB(_bucket), user(_user) {}
int BucketAsyncRefreshHandler::init_fetch()
{
- RGWBucketInfo bucket_info;
-
- auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
+ std::unique_ptr<rgw::sal::RGWBucket> rbucket;
const DoutPrefix dp(store->ctx(), dout_subsys, "rgw bucket async refresh handler: ");
- int r = store->getRados()->get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, NULL, null_yield, &dp);
+ int r = store->get_bucket(&dp, nullptr, bucket, &rbucket, null_yield);
if (r < 0) {
ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket << " r=" << r << dendl;
return r;
ldout(store->ctx(), 20) << "initiating async quota refresh for bucket=" << bucket << dendl;
- r = store->getRados()->get_bucket_stats_async(bucket_info, RGW_NO_SHARD, this);
+ r = rbucket->get_bucket_stats_async(RGW_NO_SHARD, this);
if (r < 0) {
ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket.name << dendl;
int fetch_stats_from_storage(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, optional_yield y, const DoutPrefixProvider *dpp) override;
public:
- explicit RGWBucketStatsCache(rgw::sal::RGWRadosStore *_store) : RGWQuotaCache<rgw_bucket>(_store, _store->ctx()->_conf->rgw_bucket_quota_cache_size) {
+ explicit RGWBucketStatsCache(rgw::sal::RGWStore *_store) : RGWQuotaCache<rgw_bucket>(_store, _store->ctx()->_conf->rgw_bucket_quota_cache_size) {
}
AsyncRefreshHandler *allocate_refresh_handler(const rgw_user& user, const rgw_bucket& bucket) override {
}
};
-int RGWBucketStatsCache::fetch_stats_from_storage(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, optional_yield y, const DoutPrefixProvider *dpp)
+int RGWBucketStatsCache::fetch_stats_from_storage(const rgw_user& _u, const rgw_bucket& _b, RGWStorageStats& stats, optional_yield y, const DoutPrefixProvider *dpp)
{
- RGWBucketInfo bucket_info;
-
- RGWSysObjectCtx obj_ctx = store->svc()->sysobj->init_obj_ctx();
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(_u);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
- int r = store->getRados()->get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, NULL, y, dpp);
+ int r = store->get_bucket(dpp, user.get(), _b, &bucket, y);
if (r < 0) {
- ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket << " r=" << r << dendl;
+ ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << _b << " r=" << r << dendl;
return r;
}
string master_ver;
map<RGWObjCategory, RGWStorageStats> bucket_stats;
- r = store->getRados()->get_bucket_stats(bucket_info, RGW_NO_SHARD, &bucket_ver,
- &master_ver, bucket_stats, nullptr);
+ r = bucket->get_bucket_stats(RGW_NO_SHARD, &bucket_ver, &master_ver, bucket_stats);
if (r < 0) {
ldout(store->ctx(), 0) << "could not get bucket stats for bucket="
- << bucket.name << dendl;
+ << _b.name << dendl;
return r;
}
public RGWGetUserStats_CB {
rgw_bucket bucket;
public:
- UserAsyncRefreshHandler(rgw::sal::RGWRadosStore *_store, RGWQuotaCache<rgw_user> *_cache,
+ UserAsyncRefreshHandler(rgw::sal::RGWStore *_store, RGWQuotaCache<rgw_user> *_cache,
const rgw_user& _user, const rgw_bucket& _bucket) :
RGWQuotaCache<rgw_user>::AsyncRefreshHandler(_store, _cache),
RGWGetUserStats_CB(_user),
int UserAsyncRefreshHandler::init_fetch()
{
+ std::unique_ptr<rgw::sal::RGWUser> ruser = store->get_user(user);
+
ldout(store->ctx(), 20) << "initiating async quota refresh for user=" << user << dendl;
- int r = store->ctl()->user->read_stats_async(user, this);
+ int r = ruser->read_stats_async(this);
if (r < 0) {
ldout(store->ctx(), 0) << "could not get bucket info for user=" << user << dendl;
}
public:
- RGWUserStatsCache(rgw::sal::RGWRadosStore *_store, bool quota_threads)
+ RGWUserStatsCache(rgw::sal::RGWStore *_store, bool quota_threads)
: RGWQuotaCache<rgw_user>(_store, _store->ctx()->_conf->rgw_bucket_quota_cache_size)
{
if (quota_threads) {
}
};
-int RGWUserStatsCache::fetch_stats_from_storage(const rgw_user& user,
- const rgw_bucket& bucket,
+int RGWUserStatsCache::fetch_stats_from_storage(const rgw_user& _u,
+ const rgw_bucket& _b,
RGWStorageStats& stats,
optional_yield y,
const DoutPrefixProvider *dpp)
{
- int r = store->ctl()->user->read_stats(user, &stats, y);
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(_u);
+ int r = user->read_stats(y, &stats);
if (r < 0) {
ldout(store->ctx(), 0) << "could not get user stats for user=" << user << dendl;
return r;
return 0;
}
-int RGWUserStatsCache::sync_bucket(const rgw_user& user, rgw_bucket& bucket, optional_yield y, const DoutPrefixProvider *dpp)
+int RGWUserStatsCache::sync_bucket(const rgw_user& _u, rgw_bucket& _b, optional_yield y, const DoutPrefixProvider *dpp)
{
- RGWBucketInfo bucket_info;
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(_u);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
- int r = store->ctl()->bucket->read_bucket_instance_info(bucket, &bucket_info, y, dpp);
+ int r = store->get_bucket(dpp, user.get(), _b, &bucket, y);
if (r < 0) {
- ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket << " r=" << r << dendl;
+ ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << _b << " r=" << r << dendl;
return r;
}
- RGWBucketEnt ent;
- r = store->ctl()->bucket->sync_user_stats(user, bucket_info, y, &ent);
+ r = bucket->sync_user_stats(y);
if (r < 0) {
- ldout(store->ctx(), 0) << "ERROR: sync_user_stats() for user=" << user << ", bucket=" << bucket << " returned " << r << dendl;
+ ldout(store->ctx(), 0) << "ERROR: sync_user_stats() for user=" << _u << ", bucket=" << bucket << " returned " << r << dendl;
return r;
}
- return store->getRados()->check_bucket_shards(bucket_info, bucket, ent.count, dpp);
+ return bucket->check_bucket_shards(dpp);
}
-int RGWUserStatsCache::sync_user(const DoutPrefixProvider *dpp, const rgw_user& user, optional_yield y)
+int RGWUserStatsCache::sync_user(const DoutPrefixProvider *dpp, const rgw_user& _u, optional_yield y)
{
- string user_str = user.to_str();
RGWStorageStats stats;
ceph::real_time last_stats_sync;
ceph::real_time last_stats_update;
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(rgw_user(_u.to_str()));
- int ret = store->ctl()->user->read_stats(rgw_user(user_str), &stats, y, &last_stats_sync, &last_stats_update);
+ int ret = user->read_stats(y, &stats, &last_stats_sync, &last_stats_update);
if (ret < 0) {
ldout(store->ctx(), 5) << "ERROR: can't read user header: ret=" << ret << dendl;
return ret;
// check if enough time passed since last full sync
/* FIXME: missing check? */
- ret = rgw_user_sync_all_stats(dpp, store, user, y);
+ ret = rgw_user_sync_all_stats(dpp, store, user.get(), y);
if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR: failed user stats sync, ret=" << ret << dendl;
return ret;
string key = "user";
void *handle;
- int ret = store->ctl()->meta.mgr->list_keys_init(key, &handle);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init(key, &handle);
if (ret < 0) {
ldout(store->ctx(), 10) << "ERROR: can't get key: ret=" << ret << dendl;
return ret;
do {
list<string> keys;
- ret = store->ctl()->meta.mgr->list_keys_next(handle, max, keys, &truncated);
+ ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, max, keys, &truncated);
if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR: lists_keys_next(): ret=" << ret << dendl;
goto done;
ret = 0;
done:
- store->ctl()->meta.mgr->list_keys_complete(handle);
+ static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
return ret;
}
class RGWQuotaHandlerImpl : public RGWQuotaHandler {
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
RGWBucketStatsCache bucket_stats_cache;
RGWUserStatsCache user_stats_cache;
return 0;
}
public:
- RGWQuotaHandlerImpl(rgw::sal::RGWRadosStore *_store, bool quota_threads) : store(_store),
+ RGWQuotaHandlerImpl(rgw::sal::RGWStore *_store, bool quota_threads) : store(_store),
bucket_stats_cache(_store),
user_stats_cache(_store, quota_threads) {}
};
-RGWQuotaHandler *RGWQuotaHandler::generate_handler(rgw::sal::RGWRadosStore *store, bool quota_threads)
+RGWQuotaHandler *RGWQuotaHandler::generate_handler(rgw::sal::RGWStore *store, bool quota_threads)
{
return new RGWQuotaHandlerImpl(store, quota_threads);
}
class JSONObj;
namespace rgw { namespace sal {
- class RGWRadosStore;
+ class RGWStore;
} }
struct RGWQuotaInfo {
virtual void update_stats(const rgw_user& bucket_owner, rgw_bucket& bucket, int obj_delta, uint64_t added_bytes, uint64_t removed_bytes) = 0;
- static RGWQuotaHandler *generate_handler(rgw::sal::RGWRadosStore *store, bool quota_threads);
+ static RGWQuotaHandler *generate_handler(rgw::sal::RGWStore *store, bool quota_threads);
static void free_handler(RGWQuotaHandler *handler);
};
int process() override {
list<RGWCoroutinesStack*> stacks;
auto meta = new RGWCoroutinesStack(store->ctx(), &crs);
- meta->call(create_meta_log_trim_cr(this, store, &http,
+ meta->call(create_meta_log_trim_cr(this, static_cast<rgw::sal::RGWRadosStore*>(store), &http,
cct->_conf->rgw_md_log_max_shards,
trim_interval));
stacks.push_back(meta);
if (store->svc()->zone->sync_module_exports_data()) {
auto data = new RGWCoroutinesStack(store->ctx(), &crs);
- data->call(create_data_log_trim_cr(store, &http,
+ data->call(create_data_log_trim_cr(static_cast<rgw::sal::RGWRadosStore*>(store), &http,
cct->_conf->rgw_data_log_num_shards,
trim_interval));
stacks.push_back(data);
};
class RGWObjectCtx {
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
ceph::shared_mutex lock = ceph::make_shared_mutex("RGWObjectCtx");
void *s{nullptr};
std::map<rgw_obj, RGWObjState> objs_state;
public:
- explicit RGWObjectCtx(rgw::sal::RGWRadosStore *_store) : store(_store) {}
- explicit RGWObjectCtx(rgw::sal::RGWRadosStore *_store, void *_s) : store(_store), s(_s) {}
+ explicit RGWObjectCtx(rgw::sal::RGWStore *_store) : store(_store) {}
+ explicit RGWObjectCtx(rgw::sal::RGWStore *_store, void *_s) : store(_store), s(_s) {}
void *get_private() {
return s;
}
- rgw::sal::RGWRadosStore *get_store() {
+ rgw::sal::RGWStore *get_store() {
return store;
}
class RGWDataSyncStatusManager;
class RGWCoroutinesManagerRegistry;
-class RGWGetBucketStats_CB : public RefCountedObject {
-protected:
- rgw_bucket bucket;
- map<RGWObjCategory, RGWStorageStats> *stats;
-public:
- explicit RGWGetBucketStats_CB(const rgw_bucket& _bucket) : bucket(_bucket), stats(NULL) {}
- ~RGWGetBucketStats_CB() override {}
- virtual void handle_response(int r) = 0;
- virtual void set_response(map<RGWObjCategory, RGWStorageStats> *_stats) {
- stats = _stats;
- }
-};
-
-class RGWGetUserStats_CB : public RefCountedObject {
-protected:
- rgw_user user;
- RGWStorageStats stats;
-public:
- explicit RGWGetUserStats_CB(const rgw_user& _user) : user(_user) {}
- ~RGWGetUserStats_CB() override {}
- virtual void handle_response(int r) = 0;
- virtual void set_response(RGWStorageStats& _stats) {
- stats = _stats;
- }
-};
-
class RGWGetDirHeader_CB;
class RGWGetUserHeader_CB;
namespace rgw { namespace sal {
+ class RGWStore;
class RGWRadosStore;
class MPRadosSerializer;
class LCRadosSerializer;
static constexpr bool USE_SAFE_TIMER_CALLBACKS = false;
-RGWRealmReloader::RGWRealmReloader(rgw::sal::RGWRadosStore*& store, std::map<std::string, std::string>& service_map_meta,
+RGWRealmReloader::RGWRealmReloader(rgw::sal::RGWStore*& store, std::map<std::string, std::string>& service_map_meta,
Pauser* frontends)
: store(store),
service_map_meta(service_map_meta),
// recreate and initialize a new store
store =
RGWStoreManager::get_storage(&dp, cct,
+ "rados",
cct->_conf->rgw_enable_gc_threads,
cct->_conf->rgw_enable_lc_threads,
cct->_conf->rgw_enable_quota_threads,
ldout(cct, 1) << "Creating new store" << dendl;
- rgw::sal::RGWRadosStore* store_cleanup = nullptr;
+ rgw::sal::RGWStore* store_cleanup = nullptr;
{
std::unique_lock lock{mutex};
}
}
- int r = store->getRados()->register_to_service_map("rgw", service_map_meta);
+ int r = store->register_to_service_map("rgw", service_map_meta);
if (r < 0) {
lderr(cct) << "ERROR: failed to register to service map: " << cpp_strerror(-r) << dendl;
ldout(cct, 1) << "Finishing initialization of new store" << dendl;
// finish initializing the new store
ldout(cct, 1) << " - REST subsystem init" << dendl;
- rgw_rest_init(cct, store->svc()->zone->get_zonegroup());
+ rgw_rest_init(cct, store->get_zonegroup());
ldout(cct, 1) << " - usage subsystem init" << dendl;
- rgw_log_usage_init(cct, store->getRados());
+ rgw_log_usage_init(cct, store);
ldout(cct, 1) << "Resuming frontends with new realm configuration." << dendl;
namespace rgw {
namespace sal {
-class RGWRadosStore;
+class RGWStore;
}
}
/// pause all frontends while realm reconfiguration is in progress
virtual void pause() = 0;
/// resume all frontends with the given RGWRados instance
- virtual void resume(rgw::sal::RGWRadosStore* store) = 0;
+ virtual void resume(rgw::sal::RGWStore* store) = 0;
};
- RGWRealmReloader(rgw::sal::RGWRadosStore*& store, std::map<std::string, std::string>& service_map_meta,
+ RGWRealmReloader(rgw::sal::RGWStore*& store, std::map<std::string, std::string>& service_map_meta,
Pauser* frontends);
~RGWRealmReloader() override;
class C_Reload; //< Context that calls reload()
- /// main()'s RGWRadosStore pointer as a reference, modified by reload()
- rgw::sal::RGWRadosStore*& store;
+ /// main()'s RGWStore pointer as a reference, modified by reload()
+ rgw::sal::RGWStore*& store;
std::map<std::string, std::string>& service_map_meta;
Pauser *const frontends;
// We don't need user policies in case of STS token returned by AssumeRole, hence the check for user type
if (! s->user->get_id().empty() && s->auth.identity->get_identity_type() != TYPE_ROLE) {
try {
- map<string, bufferlist> uattrs;
- if (auto ret = store->ctl()->user->get_attrs_by_uid(s, s->user->get_id(), &uattrs, y); ! ret) {
- auto user_policies = get_iam_user_policy_from_attr(s->cct, store, uattrs, s->user->get_tenant());
+ rgw::sal::RGWAttrs uattrs;
+ if (auto ret = s->user->read_attrs(s, y, &uattrs); ! ret) {
+ auto user_policies = get_iam_user_policy_from_attr(s->cct, uattrs, s->user->get_tenant());
s->iam_user_policies.insert(s->iam_user_policies.end(),
std::make_move_iterator(user_policies.begin()),
std::make_move_iterator(user_policies.end()));
}
RGWHandler_REST* RGWREST::get_handler(
- rgw::sal::RGWRadosStore * const store,
+ rgw::sal::RGWStore * const store,
struct req_state* const s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix,
public:
RGWGetObj_ObjStore() : sent_header(false) {}
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s, RGWHandler *h) override {
+ void init(rgw::sal::RGWStore *store, struct req_state *s, RGWHandler *h) override {
RGWGetObj::init(store, s, h);
sent_header = false;
}
protected:
RGWRESTFlusher flusher;
public:
- void init(rgw::sal::RGWRadosStore *store, struct req_state *s,
+ void init(rgw::sal::RGWStore *store, struct req_state *s,
RGWHandler *dialect_handler) override {
RGWOp::init(store, s, dialect_handler);
flusher.init(s, this);
}
virtual RGWHandler_REST* get_handler(
- rgw::sal::RGWRadosStore *store,
+ rgw::sal::RGWStore *store,
struct req_state* const s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix
static int preprocess(struct req_state *s, rgw::io::BasicClient* rio);
public:
RGWREST() {}
- RGWHandler_REST *get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST *get_handler(rgw::sal::RGWStore *store,
struct req_state *s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix,
#include "rgw_op.h"
#include "rgw_bucket.h"
#include "rgw_rest_bucket.h"
-#include "rgw_sal_rados.h"
+#include "rgw_sal.h"
#include "include/str_list.h"
}
rgw_user uid(uid_str);
bool bucket_arg_existed = false;
- std::string bucket;
- RESTArgs::get_string(s, "bucket", bucket, &bucket, &bucket_arg_existed);
+ std::string bucket_name;
+ RESTArgs::get_string(s, "bucket", bucket_name, &bucket_name, &bucket_arg_existed);
if (! bucket_arg_existed) {
op_ret = -EINVAL;
return;
}
}
if (use_http_params) {
- RGWBucketInfo bucket_info;
- map<string, bufferlist> attrs;
- op_ret = store->getRados()->get_bucket_info(store->svc(), uid.tenant, bucket, bucket_info, NULL, s->yield, s, &attrs);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ op_ret = store->get_bucket(s, nullptr, uid.tenant, bucket_name, &bucket, s->yield);
if (op_ret < 0) {
return;
}
- RGWQuotaInfo *old_quota = &bucket_info.quota;
+ RGWQuotaInfo *old_quota = &bucket->get_info().quota;
int64_t old_max_size_kb = rgw_rounded_kb(old_quota->max_size);
int64_t max_size_kb;
RESTArgs::get_int64(s, "max-objects", old_quota->max_objects, "a.max_objects);
RGWBucketAdminOpState op_state;
op_state.set_user_id(uid);
- op_state.set_bucket_name(bucket);
+ op_state.set_bucket_name(bucket_name);
op_state.set_quota(quota);
op_ret = RGWBucketAdminOp::set_quota(store, op_state, s);
RGWRESTMgr_Bucket() = default;
~RGWRESTMgr_Bucket() override = default;
- RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST* get_handler(rgw::sal::RGWStore *store,
struct req_state*,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string&) override {
#define dout_subsys ceph_subsys_rgw
void RGWOp_ZoneGroupMap_Get::execute(optional_yield y) {
- op_ret = zonegroup_map.read(g_ceph_context, store->svc()->sysobj, y);
+ op_ret = zonegroup_map.read(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, y);
if (op_ret < 0) {
dout(5) << "failed to read zone_group map" << dendl;
}
}
void RGWOp_ZoneConfig_Get::send_response() {
- const RGWZoneParams& zone_params = store->svc()->zone->get_zone_params();
+ const RGWZoneParams& zone_params = store->get_zone_params();
set_req_state_err(s, op_ret);
dump_errno(s);
RGWRESTMgr_Config() = default;
~RGWRESTMgr_Config() override = default;
- RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore *,
+ RGWHandler_REST* get_handler(rgw::sal::RGWStore *,
struct req_state*,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string&) override {
}
}
+RGWRESTConn::RGWRESTConn(CephContext *_cct, rgw::sal::RGWStore* store,
+ const string& _remote_id,
+ const list<string>& remote_endpoints,
+ HostStyle _host_style)
+ : cct(_cct),
+ endpoints(remote_endpoints.begin(), remote_endpoints.end()),
+ remote_id(_remote_id), host_style(_host_style)
+{
+ if (store) {
+ key = store->get_zone_params().system_key;
+ self_zone_group = store->get_zonegroup().get_id();
+ }
+}
+
RGWRESTConn::RGWRESTConn(CephContext *_cct, RGWSI_Zone *zone_svc,
const string& _remote_id,
const list<string>& remote_endpoints,
}
}
+RGWRESTConn::RGWRESTConn(CephContext *_cct, rgw::sal::RGWStore* store,
+ const string& _remote_id,
+ const list<string>& remote_endpoints,
+ RGWAccessKey _cred,
+ HostStyle _host_style)
+ : cct(_cct),
+ endpoints(remote_endpoints.begin(), remote_endpoints.end()),
+ key(std::move(_cred)),
+ remote_id(_remote_id), host_style(_host_style)
+{
+ if (store) {
+ self_zone_group = store->get_zonegroup().get_id();
+ }
+}
+
RGWRESTConn::RGWRESTConn(RGWRESTConn&& other)
: cct(other.cct),
endpoints(std::move(other.endpoints)),
#include <atomic>
+namespace rgw { namespace sal {
+ class RGWStore;
+} }
+
class RGWSI_Zone;
template <class T>
public:
RGWRESTConn(CephContext *_cct, RGWSI_Zone *zone_svc, const string& _remote_id, const list<string>& endpoints, HostStyle _host_style = PathStyle);
+ RGWRESTConn(CephContext *_cct, rgw::sal::RGWStore* store, const string& _remote_id, const list<string>& endpoints, HostStyle _host_style = PathStyle);
RGWRESTConn(CephContext *_cct, RGWSI_Zone *zone_svc, const string& _remote_id, const list<string>& endpoints, RGWAccessKey _cred, HostStyle _host_style = PathStyle);
+ RGWRESTConn(CephContext *_cct, rgw::sal::RGWStore* store, const string& _remote_id, const list<string>& endpoints, RGWAccessKey _cred, HostStyle _host_style = PathStyle);
// custom move needed for atomic
RGWRESTConn(RGWRESTConn&& other);
S3RESTConn(CephContext *_cct, RGWSI_Zone *svc_zone, const string& _remote_id, const list<string>& endpoints, HostStyle _host_style = PathStyle) :
RGWRESTConn(_cct, svc_zone, _remote_id, endpoints, _host_style) {}
+ S3RESTConn(CephContext *_cct, rgw::sal::RGWStore* store, const string& _remote_id, const list<string>& endpoints, HostStyle _host_style = PathStyle) :
+ RGWRESTConn(_cct, store, _remote_id, endpoints, _host_style) {}
+
S3RESTConn(CephContext *_cct, RGWSI_Zone *svc_zone, const string& _remote_id, const list<string>& endpoints, RGWAccessKey _cred, HostStyle _host_style = PathStyle):
RGWRESTConn(_cct, svc_zone, _remote_id, endpoints, _cred, _host_style) {}
+
+ S3RESTConn(CephContext *_cct, rgw::sal::RGWStore* store, const string& _remote_id, const list<string>& endpoints, RGWAccessKey _cred, HostStyle _host_style = PathStyle):
+ RGWRESTConn(_cct, store, _remote_id, endpoints, _cred, _host_style) {}
~S3RESTConn() override = default;
void populate_params(param_vec_t& params, const rgw_user *uid, const string& zonegroup) override {
return nullptr;
}
-int RGWHandler_REST_IAM::init(rgw::sal::RGWRadosStore *store,
+int RGWHandler_REST_IAM::init(rgw::sal::RGWStore *store,
struct req_state *s,
rgw::io::BasicClient *cio)
{
}
RGWHandler_REST*
-RGWRESTMgr_IAM::get_handler(rgw::sal::RGWRadosStore *store,
+RGWRESTMgr_IAM::get_handler(rgw::sal::RGWStore *store,
struct req_state* const s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix)
post_body(post_body) {}
~RGWHandler_REST_IAM() override = default;
- int init(rgw::sal::RGWRadosStore *store,
+ int init(rgw::sal::RGWStore *store,
struct req_state *s,
rgw::io::BasicClient *cio) override;
int authorize(const DoutPrefixProvider* dpp, optional_yield y) override;
return this;
}
- RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST* get_handler(rgw::sal::RGWStore *store,
struct req_state*,
const rgw::auth::StrategyRegistry&,
const std::string&) override;
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id trying to use current" << dendl;
- period = store->svc()->zone->get_current_period_id();
+ period = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_current_period_id();
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id" << dendl;
op_ret = -EINVAL;
}
}
- RGWMetadataLog meta_log{s->cct, store->svc()->zone, store->svc()->cls, period};
+ RGWMetadataLog meta_log{s->cct, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls, period};
meta_log.init_list_entries(shard_id, {}, {}, marker, &handle);
for (list<cls_log_entry>::iterator iter = entries.begin();
iter != entries.end(); ++iter) {
cls_log_entry& entry = *iter;
- store->ctl()->meta.mgr->dump_log_entry(entry, s->formatter);
+ static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->dump_log_entry(entry, s->formatter);
flusher.flush();
}
s->formatter->close_section();
void RGWOp_MDLog_Info::execute(optional_yield y) {
num_objects = s->cct->_conf->rgw_md_log_max_shards;
- period = store->svc()->mdlog->read_oldest_log_period(y, s);
+ period = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->mdlog->read_oldest_log_period(y, s);
op_ret = period.get_error();
}
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id trying to use current" << dendl;
- period = store->svc()->zone->get_current_period_id();
+ period = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_current_period_id();
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id" << dendl;
return;
}
}
- RGWMetadataLog meta_log{s->cct, store->svc()->zone, store->svc()->cls, period};
+ RGWMetadataLog meta_log{s->cct, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls, period};
op_ret = meta_log.get_info(shard_id, &info);
}
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id trying to use current" << dendl;
- period = store->svc()->zone->get_current_period_id();
+ period = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_current_period_id();
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id" << dendl;
return;
}
}
- RGWMetadataLog meta_log{s->cct, store->svc()->zone, store->svc()->cls, period};
+ RGWMetadataLog meta_log{s->cct, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls, period};
op_ret = meta_log.trim(shard_id, {}, {}, {}, marker);
}
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id trying to use current" << dendl;
- period = store->svc()->zone->get_current_period_id();
+ period = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_current_period_id();
}
if (period.empty() ||
return;
}
- RGWMetadataLog meta_log{s->cct, store->svc()->zone, store->svc()->cls, period};
+ RGWMetadataLog meta_log{s->cct, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls, period};
unsigned dur;
dur = (unsigned)strict_strtol(duration_str.c_str(), 10, &err);
if (!err.empty() || dur <= 0) {
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id trying to use current" << dendl;
- period = store->svc()->zone->get_current_period_id();
+ period = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_current_period_id();
}
if (period.empty() ||
return;
}
- RGWMetadataLog meta_log{s->cct, store->svc()->zone, store->svc()->cls, period};
+ RGWMetadataLog meta_log{s->cct, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls, period};
op_ret = meta_log.unlock(shard_id, zone_id, locker_id);
}
}
}
- store->getRados()->wakeup_meta_sync_shards(updated_shards);
+ store->wakeup_meta_sync_shards(updated_shards);
op_ret = 0;
}
marker = s->info.args.get("marker"),
max_entries_str = s->info.args.get("max-entries"),
bucket_instance = s->info.args.get("bucket-instance");
- RGWBucketInfo bucket_info;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ rgw_bucket b(rgw_bucket_key(tenant_name, bucket_name));
unsigned max_entries;
if (bucket_name.empty() && bucket_instance.empty()) {
}
if (!bucket_instance.empty()) {
- rgw_bucket b(rgw_bucket_key(tenant_name, bn, bucket_instance));
- op_ret = store->getRados()->get_bucket_instance_info(*s->sysobj_ctx, b, bucket_info, NULL, NULL, s->yield, s);
- if (op_ret < 0) {
- ldpp_dout(s, 5) << "could not get bucket instance info for bucket instance id=" << bucket_instance << dendl;
- return;
- }
- } else { /* !bucket_name.empty() */
- op_ret = store->getRados()->get_bucket_info(store->svc(), tenant_name, bucket_name, bucket_info, NULL, s->yield, NULL);
- if (op_ret < 0) {
- ldpp_dout(s, 5) << "could not get bucket info for bucket=" << bucket_name << dendl;
- return;
- }
+ b.name = bn;
+ b.bucket_id = bucket_instance;
+ }
+ op_ret = store->get_bucket(s, nullptr, b, &bucket, y);
+ if (op_ret < 0) {
+ ldpp_dout(s, 5) << "could not get bucket info for bucket=" << bucket_name << dendl;
+ return;
}
bool truncated;
send_response();
do {
list<rgw_bi_log_entry> entries;
- int ret = store->svc()->bilog_rados->log_list(bucket_info, shard_id,
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->bilog_rados->log_list(bucket->get_info(), shard_id,
marker, max_entries - count,
entries, &truncated);
if (ret < 0) {
string tenant_name = s->info.args.get("tenant"),
bucket_name = s->info.args.get("bucket"),
bucket_instance = s->info.args.get("bucket-instance");
- RGWBucketInfo bucket_info;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ rgw_bucket b(rgw_bucket_key(tenant_name, bucket_name));
if (bucket_name.empty() && bucket_instance.empty()) {
ldpp_dout(s, 5) << "ERROR: neither bucket nor bucket instance specified" << dendl;
}
if (!bucket_instance.empty()) {
- rgw_bucket b(rgw_bucket_key(tenant_name, bn, bucket_instance));
- op_ret = store->getRados()->get_bucket_instance_info(*s->sysobj_ctx, b, bucket_info, NULL, NULL, s->yield, s);
- if (op_ret < 0) {
- ldpp_dout(s, 5) << "could not get bucket instance info for bucket instance id=" << bucket_instance << dendl;
- return;
- }
- } else { /* !bucket_name.empty() */
- op_ret = store->getRados()->get_bucket_info(store->svc(), tenant_name, bucket_name, bucket_info, NULL, s->yield, NULL);
- if (op_ret < 0) {
- ldpp_dout(s, 5) << "could not get bucket info for bucket=" << bucket_name << dendl;
- return;
- }
+ b.name = bn;
+ b.bucket_id = bucket_instance;
+ }
+ op_ret = store->get_bucket(s, nullptr, b, &bucket, y);
+ if (op_ret < 0) {
+ ldpp_dout(s, 5) << "could not get bucket info for bucket=" << bucket_name << dendl;
+ return;
}
+
map<RGWObjCategory, RGWStorageStats> stats;
- int ret = store->getRados()->get_bucket_stats(bucket_info, shard_id, &bucket_ver, &master_ver, stats, &max_marker, &syncstopped);
+ int ret = bucket->get_bucket_stats(shard_id, &bucket_ver, &master_ver, stats, &max_marker, &syncstopped);
if (ret < 0 && ret != -ENOENT) {
op_ret = ret;
return;
end_marker = s->info.args.get("end-marker"),
bucket_instance = s->info.args.get("bucket-instance");
- RGWBucketInfo bucket_info;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ rgw_bucket b(rgw_bucket_key(tenant_name, bucket_name));
op_ret = 0;
if ((bucket_name.empty() && bucket_instance.empty()) ||
}
if (!bucket_instance.empty()) {
- rgw_bucket b(rgw_bucket_key(tenant_name, bn, bucket_instance));
- op_ret = store->getRados()->get_bucket_instance_info(*s->sysobj_ctx, b, bucket_info, NULL, NULL, s->yield, s);
- if (op_ret < 0) {
- ldpp_dout(s, 5) << "could not get bucket instance info for bucket instance id=" << bucket_instance << dendl;
- return;
- }
- } else { /* !bucket_name.empty() */
- op_ret = store->getRados()->get_bucket_info(store->svc(), tenant_name, bucket_name, bucket_info, NULL, s->yield, NULL);
- if (op_ret < 0) {
- ldpp_dout(s, 5) << "could not get bucket info for bucket=" << bucket_name << dendl;
- return;
- }
+ b.name = bn;
+ b.bucket_id = bucket_instance;
+ }
+ op_ret = store->get_bucket(s, nullptr, b, &bucket, y);
+ if (op_ret < 0) {
+ ldpp_dout(s, 5) << "could not get bucket info for bucket=" << bucket_name << dendl;
+ return;
}
- op_ret = store->svc()->bilog_rados->log_trim(bucket_info, shard_id, start_marker, end_marker);
+
+ op_ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->bilog_rados->log_trim(bucket->get_info(), shard_id, start_marker, end_marker);
if (op_ret < 0) {
ldpp_dout(s, 5) << "ERROR: trim_bi_log_entries() " << dendl;
}
// Note that last_marker is updated to be the marker of the last
// entry listed
- op_ret = store->svc()->datalog_rados->list_entries(shard_id,
+ op_ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->datalog_rados->list_entries(shard_id,
max_entries, entries,
marker, &last_marker,
&truncated);
return;
}
- op_ret = store->svc()->datalog_rados->get_info(shard_id, &info);
+ op_ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->datalog_rados->get_info(shard_id, &info);
}
void RGWOp_DATALog_ShardInfo::send_response() {
}
}
- store->getRados()->wakeup_data_sync_shards(source_zone, updated_shards);
+ store->wakeup_data_sync_shards(source_zone, updated_shards);
op_ret = 0;
}
return;
}
- op_ret = store->svc()->datalog_rados->trim_entries(shard_id, marker);
+ op_ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->datalog_rados->trim_entries(shard_id, marker);
}
// not in header to avoid pulling in rgw_sync.h
void RGWOp_MDLog_Status::execute(optional_yield y)
{
- auto sync = store->getRados()->get_meta_sync_manager();
+ auto sync = static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_meta_sync_manager();
if (sync == nullptr) {
ldout(s->cct, 1) << "no sync manager" << dendl;
op_ret = -ENOENT;
return;
}
- rgw_bucket bucket;
+ rgw_bucket b;
int shard_id{-1}; // unused
- op_ret = rgw_bucket_parse_bucket_key(s->cct, key, &bucket, &shard_id);
+ op_ret = rgw_bucket_parse_bucket_key(s->cct, key, &b, &shard_id);
if (op_ret < 0) {
ldpp_dout(s, 4) << "invalid 'bucket' provided" << dendl;
op_ret = -EINVAL;
}
// read the bucket instance info for num_shards
- auto ctx = store->svc()->sysobj->init_obj_ctx();
- RGWBucketInfo info;
- op_ret = store->getRados()->get_bucket_instance_info(ctx, bucket, info, nullptr, nullptr, s->yield, s);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ op_ret = store->get_bucket(s, nullptr, b, &bucket, y);
if (op_ret < 0) {
ldpp_dout(s, 4) << "failed to read bucket info: " << cpp_strerror(op_ret) << dendl;
return;
if (source_key.empty() ||
source_key == key) {
- source_bucket = info.bucket;
+ source_bucket = bucket->get_key();
} else {
op_ret = rgw_bucket_parse_bucket_key(s->cct, source_key, &source_bucket, nullptr);
if (op_ret < 0) {
}
}
- const auto& local_zone_id = store->svc()->zone->zone_id();
+ const auto& local_zone_id = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->zone_id();
if (!merge) {
rgw_sync_bucket_pipe pipe;
pipe.source.zone = source_zone;
pipe.source.bucket = source_bucket;
pipe.dest.zone = local_zone_id;
- pipe.dest.bucket = info.bucket;
+ pipe.dest.bucket = bucket->get_key();
ldout(s->cct, 20) << "RGWOp_BILog_Status::execute(optional_yield y): getting sync status for pipe=" << pipe << dendl;
- op_ret = rgw_bucket_sync_status(this, store, pipe, info, nullptr, &status);
+ op_ret = rgw_bucket_sync_status(this, static_cast<rgw::sal::RGWRadosStore*>(store), pipe, bucket->get_info(), nullptr, &status);
if (op_ret < 0) {
lderr(s->cct) << "ERROR: rgw_bucket_sync_status() on pipe=" << pipe << " returned ret=" << op_ret << dendl;
rgw_zone_id source_zone_id(source_zone);
RGWBucketSyncPolicyHandlerRef source_handler;
- op_ret = store->ctl()->bucket->get_sync_policy_handler(source_zone_id, source_bucket, &source_handler, y, s);
+ op_ret = store->get_sync_policy_handler(s, source_zone_id, source_bucket, &source_handler, y);
if (op_ret < 0) {
lderr(s->cct) << "could not get bucket sync policy handler (r=" << op_ret << ")" << dendl;
return;
ldout(s->cct, 20) << "RGWOp_BILog_Status::execute(optional_yield y): getting sync status for pipe=" << pipe << dendl;
- RGWBucketInfo *pinfo = &info;
+ RGWBucketInfo *pinfo = &bucket->get_info();
std::optional<RGWBucketInfo> opt_dest_info;
if (!pipe.dest.bucket) {
return;
}
- if (*pipe.dest.bucket != info.bucket) {
+ if (*pipe.dest.bucket != pinfo->bucket) {
opt_dest_info.emplace();
- pinfo = &(*opt_dest_info);
-
- /* dest bucket might not have a bucket id */
- op_ret = store->ctl()->bucket->read_bucket_info(*pipe.dest.bucket,
- pinfo,
- s->yield,
- s,
- RGWBucketCtl::BucketInstance::GetParams(),
- nullptr);
+ std::unique_ptr<rgw::sal::RGWBucket> dest_bucket;
+ op_ret = store->get_bucket(s, nullptr, *pipe.dest.bucket, &dest_bucket, y);
if (op_ret < 0) {
ldpp_dout(s, 4) << "failed to read target bucket info (bucket=: " << cpp_strerror(op_ret) << dendl;
return;
}
+ *opt_dest_info = dest_bucket->get_info();
+ pinfo = &(*opt_dest_info);
pipe.dest.bucket = pinfo->bucket;
}
- int r = rgw_bucket_sync_status(this, store, pipe, *pinfo, &info, ¤t_status);
+ int r = rgw_bucket_sync_status(this, static_cast<rgw::sal::RGWRadosStore*>(store), pipe, *pinfo, &bucket->get_info(), ¤t_status);
if (r < 0) {
lderr(s->cct) << "ERROR: rgw_bucket_sync_status() on pipe=" << pipe << " returned ret=" << r << dendl;
op_ret = r;
void RGWOp_DATALog_Status::execute(optional_yield y)
{
const auto source_zone = s->info.args.get("source-zone");
- auto sync = store->getRados()->get_data_sync_manager(source_zone);
+ auto sync = store->get_data_sync_manager(source_zone);
if (sync == nullptr) {
ldout(s->cct, 1) << "no sync manager for source-zone " << source_zone << dendl;
op_ret = -ENOENT;
RGWRESTMgr_Log() = default;
~RGWRESTMgr_Log() override = default;
- RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST* get_handler(rgw::sal::RGWStore *store,
struct req_state* const,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefixs) override {
frame_metadata_key(s, metadata_key);
- auto meta_mgr = store->ctl()->meta.mgr;
+ auto meta_mgr = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr;
/* Get keys */
op_ret = meta_mgr->get(metadata_key, s->formatter, s->yield, s);
marker = "3:bf885d8f:root::sorry_janefonda_665:head";
*/
- op_ret = store->ctl()->meta.mgr->list_keys_init(metadata_key, marker, &handle);
+ op_ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init(metadata_key, marker, &handle);
if (op_ret < 0) {
dout(5) << "ERROR: can't get key: " << cpp_strerror(op_ret) << dendl;
return;
s->formatter->open_array_section("keys");
- auto meta_mgr = store->ctl()->meta.mgr;
+ auto meta_mgr = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr;
uint64_t left;
do {
}
}
- op_ret = store->ctl()->meta.mgr->put(metadata_key, bl, s->yield, s, sync_type,
+ op_ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->put(metadata_key, bl, s->yield, s, sync_type,
false, &ondisk_version);
if (op_ret < 0) {
ldpp_dout(s, 5) << "ERROR: can't put key: " << cpp_strerror(op_ret) << dendl;
string metadata_key;
frame_metadata_key(s, metadata_key);
- op_ret = store->ctl()->meta.mgr->remove(metadata_key, s->yield, s);
+ op_ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->remove(metadata_key, s->yield, s);
if (op_ret < 0) {
ldpp_dout(s, 5) << "ERROR: can't remove key: " << cpp_strerror(op_ret) << dendl;
return;
RGWRESTMgr_Metadata() = default;
~RGWRESTMgr_Metadata() override = default;
- RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST* get_handler(rgw::sal::RGWStore *store,
struct req_state* const s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix) override {
#include "rgw_role.h"
#include "rgw_rest_oidc_provider.h"
#include "rgw_oidc_provider.h"
-#include "rgw_sal_rados.h"
+#include "rgw_sal.h"
#define dout_subsys ceph_subsys_rgw
return;
}
- RGWOIDCProvider provider(s->cct, store->getRados()->pctl, provider_url,
+ RGWOIDCProvider provider(s->cct, store->get_ctl(), provider_url,
s->user->get_tenant(), client_ids, thumbprints);
op_ret = provider.create(s, true, y);
void RGWDeleteOIDCProvider::execute(optional_yield y)
{
- RGWOIDCProvider provider(s->cct, store->getRados()->pctl, provider_arn, s->user->get_tenant());
+ RGWOIDCProvider provider(s->cct, store->get_ctl(), provider_arn, s->user->get_tenant());
op_ret = provider.delete_obj(y);
if (op_ret < 0 && op_ret != -ENOENT && op_ret != -EINVAL) {
void RGWGetOIDCProvider::execute(optional_yield y)
{
- RGWOIDCProvider provider(s->cct, store->getRados()->pctl, provider_arn, s->user->get_tenant());
+ RGWOIDCProvider provider(s->cct, store->get_ctl(), provider_arn, s->user->get_tenant());
op_ret = provider.get(s);
if (op_ret < 0 && op_ret != -ENOENT && op_ret != -EINVAL) {
void RGWListOIDCProviders::execute(optional_yield y)
{
vector<RGWOIDCProvider> result;
- op_ret = RGWOIDCProvider::get_providers(s, store->getRados(), s->user->get_tenant(), result);
+ op_ret = RGWOIDCProvider::get_providers(s, store, s->user->get_tenant(), result);
if (op_ret == 0) {
s->formatter->open_array_section("ListOpenIDConnectProvidersResponse");
dest.arn_topic = topic_name;
// the topic ARN will be sent in the reply
const rgw::ARN arn(rgw::Partition::aws, rgw::Service::sns,
- store->svc()->zone->get_zonegroup().get_name(),
+ store->get_zonegroup().get_name(),
s->user->get_tenant(), topic_name);
topic_arn = arn.to_string();
return 0;
return;
}
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
auto b = ps->get_bucket(bucket_info.bucket);
ceph_assert(b);
std::string data_bucket_prefix = "";
std::string data_oid_prefix = "";
bool push_only = true;
- if (store->getRados()->get_sync_module()) {
- const auto psmodule = dynamic_cast<RGWPSSyncModuleInstance*>(store->getRados()->get_sync_module().get());
+ if (static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_sync_module()) {
+ const auto psmodule = dynamic_cast<RGWPSSyncModuleInstance*>(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_sync_module().get());
if (psmodule) {
const auto& conf = psmodule->get_effective_conf();
data_bucket_prefix = conf["data_bucket_prefix"];
return;
}
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
auto b = ps->get_bucket(bucket_info.bucket);
ceph_assert(b);
};
void RGWPSListNotifs_ObjStore_S3::execute(optional_yield y) {
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
auto b = ps->get_bucket(bucket_info.bucket);
ceph_assert(b);
return;
}
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
op_ret = ps->create_topic(topic_name, dest, topic_arn, opaque_data, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to create topic '" << topic_name << "', ret=" << op_ret << dendl;
}
void RGWPSListTopicsOp::execute(optional_yield y) {
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
op_ret = ps->get_topics(&result);
// if there are no topics it is not considered an error
op_ret = op_ret == -ENOENT ? 0 : op_ret;
if (op_ret < 0) {
return;
}
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
op_ret = ps->get_topic(topic_name, &result);
if (topic_has_endpoint_secret(result) && !rgw_transport_is_secure(s->cct, *(s->info.env))) {
ldout(s->cct, 1) << "topic '" << topic_name << "' contain secret and cannot be sent over insecure transport" << dendl;
if (op_ret < 0) {
return;
}
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
op_ret = ps->remove_topic(topic_name, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to remove topic '" << topic_name << ", ret=" << op_ret << dendl;
if (op_ret < 0) {
return;
}
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
auto sub = ps->get_sub(sub_name);
op_ret = sub->subscribe(topic_name, dest, y);
if (op_ret < 0) {
if (op_ret < 0) {
return;
}
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
auto sub = ps->get_sub(sub_name);
op_ret = sub->get_conf(&result);
if (subscription_has_endpoint_secret(result) && !rgw_transport_is_secure(s->cct, *(s->info.env))) {
if (op_ret < 0) {
return;
}
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
auto sub = ps->get_sub(sub_name);
op_ret = sub->unsubscribe(topic_name, y);
if (op_ret < 0) {
if (op_ret < 0) {
return;
}
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
auto sub = ps->get_sub_with_events(sub_name);
op_ret = sub->remove_event(s, event_id);
if (op_ret < 0) {
if (op_ret < 0) {
return;
}
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
sub = ps->get_sub_with_events(sub_name);
if (!sub) {
op_ret = -ENOENT;
return ret;
}
- const auto& id = s->owner.get_id();
-
- ret = store->getRados()->get_bucket_info(store->svc(), id.tenant, bucket_name,
- bucket_info, nullptr, y, nullptr);
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(s->owner.get_id());
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ ret = store->get_bucket(this, user.get(), s->owner.get_id().tenant, bucket_name, &bucket, y);
if (ret < 0) {
ldout(s->cct, 1) << "failed to get bucket info, cannot verify ownership" << dendl;
return ret;
}
+ bucket_info = bucket->get_info();
- if (bucket_info.owner != id) {
+ if (bucket_info.owner != s->owner.get_id()) {
ldout(s->cct, 1) << "user doesn't own bucket, not allowed to create notification" << dendl;
return -EPERM;
}
return ret;
}
- ret = store->getRados()->get_bucket_info(store->svc(), s->owner.get_id().tenant, bucket_name,
- bucket_info, nullptr, y, nullptr);
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(s->owner.get_id());
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ ret = store->get_bucket(this, user.get(), s->owner.get_id().tenant, bucket_name, &bucket, y);
if (ret < 0) {
return ret;
}
+ bucket_info = bucket->get_info();
if (bucket_info.owner != s->owner.get_id()) {
ldout(s->cct, 1) << "user doesn't own bucket, cannot remove notification" << dendl;
return ret;
}
- ret = store->getRados()->get_bucket_info(store->svc(), s->owner.get_id().tenant, bucket_name,
- bucket_info, nullptr, y, nullptr);
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(s->owner.get_id());
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ ret = store->get_bucket(this, user.get(), s->owner.get_id().tenant, bucket_name, &bucket, y);
if (ret < 0) {
return ret;
}
+ bucket_info = bucket->get_info();
if (bucket_info.owner != s->owner.get_id()) {
ldout(s->cct, 1) << "user doesn't own bucket, cannot get notification list" << dendl;
period.set_id(period_id);
period.set_epoch(epoch);
- op_ret = period.init(store->ctx(), store->svc()->sysobj, realm_id, y, realm_name);
+ op_ret = period.init(store->ctx(), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, realm_id, y, realm_name);
if (op_ret < 0)
ldout(store->ctx(), 5) << "failed to read period" << dendl;
}
auto cct = store->ctx();
// initialize the period without reading from rados
- period.init(cct, store->svc()->sysobj, y, false);
+ period.init(cct, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, y, false);
// decode the period from input
const auto max_size = cct->_conf->rgw_max_put_param_size;
}
// require period.realm_id to match our realm
- if (period.get_realm() != store->svc()->zone->get_realm().get_id()) {
+ if (period.get_realm() != static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_realm().get_id()) {
error_stream << "period with realm id " << period.get_realm()
- << " doesn't match current realm " << store->svc()->zone->get_realm().get_id() << std::endl;
+ << " doesn't match current realm " << static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_realm().get_id() << std::endl;
op_ret = -EINVAL;
return;
}
// period that we haven't restarted with yet. we also don't want to modify
// the objects in use by RGWRados
RGWRealm realm(period.get_realm());
- op_ret = realm.init(cct, store->svc()->sysobj, y);
+ op_ret = realm.init(cct, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, y);
if (op_ret < 0) {
lderr(cct) << "failed to read current realm: "
<< cpp_strerror(-op_ret) << dendl;
}
RGWPeriod current_period;
- op_ret = current_period.init(cct, store->svc()->sysobj, realm.get_id(), y);
+ op_ret = current_period.init(cct, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, realm.get_id(), y);
if (op_ret < 0) {
lderr(cct) << "failed to read current period: "
<< cpp_strerror(-op_ret) << dendl;
}
// if it's not period commit, nobody is allowed to push to the master zone
- if (period.get_master_zone() == store->svc()->zone->get_zone_params().get_id()) {
+ if (period.get_master_zone() == store->get_zone_params().get_id()) {
ldout(cct, 10) << "master zone rejecting period id="
<< period.get_id() << " epoch=" << period.get_epoch() << dendl;
op_ret = -EINVAL; // XXX: error code
return;
}
- auto period_history = store->svc()->mdlog->get_period_history();
+ auto period_history = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->mdlog->get_period_history();
// decide whether we can set_current_period() or set_latest_epoch()
if (period.get_id() != current_period.get_id()) {
class RGWRESTMgr_Period : public RGWRESTMgr {
public:
- RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST* get_handler(rgw::sal::RGWStore *store,
struct req_state*,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string&) override {
// read realm
realm.reset(new RGWRealm(id, name));
- op_ret = realm->init(g_ceph_context, store->svc()->sysobj, y);
+ op_ret = realm->init(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj, y);
if (op_ret < 0)
lderr(store->ctx()) << "failed to read realm id=" << id
<< " name=" << name << dendl;
{
{
// read default realm
- RGWRealm realm(store->ctx(), store->svc()->sysobj);
+ RGWRealm realm(store->ctx(), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj);
[[maybe_unused]] int ret = realm.read_default_id(default_id, y);
}
- op_ret = store->svc()->zone->list_realms(realms);
+ op_ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->list_realms(realms);
if (op_ret < 0)
lderr(store->ctx()) << "failed to list realms" << dendl;
}
}
RGWHandler_REST*
-RGWRESTMgr_Realm::get_handler(rgw::sal::RGWRadosStore *store,
+RGWRESTMgr_Realm::get_handler(rgw::sal::RGWStore *store,
struct req_state*,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string&)
public:
RGWRESTMgr_Realm();
- RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST* get_handler(rgw::sal::RGWStore *store,
struct req_state*,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string&) override;
#include "rgw_rest.h"
#include "rgw_role.h"
#include "rgw_rest_role.h"
-#include "rgw_sal_rados.h"
+#include "rgw_sal.h"
#define dout_subsys ceph_subsys_rgw
}
string role_name = s->info.args.get("RoleName");
- RGWRole role(s->cct, store->getRados()->pctl, role_name, s->user->get_tenant());
+ RGWRole role(s->cct, store->get_ctl(), role_name, s->user->get_tenant());
if (op_ret = role.get(s, y); op_ret < 0) {
if (op_ret == -ENOENT) {
op_ret = -ERR_NO_ROLE_FOUND;
if (op_ret < 0) {
return;
}
- RGWRole role(s->cct, store->getRados()->pctl, role_name, role_path, trust_policy,
+ RGWRole role(s->cct, store->get_ctl(), role_name, role_path, trust_policy,
s->user->get_tenant(), max_session_duration);
op_ret = role.create(s, true, y);
if (op_ret < 0) {
return;
}
- RGWRole role(s->cct, store->getRados()->pctl, role_name, s->user->get_tenant());
+ RGWRole role(s->cct, store->get_ctl(), role_name, s->user->get_tenant());
op_ret = role.get(s, y);
if (op_ret == -ENOENT) {
return;
}
vector<RGWRole> result;
- op_ret = RGWRole::get_roles_by_path_prefix(s, store->getRados(), s->cct, path_prefix, s->user->get_tenant(), result, y);
+ op_ret = RGWRole::get_roles_by_path_prefix(s, store, s->cct, path_prefix, s->user->get_tenant(), result, y);
if (op_ret == 0) {
s->formatter->open_array_section("ListRolesResponse");
ldout(s->cct, 20) << "Read " << obj_tags.count() << "tags" << dendl;
// forward bucket tags requests to meta master zone
- if (!store->svc()->zone->is_meta_master()) {
+ if (!store->is_meta_master()) {
/* only need to keep this data around if we're not meta master */
in_data = std::move(data);
}
}
};
- set<rgw_zone_id> get_zone_ids_from_names(rgw::sal::RGWRadosStore *store,
+ set<rgw_zone_id> get_zone_ids_from_names(rgw::sal::RGWStore *store,
const vector<string>& zone_names) const {
set<rgw_zone_id> ids;
for (auto& name : zone_names) {
rgw_zone_id id;
- if (store->svc()->zone->find_zone_id_by_name(name, &id)) {
+ if (static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->find_zone_id_by_name(name, &id)) {
ids.insert(std::move(id));
}
}
return ids;
}
- vector<string> get_zone_names_from_ids(rgw::sal::RGWRadosStore *store,
+ vector<string> get_zone_names_from_ids(rgw::sal::RGWStore *store,
const set<rgw_zone_id>& zone_ids) const {
vector<string> names;
for (auto& id : zone_ids) {
RGWZone *zone;
- if (store->svc()->zone->find_zone(id, &zone)) {
+ if (static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->find_zone(id, &zone)) {
names.emplace_back(zone->name);
}
}
return true;
}
- int to_sync_policy_pipe(req_state *s, rgw::sal::RGWRadosStore *store,
+ int to_sync_policy_pipe(req_state *s, rgw::sal::RGWStore *store,
rgw_sync_bucket_pipes *pipe,
bool *enabled) const {
if (!is_valid(s->cct)) {
return 0;
}
- void from_sync_policy_pipe(rgw::sal::RGWRadosStore *store,
+ void from_sync_policy_pipe(rgw::sal::RGWStore *store,
const rgw_sync_bucket_pipes& pipe,
bool enabled) {
id = pipe.id;
encode_xml("Rule", rules, f);
}
- int to_sync_policy_groups(req_state *s, rgw::sal::RGWRadosStore *store,
+ int to_sync_policy_groups(req_state *s, rgw::sal::RGWStore *store,
vector<rgw_sync_policy_group> *result) const {
result->resize(2);
return 0;
}
- void from_sync_policy_group(rgw::sal::RGWRadosStore *store,
+ void from_sync_policy_group(rgw::sal::RGWStore *store,
const rgw_sync_policy_group& group) {
bool enabled = (group.status == rgw_sync_policy_group::Status::ENABLED);
}
// forward requests to meta master zone
- if (!store->svc()->zone->is_meta_master()) {
+ if (!store->is_meta_master()) {
/* only need to keep this data around if we're not meta master */
in_data = std::move(data);
}
RGWZoneGroup zonegroup;
string api_name;
- int ret = store->svc()->zone->get_zonegroup(s->bucket->get_info().zonegroup, zonegroup);
+ int ret = store->get_zonegroup(s->bucket->get_info().zonegroup, zonegroup);
if (ret >= 0) {
api_name = zonegroup.api_name;
} else {
return -EINVAL;
}
- if (!store->svc()->zone->is_meta_master()) {
+ if (!store->is_meta_master()) {
/* only need to keep this data around if we're not meta master */
in_data.append(data);
}
dump_start(s);
}
-static int create_s3_policy(struct req_state *s, rgw::sal::RGWRadosStore *store,
+static int create_s3_policy(struct req_state *s, rgw::sal::RGWStore *store,
RGWAccessControlPolicy_S3& s3policy,
ACLOwner& owner)
{
if (!s->canned_acl.empty())
return -ERR_INVALID_REQUEST;
- return s3policy.create_from_headers(s, store->ctl()->user, s->info.env, owner);
+ return s3policy.create_from_headers(s, store, s->info.env, owner);
}
return s3policy.create_canned(owner, s->bucket_owner, s->canned_acl);
end_header(s, this);
}
-static inline int get_obj_attrs(rgw::sal::RGWRadosStore *store, struct req_state *s, rgw_obj& obj, map<string, bufferlist>& attrs)
-{
- RGWRados::Object op_target(store->getRados(), s->bucket->get_info(), *static_cast<RGWObjectCtx *>(s->obj_ctx), obj);
- RGWRados::Object::Read read_op(&op_target);
-
- read_op.params.attrs = &attrs;
-
- return read_op.prepare(s->yield, s);
-}
-
static inline void set_attr(map<string, bufferlist>& attrs, const char* key, const std::string& value)
{
bufferlist bl;
int res = 0;
if (!multipart_upload_id.empty()) {
RGWMPObj mp(s->object->get_name(), multipart_upload_id);
- rgw_obj obj;
- obj.init_ns(s->bucket->get_key(), mp.get_meta(), RGW_OBJ_NS_MULTIPART);
- obj.set_in_extra_data(true);
- map<string, bufferlist> xattrs;
- res = get_obj_attrs(store, s, obj, xattrs);
+ std::unique_ptr<rgw::sal::RGWObject> obj = s->bucket->get_object(
+ rgw_obj_key(mp.get_meta(),
+ std::string(),
+ RGW_OBJ_NS_MULTIPART));
+ obj->set_in_extra_data(true);
+ res = obj->get_obj_attrs(s->obj_ctx, s->yield, this);
if (res == 0) {
std::unique_ptr<BlockCrypt> block_crypt;
/* We are adding to existing object.
* We use crypto mode that configured as if we were decrypting. */
- res = rgw_s3_prepare_decrypt(s, xattrs, &block_crypt, crypt_http_responses);
+ res = rgw_s3_prepare_decrypt(s, obj->get_attrs(), &block_crypt, crypt_http_responses);
if (res == 0 && block_crypt != nullptr)
filter->reset(new RGWPutObj_BlockEncrypt(s->cct, cb, std::move(block_crypt)));
}
if (! storage_class.empty()) {
s->dest_placement.storage_class = storage_class;
- if (!store->svc()->zone->get_zone_params().valid_placement(s->dest_placement)) {
+ if (!store->get_zone_params().valid_placement(s->dest_placement)) {
ldpp_dout(this, 0) << "NOTICE: invalid dest placement: " << s->dest_placement.to_str() << dendl;
err_msg = "The storage class you specified is not valid";
return -EINVAL;
return ret;
}
-int RGWPutACLs_ObjStore_S3::get_policy_from_state(rgw::sal::RGWRadosStore *store,
+int RGWPutACLs_ObjStore_S3::get_policy_from_state(rgw::sal::RGWStore *store,
struct req_state *s,
stringstream& ss)
{
}
// forward bucket cors requests to meta master zone
- if (!store->svc()->zone->is_meta_master()) {
+ if (!store->is_meta_master()) {
/* only need to keep this data around if we're not meta master */
in_data.append(data);
}
} else if (is_notification_op()) {
return RGWHandler_REST_PSNotifs_S3::create_put_op();
} else if (is_replication_op()) {
- auto sync_policy_handler = store->svc()->zone->get_sync_policy_handler(nullopt);
+ auto sync_policy_handler = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_sync_policy_handler(nullopt);
if (!sync_policy_handler ||
sync_policy_handler->is_legacy_config()) {
return nullptr;
return new RGWOptionsCORS_ObjStore_S3;
}
-int RGWHandler_REST_S3::init_from_header(rgw::sal::RGWRadosStore *store,
+int RGWHandler_REST_S3::init_from_header(rgw::sal::RGWStore *store,
struct req_state* s,
int default_formatter,
bool configurable_format)
return 0;
}
-static int verify_mfa(rgw::sal::RGWRadosStore *store, RGWUserInfo *user,
+static int verify_mfa(rgw::sal::RGWStore *store, RGWUserInfo *user,
const string& mfa_str, bool *verified, const DoutPrefixProvider *dpp, optional_yield y)
{
vector<string> params;
return -EACCES;
}
- int ret = store->svc()->cls->mfa.check_mfa(user->user_id, serial, pin, y);
+ int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->cls->mfa.check_mfa(user->user_id, serial, pin, y);
if (ret < 0) {
ldpp_dout(dpp, 20) << "NOTICE: failed to check MFA, serial=" << serial << dendl;
return -EACCES;
return 0;
}
-int RGWHandler_REST_S3::init(rgw::sal::RGWRadosStore *store, struct req_state *s,
+int RGWHandler_REST_S3::init(rgw::sal::RGWStore *store, struct req_state *s,
rgw::io::BasicClient *cio)
{
int ret;
* it tries AWS v4 before AWS v2
*/
int RGW_Auth_S3::authorize(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore* const store,
+ rgw::sal::RGWStore* const store,
const rgw::auth::StrategyRegistry& auth_registry,
struct req_state* const s, optional_yield y)
{
return ret;
}
-int RGWHandler_Auth_S3::init(rgw::sal::RGWRadosStore *store, struct req_state *state,
+int RGWHandler_Auth_S3::init(rgw::sal::RGWStore *store, struct req_state *state,
rgw::io::BasicClient *cio)
{
int ret = RGWHandler_REST_S3::init_from_header(store, state, RGW_FORMAT_JSON, true);
return RGWHandler_REST::init(store, state, cio);
}
-RGWHandler_REST* RGWRESTMgr_S3::get_handler(rgw::sal::RGWRadosStore *store,
+RGWHandler_REST* RGWRESTMgr_S3::get_handler(rgw::sal::RGWStore *store,
struct req_state* const s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix)
subdir_name.pop_back();
}
- rgw_obj obj(s->bucket->get_key(), subdir_name);
+ std::unique_ptr<rgw::sal::RGWObject> obj = s->bucket->get_object(rgw_obj_key(subdir_name));
RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
- obj_ctx.set_atomic(obj);
- obj_ctx.set_prefetch_data(obj);
+ obj->set_atomic(&obj_ctx);
+ obj->set_prefetch_data(&obj_ctx);
RGWObjState* state = nullptr;
- if (store->getRados()->get_obj_state(s, &obj_ctx, s->bucket->get_info(), obj, &state, false, s->yield) < 0) {
+ if (obj->get_obj_state(s, &obj_ctx, &state, s->yield) < 0) {
return false;
}
if (! state->exists) {
return state->exists;
}
-int RGWHandler_REST_S3Website::init(rgw::sal::RGWRadosStore *store, req_state *s,
+int RGWHandler_REST_S3Website::init(rgw::sal::RGWStore *store, req_state *s,
rgw::io::BasicClient* cio)
{
// save the original object name before retarget() replaces it with the
RGWPutACLs_ObjStore_S3() {}
~RGWPutACLs_ObjStore_S3() override {}
- int get_policy_from_state(rgw::sal::RGWRadosStore *store, struct req_state *s, stringstream& ss) override;
+ int get_policy_from_state(rgw::sal::RGWStore *store, struct req_state *s, stringstream& ss) override;
void send_response() override;
int get_params(optional_yield y) override;
};
class RGW_Auth_S3 {
public:
static int authorize(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ rgw::sal::RGWStore *store,
const rgw::auth::StrategyRegistry& auth_registry,
struct req_state *s, optional_yield y);
};
static int validate_bucket_name(const string& bucket);
static int validate_object_name(const string& bucket);
- int init(rgw::sal::RGWRadosStore *store,
+ int init(rgw::sal::RGWStore *store,
struct req_state *s,
rgw::io::BasicClient *cio) override;
int authorize(const DoutPrefixProvider *dpp, optional_yield y) override {
protected:
const rgw::auth::StrategyRegistry& auth_registry;
public:
- static int init_from_header(rgw::sal::RGWRadosStore *store, struct req_state *s, int default_formatter, bool configurable_format);
+ static int init_from_header(rgw::sal::RGWStore *store, struct req_state *s, int default_formatter, bool configurable_format);
explicit RGWHandler_REST_S3(const rgw::auth::StrategyRegistry& auth_registry)
: RGWHandler_REST(),
}
~RGWHandler_REST_S3() override = default;
- int init(rgw::sal::RGWRadosStore *store,
+ int init(rgw::sal::RGWStore *store,
struct req_state *s,
rgw::io::BasicClient *cio) override;
int authorize(const DoutPrefixProvider *dpp, optional_yield y) override;
~RGWRESTMgr_S3() override = default;
- RGWHandler_REST *get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST *get_handler(rgw::sal::RGWStore *store,
struct req_state* s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix) override;
using RGWHandler_REST_S3::RGWHandler_REST_S3;
~RGWHandler_REST_S3Website() override = default;
- int init(rgw::sal::RGWRadosStore *store, req_state *s, rgw::io::BasicClient* cio) override;
+ int init(rgw::sal::RGWStore *store, req_state *s, rgw::io::BasicClient* cio) override;
int error_handler(int err_no, string *error_content, optional_yield y) override;
};
}
int RGW_Auth_STS::authorize(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ rgw::sal::RGWStore *store,
const rgw::auth::StrategyRegistry& auth_registry,
struct req_state *s, optional_yield y)
{
return nullptr;
}
-int RGWHandler_REST_STS::init(rgw::sal::RGWRadosStore *store,
+int RGWHandler_REST_STS::init(rgw::sal::RGWStore *store,
struct req_state *s,
rgw::io::BasicClient *cio)
{
}
RGWHandler_REST*
-RGWRESTMgr_STS::get_handler(rgw::sal::RGWRadosStore *store,
+RGWRESTMgr_STS::get_handler(rgw::sal::RGWStore *store,
struct req_state* const s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix)
class RGW_Auth_STS {
public:
static int authorize(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ rgw::sal::RGWStore *store,
const rgw::auth::StrategyRegistry& auth_registry,
struct req_state *s, optional_yield y);
};
post_body(post_body) {}
~RGWHandler_REST_STS() override = default;
- int init(rgw::sal::RGWRadosStore *store,
+ int init(rgw::sal::RGWStore *store,
struct req_state *s,
rgw::io::BasicClient *cio) override;
int authorize(const DoutPrefixProvider* dpp, optional_yield y) override;
return this;
}
- RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST* get_handler(rgw::sal::RGWStore *store,
struct req_state*,
const rgw::auth::StrategyRegistry&,
const std::string&) override;
#include "rgw_process.h"
#include "rgw_zone.h"
-#include "rgw_sal_rados.h"
+#include "rgw_sal.h"
#include "services/svc_zone.h"
}
}
-void RGWListBuckets_ObjStore_SWIFT::dump_bucket_entry(const rgw::sal::RGWBucket& obj)
+void RGWListBuckets_ObjStore_SWIFT::dump_bucket_entry(const rgw::sal::RGWBucket& bucket)
{
s->formatter->open_object_section("container");
- s->formatter->dump_string("name", obj.get_name());
+ s->formatter->dump_string("name", bucket.get_name());
if (need_stats) {
- s->formatter->dump_int("count", obj.get_count());
- s->formatter->dump_int("bytes", obj.get_size());
+ s->formatter->dump_int("count", bucket.get_count());
+ s->formatter->dump_int("bytes", bucket.get_size());
}
s->formatter->close_section();
void RGWStatAccount_ObjStore_SWIFT::execute(optional_yield y)
{
RGWStatAccount_ObjStore::execute(y);
- op_ret = store->ctl()->user->get_attrs_by_uid(s, s->user->get_id(), &attrs, s->yield);
+ op_ret = s->user->read_attrs(s, s->yield, &attrs);
}
void RGWStatAccount_ObjStore_SWIFT::send_response()
}
static int get_swift_container_settings(req_state * const s,
- rgw::sal::RGWRadosStore * const store,
+ rgw::sal::RGWStore * const store,
RGWAccessControlPolicy * const policy,
bool * const has_policy,
uint32_t * rw_mask,
if (read_list || write_list) {
RGWAccessControlPolicy_SWIFT swift_policy(s->cct);
- const auto r = swift_policy.create(s, store->ctl()->user,
+ const auto r = swift_policy.create(s, store,
s->user->get_id(),
s->user->get_display_name(),
read_list,
policy.create_default(s->user->get_id(), s->user->get_display_name());
}
- location_constraint = store->svc()->zone->get_zonegroup().api_name;
+ location_constraint = store->get_zonegroup().api_name;
get_rmattrs_from_headers(s, CONT_PUT_ATTR_PREFIX,
CONT_REMOVE_ATTR_PREFIX, rmattr_names);
placement_rule.init(s->info.env->get("HTTP_X_STORAGE_POLICY", ""), s->info.storage_class);
string bucket_name = path.substr(pos_init, pos_sep - pos_init);
string obj_name = path.substr(pos_sep + 1);
- rgw_bucket bucket;
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
if (bucket_name.compare(s->bucket->get_name()) != 0) {
- RGWBucketInfo bucket_info;
- map<string, bufferlist> bucket_attrs;
- r = store->getRados()->get_bucket_info(store->svc(), s->user->get_id().tenant,
- bucket_name, bucket_info, nullptr,
- s->yield, s, &bucket_attrs);
+ r = store->get_bucket(s, s->user.get(), s->user->get_id().tenant, bucket_name, &bucket, s->yield);
if (r < 0) {
ldpp_dout(this, 0) << "could not get bucket info for bucket="
<< bucket_name << dendl;
return r;
}
- bucket = bucket_info.bucket;
} else {
- bucket = s->bucket->get_key();
+ bucket = s->bucket->clone();
}
/* fetch the stored size of the seg (or error if not valid) */
- rgw_obj_key slo_key(obj_name);
- rgw_obj slo_seg(bucket, slo_key);
+ std::unique_ptr<rgw::sal::RGWObject> slo_seg = bucket->get_object(rgw_obj_key(obj_name));
/* no prefetch */
RGWObjectCtx obj_ctx(store);
- obj_ctx.set_atomic(slo_seg);
-
- RGWRados::Object op_target(store->getRados(), s->bucket->get_info(), obj_ctx, slo_seg);
- RGWRados::Object::Read read_op(&op_target);
+ slo_seg->set_atomic(&obj_ctx);
bool compressed;
RGWCompressionInfo cs_info;
- map<std::string, buffer::list> attrs;
uint64_t size_bytes{0};
- read_op.params.attrs = &attrs;
- read_op.params.obj_size = &size_bytes;
-
- r = read_op.prepare(s->yield, s);
+ r = slo_seg->get_obj_attrs(&obj_ctx, s->yield, s);
if (r < 0) {
return r;
}
- r = rgw_compression_info_from_attrset(attrs, compressed, cs_info);
+ size_bytes = slo_seg->get_obj_size();
+
+ r = rgw_compression_info_from_attrset(slo_seg->get_attrs(), compressed, cs_info);
if (r < 0) {
return -EIO;
}
}
static int get_swift_account_settings(req_state * const s,
- rgw::sal::RGWRadosStore * const store,
+ rgw::sal::RGWStore * const store,
RGWAccessControlPolicy_SWIFTAcct * const policy,
bool * const has_policy)
{
const char * const acl_attr = s->info.env->get("HTTP_X_ACCOUNT_ACCESS_CONTROL");
if (acl_attr) {
RGWAccessControlPolicy_SWIFTAcct swift_acct_policy(s->cct);
- const bool r = swift_acct_policy.create(s, store->ctl()->user,
+ const bool r = swift_acct_policy.create(s, store,
s->user->get_id(),
s->user->get_display_name(),
string(acl_attr));
s->formatter->close_section();
}
else {
- pair.second.list_data(*(s->formatter), s->cct->_conf, *store->getRados());
+ pair.second.list_data(*(s->formatter), s->cct->_conf, store);
}
}
void RGWInfo_ObjStore_SWIFT::list_swift_data(Formatter& formatter,
const ConfigProxy& config,
- RGWRados& store)
+ rgw::sal::RGWStore* store)
{
formatter.open_object_section("swift");
formatter.dump_int("max_file_size", config->rgw_max_put_size);
}
formatter.open_array_section("policies");
- const RGWZoneGroup& zonegroup = store.svc.zone->get_zonegroup();
+ const RGWZoneGroup& zonegroup = store->get_zonegroup();
for (const auto& placement_targets : zonegroup.placement_targets) {
formatter.open_object_section("policy");
void RGWInfo_ObjStore_SWIFT::list_tempauth_data(Formatter& formatter,
const ConfigProxy& config,
- RGWRados& store)
+ rgw::sal::RGWStore* store)
{
formatter.open_object_section("tempauth");
formatter.dump_bool("account_acls", true);
}
void RGWInfo_ObjStore_SWIFT::list_tempurl_data(Formatter& formatter,
const ConfigProxy& config,
- RGWRados& store)
+ rgw::sal::RGWStore* store)
{
formatter.open_object_section("tempurl");
formatter.open_array_section("methods");
void RGWInfo_ObjStore_SWIFT::list_slo_data(Formatter& formatter,
const ConfigProxy& config,
- RGWRados& store)
+ rgw::sal::RGWStore* store)
{
formatter.open_object_section("slo");
formatter.dump_int("max_manifest_segments", config->rgw_max_slo_entries);
}
-void RGWFormPost::init(rgw::sal::RGWRadosStore* const store,
+void RGWFormPost::init(rgw::sal::RGWStore* const store,
req_state* const s,
RGWHandler* const dialect_handler)
{
* now. It will be initialized in RGWHandler_REST_SWIFT::postauth_init(). */
const string& bucket_name = s->init_state.url_bucket;
- auto user_ctl = store->ctl()->user;
+ std::unique_ptr<rgw::sal::RGWUser> user;
/* TempURL in Formpost only requires that bucket name is specified. */
if (bucket_name.empty()) {
throw -EPERM;
}
- string bucket_tenant;
if (!s->account_name.empty()) {
RGWUserInfo uinfo;
bool found = false;
const rgw_user uid(s->account_name);
if (uid.tenant.empty()) {
const rgw_user tenanted_uid(uid.id, uid.id);
+ user = store->get_user(tenanted_uid);
- if (user_ctl->get_info_by_uid(s, tenanted_uid, &uinfo, s->yield) >= 0) {
+ if (user->load_by_id(s, s->yield) >= 0) {
/* Succeeded. */
- bucket_tenant = uinfo.user_id.tenant;
found = true;
}
}
- if (!found && user_ctl->get_info_by_uid(s, uid, &uinfo, s->yield) < 0) {
- throw -EPERM;
- } else {
- bucket_tenant = uinfo.user_id.tenant;
+ if (!found) {
+ user = store->get_user(uid);
+ if (user->load_by_id(s, s->yield) < 0) {
+ throw -EPERM;
+ }
}
}
/* Need to get user info of bucket owner. */
- RGWBucketInfo bucket_info;
- int ret = store->getRados()->get_bucket_info(store->svc(),
- bucket_tenant, bucket_name,
- bucket_info, nullptr, s->yield, s);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ int ret = store->get_bucket(s, user.get(), user->get_tenant(), bucket_name, &bucket, s->yield);
if (ret < 0) {
throw ret;
}
- ldpp_dout(this, 20) << "temp url user (bucket owner): " << bucket_info.owner
+ ldpp_dout(this, 20) << "temp url user (bucket owner): " << bucket->get_info().owner
<< dendl;
- if (user_ctl->get_info_by_uid(s, bucket_info.owner, &owner_info, s->yield) < 0) {
+ user = store->get_user(bucket->get_info().owner);
+ if (user->load_by_id(s, s->yield) < 0) {
throw -EPERM;
}
+
+ owner_info = user->get_info();
}
int RGWFormPost::get_params(optional_yield y)
class RGWGetErrorPage : public RGWGetObj_ObjStore_SWIFT {
public:
- RGWGetErrorPage(rgw::sal::RGWRadosStore* const store,
+ RGWGetErrorPage(rgw::sal::RGWStore* const store,
RGWHandler_REST* const handler,
req_state* const s,
const int http_ret) {
subdir_name.pop_back();
}
- rgw::sal::RGWRadosObject obj(store, rgw_obj_key(std::move(subdir_name)), s->bucket.get());
+ std::unique_ptr<rgw::sal::RGWObject> obj = s->bucket->get_object(rgw_obj_key(std::move(subdir_name)));
/* First, get attrset of the object we'll try to retrieve. */
RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
- obj.set_atomic(&obj_ctx);
- obj.set_prefetch_data(&obj_ctx);
+ obj->set_atomic(&obj_ctx);
+ obj->set_prefetch_data(&obj_ctx);
RGWObjState* state = nullptr;
- if (obj.get_obj_state(s, &obj_ctx, *s->bucket, &state, s->yield, false)) {
+ if (obj->get_obj_state(s, &obj_ctx, &state, s->yield, false)) {
return false;
}
bool RGWSwiftWebsiteHandler::is_index_present(const std::string& index) const
{
- rgw::sal::RGWRadosObject obj(store, rgw_obj_key(index), s->bucket.get());
+ std::unique_ptr<rgw::sal::RGWObject> obj = s->bucket->get_object(rgw_obj_key(index));
RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
- obj.set_atomic(&obj_ctx);
- obj.set_prefetch_data(&obj_ctx);
+ obj->set_atomic(&obj_ctx);
+ obj->set_prefetch_data(&obj_ctx);
RGWObjState* state = nullptr;
- if (obj.get_obj_state(s, &obj_ctx, *s->bucket, &state, s->yield, false)) {
+ if (obj->get_obj_state(s, &obj_ctx, &state, s->yield, false)) {
return false;
}
}
}
-int RGWHandler_REST_SWIFT::init_from_header(rgw::sal::RGWRadosStore* store,
+int RGWHandler_REST_SWIFT::init_from_header(rgw::sal::RGWStore* store,
struct req_state* const s,
const std::string& frontend_prefix)
{
return 0;
}
-int RGWHandler_REST_SWIFT::init(rgw::sal::RGWRadosStore* store, struct req_state* s,
+int RGWHandler_REST_SWIFT::init(rgw::sal::RGWStore* store, struct req_state* s,
rgw::io::BasicClient *cio)
{
struct req_init_state *t = &s->init_state;
}
RGWHandler_REST*
-RGWRESTMgr_SWIFT::get_handler(rgw::sal::RGWRadosStore* store,
+RGWRESTMgr_SWIFT::get_handler(rgw::sal::RGWStore* store,
struct req_state* const s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix)
}
RGWHandler_REST* RGWRESTMgr_SWIFT_Info::get_handler(
- rgw::sal::RGWRadosStore* store,
+ rgw::sal::RGWStore* store,
struct req_state* const s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix)
struct info
{
bool is_admin_info;
- function<void (Formatter&, const ConfigProxy&, RGWRados&)> list_data;
+ function<void (Formatter&, const ConfigProxy&, rgw::sal::RGWStore*)> list_data;
};
static const vector<pair<string, struct info>> swift_info;
void execute(optional_yield y) override;
void send_response() override;
- static void list_swift_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store);
- static void list_tempauth_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store);
- static void list_tempurl_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store);
- static void list_slo_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store);
+ static void list_swift_data(Formatter& formatter, const ConfigProxy& config, rgw::sal::RGWStore* store);
+ static void list_tempauth_data(Formatter& formatter, const ConfigProxy& config, rgw::sal::RGWStore* store);
+ static void list_tempurl_data(Formatter& formatter, const ConfigProxy& config, rgw::sal::RGWStore* store);
+ static void list_slo_data(Formatter& formatter, const ConfigProxy& config, rgw::sal::RGWStore* store);
static bool is_expired(const std::string& expires, const DoutPrefixProvider* dpp);
};
RGWFormPost() = default;
~RGWFormPost() = default;
- void init(rgw::sal::RGWRadosStore* store,
+ void init(rgw::sal::RGWStore* store,
req_state* s,
RGWHandler* dialect_handler) override;
class RGWSwiftWebsiteHandler {
- rgw::sal::RGWRadosStore* const store;
+ rgw::sal::RGWStore* const store;
req_state* const s;
RGWHandler_REST* const handler;
RGWOp* get_ws_index_op();
RGWOp* get_ws_listing_op();
public:
- RGWSwiftWebsiteHandler(rgw::sal::RGWRadosStore* const store,
+ RGWSwiftWebsiteHandler(rgw::sal::RGWStore* const store,
req_state* const s,
RGWHandler_REST* const handler)
: store(store),
return false;
}
- static int init_from_header(rgw::sal::RGWRadosStore* store, struct req_state* s,
+ static int init_from_header(rgw::sal::RGWStore* store, struct req_state* s,
const std::string& frontend_prefix);
public:
explicit RGWHandler_REST_SWIFT(const rgw::auth::Strategy& auth_strategy)
int validate_bucket_name(const string& bucket);
- int init(rgw::sal::RGWRadosStore *store, struct req_state *s, rgw::io::BasicClient *cio) override;
+ int init(rgw::sal::RGWStore *store, struct req_state *s, rgw::io::BasicClient *cio) override;
int authorize(const DoutPrefixProvider *dpp, optional_yield y) override;
int postauth_init(optional_yield y) override;
return website_handler->retarget_bucket(op, new_op);
}
- int init(rgw::sal::RGWRadosStore* const store,
+ int init(rgw::sal::RGWStore* const store,
struct req_state* const s,
rgw::io::BasicClient* const cio) override {
website_handler = boost::in_place<RGWSwiftWebsiteHandler>(store, s, this);
return website_handler->retarget_object(op, new_op);
}
- int init(rgw::sal::RGWRadosStore* const store,
+ int init(rgw::sal::RGWStore* const store,
struct req_state* const s,
rgw::io::BasicClient* const cio) override {
website_handler = boost::in_place<RGWSwiftWebsiteHandler>(store, s, this);
RGWRESTMgr_SWIFT() = default;
~RGWRESTMgr_SWIFT() override = default;
- RGWHandler_REST *get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST *get_handler(rgw::sal::RGWStore *store,
struct req_state *s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix) override;
return new RGWGetCrossDomainPolicy_ObjStore_SWIFT();
}
- int init(rgw::sal::RGWRadosStore* const store,
+ int init(rgw::sal::RGWStore* const store,
struct req_state* const state,
rgw::io::BasicClient* const cio) override {
state->dialect = "swift";
RGWRESTMgr_SWIFT_CrossDomain() = default;
~RGWRESTMgr_SWIFT_CrossDomain() override = default;
- RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST* get_handler(rgw::sal::RGWStore *store,
struct req_state* const s,
const rgw::auth::StrategyRegistry&,
const std::string&) override {
return new RGWGetHealthCheck_ObjStore_SWIFT();
}
- int init(rgw::sal::RGWRadosStore* const store,
+ int init(rgw::sal::RGWStore* const store,
struct req_state* const state,
rgw::io::BasicClient* const cio) override {
state->dialect = "swift";
RGWRESTMgr_SWIFT_HealthCheck() = default;
~RGWRESTMgr_SWIFT_HealthCheck() override = default;
- RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST* get_handler(rgw::sal::RGWStore *store,
struct req_state* const s,
const rgw::auth::StrategyRegistry&,
const std::string&) override {
return new RGWInfo_ObjStore_SWIFT();
}
- int init(rgw::sal::RGWRadosStore* const store,
+ int init(rgw::sal::RGWStore* const store,
struct req_state* const state,
rgw::io::BasicClient* const cio) override {
state->dialect = "swift";
RGWRESTMgr_SWIFT_Info() = default;
~RGWRESTMgr_SWIFT_Info() override = default;
- RGWHandler_REST *get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST *get_handler(rgw::sal::RGWStore *store,
struct req_state* s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix) override;
#include "rgw_op.h"
#include "rgw_usage.h"
#include "rgw_rest_usage.h"
-#include "rgw_sal_rados.h"
+#include "rgw_sal.h"
#include "include/str_list.h"
RESTArgs::get_string(s, "uid", uid_str, &uid_str);
RESTArgs::get_string(s, "bucket", bucket_name, &bucket_name);
- rgw_user uid(uid_str);
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(rgw_user(uid_str));
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+
+ if (!bucket_name.empty()) {
+ store->get_bucket(nullptr, user.get(), std::string(), bucket_name, &bucket, null_yield);
+ }
RESTArgs::get_epoch(s, "start", 0, &start);
RESTArgs::get_epoch(s, "end", (uint64_t)-1, &end);
}
}
- op_ret = RGWUsage::show(store->getRados(), uid, bucket_name, start, end, show_entries, show_summary, &categories, flusher);
+ op_ret = RGWUsage::show(this, store, user.get(), bucket.get(), start, end, show_entries, show_summary, &categories, flusher);
}
class RGWOp_Usage_Delete : public RGWRESTOp {
RESTArgs::get_string(s, "uid", uid_str, &uid_str);
RESTArgs::get_string(s, "bucket", bucket_name, &bucket_name);
- rgw_user uid(uid_str);
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(rgw_user(uid_str));
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+
+ if (!bucket_name.empty()) {
+ store->get_bucket(nullptr, user.get(), std::string(), bucket_name, &bucket, null_yield);
+ }
RESTArgs::get_epoch(s, "start", 0, &start);
RESTArgs::get_epoch(s, "end", (uint64_t)-1, &end);
- if (uid.empty() &&
+ if (rgw::sal::RGWUser::empty(user.get()) &&
!bucket_name.empty() &&
!start &&
end == (uint64_t)-1) {
}
}
- op_ret = RGWUsage::trim(store->getRados(), uid, bucket_name, start, end);
+ op_ret = RGWUsage::trim(this, store, user.get(), bucket.get(), start, end);
}
RGWOp *RGWHandler_Usage::op_get()
RGWRESTMgr_Usage() = default;
~RGWRESTMgr_Usage() override = default;
- RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore* store,
+ RGWHandler_REST* get_handler(rgw::sal::RGWStore* store,
struct req_state*,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string&) override {
#include "rgw_op.h"
#include "rgw_user.h"
#include "rgw_rest_user.h"
-#include "rgw_sal_rados.h"
+#include "rgw_sal.h"
#include "include/str_list.h"
#include "include/ceph_assert.h"
if (!default_placement_str.empty()) {
rgw_placement_rule target_rule;
target_rule.from_str(default_placement_str);
- if (!store->svc()->zone->get_zone_params().valid_placement(target_rule)) {
+ if (!store->get_zone_params().valid_placement(target_rule)) {
ldout(s->cct, 0) << "NOTICE: invalid dest placement: " << target_rule.to_str() << dendl;
op_ret = -EINVAL;
return;
if (!default_placement_str.empty()) {
rgw_placement_rule target_rule;
target_rule.from_str(default_placement_str);
- if (!store->svc()->zone->get_zone_params().valid_placement(target_rule)) {
+ if (!store->get_zone_params().valid_placement(target_rule)) {
ldout(s->cct, 0) << "NOTICE: invalid dest placement: " << target_rule.to_str() << dendl;
op_ret = -EINVAL;
return;
RGWRESTMgr_User() = default;
~RGWRESTMgr_User() override = default;
- RGWHandler_REST *get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST *get_handler(rgw::sal::RGWStore *store,
struct req_state*,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string&) override {
#include "rgw_op.h"
#include "rgw_rest.h"
#include "rgw_rest_user_policy.h"
-#include "rgw_sal_rados.h"
+#include "rgw_sal.h"
#include "services/svc_zone.h"
#define dout_subsys ceph_subsys_rgw
bufferlist bl = bufferlist::static_from_string(policy);
- RGWUserInfo info;
- rgw_user user_id(user_name);
- op_ret = store->ctl()->user->get_info_by_uid(s, user_id, &info, s->yield);
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(rgw_user(user_name));
+
+ op_ret = user->load_by_id(s, s->yield);
if (op_ret < 0) {
op_ret = -ERR_NO_SUCH_ENTITY;
return;
}
- map<string, bufferlist> uattrs;
- op_ret = store->ctl()->user->get_attrs_by_uid(s, user_id, &uattrs, s->yield);
+ rgw::sal::RGWAttrs uattrs;
+ op_ret = user->read_attrs(s, s->yield, &uattrs);
if (op_ret == -ENOENT) {
op_ret = -ERR_NO_SUCH_ENTITY;
return;
uattrs[RGW_ATTR_USER_POLICY] = in_bl;
RGWObjVersionTracker objv_tracker;
- op_ret = store->ctl()->user->store_info(s, info, s->yield,
- RGWUserCtl::PutParams()
- .set_objv_tracker(&objv_tracker)
- .set_attrs(&uattrs));
+ op_ret = user->store_info(s, s->yield,
+ RGWUserCtl::PutParams()
+ .set_objv_tracker(&objv_tracker)
+ .set_attrs(&uattrs));
if (op_ret < 0) {
op_ret = -ERR_INTERNAL_ERROR;
}
return;
}
- rgw_user user_id(user_name);
- map<string, bufferlist> uattrs;
- op_ret = store->ctl()->user->get_attrs_by_uid(s, user_id, &uattrs, s->yield);
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(rgw_user(user_name));
+ rgw::sal::RGWAttrs uattrs;
+ op_ret = user->read_attrs(s, s->yield, &uattrs);
if (op_ret == -ENOENT) {
ldpp_dout(this, 0) << "ERROR: attrs not found for user" << user_name << dendl;
op_ret = -ERR_NO_SUCH_ENTITY;
return;
}
- rgw_user user_id(user_name);
- map<string, bufferlist> uattrs;
- op_ret = store->ctl()->user->get_attrs_by_uid(s, user_id, &uattrs, s->yield);
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(rgw_user(user_name));
+ rgw::sal::RGWAttrs uattrs;
+ op_ret = user->read_attrs(s, s->yield, &uattrs);
if (op_ret == -ENOENT) {
ldpp_dout(this, 0) << "ERROR: attrs not found for user" << user_name << dendl;
op_ret = -ERR_NO_SUCH_ENTITY;
return;
}
- RGWUserInfo info;
- map<string, bufferlist> uattrs;
- rgw_user user_id(user_name);
- op_ret = store->ctl()->user->get_info_by_uid(s, user_id, &info, s->yield,
- RGWUserCtl::GetParams()
- .set_attrs(&uattrs));
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(rgw_user(user_name));
+ op_ret = user->load_by_id(s, s->yield);
if (op_ret < 0) {
op_ret = -ERR_NO_SUCH_ENTITY;
return;
}
+ rgw::sal::RGWAttrs uattrs;
+ op_ret = user->read_attrs(this, s->yield, &uattrs);
+ if (op_ret == -ENOENT) {
+ op_ret = -ERR_NO_SUCH_ENTITY;
+ return;
+ }
+
ceph::bufferlist in_data;
op_ret = store->forward_request_to_master(s->user.get(), nullptr, in_data, nullptr, s->info, y);
if (op_ret < 0) {
uattrs[RGW_ATTR_USER_POLICY] = in_bl;
RGWObjVersionTracker objv_tracker;
- op_ret = store->ctl()->user->store_info(s, info, s->yield,
- RGWUserCtl::PutParams()
- .set_old_info(&info)
- .set_objv_tracker(&objv_tracker)
- .set_attrs(&uattrs));
+ op_ret = user->store_info(s, s->yield,
+ RGWUserCtl::PutParams()
+ .set_old_info(&user->get_info())
+ .set_objv_tracker(&objv_tracker)
+ .set_attrs(&uattrs));
if (op_ret < 0) {
op_ret = -ERR_INTERNAL_ERROR;
}
this->trust_policy = trust_policy;
}
-int RGWRole::get_roles_by_path_prefix(const DoutPrefixProvider *dpp,
- RGWRados *store,
+int RGWRole::get_roles_by_path_prefix(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
CephContext *cct,
const string& path_prefix,
const string& tenant,
vector<RGWRole>& roles,
optional_yield y)
{
- auto pool = store->svc.zone->get_zone_params().roles_pool;
+ auto pool = store->get_zone_params().roles_pool;
string prefix;
// List all roles if path prefix is empty
//Get id from info oid prefix + id
string id = it.substr(pos + role_oid_prefix.length());
- RGWRole role(cct, store->pctl);
+ RGWRole role(cct, store->get_ctl());
role.set_id(id);
int ret = role.read_info(dpp, y);
if (ret < 0) {
static const string& get_names_oid_prefix();
static const string& get_info_oid_prefix();
static const string& get_path_oid_prefix();
- static int get_roles_by_path_prefix(const DoutPrefixProvider *dpp,
- RGWRados *store,
+ static int get_roles_by_path_prefix(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
CephContext *cct,
const string& path_prefix,
const string& tenant,
#include <unistd.h>
#include <sstream>
+#include "common/errno.h"
+
#include "rgw_sal.h"
+#include "rgw_sal_rados.h"
#define dout_subsys ceph_subsys_rgw
+extern "C" {
+extern rgw::sal::RGWStore* newRGWStore(void);
+}
+
+rgw::sal::RGWStore *RGWStoreManager::init_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct, const std::string svc, bool use_gc_thread, bool use_lc_thread, bool quota_threads, bool run_sync_thread, bool run_reshard_thread, bool use_cache)
+{
+ rgw::sal::RGWStore *store = nullptr;
+ if (svc.compare("rados") == 0) {
+ store = newRGWStore();
+ RGWRados *rados = static_cast<rgw::sal::RGWRadosStore *>(store)->getRados();
+
+ if ((*rados).set_use_cache(use_cache)
+ .set_run_gc_thread(use_gc_thread)
+ .set_run_lc_thread(use_lc_thread)
+ .set_run_quota_threads(quota_threads)
+ .set_run_sync_thread(run_sync_thread)
+ .set_run_reshard_thread(run_reshard_thread)
+ .initialize(cct, dpp) < 0) {
+ delete store; store = nullptr;
+ }
+ }
+
+ return store;
+}
+
+rgw::sal::RGWStore *RGWStoreManager::init_raw_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct, const std::string svc)
+{
+ rgw::sal::RGWStore *store = nullptr;
+ if (svc.compare("rados") == 0) {
+ store = newRGWStore();
+ RGWRados *rados = static_cast<rgw::sal::RGWRadosStore *>(store)->getRados();
+
+ rados->set_context(cct);
+
+ int ret = rados->init_svc(true, dpp);
+ if (ret < 0) {
+ ldout(cct, 0) << "ERROR: failed to init services (ret=" << cpp_strerror(-ret) << ")" << dendl;
+ delete store; store = nullptr;
+ return store;
+ }
+
+ if (rados->init_rados() < 0) {
+ delete store; store = nullptr;
+ }
+ }
+
+ return store;
+}
+
+void RGWStoreManager::close_storage(rgw::sal::RGWStore *store)
+{
+ if (!store)
+ return;
+
+ store->finalize();
+
+ delete store;
+}
#pragma once
#include "rgw_user.h"
+#include "rgw_notify_event_type.h"
+#include "rgw_putobj.h"
class RGWGetDataCB;
struct RGWObjState;
class RGWLC;
class RGWObjManifest;
struct RGWZoneGroup;
+struct RGWZoneParams;
+struct RGWRealm;
+struct RGWCtl;
+struct rgw_user_bucket;
+class RGWUsageBatch;
+class RGWCoroutinesManagerRegistry;
+class RGWListRawObjsCtx;
+class RGWBucketSyncPolicyHandler;
+using RGWBucketSyncPolicyHandlerRef = std::shared_ptr<RGWBucketSyncPolicyHandler>;
+class RGWDataSyncStatusManager;
+namespace rgw {
+ class Aio;
+ namespace IAM { struct Policy; }
+}
struct RGWUsageIter {
string read_iter;
uint64_t num_objects;
};
+class RGWGetBucketStats_CB : public RefCountedObject {
+protected:
+ rgw_bucket bucket;
+ map<RGWObjCategory, RGWStorageStats> *stats;
+public:
+ explicit RGWGetBucketStats_CB(const rgw_bucket& _bucket) : bucket(_bucket), stats(NULL) {}
+ ~RGWGetBucketStats_CB() override {}
+ virtual void handle_response(int r) = 0;
+ virtual void set_response(map<RGWObjCategory, RGWStorageStats> *_stats) {
+ stats = _stats;
+ }
+};
+
+class RGWGetUserStats_CB : public RefCountedObject {
+protected:
+ rgw_user user;
+ RGWStorageStats stats;
+public:
+ explicit RGWGetUserStats_CB(const rgw_user& _user) : user(_user) {}
+ ~RGWGetUserStats_CB() override {}
+ virtual void handle_response(int r) = 0;
+ virtual void set_response(RGWStorageStats& _stats) {
+ stats = _stats;
+ }
+};
+
namespace rgw { namespace sal {
class RGWBucketList;
struct MPSerializer;
class Lifecycle;
+class Notification;
+class GCChain;
+class Writer;
enum AttrsMod {
ATTRSMOD_NONE = 0,
ATTRSMOD_MERGE = 2
};
+/**
+ * Base class for AIO completions
+ */
+class Completions {
+ public:
+ Completions() {}
+ virtual ~Completions() = default;
+ virtual int drain() = 0;
+};
+
using RGWAttrs = std::map<std::string, ceph::buffer::list>;
class RGWStore {
virtual ~RGWStore() = default;
virtual std::unique_ptr<RGWUser> get_user(const rgw_user& u) = 0;
+ virtual int get_user(const DoutPrefixProvider *dpp, const RGWAccessKey& key, optional_yield y, std::unique_ptr<RGWUser>* user) = 0;
+ virtual int get_user_by_email(const DoutPrefixProvider *dpp, const std::string& email, optional_yield y, std::unique_ptr<RGWUser>* user) = 0;
+ virtual int get_user_by_swift(const DoutPrefixProvider *dpp, const std::string& user_str, optional_yield y, std::unique_ptr<RGWUser>* user) = 0;
virtual std::unique_ptr<RGWObject> get_object(const rgw_obj_key& k) = 0;
virtual int get_bucket(const DoutPrefixProvider *dpp, RGWUser* u, const rgw_bucket& b, std::unique_ptr<RGWBucket>* bucket, optional_yield y) = 0;
virtual int get_bucket(RGWUser* u, const RGWBucketInfo& i, std::unique_ptr<RGWBucket>* bucket) = 0;
req_info& req_info,
std::unique_ptr<RGWBucket>* bucket,
optional_yield y) = 0;
- virtual RGWBucketList* list_buckets(void) = 0;
virtual bool is_meta_master() = 0;
virtual int forward_request_to_master(RGWUser* user, obj_version *objv,
bufferlist& in_data, JSONParser *jp, req_info& info,
optional_yield y) = 0;
virtual const RGWZoneGroup& get_zonegroup() = 0;
virtual int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) = 0;
+ virtual const RGWZoneParams& get_zone_params() = 0;
+ virtual const rgw_zone_id& get_zone_id() = 0;
+ virtual const RGWRealm& get_realm() = 0;
virtual int cluster_stat(RGWClusterStat& stats) = 0;
virtual std::unique_ptr<Lifecycle> get_lifecycle(void) = 0;
+ virtual std::unique_ptr<Completions> get_completions(void) = 0;
+ virtual std::unique_ptr<Notification> get_notification(rgw::sal::RGWObject* obj, struct req_state* s, rgw::notify::EventType event_type) = 0;
+ virtual std::unique_ptr<GCChain> get_gc_chain(rgw::sal::RGWObject* obj) = 0;
+ virtual std::unique_ptr<Writer> get_writer(Aio *aio, rgw::sal::RGWBucket* bucket,
+ RGWObjectCtx& obj_ctx, std::unique_ptr<rgw::sal::RGWObject> _head_obj,
+ const DoutPrefixProvider *dpp, optional_yield y) = 0;
virtual RGWLC* get_rgwlc(void) = 0;
+ virtual RGWCtl* get_ctl(void) = 0;
+ virtual RGWCoroutinesManagerRegistry* get_cr_registry() = 0;
virtual int delete_raw_obj(const rgw_raw_obj& obj) = 0;
+ virtual int delete_raw_obj_aio(const rgw_raw_obj& obj, Completions* aio) = 0;
virtual void get_raw_obj(const rgw_placement_rule& placement_rule, const rgw_obj& obj, rgw_raw_obj* raw_obj) = 0;
virtual int get_raw_chunk_size(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, uint64_t* chunk_size) = 0;
- virtual void finalize(void)=0;
-
- virtual CephContext *ctx(void)=0;
+ virtual int log_usage(map<rgw_user_bucket, RGWUsageBatch>& usage_info) = 0;
+ virtual int log_op(string& oid, bufferlist& bl) = 0;
+ virtual int register_to_service_map(const string& daemon_type,
+ const map<string, string>& meta) = 0;
+ virtual void get_quota(RGWQuotaInfo& bucket_quota, RGWQuotaInfo& user_quota) = 0;
+ virtual int list_raw_objects(const rgw_pool& pool, const string& prefix_filter,
+ int max, RGWListRawObjsCtx& ctx, std::list<string>& oids,
+ bool *is_truncated) = 0;
+ virtual int set_buckets_enabled(const DoutPrefixProvider *dpp, vector<rgw_bucket>& buckets, bool enabled) = 0;
+ virtual uint64_t get_new_req_id() = 0;
+ virtual int get_sync_policy_handler(const DoutPrefixProvider *dpp,
+ std::optional<rgw_zone_id> zone,
+ std::optional<rgw_bucket> bucket,
+ RGWBucketSyncPolicyHandlerRef *phandler,
+ optional_yield y) = 0;
+ virtual RGWDataSyncStatusManager* get_data_sync_manager(const rgw_zone_id& source_zone) = 0;
+ virtual void wakeup_meta_sync_shards(set<int>& shard_ids) = 0;
+ virtual void wakeup_data_sync_shards(const rgw_zone_id& source_zone, map<int, set<string> >& shard_ids) = 0;
+ virtual int clear_usage() = 0;
+ virtual int read_all_usage(uint64_t start_epoch, uint64_t end_epoch,
+ uint32_t max_entries, bool *is_truncated,
+ RGWUsageIter& usage_iter,
+ map<rgw_user_bucket, rgw_usage_log_entry>& usage) = 0;
+ virtual int trim_all_usage(uint64_t start_epoch, uint64_t end_epoch) = 0;
+ virtual int get_config_key_val(string name, bufferlist *bl) = 0;
+ virtual void finalize(void) = 0;
+
+ virtual CephContext *ctx(void) = 0;
// get the location of where lua packages are installed
virtual const std::string& get_luarocks_path() const = 0;
RGWUser() : info() {}
RGWUser(const rgw_user& _u) : info() { info.user_id = _u; }
RGWUser(const RGWUserInfo& _i) : info(_i) {}
+ RGWUser(RGWUser& _o) = default;
virtual ~RGWUser() = default;
- virtual int list_buckets(const DoutPrefixProvider *dpp,
- const std::string& marker, const std::string& end_marker,
+ virtual std::unique_ptr<RGWUser> clone() = 0;
+ virtual int list_buckets(const DoutPrefixProvider *dpp,
+ const std::string& marker, const std::string& end_marker,
uint64_t max, bool need_stats, RGWBucketList& buckets,
optional_yield y) = 0;
virtual RGWBucket* create_bucket(rgw_bucket& bucket, ceph::real_time creation_time) = 0;
friend class RGWBucket;
virtual std::string& get_display_name() { return info.display_name; }
- std::string& get_tenant() { return info.user_id.tenant; }
+ const std::string& get_tenant() { return info.user_id.tenant; }
+ void set_tenant(std::string& _t) { info.user_id.tenant = _t; }
+ const std::string& get_ns() { return info.user_id.ns; }
+ void set_ns(std::string& _ns) { info.user_id.ns = _ns; }
const rgw_user& get_id() const { return info.user_id; }
uint32_t get_type() const { return info.type; }
int32_t get_max_buckets() const { return info.max_buckets; }
const RGWUserCaps& get_caps() const { return info.caps; }
static bool empty(RGWUser* u) { return (!u || u->info.user_id.id.empty()); }
+ virtual int read_attrs(const DoutPrefixProvider *dpp, optional_yield y, RGWAttrs* uattrs, RGWObjVersionTracker* tracker = nullptr) = 0;
+ virtual int read_stats(optional_yield y, RGWStorageStats* stats,
+ ceph::real_time *last_stats_sync = nullptr,
+ ceph::real_time *last_stats_update = nullptr) = 0;
+ virtual int read_stats_async(RGWGetUserStats_CB *cb) = 0;
+ virtual int complete_flush_stats(optional_yield y) = 0;
+ virtual int read_usage(uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
+ bool *is_truncated, RGWUsageIter& usage_iter,
+ map<rgw_user_bucket, rgw_usage_log_entry>& usage) = 0;
+ virtual int trim_usage(uint64_t start_epoch, uint64_t end_epoch) = 0;
/* Placeholders */
- virtual int load_by_id(const DoutPrefixProvider *dpp, optional_yield y) = 0;
+ virtual int load_by_id(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::GetParams& params = {}) = 0;
+ virtual int store_info(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::PutParams& params = {}) = 0;
/* dang temporary; will be removed when User is complete */
rgw_user& get_user() { return info.user_id; }
RGWAccessListFilter *filter{nullptr};
bool list_versions{false};
bool allow_unordered{false};
- int shard_id{-1};
+ int shard_id{RGW_NO_SHARD};
};
struct ListResults {
vector<rgw_bucket_dir_entry> objs;
};
RGWBucket() : ent(), info(), owner(nullptr), attrs(), bucket_version() {}
+ RGWBucket(RGWUser* _u) :
+ ent(), info(), owner(_u), attrs(), bucket_version() { }
RGWBucket(const rgw_bucket& _b) :
ent(), info(), owner(nullptr), attrs(), bucket_version() { ent.bucket = _b; info.bucket = _b; }
RGWBucket(const RGWBucketEnt& _e) :
ent(), info(_i), owner(_u), attrs(), bucket_version() { ent.bucket = info.bucket; ent.placement_rule = info.placement_rule;}
virtual ~RGWBucket() = default;
- virtual int load_by_name(const DoutPrefixProvider *dpp, const std::string& tenant, const std::string& bucket_name, const std::string bucket_instance_id, RGWSysObjectCtx *rctx, optional_yield y) = 0;
virtual std::unique_ptr<RGWObject> get_object(const rgw_obj_key& key) = 0;
virtual int list(const DoutPrefixProvider *dpp, ListParams&, int, ListResults&, optional_yield y) = 0;
virtual RGWObject* create_object(const rgw_obj_key& key /* Attributes */) = 0;
virtual RGWAccessControlPolicy& get_acl(void) = 0;
virtual int set_acl(const DoutPrefixProvider *dpp, RGWAccessControlPolicy& acl, optional_yield y) = 0;
virtual int get_bucket_info(const DoutPrefixProvider *dpp, optional_yield y) = 0;
- virtual int get_bucket_stats(RGWBucketInfo& bucket_info, int shard_id,
+ virtual int get_bucket_stats(int shard_id,
std::string *bucket_ver, std::string *master_ver,
std::map<RGWObjCategory, RGWStorageStats>& stats,
std::string *max_marker = nullptr,
bool *syncstopped = nullptr) = 0;
+ virtual int get_bucket_stats_async(int shard_id, RGWGetBucketStats_CB *ctx) = 0;
virtual int read_bucket_stats(const DoutPrefixProvider *dpp, optional_yield y) = 0;
virtual int sync_user_stats(optional_yield y) = 0;
virtual int update_container_stats(const DoutPrefixProvider *dpp) = 0;
virtual int check_bucket_shards(const DoutPrefixProvider *dpp) = 0;
- virtual int link(const DoutPrefixProvider *dpp, RGWUser* new_user, optional_yield y) = 0;
- virtual int unlink(RGWUser* new_user, optional_yield y) = 0;
- virtual int chown(RGWUser* new_user, RGWUser* old_user, optional_yield y, const DoutPrefixProvider *dpp) = 0;
+ virtual int link(const DoutPrefixProvider *dpp, RGWUser* new_user, optional_yield y, bool update_entrypoint = true, RGWObjVersionTracker* objv = nullptr) = 0;
+ virtual int unlink(const DoutPrefixProvider *dpp, RGWUser* new_user, optional_yield y, bool update_entrypoint = true) = 0;
+ virtual int chown(const DoutPrefixProvider *dpp, RGWUser* new_user, RGWUser* old_user, optional_yield y, const std::string* marker = nullptr) = 0;
virtual int put_instance_info(const DoutPrefixProvider *dpp, bool exclusive, ceph::real_time mtime) = 0;
+ virtual int remove_entrypoint(const DoutPrefixProvider *dpp, RGWObjVersionTracker* objv, optional_yield y) = 0;
+ virtual int remove_instance_info(const DoutPrefixProvider *dpp, RGWObjVersionTracker* objv, optional_yield y) = 0;
virtual bool is_owner(RGWUser* user) = 0;
virtual RGWUser* get_owner(void) { return owner; };
virtual ACLOwner get_acl_owner(void) { return ACLOwner(info.owner); };
virtual int read_usage(uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
bool *is_truncated, RGWUsageIter& usage_iter,
map<rgw_user_bucket, rgw_usage_log_entry>& usage) = 0;
+ virtual int trim_usage(uint64_t start_epoch, uint64_t end_epoch) = 0;
+ virtual int remove_objs_from_index(std::list<rgw_obj_index_key>& objs_to_unlink) = 0;
+ virtual int check_index(std::map<RGWObjCategory, RGWStorageStats>& existing_stats, std::map<RGWObjCategory, RGWStorageStats>& calculated_stats) = 0;
+ virtual int rebuild_index() = 0;
+ virtual int set_tag_timeout(uint64_t timeout) = 0;
+ virtual int purge_instance(const DoutPrefixProvider *dpp) = 0;
bool empty() const { return info.bucket.name.empty(); }
const std::string& get_name() const { return info.bucket.name; }
return out;
}
+ bool operator==(const RGWBucket& b) const {
+ return (info.bucket.tenant == b.info.bucket.tenant) &&
+ (info.bucket.name == b.info.bucket.name) &&
+ (info.bucket.bucket_id == b.info.bucket.bucket_id);
+ }
+ bool operator!=(const RGWBucket& b) const {
+ return (info.bucket.tenant != b.info.bucket.tenant) ||
+ (info.bucket.name != b.info.bucket.name) ||
+ (info.bucket.bucket_id != b.info.bucket.bucket_id);
+ }
friend class RGWBucketList;
protected:
const bufferlist* data{nullptr};
RGWObjManifest* manifest{nullptr};
const string* ptag{nullptr};
- list<rgw_obj_index_key>* remove_objs{nullptr};
+ std::list<rgw_obj_index_key>* remove_objs{nullptr};
ceph::real_time set_mtime;
ACLOwner owner;
RGWObjCategory category{RGWObjCategory::Main};
//virtual int write_data(const char *data, uint64_t ofs, uint64_t len, bool exclusive) = 0;
};
+ struct DeleteOp {
+ struct Params {
+ ACLOwner bucket_owner;
+ ACLOwner obj_owner;
+ int versioning_status{0};
+ uint64_t olh_epoch{0};
+ string marker_version_id;
+ uint32_t bilog_flags{0};
+ list<rgw_obj_index_key> *remove_objs{nullptr};
+ ceph::real_time expiration_time;
+ ceph::real_time unmod_since;
+ ceph::real_time mtime;
+ bool high_precision_time{false};
+ rgw_zone_set *zones_trace{nullptr};
+ bool abortmp{false};
+ uint64_t parts_accounted_size{0};
+ } params;
+
+ struct Result {
+ bool delete_marker{false};
+ string version_id;
+ } result;
+
+ virtual ~DeleteOp() = default;
+
+ virtual int delete_obj(const DoutPrefixProvider *dpp, optional_yield y) = 0;
+ };
+
+ struct StatOp {
+ struct Result {
+ RGWObject* obj;
+ RGWObjManifest* manifest;
+ } result;
+
+ virtual ~StatOp() = default;
+
+ virtual int stat_async() = 0;
+ virtual int wait() = 0;
+ };
+
RGWObject()
: key(),
bucket(nullptr),
virtual ~RGWObject() = default;
- virtual int read(off_t offset, off_t length, std::iostream& stream) = 0;
- virtual int write(off_t offset, off_t length, std::iostream& stream) = 0;
- virtual int delete_object(const DoutPrefixProvider *dpp, RGWObjectCtx* obj_ctx, ACLOwner obj_owner,
- ACLOwner bucket_owner, ceph::real_time unmod_since,
- bool high_precision_time, uint64_t epoch,
- std::string& version_id, optional_yield y) = 0;
+ virtual int delete_object(const DoutPrefixProvider *dpp, RGWObjectCtx* obj_ctx, optional_yield y) = 0;
+ virtual int delete_obj_aio(const DoutPrefixProvider *dpp, RGWObjState *astate, Completions* aio,
+ bool keep_index_consistent, optional_yield y) = 0;
virtual int copy_object(RGWObjectCtx& obj_ctx, RGWUser* user,
req_info *info, const rgw_zone_id& source_zone,
rgw::sal::RGWObject* dest_object, rgw::sal::RGWBucket* dest_bucket,
bool empty() const { return key.empty(); }
const std::string &get_name() const { return key.name; }
- virtual int get_obj_state(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, RGWBucket& bucket, RGWObjState **state, optional_yield y, bool follow_olh = false) = 0;
+ virtual int get_obj_state(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, RGWObjState **state, optional_yield y, bool follow_olh = false) = 0;
virtual int set_obj_attrs(const DoutPrefixProvider *dpp, RGWObjectCtx* rctx, RGWAttrs* setattrs, RGWAttrs* delattrs, optional_yield y, rgw_obj* target_obj = NULL) = 0;
virtual int get_obj_attrs(RGWObjectCtx *rctx, optional_yield y, const DoutPrefixProvider *dpp, rgw_obj* target_obj = NULL) = 0;
virtual int modify_obj_attrs(RGWObjectCtx *rctx, const char *attr_name, bufferlist& attr_val, optional_yield y, const DoutPrefixProvider *dpp) = 0;
/* OPs */
virtual std::unique_ptr<ReadOp> get_read_op(RGWObjectCtx*) = 0;
virtual std::unique_ptr<WriteOp> get_write_op(RGWObjectCtx*) = 0;
+ virtual std::unique_ptr<DeleteOp> get_delete_op(RGWObjectCtx*) = 0;
+ virtual std::unique_ptr<StatOp> get_stat_op(RGWObjectCtx*) = 0;
/* OMAP */
+ virtual int omap_get_vals(const string& marker, uint64_t count,
+ std::map<string, bufferlist> *m,
+ bool *pmore, optional_yield y) = 0;
+ virtual int omap_get_all(std::map<string, bufferlist> *m,
+ optional_yield y) = 0;
virtual int omap_get_vals_by_keys(const std::string& oid,
const std::set<std::string>& keys,
RGWAttrs *vals) = 0;
virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) = 0;
};
+class Notification {
+protected:
+ RGWObject* obj;
+ rgw::notify::EventType event_type;
+
+ public:
+ Notification(RGWObject* _obj, rgw::notify::EventType _type) : obj(_obj), event_type(_type) {}
+ virtual ~Notification() = default;
+
+ virtual int publish_reserve(RGWObjTags* obj_tags = nullptr) = 0;
+ virtual int publish_commit(const DoutPrefixProvider *dpp, uint64_t size,
+ const ceph::real_time& mtime, const std::string& etag) = 0;
+};
+
+class GCChain {
+protected:
+ RGWObject* obj;
+
+ public:
+ GCChain(RGWObject* _obj) : obj(_obj) {}
+ virtual ~GCChain() = default;
+
+ virtual void update(RGWObjManifest* manifest) = 0;
+ virtual int send(const std::string& tag) = 0;
+ virtual void delete_inline(const std::string& tag) = 0;
+};
+
+using RawObjSet = std::set<rgw_raw_obj>;
+
+class Writer : public rgw::putobj::DataProcessor {
+protected:
+ Aio *const aio;
+ rgw::sal::RGWBucket* bucket;
+ RGWObjectCtx& obj_ctx;
+ std::unique_ptr<rgw::sal::RGWObject> head_obj;
+ RawObjSet written; // set of written objects for deletion
+ const DoutPrefixProvider *dpp;
+ optional_yield y;
+
+ public:
+ Writer(Aio *aio,
+ rgw::sal::RGWBucket* bucket,
+ RGWObjectCtx& obj_ctx, std::unique_ptr<rgw::sal::RGWObject> _head_obj,
+ const DoutPrefixProvider *dpp, optional_yield y)
+ : aio(aio), bucket(bucket),
+ obj_ctx(obj_ctx), head_obj(std::move(_head_obj)), dpp(dpp), y(y)
+ {}
+ Writer(Writer&& r)
+ : aio(r.aio), bucket(r.bucket),
+ obj_ctx(r.obj_ctx), head_obj(std::move(r.head_obj)), dpp(r.dpp), y(r.y)
+ {}
+
+ ~Writer() = default;
+
+ // change the current stripe object
+ virtual int set_stripe_obj(const rgw_raw_obj& obj) = 0;
+
+ // write the data as an exclusive create and wait for it to complete
+ virtual int write_exclusive(const bufferlist& data) = 0;
+
+ virtual int drain() = 0;
+
+ // when the operation completes successfully, clear the set of written objects
+ // so they aren't deleted on destruction
+ virtual void clear_written() { written.clear(); }
+
+};
+
} } // namespace rgw::sal
+class RGWStoreManager {
+public:
+ RGWStoreManager() {}
+ static rgw::sal::RGWStore *get_storage(const DoutPrefixProvider *dpp, CephContext *cct, const std::string svc, bool use_gc_thread, bool use_lc_thread, bool quota_threads,
+ bool run_sync_thread, bool run_reshard_thread, bool use_cache = true) {
+ rgw::sal::RGWStore *store = init_storage_provider(dpp, cct, svc, use_gc_thread, use_lc_thread,
+ quota_threads, run_sync_thread, run_reshard_thread, use_cache);
+ return store;
+ }
+ static rgw::sal::RGWStore *get_raw_storage(const DoutPrefixProvider *dpp, CephContext *cct, const std::string svc) {
+ rgw::sal::RGWStore *store = init_raw_storage_provider(dpp, cct, svc);
+ return store;
+ }
+ static rgw::sal::RGWStore *init_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct, const std::string svc, bool use_gc_thread, bool use_lc_thread, bool quota_threads, bool run_sync_thread, bool run_reshard_thread, bool use_metadata_cache);
+ static rgw::sal::RGWStore *init_raw_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct, const std::string svc);
+ static void close_storage(rgw::sal::RGWStore *store);
+
+};
#include "rgw_bucket.h"
#include "rgw_multi.h"
#include "rgw_acl_s3.h"
+#include "rgw_aio.h"
#include "rgw_zone.h"
#include "rgw_rest_conn.h"
+#include "rgw_service.h"
#include "services/svc_sys_obj.h"
#include "services/svc_zone.h"
#include "services/svc_tier_rados.h"
+#include "services/svc_quota.h"
+#include "rgw/services/svc_config_key.h"
#include "cls/rgw/cls_rgw_client.h"
#include "rgw_pubsub.h"
namespace rgw::sal {
-int RGWRadosUser::list_buckets(const DoutPrefixProvider *dpp, const string& marker, const string& end_marker,
- uint64_t max, bool need_stats, RGWBucketList &buckets,
- optional_yield y)
+static int decode_policy(CephContext *cct,
+ bufferlist& bl,
+ RGWAccessControlPolicy *policy)
+{
+ auto iter = bl.cbegin();
+ try {
+ policy->decode(iter);
+ } catch (buffer::error& err) {
+ ldout(cct, 0) << "ERROR: could not decode policy, caught buffer::error" << dendl;
+ return -EIO;
+ }
+ if (cct->_conf->subsys.should_gather<ceph_subsys_rgw, 15>()) {
+ ldout(cct, 15) << __func__ << " Read AccessControlPolicy";
+ RGWAccessControlPolicy_S3 *s3policy = static_cast<RGWAccessControlPolicy_S3 *>(policy);
+ s3policy->to_xml(*_dout);
+ *_dout << dendl;
+ }
+ return 0;
+}
+
+static int rgw_op_get_bucket_policy_from_attr(const DoutPrefixProvider *dpp,
+ RGWRadosStore *store,
+ RGWUser& user,
+ RGWAttrs& bucket_attrs,
+ RGWAccessControlPolicy *policy,
+ optional_yield y)
+{
+ auto aiter = bucket_attrs.find(RGW_ATTR_ACL);
+
+ if (aiter != bucket_attrs.end()) {
+ int ret = decode_policy(store->ctx(), aiter->second, policy);
+ if (ret < 0)
+ return ret;
+ } else {
+ ldout(store->ctx(), 0) << "WARNING: couldn't find acl header for bucket, generating default" << dendl;
+ /* object exists, but policy is broken */
+ int r = user.load_by_id(dpp, y);
+ if (r < 0)
+ return r;
+
+ policy->create_default(user.get_user(), user.get_display_name());
+ }
+ return 0;
+}
+
+static int process_completed(const AioResultList& completed, RawObjSet *written)
+{
+ std::optional<int> error;
+ for (auto& r : completed) {
+ if (r.result >= 0) {
+ written->insert(r.obj.get_ref().obj);
+ } else if (!error) { // record first error code
+ error = r.result;
+ }
+ }
+ return error.value_or(0);
+}
+
+int RadosCompletions::drain()
+{
+ int ret = 0;
+ while (!handles.empty()) {
+ librados::AioCompletion *handle = handles.front();
+ handles.pop_front();
+ handle->wait_for_complete();
+ int r = handle->get_return_value();
+ handle->release();
+ if (r < 0) {
+ ret = r;
+ }
+ }
+ return ret;
+}
+
+int RGWRadosUser::list_buckets(const DoutPrefixProvider *dpp, const string& marker,
+ const string& end_marker, uint64_t max, bool need_stats,
+ RGWBucketList &buckets, optional_yield y)
{
RGWUserBuckets ulist;
bool is_truncated = false;
return NULL;
}
-int RGWRadosUser::load_by_id(const DoutPrefixProvider *dpp, optional_yield y)
+int RGWRadosUser::read_attrs(const DoutPrefixProvider *dpp, optional_yield y, RGWAttrs* uattrs, RGWObjVersionTracker* tracker)
+{
+ return store->ctl()->user->get_attrs_by_uid(dpp, get_id(), uattrs, y, tracker);
+}
+int RGWRadosUser::read_stats(optional_yield y, RGWStorageStats* stats,
+ ceph::real_time *last_stats_sync,
+ ceph::real_time *last_stats_update)
{
- return store->ctl()->user->get_info_by_uid(dpp, info.user_id, &info, y);
+ return store->ctl()->user->read_stats(get_id(), stats, y, last_stats_sync, last_stats_update);
}
-std::unique_ptr<RGWObject> RGWRadosStore::get_object(const rgw_obj_key& k)
+int RGWRadosUser::read_stats_async(RGWGetUserStats_CB *cb)
{
- return std::unique_ptr<RGWObject>(new RGWRadosObject(this, k));
+ return store->ctl()->user->read_stats_async(get_id(), cb);
+}
+
+int RGWRadosUser::complete_flush_stats(optional_yield y)
+{
+ return store->ctl()->user->complete_flush_stats(get_id(), y);
+}
+
+int RGWRadosUser::read_usage(uint64_t start_epoch, uint64_t end_epoch,
+ uint32_t max_entries, bool *is_truncated,
+ RGWUsageIter& usage_iter,
+ map<rgw_user_bucket, rgw_usage_log_entry>& usage)
+{
+ std::string bucket_name;
+ return store->getRados()->read_usage(get_id(), bucket_name, start_epoch,
+ end_epoch, max_entries, is_truncated,
+ usage_iter, usage);
+}
+
+int RGWRadosUser::trim_usage(uint64_t start_epoch, uint64_t end_epoch)
+{
+ std::string bucket_name;
+
+ return store->getRados()->trim_usage(get_id(), bucket_name, start_epoch, end_epoch);
+}
+
+int RGWRadosUser::load_by_id(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::GetParams& params)
+{
+ return store->ctl()->user->get_info_by_uid(dpp, info.user_id, &info, y, params);
+}
+
+int RGWRadosUser::store_info(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::PutParams& params)
+{
+ return store->ctl()->user->store_info(dpp, info, y, params);
}
/* Placeholder */
for (const auto& obj : results.objs) {
rgw_obj_key key(obj.key);
/* xxx dang */
- ret = rgw_remove_object(dpp, store, info, info.bucket, key);
+ ret = rgw_remove_object(dpp, store, this, key);
if (ret < 0 && ret != -ENOENT) {
return ret;
}
/* If there's a prefix, then we are aborting multiparts as well */
if (!prefix.empty()) {
- ret = abort_bucket_multiparts(dpp, store, store->ctx(), info, prefix, delimiter);
+ ret = abort_bucket_multiparts(dpp, store, store->ctx(), this, prefix, delimiter);
if (ret < 0) {
return ret;
}
int RGWRadosBucket::get_bucket_info(const DoutPrefixProvider *dpp, optional_yield y)
{
auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
+ int ret;
+
RGWSI_MetaBackend_CtxParams bectx_params = RGWSI_MetaBackend_CtxParams_SObj(&obj_ctx);
RGWObjVersionTracker ep_ot;
- int ret = store->ctl()->bucket->read_bucket_info(info.bucket, &info, y, dpp,
+ if (info.bucket.bucket_id.empty()) {
+ ret = store->ctl()->bucket->read_bucket_info(info.bucket, &info, y, dpp,
RGWBucketCtl::BucketInstance::GetParams()
.set_mtime(&mtime)
.set_attrs(&attrs)
.set_bectx_params(bectx_params),
&ep_ot);
+ } else {
+ ret = store->ctl()->bucket->read_bucket_instance_info(info.bucket, &info, y, dpp,
+ RGWBucketCtl::BucketInstance::GetParams()
+ .set_mtime(&mtime)
+ .set_attrs(&attrs)
+ .set_bectx_params(bectx_params));
+ }
if (ret == 0) {
bucket_version = ep_ot.read_version;
ent.placement_rule = info.placement_rule;
return ret;
}
-int RGWRadosBucket::load_by_name(const DoutPrefixProvider *dpp, const std::string& tenant, const std::string& bucket_name, const std::string bucket_instance_id, RGWSysObjectCtx *rctx, optional_yield y)
-{
- info.bucket.tenant = tenant;
- info.bucket.name = bucket_name;
- info.bucket.bucket_id = bucket_instance_id;
- ent.bucket = info.bucket;
-
- if (bucket_instance_id.empty()) {
- return get_bucket_info(dpp, y);
- }
-
- return store->getRados()->get_bucket_instance_info(*rctx, info.bucket, info, NULL, &attrs, y, dpp);
-}
-
-int RGWRadosBucket::get_bucket_stats(RGWBucketInfo& bucket_info, int shard_id,
+int RGWRadosBucket::get_bucket_stats(int shard_id,
std::string *bucket_ver, std::string *master_ver,
std::map<RGWObjCategory, RGWStorageStats>& stats,
std::string *max_marker, bool *syncstopped)
{
- return store->getRados()->get_bucket_stats(bucket_info, shard_id, bucket_ver, master_ver, stats, max_marker, syncstopped);
+ return store->getRados()->get_bucket_stats(info, shard_id, bucket_ver, master_ver, stats, max_marker, syncstopped);
+}
+
+int RGWRadosBucket::get_bucket_stats_async(int shard_id, RGWGetBucketStats_CB *ctx)
+{
+ return store->getRados()->get_bucket_stats_async(get_info(), shard_id, ctx);
}
int RGWRadosBucket::read_bucket_stats(const DoutPrefixProvider *dpp, optional_yield y)
return store->getRados()->check_bucket_shards(info, info.bucket, get_count(), dpp);
}
-int RGWRadosBucket::link(const DoutPrefixProvider *dpp, RGWUser* new_user, optional_yield y)
+int RGWRadosBucket::link(const DoutPrefixProvider *dpp, RGWUser* new_user, optional_yield y, bool update_entrypoint, RGWObjVersionTracker* objv)
{
RGWBucketEntryPoint ep;
ep.bucket = info.bucket;
RGWAttrs ep_attrs;
rgw_ep_info ep_data{ep, ep_attrs};
- return store->ctl()->bucket->link_bucket(new_user->get_user(), info.bucket,
- ceph::real_time(), y, dpp, true, &ep_data);
+ int r = store->ctl()->bucket->link_bucket(new_user->get_user(), info.bucket,
+ get_creation_time(), y, dpp, update_entrypoint,
+ &ep_data);
+ if (r < 0)
+ return r;
+
+ if (objv)
+ *objv = ep_data.ep_objv;
+
+ return r;
}
-int RGWRadosBucket::unlink(RGWUser* new_user, optional_yield y)
+int RGWRadosBucket::unlink(const DoutPrefixProvider *dpp, RGWUser* new_user, optional_yield y, bool update_entrypoint)
{
- return -1;
+ return store->ctl()->bucket->unlink_bucket(new_user->get_id(), info.bucket, y, dpp, update_entrypoint);
}
-int RGWRadosBucket::chown(RGWUser* new_user, RGWUser* old_user, optional_yield y, const DoutPrefixProvider *dpp)
+int RGWRadosBucket::chown(const DoutPrefixProvider *dpp, RGWUser* new_user, RGWUser* old_user, optional_yield y, const std::string* marker)
{
string obj_marker;
- return store->ctl()->bucket->chown(store, info, new_user->get_user(),
- old_user->get_display_name(), obj_marker, y, dpp);
+ if (marker == nullptr)
+ marker = &obj_marker;
+
+ return store->ctl()->bucket->chown(store, this, new_user->get_user(),
+ old_user->get_display_name(), *marker, y, dpp);
}
int RGWRadosBucket::put_instance_info(const DoutPrefixProvider *dpp, bool exclusive, ceph::real_time _mtime)
return store->getRados()->put_bucket_instance_info(info, exclusive, mtime, &attrs, dpp);
}
+int RGWRadosBucket::remove_entrypoint(const DoutPrefixProvider *dpp, RGWObjVersionTracker* objv, optional_yield y)
+{
+ return store->ctl()->bucket->remove_bucket_entrypoint_info(get_key(), y, dpp,
+ RGWBucketCtl::Bucket::RemoveParams()
+ .set_objv_tracker(objv));
+}
+
+int RGWRadosBucket::remove_instance_info(const DoutPrefixProvider *dpp, RGWObjVersionTracker* objv, optional_yield y)
+{
+ return store->ctl()->bucket->remove_bucket_instance_info(get_key(), info, y, dpp,
+ RGWBucketCtl::BucketInstance::RemoveParams()
+ .set_objv_tracker(objv));
+}
+
/* Make sure to call get_bucket_info() if you need it first */
bool RGWRadosBucket::is_owner(RGWUser* user)
{
RGWUsageIter& usage_iter,
map<rgw_user_bucket, rgw_usage_log_entry>& usage)
{
- return store->getRados()->read_usage(owner->get_id(), get_name(), start_epoch,
- end_epoch, max_entries, is_truncated,
- usage_iter, usage);
+ return store->getRados()->read_usage(owner->get_id(), get_name(), start_epoch,
+ end_epoch, max_entries, is_truncated,
+ usage_iter, usage);
+}
+
+int RGWRadosBucket::trim_usage(uint64_t start_epoch, uint64_t end_epoch)
+{
+ return store->getRados()->trim_usage(owner->get_id(), get_name(), start_epoch, end_epoch);
+}
+
+int RGWRadosBucket::remove_objs_from_index(std::list<rgw_obj_index_key>& objs_to_unlink)
+{
+ return store->getRados()->remove_objs_from_index(info, objs_to_unlink);
+}
+
+int RGWRadosBucket::check_index(std::map<RGWObjCategory, RGWStorageStats>& existing_stats, std::map<RGWObjCategory, RGWStorageStats>& calculated_stats)
+{
+ return store->getRados()->bucket_check_index(info, &existing_stats, &calculated_stats);
+}
+
+int RGWRadosBucket::rebuild_index()
+{
+ return store->getRados()->bucket_rebuild_index(info);
+}
+
+int RGWRadosBucket::set_tag_timeout(uint64_t timeout)
+{
+ return store->getRados()->cls_obj_set_bucket_tag_timeout(info, timeout);
+}
+
+int RGWRadosBucket::purge_instance(const DoutPrefixProvider *dpp)
+{
+ int max_shards = (info.layout.current_index.layout.normal.num_shards > 0 ? info.layout.current_index.layout.normal.num_shards : 1);
+ for (int i = 0; i < max_shards; i++) {
+ RGWRados::BucketShard bs(store->getRados());
+ int shard_id = (info.layout.current_index.layout.normal.num_shards > 0 ? i : -1);
+ int ret = bs.init(info.bucket, shard_id, info.layout.current_index, nullptr, dpp);
+ if (ret < 0) {
+ cerr << "ERROR: bs.init(bucket=" << info.bucket << ", shard=" << shard_id
+ << "): " << cpp_strerror(-ret) << std::endl;
+ return ret;
+ }
+ ret = store->getRados()->bi_remove(bs);
+ if (ret < 0) {
+ cerr << "ERROR: failed to remove bucket index object: "
+ << cpp_strerror(-ret) << std::endl;
+ return ret;
+ }
+ }
+ return 0;
}
int RGWRadosBucket::set_acl(const DoutPrefixProvider *dpp, RGWAccessControlPolicy &acl, optional_yield y)
list_op.params.marker = params.marker;
list_op.params.ns = params.ns;
list_op.params.end_marker = params.end_marker;
+ list_op.params.ns = params.ns;
+ list_op.params.enforce_ns = params.enforce_ns;
+ list_op.params.filter = params.filter;
list_op.params.list_versions = params.list_versions;
list_op.params.allow_unordered = params.allow_unordered;
return std::unique_ptr<RGWUser>(new RGWRadosUser(this, u));
}
-//RGWBucket *RGWRadosStore::create_bucket(RGWUser &u, const rgw_bucket &b)
-//{
- //if (!bucket) {
- //bucket = new RGWRadosBucket(this, u, b);
- //}
-//
- //return bucket;
-//}
-//
-void RGWRadosStore::finalize(void)
+int RGWRadosStore::get_user(const DoutPrefixProvider *dpp, const RGWAccessKey& key, optional_yield y, std::unique_ptr<RGWUser>* user)
{
- if (rados)
- rados->finalize();
-}
+ RGWUserInfo uinfo;
+ RGWUser *u;
-int RGWObject::range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end)
-{
- if (ofs < 0) {
- ofs += obj_size;
- if (ofs < 0)
- ofs = 0;
- end = obj_size - 1;
- } else if (end < 0) {
- end = obj_size - 1;
- }
+ int r = ctl()->user->get_info_by_access_key(dpp, key.id, &uinfo, y);
+ if (r < 0)
+ return r;
- if (obj_size > 0) {
- if (ofs >= (off_t)obj_size) {
- return -ERANGE;
- }
- if (end >= (off_t)obj_size) {
- end = obj_size - 1;
- }
- }
+ u = new RGWRadosUser(this, uinfo);
+ if (!u)
+ return -ENOMEM;
+
+ user->reset(u);
return 0;
}
-int RGWRadosObject::get_obj_state(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, RGWBucket& bucket, RGWObjState **state, optional_yield y, bool follow_olh)
+int RGWRadosStore::get_user_by_email(const DoutPrefixProvider *dpp, const std::string& email, optional_yield y, std::unique_ptr<RGWUser>* user)
{
- rgw_obj obj(bucket.get_key(), key.name);
+ RGWUserInfo uinfo;
+ RGWUser *u;
- return store->getRados()->get_obj_state(dpp, rctx, bucket.get_info(), obj, state, follow_olh, y);
-}
+ int r = ctl()->user->get_info_by_email(dpp, email, &uinfo, y);
+ if (r < 0)
+ return r;
-int RGWRadosObject::read_attrs(RGWRados::Object::Read &read_op, optional_yield y, const DoutPrefixProvider *dpp, rgw_obj *target_obj)
-{
- read_op.params.attrs = &attrs;
- read_op.params.target_obj = target_obj;
- read_op.params.obj_size = &obj_size;
- read_op.params.lastmod = &mtime;
+ u = new RGWRadosUser(this, uinfo);
+ if (!u)
+ return -ENOMEM;
- return read_op.prepare(y, dpp);
+ user->reset(u);
+ return 0;
}
-int RGWRadosObject::set_obj_attrs(const DoutPrefixProvider *dpp, RGWObjectCtx* rctx, RGWAttrs* setattrs, RGWAttrs* delattrs, optional_yield y, rgw_obj* target_obj)
+int RGWRadosStore::get_user_by_swift(const DoutPrefixProvider *dpp, const std::string& user_str, optional_yield y, std::unique_ptr<RGWUser>* user)
{
- RGWAttrs empty;
- rgw_obj target = get_obj();
+ RGWUserInfo uinfo;
+ RGWUser *u;
- if (!target_obj)
- target_obj = ⌖
-
- return store->getRados()->set_attrs(dpp, rctx,
- bucket->get_info(),
- *target_obj,
- setattrs ? *setattrs : empty,
- delattrs ? delattrs : nullptr,
- y);
-}
+ int r = ctl()->user->get_info_by_swift(dpp, user_str, &uinfo, y);
+ if (r < 0)
+ return r;
-int RGWRadosObject::get_obj_attrs(RGWObjectCtx *rctx, optional_yield y, const DoutPrefixProvider *dpp, rgw_obj* target_obj)
-{
- RGWRados::Object op_target(store->getRados(), bucket->get_info(), *rctx, get_obj());
- RGWRados::Object::Read read_op(&op_target);
+ u = new RGWRadosUser(this, uinfo);
+ if (!u)
+ return -ENOMEM;
- return read_attrs(read_op, y, dpp, target_obj);
+ user->reset(u);
+ return 0;
}
-int RGWRadosObject::modify_obj_attrs(RGWObjectCtx *rctx, const char *attr_name, bufferlist& attr_val, optional_yield y, const DoutPrefixProvider *dpp)
+std::unique_ptr<RGWObject> RGWRadosStore::get_object(const rgw_obj_key& k)
{
- rgw_obj target = get_obj();
- int r = get_obj_attrs(rctx, y, dpp, &target);
- if (r < 0) {
- return r;
- }
- set_atomic(rctx);
- attrs[attr_name] = attr_val;
- return set_obj_attrs(dpp, rctx, &attrs, nullptr, y, &target);
+ return std::unique_ptr<RGWObject>(new RGWRadosObject(this, k));
}
-int RGWRadosObject::delete_obj_attrs(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, const char *attr_name, optional_yield y)
+int RGWRadosStore::get_bucket(const DoutPrefixProvider *dpp, RGWUser* u, const rgw_bucket& b, std::unique_ptr<RGWBucket>* bucket, optional_yield y)
{
- RGWAttrs rmattr;
- bufferlist bl;
+ int ret;
+ RGWBucket* bp;
- set_atomic(rctx);
- rmattr[attr_name] = bl;
- return set_obj_attrs(dpp, rctx, nullptr, &rmattr, y);
+ bp = new RGWRadosBucket(this, b, u);
+ ret = bp->get_bucket_info(dpp, y);
+ if (ret < 0) {
+ delete bp;
+ return ret;
+ }
+
+ bucket->reset(bp);
+ return 0;
}
-int RGWRadosObject::copy_obj_data(RGWObjectCtx& rctx, RGWBucket* dest_bucket,
- RGWObject* dest_obj,
- uint16_t olh_epoch,
- std::string* petag,
- const DoutPrefixProvider *dpp,
- optional_yield y)
+int RGWRadosStore::get_bucket(RGWUser* u, const RGWBucketInfo& i, std::unique_ptr<RGWBucket>* bucket)
{
- RGWAttrs attrset;
- RGWRados::Object op_target(store->getRados(), dest_bucket->get_info(), rctx, get_obj());
- RGWRados::Object::Read read_op(&op_target);
-
- int ret = read_attrs(read_op, y, dpp);
- if (ret < 0)
- return ret;
-
- attrset = attrs;
+ RGWBucket* bp;
- attrset.erase(RGW_ATTR_ID_TAG);
- attrset.erase(RGW_ATTR_TAIL_TAG);
+ bp = new RGWRadosBucket(this, i, u);
+ /* Don't need to fetch the bucket info, use the provided one */
- return store->getRados()->copy_obj_data(rctx, dest_bucket,
- dest_bucket->get_info().placement_rule, read_op,
- obj_size - 1, dest_obj, NULL, mtime, attrset, 0,
- real_time(), NULL, dpp, y);
+ bucket->reset(bp);
+ return 0;
}
-void RGWRadosObject::set_atomic(RGWObjectCtx *rctx) const
+int RGWRadosStore::get_bucket(const DoutPrefixProvider *dpp, RGWUser* u, const std::string& tenant, const std::string& name, std::unique_ptr<RGWBucket>* bucket, optional_yield y)
{
- rgw_obj obj = get_obj();
- store->getRados()->set_atomic(rctx, obj);
-}
+ rgw_bucket b;
-void RGWRadosObject::set_prefetch_data(RGWObjectCtx *rctx)
-{
- rgw_obj obj = get_obj();
- store->getRados()->set_prefetch_data(rctx, obj);
+ b.tenant = tenant;
+ b.name = name;
+
+ return get_bucket(dpp, u, b, bucket, y);
}
-bool RGWRadosObject::is_expired() {
- auto iter = attrs.find(RGW_ATTR_DELETE_AT);
- if (iter != attrs.end()) {
- utime_t delete_at;
+int RGWRadosStore::create_bucket(const DoutPrefixProvider *dpp,
+ RGWUser& u, const rgw_bucket& b,
+ const string& zonegroup_id,
+ rgw_placement_rule& placement_rule,
+ string& swift_ver_location,
+ const RGWQuotaInfo * pquota_info,
+ const RGWAccessControlPolicy& policy,
+ RGWAttrs& attrs,
+ RGWBucketInfo& info,
+ obj_version& ep_objv,
+ bool exclusive,
+ bool obj_lock_enabled,
+ bool *existed,
+ req_info& req_info,
+ std::unique_ptr<RGWBucket>* bucket_out,
+ optional_yield y)
+{
+ int ret;
+ bufferlist in_data;
+ RGWBucketInfo master_info;
+ rgw_bucket *pmaster_bucket;
+ uint32_t *pmaster_num_shards;
+ real_time creation_time;
+ std::unique_ptr<RGWBucket> bucket;
+ obj_version objv, *pobjv = NULL;
+
+ /* If it exists, look it up; otherwise create it */
+ ret = get_bucket(dpp, &u, b, &bucket, y);
+ if (ret < 0 && ret != -ENOENT)
+ return ret;
+
+ if (ret != -ENOENT) {
+ RGWAccessControlPolicy old_policy(ctx());
+ *existed = true;
+ if (swift_ver_location.empty()) {
+ swift_ver_location = bucket->get_info().swift_ver_location;
+ }
+ placement_rule.inherit_from(bucket->get_info().placement_rule);
+
+ // don't allow changes to the acl policy
+ int r = rgw_op_get_bucket_policy_from_attr(dpp, this, u, bucket->get_attrs(),
+ &old_policy, y);
+ if (r >= 0 && old_policy != policy) {
+ bucket_out->swap(bucket);
+ return -EEXIST;
+ }
+ } else {
+ bucket = std::unique_ptr<RGWBucket>(new RGWRadosBucket(this, b, &u));
+ *existed = false;
+ bucket->set_attrs(attrs);
+ }
+
+ if (!svc()->zone->is_meta_master()) {
+ JSONParser jp;
+ ret = forward_request_to_master(&u, NULL, in_data, &jp, req_info, y);
+ if (ret < 0) {
+ return ret;
+ }
+
+ JSONDecoder::decode_json("entry_point_object_ver", ep_objv, &jp);
+ JSONDecoder::decode_json("object_ver", objv, &jp);
+ JSONDecoder::decode_json("bucket_info", master_info, &jp);
+ ldpp_dout(dpp, 20) << "parsed: objv.tag=" << objv.tag << " objv.ver=" << objv.ver << dendl;
+ std::time_t ctime = ceph::real_clock::to_time_t(master_info.creation_time);
+ ldpp_dout(dpp, 20) << "got creation time: << " << std::put_time(std::localtime(&ctime), "%F %T") << dendl;
+ pmaster_bucket= &master_info.bucket;
+ creation_time = master_info.creation_time;
+ pmaster_num_shards = &master_info.layout.current_index.layout.normal.num_shards;
+ pobjv = &objv;
+ if (master_info.obj_lock_enabled()) {
+ info.flags = BUCKET_VERSIONED | BUCKET_OBJ_LOCK_ENABLED;
+ }
+ } else {
+ pmaster_bucket = NULL;
+ pmaster_num_shards = NULL;
+ if (obj_lock_enabled)
+ info.flags = BUCKET_VERSIONED | BUCKET_OBJ_LOCK_ENABLED;
+ }
+
+ std::string zid = zonegroup_id;
+ if (zid.empty()) {
+ zid = svc()->zone->get_zonegroup().get_id();
+ }
+
+ if (*existed) {
+ rgw_placement_rule selected_placement_rule;
+ ret = svc()->zone->select_bucket_placement(u.get_info(),
+ zid, placement_rule,
+ &selected_placement_rule, nullptr, y);
+ if (selected_placement_rule != info.placement_rule) {
+ ret = -EEXIST;
+ bucket_out->swap(bucket);
+ return ret;
+ }
+ } else {
+
+ ret = getRados()->create_bucket(u.get_info(), bucket->get_key(),
+ zid, placement_rule, swift_ver_location, pquota_info,
+ attrs, info, pobjv, &ep_objv, creation_time,
+ pmaster_bucket, pmaster_num_shards, y, dpp,
+ exclusive);
+ if (ret == -EEXIST) {
+ *existed = true;
+ ret = 0;
+ } else if (ret != 0) {
+ return ret;
+ }
+ }
+
+ bucket->set_version(ep_objv);
+ bucket->get_info() = info;
+
+ bucket_out->swap(bucket);
+
+ return ret;
+}
+
+bool RGWRadosStore::is_meta_master()
+{
+ return svc()->zone->is_meta_master();
+}
+
+int RGWRadosStore::forward_request_to_master(RGWUser* user, obj_version *objv,
+ bufferlist& in_data,
+ JSONParser *jp, req_info& info,
+ optional_yield y)
+{
+ if (is_meta_master()) {
+ /* We're master, don't forward */
+ return 0;
+ }
+
+ if (!svc()->zone->get_master_conn()) {
+ ldout(ctx(), 0) << "rest connection is invalid" << dendl;
+ return -EINVAL;
+ }
+ ldout(ctx(), 0) << "sending request to master zonegroup" << dendl;
+ bufferlist response;
+ string uid_str = user->get_id().to_str();
+#define MAX_REST_RESPONSE (128 * 1024) // we expect a very small response
+ int ret = svc()->zone->get_master_conn()->forward(rgw_user(uid_str), info,
+ objv, MAX_REST_RESPONSE,
+ &in_data, &response, y);
+ if (ret < 0)
+ return ret;
+
+ ldout(ctx(), 20) << "response: " << response.c_str() << dendl;
+ if (jp && !jp->parse(response.c_str(), response.length())) {
+ ldout(ctx(), 0) << "failed parsing response from master zonegroup" << dendl;
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+int RGWRadosStore::defer_gc(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, RGWBucket* bucket, RGWObject* obj, optional_yield y)
+{
+ return rados->defer_gc(dpp, rctx, bucket->get_info(), obj->get_obj(), y);
+}
+
+const RGWZoneGroup& RGWRadosStore::get_zonegroup()
+{
+ return svc()->zone->get_zonegroup();
+}
+
+int RGWRadosStore::get_zonegroup(const string& id, RGWZoneGroup& zonegroup)
+{
+ return svc()->zone->get_zonegroup(id, zonegroup);
+}
+
+const RGWZoneParams& RGWRadosStore::get_zone_params()
+{
+ return svc()->zone->get_zone_params();
+}
+
+const rgw_zone_id& RGWRadosStore::get_zone_id()
+{
+ return svc()->zone->zone_id();
+}
+
+const RGWRealm& RGWRadosStore::get_realm()
+{
+ return svc()->zone->get_realm();
+}
+
+int RGWRadosStore::cluster_stat(RGWClusterStat& stats)
+{
+ rados_cluster_stat_t rados_stats;
+ int ret;
+
+ ret = rados->get_rados_handle()->cluster_stat(rados_stats);
+ if (ret < 0)
+ return ret;
+
+ stats.kb = rados_stats.kb;
+ stats.kb_used = rados_stats.kb_used;
+ stats.kb_avail = rados_stats.kb_avail;
+ stats.num_objects = rados_stats.num_objects;
+
+ return ret;
+}
+
+std::unique_ptr<Lifecycle> RGWRadosStore::get_lifecycle(void)
+{
+ return std::unique_ptr<Lifecycle>(new RadosLifecycle(this));
+}
+
+std::unique_ptr<Completions> RGWRadosStore::get_completions(void)
+{
+ return std::unique_ptr<Completions>(new RadosCompletions());
+}
+
+std::unique_ptr<Notification> RGWRadosStore::get_notification(rgw::sal::RGWObject* obj,
+ struct req_state* s,
+ rgw::notify::EventType event_type)
+{
+ return std::unique_ptr<Notification>(new RadosNotification(this, obj, s, event_type));
+}
+
+std::unique_ptr<GCChain> RGWRadosStore::get_gc_chain(rgw::sal::RGWObject* obj)
+{
+ return std::unique_ptr<GCChain>(new RadosGCChain(this, obj));
+}
+
+std::unique_ptr<Writer> RGWRadosStore::get_writer(Aio *aio, rgw::sal::RGWBucket* bucket,
+ RGWObjectCtx& obj_ctx, std::unique_ptr<rgw::sal::RGWObject> _head_obj,
+ const DoutPrefixProvider *dpp, optional_yield y)
+{
+ return std::unique_ptr<Writer>(new RadosWriter(aio, this, bucket, obj_ctx, std::move(_head_obj), dpp, y));
+}
+
+int RGWRadosStore::delete_raw_obj(const rgw_raw_obj& obj)
+{
+ return rados->delete_raw_obj(obj);
+}
+
+int RGWRadosStore::delete_raw_obj_aio(const rgw_raw_obj& obj, Completions* aio)
+{
+ RadosCompletions *raio = static_cast<RadosCompletions*>(aio);
+
+ return rados->delete_raw_obj_aio(obj, raio->handles);
+}
+
+void RGWRadosStore::get_raw_obj(const rgw_placement_rule& placement_rule, const rgw_obj& obj, rgw_raw_obj* raw_obj)
+{
+ rados->obj_to_raw(placement_rule, obj, raw_obj);
+}
+
+int RGWRadosStore::get_raw_chunk_size(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, uint64_t* chunk_size)
+{
+ return rados->get_max_chunk_size(obj.pool, chunk_size, dpp);
+}
+
+int RGWRadosStore::log_usage(map<rgw_user_bucket, RGWUsageBatch>& usage_info)
+{
+ return rados->log_usage(usage_info);
+}
+
+int RGWRadosStore::log_op(string& oid, bufferlist& bl)
+{
+ rgw_raw_obj obj(svc()->zone->get_zone_params().log_pool, oid);
+
+ int ret = rados->append_async(obj, bl.length(), bl);
+ if (ret == -ENOENT) {
+ ret = rados->create_pool(svc()->zone->get_zone_params().log_pool);
+ if (ret < 0)
+ return ret;
+ // retry
+ ret = rados->append_async(obj, bl.length(), bl);
+ }
+
+ return ret;
+}
+
+int RGWRadosStore::register_to_service_map(const string& daemon_type,
+ const map<string, string>& meta)
+{
+ return rados->register_to_service_map(daemon_type, meta);
+}
+
+void RGWRadosStore::get_quota(RGWQuotaInfo& bucket_quota, RGWQuotaInfo& user_quota)
+{
+ bucket_quota = svc()->quota->get_bucket_quota();
+ user_quota = svc()->quota->get_user_quota();
+}
+
+int RGWRadosStore::list_raw_objects(const rgw_pool& pool, const string& prefix_filter,
+ int max, RGWListRawObjsCtx& ctx, list<string>& oids,
+ bool *is_truncated)
+{
+ return rados->list_raw_objects(pool, prefix_filter, max, ctx, oids, is_truncated);
+}
+
+int RGWRadosStore::set_buckets_enabled(const DoutPrefixProvider *dpp, vector<rgw_bucket>& buckets, bool enabled)
+{
+ return rados->set_buckets_enabled(buckets, enabled, dpp);
+}
+
+int RGWRadosStore::get_sync_policy_handler(const DoutPrefixProvider *dpp,
+ std::optional<rgw_zone_id> zone,
+ std::optional<rgw_bucket> bucket,
+ RGWBucketSyncPolicyHandlerRef *phandler,
+ optional_yield y)
+{
+ return ctl()->bucket->get_sync_policy_handler(zone, bucket, phandler, y, dpp);
+}
+
+RGWDataSyncStatusManager* RGWRadosStore::get_data_sync_manager(const rgw_zone_id& source_zone)
+{
+ return rados->get_data_sync_manager(source_zone);
+}
+
+int RGWRadosStore::read_all_usage(uint64_t start_epoch, uint64_t end_epoch,
+ uint32_t max_entries, bool *is_truncated,
+ RGWUsageIter& usage_iter,
+ map<rgw_user_bucket, rgw_usage_log_entry>& usage)
+{
+ rgw_user uid;
+ std::string bucket_name;
+
+ return rados->read_usage(uid, bucket_name, start_epoch, end_epoch, max_entries,
+ is_truncated, usage_iter, usage);
+}
+
+int RGWRadosStore::trim_all_usage(uint64_t start_epoch, uint64_t end_epoch)
+{
+ rgw_user uid;
+ std::string bucket_name;
+
+ return rados->trim_usage(uid, bucket_name, start_epoch, end_epoch);
+}
+
+int RGWRadosStore::get_config_key_val(string name, bufferlist *bl)
+{
+ return svc()->config_key->get(name, true, bl);
+}
+
+void RGWRadosStore::finalize(void)
+{
+ if (rados)
+ rados->finalize();
+}
+
+int RGWRadosStore::get_obj_head_ioctx(const RGWBucketInfo& bucket_info, const rgw_obj& obj, librados::IoCtx *ioctx)
+{
+ return rados->get_obj_head_ioctx(bucket_info, obj, ioctx);
+}
+
+int RGWObject::range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end)
+{
+ if (ofs < 0) {
+ ofs += obj_size;
+ if (ofs < 0)
+ ofs = 0;
+ end = obj_size - 1;
+ } else if (end < 0) {
+ end = obj_size - 1;
+ }
+
+ if (obj_size > 0) {
+ if (ofs >= (off_t)obj_size) {
+ return -ERANGE;
+ }
+ if (end >= (off_t)obj_size) {
+ end = obj_size - 1;
+ }
+ }
+ return 0;
+}
+
+int RGWRadosObject::get_obj_state(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, RGWObjState **state, optional_yield y, bool follow_olh)
+{
+ return store->getRados()->get_obj_state(dpp, rctx, bucket->get_info(), get_obj(), state, follow_olh, y);
+}
+
+int RGWRadosObject::read_attrs(const DoutPrefixProvider *dpp, RGWRados::Object::Read &read_op, optional_yield y, rgw_obj *target_obj)
+{
+ read_op.params.attrs = &attrs;
+ read_op.params.target_obj = target_obj;
+ read_op.params.obj_size = &obj_size;
+ read_op.params.lastmod = &mtime;
+
+ return read_op.prepare(y, dpp);
+}
+
+int RGWRadosObject::set_obj_attrs(const DoutPrefixProvider *dpp, RGWObjectCtx* rctx, RGWAttrs* setattrs, RGWAttrs* delattrs, optional_yield y, rgw_obj* target_obj)
+{
+ RGWAttrs empty;
+ rgw_obj target = get_obj();
+
+ if (!target_obj)
+ target_obj = ⌖
+
+ return store->getRados()->set_attrs(dpp, rctx,
+ bucket->get_info(),
+ *target_obj,
+ setattrs ? *setattrs : empty,
+ delattrs ? delattrs : nullptr,
+ y);
+}
+
+int RGWRadosObject::get_obj_attrs(RGWObjectCtx *rctx, optional_yield y, const DoutPrefixProvider *dpp, rgw_obj* target_obj)
+{
+ RGWRados::Object op_target(store->getRados(), bucket->get_info(), *rctx, get_obj());
+ RGWRados::Object::Read read_op(&op_target);
+
+ return read_attrs(dpp, read_op, y, target_obj);
+}
+
+int RGWRadosObject::modify_obj_attrs(RGWObjectCtx *rctx, const char *attr_name, bufferlist& attr_val, optional_yield y, const DoutPrefixProvider *dpp)
+{
+ rgw_obj target = get_obj();
+ int r = get_obj_attrs(rctx, y, dpp, &target);
+ if (r < 0) {
+ return r;
+ }
+ set_atomic(rctx);
+ attrs[attr_name] = attr_val;
+ return set_obj_attrs(dpp, rctx, &attrs, nullptr, y, &target);
+}
+
+int RGWRadosObject::delete_obj_attrs(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, const char *attr_name, optional_yield y)
+{
+ RGWAttrs rmattr;
+ bufferlist bl;
+
+ set_atomic(rctx);
+ rmattr[attr_name] = bl;
+ return set_obj_attrs(dpp, rctx, nullptr, &rmattr, y);
+}
+
+int RGWRadosObject::copy_obj_data(RGWObjectCtx& rctx, RGWBucket* dest_bucket,
+ RGWObject* dest_obj,
+ uint16_t olh_epoch,
+ std::string* petag,
+ const DoutPrefixProvider *dpp,
+ optional_yield y)
+{
+ RGWAttrs attrset;
+ RGWRados::Object op_target(store->getRados(), dest_bucket->get_info(), rctx, get_obj());
+ RGWRados::Object::Read read_op(&op_target);
+
+ int ret = read_attrs(dpp, read_op, y);
+ if (ret < 0)
+ return ret;
+
+ attrset = attrs;
+
+ attrset.erase(RGW_ATTR_ID_TAG);
+ attrset.erase(RGW_ATTR_TAIL_TAG);
+
+ return store->getRados()->copy_obj_data(rctx, dest_bucket,
+ dest_bucket->get_info().placement_rule, read_op,
+ obj_size - 1, dest_obj, NULL, mtime, attrset, 0,
+ real_time(), NULL, dpp, y);
+}
+
+void RGWRadosObject::set_atomic(RGWObjectCtx *rctx) const
+{
+ rgw_obj obj = get_obj();
+ store->getRados()->set_atomic(rctx, obj);
+}
+
+void RGWRadosObject::set_prefetch_data(RGWObjectCtx *rctx)
+{
+ rgw_obj obj = get_obj();
+ store->getRados()->set_prefetch_data(rctx, obj);
+}
+
+bool RGWRadosObject::is_expired() {
+ auto iter = attrs.find(RGW_ATTR_DELETE_AT);
+ if (iter != attrs.end()) {
+ utime_t delete_at;
try {
auto bufit = iter->second.cbegin();
decode(delete_at, bufit);
store->getRados()->obj_to_raw((bucket->get_info()).placement_rule, get_obj(), raw_obj);
}
+int RGWRadosObject::omap_get_vals(const string& marker, uint64_t count,
+ std::map<string, bufferlist> *m,
+ bool *pmore, optional_yield y)
+{
+ auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
+ rgw_raw_obj raw_obj;
+ get_raw_obj(&raw_obj);
+ auto sysobj = obj_ctx.get_obj(raw_obj);
+
+ return sysobj.omap().get_vals(marker, count, m, pmore, y);
+}
+
+int RGWRadosObject::omap_get_all(std::map<string, bufferlist> *m,
+ optional_yield y)
+{
+ auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
+ rgw_raw_obj raw_obj;
+ get_raw_obj(&raw_obj);
+ auto sysobj = obj_ctx.get_obj(raw_obj);
+
+ return sysobj.omap().get_all(m, y);
+}
+
int RGWRadosObject::omap_get_vals_by_keys(const std::string& oid,
const std::set<std::string>& keys,
RGWAttrs *vals)
return parent_op.get_attr(dpp, name, dest, y);
}
-int RGWRadosObject::delete_object(const DoutPrefixProvider *dpp, RGWObjectCtx* obj_ctx, ACLOwner obj_owner, ACLOwner bucket_owner, ceph::real_time unmod_since, bool high_precision_time, uint64_t epoch, string& version_id, optional_yield y)
+std::unique_ptr<RGWObject::DeleteOp> RGWRadosObject::get_delete_op(RGWObjectCtx *ctx)
+{
+ return std::unique_ptr<RGWObject::DeleteOp>(new RGWRadosObject::RadosDeleteOp(this, ctx));
+}
+
+RGWRadosObject::RadosDeleteOp::RadosDeleteOp(RGWRadosObject *_source, RGWObjectCtx *_rctx) :
+ source(_source),
+ rctx(_rctx),
+ op_target(_source->store->getRados(),
+ _source->get_bucket()->get_info(),
+ *static_cast<RGWObjectCtx *>(rctx),
+ _source->get_obj()),
+ parent_op(&op_target)
+{ }
+
+int RGWRadosObject::RadosDeleteOp::delete_obj(const DoutPrefixProvider *dpp, optional_yield y)
+{
+ parent_op.params.bucket_owner = params.bucket_owner.get_id();
+ parent_op.params.versioning_status = params.versioning_status;
+ parent_op.params.obj_owner = params.obj_owner;
+ parent_op.params.olh_epoch = params.olh_epoch;
+ parent_op.params.marker_version_id = params.marker_version_id;
+ parent_op.params.bilog_flags = params.bilog_flags;
+ parent_op.params.remove_objs = params.remove_objs;
+ parent_op.params.expiration_time = params.expiration_time;
+ parent_op.params.unmod_since = params.unmod_since;
+ parent_op.params.mtime = params.mtime;
+ parent_op.params.high_precision_time = params.high_precision_time;
+ parent_op.params.zones_trace = params.zones_trace;
+ parent_op.params.abortmp = params.abortmp;
+ parent_op.params.parts_accounted_size = params.parts_accounted_size;
+
+ int ret = parent_op.delete_obj(y, dpp);
+ if (ret < 0)
+ return ret;
+
+ result.delete_marker = parent_op.result.delete_marker;
+ result.version_id = parent_op.result.version_id;
+
+ return ret;
+}
+
+int RGWRadosObject::delete_object(const DoutPrefixProvider *dpp, RGWObjectCtx* obj_ctx, optional_yield y)
{
- int ret = 0;
RGWRados::Object del_target(store->getRados(), bucket->get_info(), *obj_ctx, get_obj());
RGWRados::Object::Delete del_op(&del_target);
- del_op.params.olh_epoch = epoch;
- del_op.params.marker_version_id = version_id;
- del_op.params.bucket_owner = bucket_owner.get_id();
+ del_op.params.bucket_owner = bucket->get_info().owner;
del_op.params.versioning_status = bucket->get_info().versioning_status();
- del_op.params.obj_owner = obj_owner;
- del_op.params.unmod_since = unmod_since;
- del_op.params.high_precision_time = high_precision_time;
- ret = del_op.delete_obj(y, dpp);
- if (ret >= 0) {
- delete_marker = del_op.result.delete_marker;
- version_id = del_op.result.version_id;
- }
+ return del_op.delete_obj(y, dpp);
+}
+
+int RGWRadosObject::delete_obj_aio(const DoutPrefixProvider *dpp, RGWObjState *astate,
+ Completions* aio, bool keep_index_consistent,
+ optional_yield y)
+{
+ RadosCompletions* raio = static_cast<RadosCompletions*>(aio);
+
+ return store->getRados()->delete_obj_aio(dpp, get_obj(), bucket->get_info(), astate,
+ raio->handles, keep_index_consistent, y);
+}
+
+std::unique_ptr<RGWObject::StatOp> RGWRadosObject::get_stat_op(RGWObjectCtx *ctx)
+{
+ return std::unique_ptr<RGWObject::StatOp>(new RGWRadosObject::RadosStatOp(this, ctx));
+}
+
+RGWRadosObject::RadosStatOp::RadosStatOp(RGWRadosObject *_source, RGWObjectCtx *_rctx) :
+ source(_source),
+ rctx(_rctx),
+ op_target(_source->store->getRados(),
+ _source->get_bucket()->get_info(),
+ *static_cast<RGWObjectCtx *>(rctx),
+ _source->get_obj()),
+ parent_op(&op_target)
+{ }
+
+int RGWRadosObject::RadosStatOp::stat_async()
+{
+ return parent_op.stat_async();
+}
+
+int RGWRadosObject::RadosStatOp::wait()
+{
+ result.obj = source;
+ int ret = parent_op.wait();
+ if (ret < 0)
+ return ret;
+
+ source->obj_size = parent_op.result.size;
+ source->mtime = ceph::real_clock::from_timespec(parent_op.result.mtime);
+ source->attrs = parent_op.result.attrs;
+ source->key = parent_op.result.obj.key;
+ source->in_extra_data = parent_op.result.obj.in_extra_data;
+ source->index_hash_source = parent_op.result.obj.index_hash_source;
+ if (parent_op.result.manifest)
+ result.manifest = &(*parent_op.result.manifest);
+ else
+ result.manifest = nullptr;
return ret;
}
if_match,
if_nomatch,
static_cast<RGWRados::AttrsMod>(attrs_mod),
- copy_if_newer,
- attrs,
- category,
- olh_epoch,
- (delete_at ? *delete_at : real_time()),
- version_id,
- tag,
- etag,
- progress_cb,
- progress_data,
- dpp,
- y);
-}
-
-int RGWRadosObject::RadosReadOp::iterate(const DoutPrefixProvider *dpp, int64_t ofs, int64_t end, RGWGetDataCB *cb, optional_yield y)
-{
- return parent_op.iterate(dpp, ofs, end, cb, y);
-}
-
-std::unique_ptr<RGWObject::WriteOp> RGWRadosObject::get_write_op(RGWObjectCtx* ctx)
-{
- return std::unique_ptr<RGWObject::WriteOp>(new RGWRadosObject::RadosWriteOp(this, ctx));
-}
-
-RGWRadosObject::RadosWriteOp::RadosWriteOp(RGWRadosObject* _source, RGWObjectCtx* _rctx) :
- source(_source),
- rctx(_rctx),
- op_target(_source->store->getRados(),
- _source->get_bucket()->get_info(),
- *static_cast<RGWObjectCtx *>(rctx),
- _source->get_obj()),
- parent_op(&op_target)
-{ }
-
-int RGWRadosObject::RadosWriteOp::prepare(optional_yield y)
-{
- op_target.set_versioning_disabled(params.versioning_disabled);
- parent_op.meta.mtime = params.mtime;
- parent_op.meta.rmattrs = params.rmattrs;
- parent_op.meta.data = params.data;
- parent_op.meta.manifest = params.manifest;
- parent_op.meta.ptag = params.ptag;
- parent_op.meta.remove_objs = params.remove_objs;
- parent_op.meta.set_mtime = params.set_mtime;
- parent_op.meta.owner = params.owner.get_id();
- parent_op.meta.category = params.category;
- parent_op.meta.flags = params.flags;
- parent_op.meta.if_match = params.if_match;
- parent_op.meta.if_nomatch = params.if_nomatch;
- parent_op.meta.olh_epoch = params.olh_epoch;
- parent_op.meta.delete_at = params.delete_at;
- parent_op.meta.canceled = params.canceled;
- parent_op.meta.user_data = params.user_data;
- parent_op.meta.zones_trace = params.zones_trace;
- parent_op.meta.modify_tail = params.modify_tail;
- parent_op.meta.completeMultipart = params.completeMultipart;
- parent_op.meta.appendable = params.appendable;
-
- return 0;
-}
-
-int RGWRadosObject::RadosWriteOp::write_meta(const DoutPrefixProvider *dpp, uint64_t size, uint64_t accounted_size, optional_yield y)
-{
- int ret = parent_op.write_meta(dpp, size, accounted_size, *params.attrs, y);
- params.canceled = parent_op.meta.canceled;
-
- return ret;
-}
-
-int RGWRadosObject::swift_versioning_restore(RGWObjectCtx* obj_ctx,
- bool& restored,
- const DoutPrefixProvider *dpp)
-{
- return store->getRados()->swift_versioning_restore(*obj_ctx,
- bucket->get_owner()->get_id(),
- bucket,
- this,
- restored,
- dpp);
-}
-
-int RGWRadosObject::swift_versioning_copy(RGWObjectCtx* obj_ctx,
- const DoutPrefixProvider *dpp,
- optional_yield y)
-{
- return store->getRados()->swift_versioning_copy(*obj_ctx,
- bucket->get_info().owner,
- bucket,
- this,
- dpp,
- y);
-}
-
-int RGWRadosStore::get_bucket(const DoutPrefixProvider *dpp, RGWUser* u, const rgw_bucket& b, std::unique_ptr<RGWBucket>* bucket, optional_yield y)
-{
- int ret;
- RGWBucket* bp;
-
- bp = new RGWRadosBucket(this, b, u);
- ret = bp->get_bucket_info(dpp, y);
- if (ret < 0) {
- delete bp;
- return ret;
- }
-
- bucket->reset(bp);
- return 0;
-}
-
-int RGWRadosStore::get_bucket(RGWUser* u, const RGWBucketInfo& i, std::unique_ptr<RGWBucket>* bucket)
-{
- RGWBucket* bp;
-
- bp = new RGWRadosBucket(this, i, u);
- /* Don't need to fetch the bucket info, use the provided one */
-
- bucket->reset(bp);
- return 0;
-}
-
-int RGWRadosStore::get_bucket(const DoutPrefixProvider *dpp, RGWUser* u, const std::string& tenant, const std::string&name, std::unique_ptr<RGWBucket>* bucket, optional_yield y)
-{
- rgw_bucket b;
-
- b.tenant = tenant;
- b.name = name;
-
- return get_bucket(dpp, u, b, bucket, y);
-}
-
-static int decode_policy(CephContext *cct,
- bufferlist& bl,
- RGWAccessControlPolicy *policy)
-{
- auto iter = bl.cbegin();
- try {
- policy->decode(iter);
- } catch (buffer::error& err) {
- ldout(cct, 0) << "ERROR: could not decode policy, caught buffer::error" << dendl;
- return -EIO;
- }
- if (cct->_conf->subsys.should_gather<ceph_subsys_rgw, 15>()) {
- ldout(cct, 15) << __func__ << " Read AccessControlPolicy";
- RGWAccessControlPolicy_S3 *s3policy = static_cast<RGWAccessControlPolicy_S3 *>(policy);
- s3policy->to_xml(*_dout);
- *_dout << dendl;
- }
- return 0;
-}
-
-static int rgw_op_get_bucket_policy_from_attr(const DoutPrefixProvider *dpp, RGWRadosStore *store,
- RGWUser& user,
- RGWAttrs& bucket_attrs,
- RGWAccessControlPolicy *policy,
- optional_yield y)
-{
- auto aiter = bucket_attrs.find(RGW_ATTR_ACL);
-
- if (aiter != bucket_attrs.end()) {
- int ret = decode_policy(store->ctx(), aiter->second, policy);
- if (ret < 0)
- return ret;
- } else {
- ldout(store->ctx(), 0) << "WARNING: couldn't find acl header for bucket, generating default" << dendl;
- /* object exists, but policy is broken */
- int r = user.load_by_id(dpp, y);
- if (r < 0)
- return r;
-
- policy->create_default(user.get_user(), user.get_display_name());
- }
- return 0;
-}
-
-bool RGWRadosStore::is_meta_master()
-{
- return svc()->zone->is_meta_master();
-}
-
-int RGWRadosStore::forward_request_to_master(RGWUser* user, obj_version *objv,
- bufferlist& in_data,
- JSONParser *jp, req_info& info,
- optional_yield y)
-{
- if (is_meta_master()) {
- /* We're master, don't forward */
- return 0;
- }
-
- if (!svc()->zone->get_master_conn()) {
- ldout(ctx(), 0) << "rest connection is invalid" << dendl;
- return -EINVAL;
- }
- ldout(ctx(), 0) << "sending request to master zonegroup" << dendl;
- bufferlist response;
- string uid_str = user->get_id().to_str();
-#define MAX_REST_RESPONSE (128 * 1024) // we expect a very small response
- int ret = svc()->zone->get_master_conn()->forward(rgw_user(uid_str), info,
- objv, MAX_REST_RESPONSE,
- &in_data, &response, y);
- if (ret < 0)
- return ret;
-
- ldout(ctx(), 20) << "response: " << response.c_str() << dendl;
- if (jp && !jp->parse(response.c_str(), response.length())) {
- ldout(ctx(), 0) << "failed parsing response from master zonegroup" << dendl;
- return -EINVAL;
- }
-
- return 0;
+ copy_if_newer,
+ attrs,
+ category,
+ olh_epoch,
+ (delete_at ? *delete_at : real_time()),
+ version_id,
+ tag,
+ etag,
+ progress_cb,
+ progress_data,
+ dpp,
+ y);
}
-int RGWRadosStore::defer_gc(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, RGWBucket* bucket, RGWObject* obj, optional_yield y)
+int RGWRadosObject::RadosReadOp::iterate(const DoutPrefixProvider *dpp, int64_t ofs, int64_t end, RGWGetDataCB *cb, optional_yield y)
{
- return rados->defer_gc(dpp, rctx, bucket->get_info(), obj->get_obj(), y);
+ return parent_op.iterate(dpp, ofs, end, cb, y);
}
-const RGWZoneGroup& RGWRadosStore::get_zonegroup()
+std::unique_ptr<RGWObject::WriteOp> RGWRadosObject::get_write_op(RGWObjectCtx* ctx)
{
- return rados->svc.zone->get_zonegroup();
+ return std::unique_ptr<RGWObject::WriteOp>(new RGWRadosObject::RadosWriteOp(this, ctx));
}
-int RGWRadosStore::get_zonegroup(const string& id, RGWZoneGroup& zonegroup)
-{
- return rados->svc.zone->get_zonegroup(id, zonegroup);
-}
+RGWRadosObject::RadosWriteOp::RadosWriteOp(RGWRadosObject* _source, RGWObjectCtx* _rctx) :
+ source(_source),
+ rctx(_rctx),
+ op_target(_source->store->getRados(),
+ _source->get_bucket()->get_info(),
+ *static_cast<RGWObjectCtx *>(rctx),
+ _source->get_obj()),
+ parent_op(&op_target)
+{ }
-int RGWRadosStore::cluster_stat(RGWClusterStat& stats)
+int RGWRadosObject::RadosWriteOp::prepare(optional_yield y)
{
- rados_cluster_stat_t rados_stats;
- int ret;
-
- ret = rados->get_rados_handle()->cluster_stat(rados_stats);
- if (ret < 0)
- return ret;
-
- stats.kb = rados_stats.kb;
- stats.kb_used = rados_stats.kb_used;
- stats.kb_avail = rados_stats.kb_avail;
- stats.num_objects = rados_stats.num_objects;
+ op_target.set_versioning_disabled(params.versioning_disabled);
+ parent_op.meta.mtime = params.mtime;
+ parent_op.meta.rmattrs = params.rmattrs;
+ parent_op.meta.data = params.data;
+ parent_op.meta.manifest = params.manifest;
+ parent_op.meta.ptag = params.ptag;
+ parent_op.meta.remove_objs = params.remove_objs;
+ parent_op.meta.set_mtime = params.set_mtime;
+ parent_op.meta.owner = params.owner.get_id();
+ parent_op.meta.category = params.category;
+ parent_op.meta.flags = params.flags;
+ parent_op.meta.if_match = params.if_match;
+ parent_op.meta.if_nomatch = params.if_nomatch;
+ parent_op.meta.olh_epoch = params.olh_epoch;
+ parent_op.meta.delete_at = params.delete_at;
+ parent_op.meta.canceled = params.canceled;
+ parent_op.meta.user_data = params.user_data;
+ parent_op.meta.zones_trace = params.zones_trace;
+ parent_op.meta.modify_tail = params.modify_tail;
+ parent_op.meta.completeMultipart = params.completeMultipart;
+ parent_op.meta.appendable = params.appendable;
- return ret;
+ return 0;
}
-int RGWRadosStore::create_bucket(const DoutPrefixProvider *dpp,
- RGWUser& u, const rgw_bucket& b,
- const string& zonegroup_id,
- rgw_placement_rule& placement_rule,
- string& swift_ver_location,
- const RGWQuotaInfo * pquota_info,
- const RGWAccessControlPolicy& policy,
- RGWAttrs& attrs,
- RGWBucketInfo& info,
- obj_version& ep_objv,
- bool exclusive,
- bool obj_lock_enabled,
- bool *existed,
- req_info& req_info,
- std::unique_ptr<RGWBucket>* bucket_out,
- optional_yield y)
+int RGWRadosObject::RadosWriteOp::write_meta(const DoutPrefixProvider *dpp, uint64_t size, uint64_t accounted_size, optional_yield y)
{
- int ret;
- bufferlist in_data;
- RGWBucketInfo master_info;
- rgw_bucket *pmaster_bucket;
- uint32_t *pmaster_num_shards;
- real_time creation_time;
- std::unique_ptr<RGWBucket> bucket;
- obj_version objv, *pobjv = NULL;
-
- /* If it exists, look it up; otherwise create it */
- ret = get_bucket(dpp, &u, b, &bucket, y);
- if (ret < 0 && ret != -ENOENT)
- return ret;
-
- if (ret != -ENOENT) {
- RGWAccessControlPolicy old_policy(ctx());
- *existed = true;
- if (swift_ver_location.empty()) {
- swift_ver_location = bucket->get_info().swift_ver_location;
- }
- placement_rule.inherit_from(bucket->get_info().placement_rule);
-
- // don't allow changes to the acl policy
- int r = rgw_op_get_bucket_policy_from_attr(dpp, this, u, bucket->get_attrs(),
- &old_policy, y);
- if (r >= 0 && old_policy != policy) {
- bucket_out->swap(bucket);
- return -EEXIST;
- }
- } else {
- bucket = std::unique_ptr<RGWBucket>(new RGWRadosBucket(this, b, &u));
- *existed = false;
- bucket->set_attrs(attrs);
- }
-
- if (!svc()->zone->is_meta_master()) {
- JSONParser jp;
- ret = forward_request_to_master(&u, NULL, in_data, &jp, req_info, y);
- if (ret < 0) {
- return ret;
- }
-
- JSONDecoder::decode_json("entry_point_object_ver", ep_objv, &jp);
- JSONDecoder::decode_json("object_ver", objv, &jp);
- JSONDecoder::decode_json("bucket_info", master_info, &jp);
- ldpp_dout(dpp, 20) << "parsed: objv.tag=" << objv.tag << " objv.ver=" << objv.ver << dendl;
- std::time_t ctime = ceph::real_clock::to_time_t(master_info.creation_time);
- ldpp_dout(dpp, 20) << "got creation time: << " << std::put_time(std::localtime(&ctime), "%F %T") << dendl;
- pmaster_bucket= &master_info.bucket;
- creation_time = master_info.creation_time;
- pmaster_num_shards = &master_info.layout.current_index.layout.normal.num_shards;
- pobjv = &objv;
- if (master_info.obj_lock_enabled()) {
- info.flags = BUCKET_VERSIONED | BUCKET_OBJ_LOCK_ENABLED;
- }
- } else {
- pmaster_bucket = NULL;
- pmaster_num_shards = NULL;
- if (obj_lock_enabled)
- info.flags = BUCKET_VERSIONED | BUCKET_OBJ_LOCK_ENABLED;
- }
-
- std::string zid = zonegroup_id;
- if (zid.empty()) {
- zid = svc()->zone->get_zonegroup().get_id();
- }
-
- if (*existed) {
- rgw_placement_rule selected_placement_rule;
- ret = svc()->zone->select_bucket_placement(u.get_info(),
- zid, placement_rule,
- &selected_placement_rule, nullptr, y);
- if (selected_placement_rule != info.placement_rule) {
- ret = -EEXIST;
- bucket_out->swap(bucket);
- return ret;
- }
- } else {
-
- ret = getRados()->create_bucket(u.get_info(), bucket->get_key(),
- zid, placement_rule, swift_ver_location,
- pquota_info, attrs,
- info, pobjv, &ep_objv, creation_time,
- pmaster_bucket, pmaster_num_shards, y, dpp, exclusive);
- if (ret == -EEXIST) {
- *existed = true;
- ret = 0;
- } else if (ret != 0) {
- return ret;
- }
- }
-
- bucket->set_version(ep_objv);
- bucket->get_info() = info;
-
- bucket_out->swap(bucket);
+ int ret = parent_op.write_meta(dpp, size, accounted_size, *params.attrs, y);
+ params.canceled = parent_op.meta.canceled;
return ret;
}
-std::unique_ptr<Lifecycle> RGWRadosStore::get_lifecycle(void)
-{
- return std::unique_ptr<Lifecycle>(new RadosLifecycle(this));
-}
-
-int RGWRadosStore::delete_raw_obj(const rgw_raw_obj& obj)
-{
- return rados->delete_raw_obj(obj);
-}
-
-void RGWRadosStore::get_raw_obj(const rgw_placement_rule& placement_rule, const rgw_obj& obj, rgw_raw_obj* raw_obj)
+int RGWRadosObject::swift_versioning_restore(RGWObjectCtx* obj_ctx,
+ bool& restored,
+ const DoutPrefixProvider *dpp)
{
- rados->obj_to_raw(placement_rule, obj, raw_obj);
+ return store->getRados()->swift_versioning_restore(*obj_ctx,
+ bucket->get_owner()->get_id(),
+ bucket,
+ this,
+ restored,
+ dpp);
}
-int RGWRadosStore::get_raw_chunk_size(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, uint64_t* chunk_size)
+int RGWRadosObject::swift_versioning_copy(RGWObjectCtx* obj_ctx,
+ const DoutPrefixProvider *dpp,
+ optional_yield y)
{
- return rados->get_max_chunk_size(obj.pool, chunk_size, dpp);
+ return store->getRados()->swift_versioning_copy(*obj_ctx,
+ bucket->get_info().owner,
+ bucket,
+ this,
+ dpp,
+ y);
}
MPRadosSerializer::MPRadosSerializer(RGWRadosStore* store, RGWRadosObject* obj, const std::string& lock_name) :
return new LCRadosSerializer(store, oid, lock_name, cookie);
}
-} // namespace rgw::sal
-
-rgw::sal::RGWRadosStore *RGWStoreManager::init_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct, bool use_gc_thread, bool use_lc_thread, bool quota_threads, bool run_sync_thread, bool run_reshard_thread, bool use_cache)
+int RadosNotification::publish_reserve(RGWObjTags* obj_tags)
{
- RGWRados *rados = new RGWRados;
- rgw::sal::RGWRadosStore *store = new rgw::sal::RGWRadosStore();
+ return rgw::notify::publish_reserve(event_type, res, obj_tags);
+}
- store->setRados(rados);
- rados->set_store(store);
-
- if ((*rados).set_use_cache(use_cache)
- .set_run_gc_thread(use_gc_thread)
- .set_run_lc_thread(use_lc_thread)
- .set_run_quota_threads(quota_threads)
- .set_run_sync_thread(run_sync_thread)
- .set_run_reshard_thread(run_reshard_thread)
- .initialize(cct, dpp) < 0) {
- delete store;
- return NULL;
- }
+int RadosNotification::publish_commit(const DoutPrefixProvider *dpp, uint64_t size,
+ const ceph::real_time& mtime, const std::string& etag)
+{
+ return rgw::notify::publish_commit(obj, size, mtime, etag, event_type, res, dpp);
+}
- return store;
+void RadosGCChain::update(RGWObjManifest* manifest)
+{
+ rgw_obj target = obj->get_obj();
+ store->getRados()->update_gc_chain(target, *manifest, &chain);
}
-rgw::sal::RGWRadosStore *RGWStoreManager::init_raw_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct)
+int RadosGCChain::send(const std::string& tag)
{
- RGWRados *rados = new RGWRados;
- rgw::sal::RGWRadosStore *store = new rgw::sal::RGWRadosStore();
+ return store->getRados()->send_chain_to_gc(chain, tag);
+}
- store->setRados(rados);
- rados->set_store(store);
+void RadosGCChain::delete_inline(const std::string& tag)
+{
+ store->getRados()->delete_objs_inline(chain, tag);
+}
- rados->set_context(cct);
+int RadosWriter::set_stripe_obj(const rgw_raw_obj& raw_obj)
+{
+ stripe_obj = store->svc()->rados->obj(raw_obj);
+ return stripe_obj.open();
+}
- int ret = rados->init_svc(true, dpp);
- if (ret < 0) {
- ldout(cct, 0) << "ERROR: failed to init services (ret=" << cpp_strerror(-ret) << ")" << dendl;
- delete store;
- return nullptr;
+int RadosWriter::process(bufferlist&& bl, uint64_t offset)
+{
+ bufferlist data = std::move(bl);
+ const uint64_t cost = data.length();
+ if (cost == 0) { // no empty writes, use aio directly for creates
+ return 0;
}
-
- if (rados->init_rados() < 0) {
- delete store;
- return nullptr;
+ librados::ObjectWriteOperation op;
+ if (offset == 0) {
+ op.write_full(data);
+ } else {
+ op.write(offset, data);
}
+ constexpr uint64_t id = 0; // unused
+ auto c = aio->get(stripe_obj, Aio::librados_op(std::move(op), y), cost, id);
+ return process_completed(c, &written);
+}
- return store;
+int RadosWriter::write_exclusive(const bufferlist& data)
+{
+ const uint64_t cost = data.length();
+
+ librados::ObjectWriteOperation op;
+ op.create(true); // exclusive create
+ op.write_full(data);
+
+ constexpr uint64_t id = 0; // unused
+ auto c = aio->get(stripe_obj, Aio::librados_op(std::move(op), y), cost, id);
+ auto d = aio->drain();
+ c.splice(c.end(), d);
+ return process_completed(c, &written);
}
-int rgw::sal::RGWRadosStore::get_obj_head_ioctx(const RGWBucketInfo& bucket_info, const rgw_obj& obj, librados::IoCtx *ioctx)
+int RadosWriter::drain()
{
- return rados->get_obj_head_ioctx(bucket_info, obj, ioctx);
+ return process_completed(aio->drain(), &written);
+}
+
+RadosWriter::~RadosWriter()
+{
+ // wait on any outstanding aio completions
+ process_completed(aio->drain(), &written);
+
+ bool need_to_remove_head = false;
+ std::optional<rgw_raw_obj> raw_head;
+ if (!rgw::sal::RGWObject::empty(head_obj.get())) {
+ raw_head.emplace();
+ head_obj->get_raw_obj(&*raw_head);
+ }
+
+ /**
+ * We should delete the object in the "multipart" namespace to avoid race condition.
+ * Such race condition is caused by the fact that the multipart object is the gatekeeper of a multipart
+ * upload, when it is deleted, a second upload would start with the same suffix("2/"), therefore, objects
+ * written by the second upload may be deleted by the first upload.
+ * details is describled on #11749
+ *
+ * The above comment still stands, but instead of searching for a specific object in the multipart
+ * namespace, we just make sure that we remove the object that is marked as the head object after
+ * we remove all the other raw objects. Note that we use different call to remove the head object,
+ * as this one needs to go via the bucket index prepare/complete 2-phase commit scheme.
+ */
+ for (const auto& obj : written) {
+ if (raw_head && obj == *raw_head) {
+ ldpp_dout(dpp, 5) << "NOTE: we should not process the head object (" << obj << ") here" << dendl;
+ need_to_remove_head = true;
+ continue;
+ }
+
+ int r = store->delete_raw_obj(obj);
+ if (r < 0 && r != -ENOENT) {
+ ldpp_dout(dpp, 0) << "WARNING: failed to remove obj (" << obj << "), leaked" << dendl;
+ }
+ }
+
+ if (need_to_remove_head) {
+ ldpp_dout(dpp, 5) << "NOTE: we are going to process the head obj (" << *raw_head << ")" << dendl;
+ std::unique_ptr<rgw::sal::RGWObject::DeleteOp> del_op = head_obj->get_delete_op(&obj_ctx);
+ del_op->params.bucket_owner = bucket->get_acl_owner();
+
+ int r = del_op->delete_obj(dpp, y);
+ if (r < 0 && r != -ENOENT) {
+ ldpp_dout(dpp, 0) << "WARNING: failed to remove obj (" << *raw_head << "), leaked" << dendl;
+ }
+ }
}
-void RGWStoreManager::close_storage(rgw::sal::RGWRadosStore *store)
+} // namespace rgw::sal
+
+extern "C" {
+
+void *newRGWStore(void)
{
- if (!store)
- return;
+ rgw::sal::RGWRadosStore *store = new rgw::sal::RGWRadosStore();
+ if (store) {
+ RGWRados *rados = new RGWRados();
+
+ if (!rados) {
+ delete store; store = nullptr;
+ } else {
+ store->setRados(rados);
+ rados->set_store(store);
+ }
+ }
- store->finalize();
+ return store;
+}
- delete store;
}
#include "rgw_sal.h"
#include "rgw_rados.h"
+#include "rgw_notify.h"
#include "cls/lock/cls_lock_client.h"
namespace rgw { namespace sal {
class RGWRadosStore;
+class RadosCompletions : public Completions {
+ public:
+ std::list<librados::AioCompletion*> handles;
+ RadosCompletions() {}
+ ~RadosCompletions() = default;
+ virtual int drain() override;
+};
+
class RGWRadosUser : public RGWUser {
private:
RGWRadosStore *store;
RGWRadosUser(RGWRadosStore *_st, const rgw_user& _u) : RGWUser(_u), store(_st) { }
RGWRadosUser(RGWRadosStore *_st, const RGWUserInfo& _i) : RGWUser(_i), store(_st) { }
RGWRadosUser(RGWRadosStore *_st) : store(_st) { }
+ RGWRadosUser(RGWRadosUser& _o) = default;
RGWRadosUser() {}
+ virtual std::unique_ptr<RGWUser> clone() override {
+ return std::unique_ptr<RGWUser>(new RGWRadosUser(*this));
+ }
int list_buckets(const DoutPrefixProvider *dpp, const std::string& marker, const std::string& end_marker,
uint64_t max, bool need_stats, RGWBucketList& buckets,
optional_yield y) override;
- RGWBucket* create_bucket(rgw_bucket& bucket, ceph::real_time creation_time);
+ virtual RGWBucket* create_bucket(rgw_bucket& bucket, ceph::real_time creation_time) override;
+ virtual int read_attrs(const DoutPrefixProvider *dpp, optional_yield y, RGWAttrs* uattrs, RGWObjVersionTracker* tracker) override;
+ virtual int read_stats(optional_yield y, RGWStorageStats* stats,
+ ceph::real_time *last_stats_sync = nullptr,
+ ceph::real_time *last_stats_update = nullptr) override;
+ virtual int read_stats_async(RGWGetUserStats_CB *cb) override;
+ virtual int complete_flush_stats(optional_yield y) override;
+ virtual int read_usage(uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
+ bool *is_truncated, RGWUsageIter& usage_iter,
+ map<rgw_user_bucket, rgw_usage_log_entry>& usage) override;
+ virtual int trim_usage(uint64_t start_epoch, uint64_t end_epoch) override;
/* Placeholders */
- virtual int load_by_id(const DoutPrefixProvider *dpp, optional_yield y);
+ virtual int load_by_id(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::GetParams& params = {}) override;
+ virtual int store_info(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::PutParams& params = {}) override;
friend class RGWRadosBucket;
};
//virtual int write_data(const char *data, uint64_t ofs, uint64_t len, bool exclusive) override;
};
+ struct RadosDeleteOp : public DeleteOp {
+ private:
+ RGWRadosObject* source;
+ RGWObjectCtx* rctx;
+ RGWRados::Object op_target;
+ RGWRados::Object::Delete parent_op;
+
+ public:
+ RadosDeleteOp(RGWRadosObject* _source, RGWObjectCtx* _rctx);
+
+ virtual int delete_obj(const DoutPrefixProvider *dpp, optional_yield y) override;
+ };
+
+ struct RadosStatOp : public StatOp {
+ private:
+ RGWRadosObject* source;
+ RGWObjectCtx* rctx;
+ RGWRados::Object op_target;
+ RGWRados::Object::Stat parent_op;
+
+ public:
+ RadosStatOp(RGWRadosObject* _source, RGWObjectCtx* _rctx);
+
+ virtual int stat_async() override;
+ virtual int wait() override;
+ };
+
RGWRadosObject() = default;
RGWRadosObject(RGWRadosStore *_st, const rgw_obj_key& _k)
}
RGWRadosObject(RGWRadosObject& _o) = default;
- int read(off_t offset, off_t length, std::iostream& stream) { return length; }
- int write(off_t offset, off_t length, std::iostream& stream) { return length; }
- virtual int delete_object(const DoutPrefixProvider *dpp, RGWObjectCtx* obj_ctx, ACLOwner obj_owner,
- ACLOwner bucket_owner, ceph::real_time unmod_since,
- bool high_precision_time, uint64_t epoch,
- std::string& version_id,optional_yield y) override;
+ virtual int delete_object(const DoutPrefixProvider *dpp, RGWObjectCtx* obj_ctx, optional_yield y) override;
+ virtual int delete_obj_aio(const DoutPrefixProvider *dpp, RGWObjState *astate, Completions* aio,
+ bool keep_index_consistent, optional_yield y) override;
virtual int copy_object(RGWObjectCtx& obj_ctx, RGWUser* user,
req_info *info, const rgw_zone_id& source_zone,
rgw::sal::RGWObject* dest_object, rgw::sal::RGWBucket* dest_bucket,
string *version_id, string *tag, string *etag,
void (*progress_cb)(off_t, void *), void *progress_data,
const DoutPrefixProvider *dpp, optional_yield y) override;
- RGWAccessControlPolicy& get_acl(void) { return acls; }
- int set_acl(const RGWAccessControlPolicy& acl) { acls = acl; return 0; }
- virtual void set_atomic(RGWObjectCtx *rctx) const;
- virtual void set_prefetch_data(RGWObjectCtx *rctx);
+ virtual RGWAccessControlPolicy& get_acl(void) override { return acls; }
+ virtual int set_acl(const RGWAccessControlPolicy& acl) override { acls = acl; return 0; }
+ virtual void set_atomic(RGWObjectCtx *rctx) const override;
+ virtual void set_prefetch_data(RGWObjectCtx *rctx) override;
- virtual int get_obj_state(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, RGWBucket& bucket, RGWObjState **state, optional_yield y, bool follow_olh = true) override;
+ virtual int get_obj_state(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, RGWObjState **state, optional_yield y, bool follow_olh = true) override;
virtual int set_obj_attrs(const DoutPrefixProvider *dpp, RGWObjectCtx* rctx, RGWAttrs* setattrs, RGWAttrs* delattrs, optional_yield y, rgw_obj* target_obj = NULL) override;
virtual int get_obj_attrs(RGWObjectCtx *rctx, optional_yield y, const DoutPrefixProvider *dpp, rgw_obj* target_obj = NULL) override;
virtual int modify_obj_attrs(RGWObjectCtx *rctx, const char *attr_name, bufferlist& attr_val, optional_yield y, const DoutPrefixProvider *dpp) override;
virtual void gen_rand_obj_instance_name() override;
virtual void raw_obj_to_obj(const rgw_raw_obj& raw_obj) override;
virtual void get_raw_obj(rgw_raw_obj* raw_obj) override;
- virtual std::unique_ptr<RGWObject> clone() {
+ virtual std::unique_ptr<RGWObject> clone() override {
return std::unique_ptr<RGWObject>(new RGWRadosObject(*this));
}
virtual MPSerializer* get_serializer(const std::string& lock_name) override;
/* OPs */
virtual std::unique_ptr<ReadOp> get_read_op(RGWObjectCtx *) override;
virtual std::unique_ptr<WriteOp> get_write_op(RGWObjectCtx *) override;
+ virtual std::unique_ptr<DeleteOp> get_delete_op(RGWObjectCtx*) override;
+ virtual std::unique_ptr<StatOp> get_stat_op(RGWObjectCtx*) override;
/* OMAP */
+ virtual int omap_get_vals(const string& marker, uint64_t count,
+ std::map<string, bufferlist> *m,
+ bool *pmore, optional_yield y) override;
+ virtual int omap_get_all(std::map<string, bufferlist> *m,
+ optional_yield y) override;
virtual int omap_get_vals_by_keys(const std::string& oid,
const std::set<std::string>& keys,
RGWAttrs *vals) override;
bool must_exist, optional_yield y) override;
private:
- int read_attrs(RGWRados::Object::Read &read_op, optional_yield y, const DoutPrefixProvider *dpp, rgw_obj *target_obj = nullptr);
+ int read_attrs(const DoutPrefixProvider *dpp, RGWRados::Object::Read &read_op, optional_yield y, rgw_obj *target_obj = nullptr);
};
class RGWRadosBucket : public RGWBucket {
acls() {
}
+ RGWRadosBucket(RGWRadosStore *_st, RGWUser* _u)
+ : RGWBucket(_u),
+ store(_st),
+ acls() {
+ }
+
RGWRadosBucket(RGWRadosStore *_st, const rgw_bucket& _b)
: RGWBucket(_b),
store(_st),
~RGWRadosBucket() { }
- virtual int load_by_name(const DoutPrefixProvider *dpp, const std::string& tenant, const std::string& bucket_name, const std::string bucket_instance_id, RGWSysObjectCtx *rctx, optional_yield y) override;
virtual std::unique_ptr<RGWObject> get_object(const rgw_obj_key& k) override;
- RGWBucketList* list(void) { return new RGWBucketList(); }
virtual int list(const DoutPrefixProvider *dpp, ListParams&, int, ListResults&, optional_yield y) override;
RGWObject* create_object(const rgw_obj_key& key /* Attributes */) override;
virtual int remove_bucket(const DoutPrefixProvider *dpp, bool delete_children, std::string prefix, std::string delimiter, bool forward_to_master, req_info* req_info, optional_yield y) override;
- RGWAccessControlPolicy& get_acl(void) { return acls; }
+ virtual RGWAccessControlPolicy& get_acl(void) override { return acls; }
virtual int set_acl(const DoutPrefixProvider *dpp, RGWAccessControlPolicy& acl, optional_yield y) override;
virtual int get_bucket_info(const DoutPrefixProvider *dpp, optional_yield y) override;
- virtual int get_bucket_stats(RGWBucketInfo& bucket_info, int shard_id,
+ virtual int get_bucket_stats(int shard_id,
std::string *bucket_ver, std::string *master_ver,
std::map<RGWObjCategory, RGWStorageStats>& stats,
std::string *max_marker = nullptr,
bool *syncstopped = nullptr) override;
+ virtual int get_bucket_stats_async(int shard_id, RGWGetBucketStats_CB *ctx) override;
virtual int read_bucket_stats(const DoutPrefixProvider *dpp, optional_yield y) override;
virtual int sync_user_stats(optional_yield y) override;
virtual int update_container_stats(const DoutPrefixProvider *dpp) override;
virtual int check_bucket_shards(const DoutPrefixProvider *dpp) override;
- virtual int link(const DoutPrefixProvider *dpp, RGWUser* new_user, optional_yield y) override;
- virtual int unlink(RGWUser* new_user, optional_yield y) override;
- virtual int chown(RGWUser* new_user, RGWUser* old_user, optional_yield y, const DoutPrefixProvider *dpp) override;
+ virtual int link(const DoutPrefixProvider *dpp, RGWUser* new_user, optional_yield y, bool update_entrypoint, RGWObjVersionTracker* objv) override;
+ virtual int unlink(const DoutPrefixProvider *dpp, RGWUser* new_user, optional_yield y, bool update_entrypoint = true) override;
+ virtual int chown(const DoutPrefixProvider *dpp, RGWUser* new_user, RGWUser* old_user, optional_yield y, const std::string* marker = nullptr) override;
virtual int put_instance_info(const DoutPrefixProvider *dpp, bool exclusive, ceph::real_time mtime) override;
+ virtual int remove_entrypoint(const DoutPrefixProvider *dpp, RGWObjVersionTracker* objv, optional_yield y) override;
+ virtual int remove_instance_info(const DoutPrefixProvider *dpp, RGWObjVersionTracker* objv, optional_yield y) override;
virtual bool is_owner(RGWUser* user) override;
virtual int check_empty(const DoutPrefixProvider *dpp, optional_yield y) override;
virtual int check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) override;
virtual int read_usage(uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
bool *is_truncated, RGWUsageIter& usage_iter,
map<rgw_user_bucket, rgw_usage_log_entry>& usage) override;
- virtual std::unique_ptr<RGWBucket> clone() {
+ virtual int trim_usage(uint64_t start_epoch, uint64_t end_epoch) override;
+ virtual int remove_objs_from_index(std::list<rgw_obj_index_key>& objs_to_unlink) override;
+ virtual int check_index(std::map<RGWObjCategory, RGWStorageStats>& existing_stats, std::map<RGWObjCategory, RGWStorageStats>& calculated_stats) override;
+ virtual int rebuild_index() override;
+ virtual int set_tag_timeout(uint64_t timeout) override;
+ virtual int purge_instance(const DoutPrefixProvider *dpp) override;
+ virtual std::unique_ptr<RGWBucket> clone() override {
return std::make_unique<RGWRadosBucket>(*this);
}
delete rados;
}
- virtual std::unique_ptr<RGWUser> get_user(const rgw_user& u);
+ virtual std::unique_ptr<RGWUser> get_user(const rgw_user& u) override;
+ virtual int get_user(const DoutPrefixProvider *dpp, const RGWAccessKey& key, optional_yield y, std::unique_ptr<RGWUser>* user) override;
+ virtual int get_user_by_email(const DoutPrefixProvider *dpp, const std::string& email, optional_yield y, std::unique_ptr<RGWUser>* user) override;
+ virtual int get_user_by_swift(const DoutPrefixProvider *dpp, const std::string& user_str, optional_yield y, std::unique_ptr<RGWUser>* user) override;
virtual std::unique_ptr<RGWObject> get_object(const rgw_obj_key& k) override;
virtual int get_bucket(const DoutPrefixProvider *dpp, RGWUser* u, const rgw_bucket& b, std::unique_ptr<RGWBucket>* bucket, optional_yield y) override;
virtual int get_bucket(RGWUser* u, const RGWBucketInfo& i, std::unique_ptr<RGWBucket>* bucket) override;
bool *existed,
req_info& req_info,
std::unique_ptr<RGWBucket>* bucket,
- optional_yield y);
- virtual RGWBucketList* list_buckets(void) { return new RGWBucketList(); }
+ optional_yield y) override;
virtual bool is_meta_master() override;
virtual int forward_request_to_master(RGWUser* user, obj_version *objv,
bufferlist& in_data, JSONParser *jp, req_info& info,
optional_yield y) override;
virtual const RGWZoneGroup& get_zonegroup() override;
virtual int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) override;
+ virtual const RGWZoneParams& get_zone_params() override;
+ virtual const rgw_zone_id& get_zone_id() override;
+ virtual const RGWRealm& get_realm() override;
virtual int cluster_stat(RGWClusterStat& stats) override;
virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override;
- virtual RGWLC* get_rgwlc(void) { return rados->get_lc(); }
+ virtual std::unique_ptr<Completions> get_completions(void) override;
+ virtual std::unique_ptr<Notification> get_notification(rgw::sal::RGWObject* obj, struct req_state* s, rgw::notify::EventType event_type) override;
+ virtual std::unique_ptr<GCChain> get_gc_chain(rgw::sal::RGWObject* obj) override;
+ virtual std::unique_ptr<Writer> get_writer(Aio *aio, rgw::sal::RGWBucket* bucket,
+ RGWObjectCtx& obj_ctx, std::unique_ptr<rgw::sal::RGWObject> _head_obj,
+ const DoutPrefixProvider *dpp, optional_yield y) override;
+ virtual RGWLC* get_rgwlc(void) override { return rados->get_lc(); }
+ virtual RGWCtl* get_ctl(void) override { return rados->pctl; }
+ virtual RGWCoroutinesManagerRegistry* get_cr_registry() override { return rados->get_cr_registry(); }
virtual int delete_raw_obj(const rgw_raw_obj& obj) override;
+ virtual int delete_raw_obj_aio(const rgw_raw_obj& obj, Completions* aio) override;
virtual void get_raw_obj(const rgw_placement_rule& placement_rule, const rgw_obj& obj, rgw_raw_obj* raw_obj) override;
virtual int get_raw_chunk_size(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, uint64_t* chunk_size) override;
+ virtual int log_usage(map<rgw_user_bucket, RGWUsageBatch>& usage_info) override;
+ virtual int log_op(string& oid, bufferlist& bl) override;
+ virtual int register_to_service_map(const string& daemon_type,
+ const map<string, string>& meta) override;
+ virtual void get_quota(RGWQuotaInfo& bucket_quota, RGWQuotaInfo& user_quota) override;
+ virtual int list_raw_objects(const rgw_pool& pool, const string& prefix_filter,
+ int max, RGWListRawObjsCtx& ctx, std::list<string>& oids,
+ bool *is_truncated) override;
+ virtual int set_buckets_enabled(const DoutPrefixProvider *dpp, vector<rgw_bucket>& buckets, bool enabled) override;
+ virtual uint64_t get_new_req_id() override { return rados->get_new_req_id(); }
+ virtual int get_sync_policy_handler(const DoutPrefixProvider *dpp,
+ std::optional<rgw_zone_id> zone,
+ std::optional<rgw_bucket> bucket,
+ RGWBucketSyncPolicyHandlerRef *phandler,
+ optional_yield y) override;
+ virtual RGWDataSyncStatusManager* get_data_sync_manager(const rgw_zone_id& source_zone) override;
+ virtual void wakeup_meta_sync_shards(set<int>& shard_ids) override { rados->wakeup_meta_sync_shards(shard_ids); }
+ virtual void wakeup_data_sync_shards(const rgw_zone_id& source_zone, map<int, set<string> >& shard_ids) override { rados->wakeup_data_sync_shards(source_zone, shard_ids); }
+ virtual int clear_usage() override { return rados->clear_usage(); }
+ virtual int read_all_usage(uint64_t start_epoch, uint64_t end_epoch,
+ uint32_t max_entries, bool *is_truncated,
+ RGWUsageIter& usage_iter,
+ map<rgw_user_bucket, rgw_usage_log_entry>& usage) override;
+ virtual int trim_all_usage(uint64_t start_epoch, uint64_t end_epoch) override;
+ virtual int get_config_key_val(string name, bufferlist *bl) override;
+ virtual void finalize(void) override;
+
+ virtual CephContext *ctx(void) override { return rados->ctx(); }
+
+ virtual const std::string& get_luarocks_path() const override {
+ return luarocks_path;
+ }
+
+ virtual void set_luarocks_path(const std::string& path) override {
+ luarocks_path = path;
+ }
+
+ /* Unique to RGWRadosStore */
+ int get_obj_head_ioctx(const RGWBucketInfo& bucket_info, const rgw_obj& obj,
+ librados::IoCtx *ioctx);
+
void setRados(RGWRados * st) { rados = st; }
RGWRados *getRados(void) { return rados; }
const RGWCtl *ctl() const { return &rados->ctl; }
void setUserCtl(RGWUserCtl *_ctl) { user_ctl = _ctl; }
-
- void finalize(void) override;
-
- virtual CephContext *ctx(void) { return rados->ctx(); }
-
-
- int get_obj_head_ioctx(const RGWBucketInfo& bucket_info, const rgw_obj& obj,
- librados::IoCtx *ioctx);
-
- const std::string& get_luarocks_path() const override {
- return luarocks_path;
- }
-
- void set_luarocks_path(const std::string& path) override {
- luarocks_path = path;
- }
};
class MPRadosSerializer : public MPSerializer {
MPRadosSerializer(RGWRadosStore* store, RGWRadosObject* obj, const std::string& lock_name);
virtual int try_lock(utime_t dur, optional_yield y) override;
- int unlock() {
+ virtual int unlock() override {
return lock.unlock(&ioctx, oid);
}
};
LCRadosSerializer(RGWRadosStore* store, const std::string& oid, const std::string& lock_name, const std::string& cookie);
virtual int try_lock(utime_t dur, optional_yield y) override;
- int unlock() {
+ virtual int unlock() override {
return lock.unlock(ioctx, oid);
}
};
virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) override;
};
-} } // namespace rgw::sal
+class RadosNotification : public Notification {
+ RGWRadosStore* store;
+ rgw::notify::reservation_t res;
-class RGWStoreManager {
-public:
- RGWStoreManager() {}
- static rgw::sal::RGWRadosStore *get_storage(const DoutPrefixProvider *dpp, CephContext *cct, bool use_gc_thread, bool use_lc_thread, bool quota_threads,
- bool run_sync_thread, bool run_reshard_thread, bool use_cache = true) {
- rgw::sal::RGWRadosStore *store = init_storage_provider(dpp, cct, use_gc_thread, use_lc_thread,
- quota_threads, run_sync_thread, run_reshard_thread, use_cache);
- return store;
- }
- static rgw::sal::RGWRadosStore *get_raw_storage(const DoutPrefixProvider *dpp, CephContext *cct) {
- rgw::sal::RGWRadosStore *rados = init_raw_storage_provider(dpp, cct);
- return rados;
- }
- static rgw::sal::RGWRadosStore *init_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct, bool use_gc_thread, bool use_lc_thread, bool quota_threads, bool run_sync_thread, bool run_reshard_thread, bool use_metadata_cache);
- static rgw::sal::RGWRadosStore *init_raw_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct);
- static void close_storage(rgw::sal::RGWRadosStore *store);
+ public:
+ RadosNotification(RGWRadosStore* _store, RGWObject* _obj, req_state* _s, rgw::notify::EventType _type) : Notification(_obj, _type), store(_store), res(_store, _s, _obj) { }
+ ~RadosNotification() = default;
+
+ virtual int publish_reserve(RGWObjTags* obj_tags = nullptr) override;
+ virtual int publish_commit(const DoutPrefixProvider *dpp, uint64_t size,
+ const ceph::real_time& mtime, const std::string& etag) override;
+};
+
+class RadosGCChain : public GCChain {
+protected:
+ RGWRadosStore* store;
+ cls_rgw_obj_chain chain;
+
+ public:
+ RadosGCChain(RGWRadosStore* _store, RGWObject* _obj) : GCChain(_obj), store(_store) {}
+ ~RadosGCChain() = default;
+
+ virtual void update(RGWObjManifest* manifest) override;
+ virtual int send(const std::string& tag) override;
+ virtual void delete_inline(const std::string& tag) override;
+};
+
+class RadosWriter : public Writer {
+ rgw::sal::RGWRadosStore* store;
+ RGWSI_RADOS::Obj stripe_obj; // current stripe object
+
+ public:
+ RadosWriter(Aio *aio, rgw::sal::RGWRadosStore* _store,
+ rgw::sal::RGWBucket* bucket,
+ RGWObjectCtx& obj_ctx, std::unique_ptr<rgw::sal::RGWObject> _head_obj,
+ const DoutPrefixProvider *dpp, optional_yield y)
+ : Writer(aio, bucket, obj_ctx, std::move(_head_obj), dpp, y), store(_store)
+ {}
+
+ ~RadosWriter();
+
+ // change the current stripe object
+ virtual int set_stripe_obj(const rgw_raw_obj& obj) override;
+ // write the data at the given offset of the current stripe object
+ virtual int process(bufferlist&& data, uint64_t stripe_offset) override;
+
+ // write the data as an exclusive create and wait for it to complete
+ virtual int write_exclusive(const bufferlist& data) override;
+
+ virtual int drain() override;
};
+
+} } // namespace rgw::sal
}
int AssumedRoleUser::generateAssumedRoleUser(CephContext* cct,
- rgw::sal::RGWRadosStore *store,
+ rgw::sal::RGWStore *store,
const string& roleId,
const rgw::ARN& roleArn,
const string& roleSessionName)
if (auto r_arn = rgw::ARN::parse(arn); r_arn) {
auto pos = r_arn->resource.find_last_of('/');
string roleName = r_arn->resource.substr(pos + 1);
- RGWRole role(cct, store->getRados()->pctl, roleName, r_arn->account);
+ RGWRole role(cct, store->get_ctl(), roleName, r_arn->account);
if (int ret = role.get(dpp, y); ret < 0) {
if (ret == -ENOENT) {
ldpp_dout(dpp, 0) << "Role doesn't exist: " << roleName << dendl;
int STSService::storeARN(const DoutPrefixProvider *dpp, string& arn, optional_yield y)
{
int ret = 0;
- RGWUserInfo info;
- if (ret = rgw_get_user_info_by_uid(dpp, store->ctl()->user, user_id, info, y); ret < 0) {
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(user_id);
+ if ((ret = user->load_by_id(dpp, y)) < 0) {
return -ERR_NO_SUCH_ENTITY;
}
- info.assumed_role_arn = arn;
+ user->get_info().assumed_role_arn = arn;
- RGWObjVersionTracker objv_tracker;
- if (ret = rgw_store_user_info(dpp, store->ctl()->user, info, &info, &objv_tracker, real_time(),
- false, y); ret < 0) {
+ ret = user->store_info(dpp, y, RGWUserCtl::PutParams()
+ .set_old_info(&user->get_info())
+ .set_exclusive(false));
+ if (ret < 0) {
return -ERR_INTERNAL_ERROR;
}
return ret;
string assumeRoleId;
public:
int generateAssumedRoleUser( CephContext* cct,
- rgw::sal::RGWRadosStore *store,
+ rgw::sal::RGWStore *store,
const string& roleId,
const rgw::ARN& roleArn,
const string& roleSessionName);
class STSService {
CephContext* cct;
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
rgw_user user_id;
RGWRole role;
rgw::auth::Identity* identity;
int storeARN(const DoutPrefixProvider *dpp, string& arn, optional_yield y);
public:
STSService() = default;
- STSService(CephContext* cct, rgw::sal::RGWRadosStore *store, rgw_user user_id,
+ STSService(CephContext* cct, rgw::sal::RGWStore *store, rgw_user user_id,
rgw::auth::Identity* identity)
: cct(cct), store(store), user_id(user_id), identity(identity) {}
std::tuple<int, RGWRole> getRoleInfo(const DoutPrefixProvider *dpp, const string& arn, optional_yield y);
int ret = -EPERM;
const char *key = s->info.env->get("HTTP_X_AUTH_KEY");
- const char *user = s->info.env->get("HTTP_X_AUTH_USER");
+ const char *user_name = s->info.env->get("HTTP_X_AUTH_USER");
s->prot_flags |= RGW_REST_SWIFT;
string user_str;
- RGWUserInfo info;
+ std::unique_ptr<rgw::sal::RGWUser> user;
bufferlist bl;
RGWAccessKey *swift_key;
map<string, RGWAccessKey>::iterator siter;
}
}
- if (!key || !user)
+ if (!key || !user_name)
goto done;
- user_str = user;
+ user_str = user_name;
- if ((ret = store->ctl()->user->get_info_by_swift(s, user_str, &info, s->yield)) < 0)
- {
+ ret = store->get_user_by_swift(s, user_str, s->yield, &user);
+ if (ret < 0) {
ret = -EACCES;
goto done;
}
- siter = info.swift_keys.find(user_str);
- if (siter == info.swift_keys.end()) {
+ siter = user->get_info().swift_keys.find(user_str);
+ if (siter == user->get_info().swift_keys.end()) {
ret = -EPERM;
goto done;
}
tenant_path.append(g_conf()->rgw_swift_tenant_name);
} else if (g_conf()->rgw_swift_account_in_url) {
tenant_path = "/AUTH_";
- tenant_path.append(info.user_id.to_str());
+ tenant_path.append(user->get_id().to_str());
}
dump_header(s, "X-Storage-Url", swift_url + swift_prefix + "/v1" +
end_header(s);
}
-int RGWHandler_SWIFT_Auth::init(rgw::sal::RGWRadosStore *store, struct req_state *state,
+int RGWHandler_SWIFT_Auth::init(rgw::sal::RGWStore *store, struct req_state *state,
rgw::io::BasicClient *cio)
{
state->dialect = "swift-auth";
~RGWHandler_SWIFT_Auth() override {}
RGWOp *op_get() override;
- int init(rgw::sal::RGWRadosStore *store, struct req_state *state, rgw::io::BasicClient *cio) override;
+ int init(rgw::sal::RGWStore *store, struct req_state *state, rgw::io::BasicClient *cio) override;
int authorize(const DoutPrefixProvider *dpp, optional_yield y) override;
int postauth_init(optional_yield) override { return 0; }
int read_permissions(RGWOp *op, optional_yield) override { return 0; }
return this;
}
- RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST* get_handler(rgw::sal::RGWStore *store,
struct req_state*,
const rgw::auth::StrategyRegistry&,
const std::string&) override {
void init(CephContext *cct, const JSONFormattable& config) {
string elastic_endpoint = config["endpoint"];
id = string("elastic:") + elastic_endpoint;
- conn.reset(new RGWRESTConn(cct, nullptr, id, { elastic_endpoint }));
+ conn.reset(new RGWRESTConn(cct, (RGWSI_Zone*)nullptr, id, { elastic_endpoint }));
explicit_custom_meta = config["explicit_custom_meta"](true);
index_buckets.init(config["index_buckets_list"], true); /* approve all buckets by default */
allow_owners.init(config["approved_owners_list"], true); /* approve all bucket owners by default */
protected:
RGWOp *op_get() override {
if (s->info.args.exists("query")) {
- return new RGWMetadataSearch_ObjStore_S3(store->getRados()->get_sync_module());
+ return new RGWMetadataSearch_ObjStore_S3(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_sync_module());
}
if (!s->init_state.url_bucket.empty() &&
s->info.args.exists("mdsearch")) {
};
-RGWHandler_REST* RGWRESTMgr_MDSearch_S3::get_handler(rgw::sal::RGWRadosStore *store,
+RGWHandler_REST* RGWRESTMgr_MDSearch_S3::get_handler(rgw::sal::RGWStore *store,
struct req_state* const s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix)
public:
explicit RGWRESTMgr_MDSearch_S3() {}
- RGWHandler_REST *get_handler(rgw::sal::RGWRadosStore *store,
+ RGWHandler_REST *get_handler(rgw::sal::RGWStore *store,
struct req_state* s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix) override;
public:
InitBucketLifecycleCR(RGWDataSyncCtx *_sc,
PSConfigRef& _conf,
- RGWBucketInfo& _bucket_info,
- std::map<string, bufferlist>& _bucket_attrs) : RGWCoroutine(_sc->cct),
+ rgw::sal::RGWBucket* _bucket) : RGWCoroutine(_sc->cct),
sc(_sc), sync_env(_sc->env),
conf(_conf) {
- lc_config.bucket_info = _bucket_info;
- lc_config.bucket_attrs = _bucket_attrs;
+ lc_config.bucket = _bucket;
+ lc_config.bucket_attrs = _bucket->get_attrs();
retention_days = conf->events_retention_days;
}
if (retcode == 0) {
{
auto& result = sub->get_bucket_info_result;
- sub->bucket_info = &result->bucket_info;
+ sub->bucket_info = &result->bucket->get_info();
- int ret = sub->data_access->get_bucket(result->bucket_info, result->attrs, &sub->bucket);
+ int ret = sub->data_access->get_bucket(result->bucket->get_info(), result->bucket->get_attrs(), &sub->bucket);
if (ret < 0) {
- ldpp_dout(sync_env->dpp, 1) << "ERROR: data_access.get_bucket() bucket=" << result->bucket_info.bucket << " failed, ret=" << ret << dendl;
+ ldpp_dout(sync_env->dpp, 1) << "ERROR: data_access.get_bucket() bucket=" << result->bucket << " failed, ret=" << ret << dendl;
return set_cr_error(ret);
}
}
yield call(new InitBucketLifecycleCR(sc, conf,
- sub->get_bucket_info_result->bucket_info,
- sub->get_bucket_info_result->attrs));
+ sub->get_bucket_info_result->bucket.get()));
if (retcode < 0) {
ldpp_dout(sync_env->dpp, 1) << "ERROR: failed to init lifecycle on bucket (bucket=" << sub_conf->data_bucket_name << ") ret=" << retcode << dendl;
return set_cr_error(retcode);
dest.arn_topic = topic_name;
// the topic ARN will be sent in the reply
const rgw::ARN arn(rgw::Partition::aws, rgw::Service::sns,
- store->svc()->zone->get_zonegroup().get_name(),
+ store->get_zonegroup().get_name(),
s->user->get_tenant(), topic_name);
topic_arn = arn.to_string();
return 0;
return -EINVAL;
}
- const auto psmodule = static_cast<RGWPSSyncModuleInstance*>(store->getRados()->get_sync_module().get());
+ const auto psmodule = static_cast<RGWPSSyncModuleInstance*>(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_sync_module().get());
const auto& conf = psmodule->get_effective_conf();
dest.push_endpoint = s->info.args.get("push-endpoint");
void RGWPSCreateNotif_ObjStore::execute(optional_yield y)
{
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
auto b = ps->get_bucket(bucket_info.bucket);
op_ret = b->create_notification(topic_name, events, y);
return;
}
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
auto b = ps->get_bucket(bucket_info.bucket);
op_ret = b->remove_notification(topic_name, y);
if (op_ret < 0) {
void RGWPSListNotifs_ObjStore::execute(optional_yield y)
{
- ps.emplace(store, s->owner.get_id().tenant);
+ ps.emplace(static_cast<rgw::sal::RGWRadosStore*>(store), s->owner.get_id().tenant);
auto b = ps->get_bucket(bucket_info.bucket);
op_ret = b->get_topics(&result);
if (op_ret < 0) {
};
// factory for ceph specific PubSub REST handlers
-RGWHandler_REST* RGWRESTMgr_PubSub::get_handler(rgw::sal::RGWRadosStore *store,
+RGWHandler_REST* RGWRESTMgr_PubSub::get_handler(rgw::sal::RGWStore *store,
struct req_state* const s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix)
class RGWRESTMgr_PubSub : public RGWRESTMgr {
public:
- virtual RGWHandler_REST* get_handler(rgw::sal::RGWRadosStore *store,
+ virtual RGWHandler_REST* get_handler(rgw::sal::RGWStore *store,
struct req_state* s,
const rgw::auth::StrategyRegistry& auth_registry,
const std::string& frontend_prefix) override;
}
}
-RGWDataAccess::RGWDataAccess(rgw::sal::RGWRadosStore *_store) : store(_store)
+RGWDataAccess::RGWDataAccess(rgw::sal::RGWStore *_store) : store(_store)
{
- sysobj_ctx = std::make_unique<RGWSysObjectCtx>(store->svc()->sysobj->init_obj_ctx());
+ sysobj_ctx = std::make_unique<RGWSysObjectCtx>(static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj->init_obj_ctx());
}
int RGWDataAccess::Bucket::init(const DoutPrefixProvider *dpp, optional_yield y)
{
- int ret = sd->store->getRados()->get_bucket_info(sd->store->svc(),
- tenant, name,
- bucket_info,
- &mtime,
- y,
- dpp,
- &attrs);
+ std::unique_ptr<rgw::sal::RGWBucket> bucket;
+ int ret = sd->store->get_bucket(dpp, nullptr, tenant, name, &bucket, y);
if (ret < 0) {
return ret;
}
+ bucket_info = bucket->get_info();
+ mtime = bucket->get_modification_time();
+ attrs = bucket->get_attrs();
+
return finish_init();
}
const DoutPrefixProvider *dpp,
optional_yield y)
{
- rgw::sal::RGWRadosStore *store = sd->store;
+ rgw::sal::RGWStore *store = sd->store;
CephContext *cct = store->ctx();
string tag;
auto& owner = bucket->policy.get_owner();
- string req_id = store->svc()->zone_utils->unique_id(store->getRados()->get_new_req_id());
+ string req_id = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone_utils->unique_id(static_cast<rgw::sal::RGWRadosStore*>(store)->getRados()->get_new_req_id());
using namespace rgw::putobj;
AtomicObjectProcessor processor(&aio, store, b.get(), nullptr,
CompressorRef plugin;
boost::optional<RGWPutObj_Compress> compressor;
- const auto& compression_type = store->svc()->zone->get_zone_params().get_compression_type(bucket_info.placement_rule);
+ const auto& compression_type = store->get_zone_params().get_compression_type(bucket_info.placement_rule);
if (compression_type != "none") {
plugin = Compressor::create(store->ctx(), compression_type);
if (!plugin) {
struct RGWObjVersionTracker;
class optional_yield;
namespace rgw { namespace sal {
- class RGWRadosStore;
+ class RGWStore;
} }
struct obj_version;
class RGWDataAccess
{
- rgw::sal::RGWRadosStore *store;
+ rgw::sal::RGWStore *store;
std::unique_ptr<RGWSysObjectCtx> sysobj_ctx;
public:
- RGWDataAccess(rgw::sal::RGWRadosStore *_store);
+ RGWDataAccess(rgw::sal::RGWStore *_store);
class Object;
class Bucket;
store = NULL;
}
-void seed::init(struct req_state *p_req, rgw::sal::RGWRadosStore *p_store)
+void seed::init(struct req_state *p_req, rgw::sal::RGWStore *p_store)
{
s = p_req;
store = p_store;
{
int op_ret = 0;
string key = RGW_OBJ_TORRENT;
- rgw_obj obj(s->bucket->get_key(), s->object->get_name());
- rgw_raw_obj raw_obj;
- store->getRados()->obj_to_raw(s->bucket->get_info().placement_rule, obj, &raw_obj);
-
- auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
- auto sysobj = obj_ctx.get_obj(raw_obj);
-
- op_ret = sysobj.omap().set(key, bl, y);
+ op_ret = s->object->omap_set_val_by_key(key, bl, false, y);
if (op_ret < 0)
{
ldout(s->cct, 0) << "ERROR: failed to omap_set() op_ret = " << op_ret << dendl;
bufferlist bl; // bufflist ready to send
struct req_state *s{nullptr};
- rgw::sal::RGWRadosStore *store{nullptr};
+ rgw::sal::RGWStore *store{nullptr};
SHA1 h;
TorrentBencode dencode;
~seed();
int get_params();
- void init(struct req_state *p_req, rgw::sal::RGWRadosStore *p_store);
+ void init(struct req_state *p_req, rgw::sal::RGWStore *p_store);
int get_torrent_file(rgw::sal::RGWObject* object,
uint64_t &total_len,
ceph::bufferlist &bl_data,
Impl(rgw::sal::RGWRadosStore *store, const BucketTrimConfig& config)
: store(store), config(config),
- status_obj(store->svc()->zone->get_zone_params().log_pool, BucketTrimStatus::oid),
+ status_obj(store->get_zone_params().log_pool, BucketTrimStatus::oid),
counter(config.counter_size),
trimmed(config.recent_size, config.recent_duration),
watcher(store, status_obj, this)
#include "rgw_rados.h"
#include "rgw_usage.h"
#include "rgw_formats.h"
+#include "rgw_sal.h"
formatter->close_section(); // categories
}
-int RGWUsage::show(RGWRados *store, const rgw_user& uid, const string& bucket_name, uint64_t start_epoch,
- uint64_t end_epoch, bool show_log_entries, bool show_log_sum, map<string, bool> *categories,
- RGWFormatterFlusher& flusher)
+int RGWUsage::show(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store,
+ rgw::sal::RGWUser* user , rgw::sal::RGWBucket* bucket,
+ uint64_t start_epoch, uint64_t end_epoch, bool show_log_entries,
+ bool show_log_sum,
+ map<string, bool> *categories, RGWFormatterFlusher& flusher)
{
uint32_t max_entries = 1000;
string last_owner;
bool user_section_open = false;
map<string, rgw_usage_log_entry> summary_map;
+ int ret;
+
while (is_truncated) {
- int ret = store->read_usage(uid, bucket_name, start_epoch, end_epoch, max_entries,
- &is_truncated, usage_iter, usage);
+ if (bucket) {
+ ret = bucket->read_usage(start_epoch, end_epoch, max_entries, &is_truncated,
+ usage_iter, usage);
+ } else if (user) {
+ ret = user->read_usage(start_epoch, end_epoch, max_entries, &is_truncated,
+ usage_iter, usage);
+ } else {
+ ret = store->read_all_usage(start_epoch, end_epoch, max_entries, &is_truncated,
+ usage_iter, usage);
+ }
if (ret == -ENOENT) {
ret = 0;
return 0;
}
-int RGWUsage::trim(RGWRados *store, const rgw_user& uid, const string& bucket_name, uint64_t start_epoch,
- uint64_t end_epoch)
+int RGWUsage::trim(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store,
+ rgw::sal::RGWUser* user , rgw::sal::RGWBucket* bucket,
+ uint64_t start_epoch, uint64_t end_epoch)
{
- return store->trim_usage(uid, bucket_name, start_epoch, end_epoch);
+ if (bucket) {
+ return bucket->trim_usage(start_epoch, end_epoch);
+ } else if (user) {
+ return user->trim_usage(start_epoch, end_epoch);
+ } else {
+ return store->trim_all_usage(start_epoch, end_epoch);
+ }
}
-int RGWUsage::clear(RGWRados *store)
+int RGWUsage::clear(rgw::sal::RGWStore* store)
{
return store->clear_usage();
}
#include "rgw_formats.h"
#include "rgw_user.h"
-class RGWRados;
+namespace rgw { namespace sal { class RGWStore; } }
class RGWUsage
{
public:
- static int show(RGWRados *store, const rgw_user& uid, const string& bucket_name, uint64_t start_epoch,
- uint64_t end_epoch, bool show_log_entries, bool show_log_sum,
+ static int show(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store,
+ rgw::sal::RGWUser* user , rgw::sal::RGWBucket* bucket,
+ uint64_t start_epoch, uint64_t end_epoch, bool show_log_entries,
+ bool show_log_sum,
std::map<std::string, bool> *categories, RGWFormatterFlusher& flusher);
- static int trim(RGWRados *store, const rgw_user& uid, const string& bucket_name, uint64_t start_epoch,
- uint64_t end_epoch);
+ static int trim(const DoutPrefixProvider *dpp, rgw::sal::RGWStore *store,
+ rgw::sal::RGWUser* user , rgw::sal::RGWBucket* bucket,
+ uint64_t start_epoch, uint64_t end_epoch);
- static int clear(RGWRados *store);
+ static int clear(rgw::sal::RGWStore *store);
};
#include "common/Formatter.h"
#include "common/ceph_json.h"
#include "common/RWLock.h"
-#include "rgw_sal.h"
#include "rgw_sal_rados.h"
#include "rgw_zone.h"
#include "rgw_acl.h"
info.access_keys.clear();
}
-int rgw_user_sync_all_stats(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store,
- const rgw_user& user_id, optional_yield y)
+int rgw_user_sync_all_stats(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store,
+ rgw::sal::RGWUser* user, optional_yield y)
{
rgw::sal::RGWBucketList user_buckets;
- rgw::sal::RGWRadosUser user(store, user_id);
CephContext *cct = store->ctx();
size_t max_entries = cct->_conf->rgw_list_buckets_max_chunk;
int ret;
do {
- ret = user.list_buckets(dpp, marker, string(), max_entries, false, user_buckets, y);
+ ret = user->list_buckets(dpp, marker, string(), max_entries, false, user_buckets, y);
if (ret < 0) {
ldpp_dout(dpp, 0) << "failed to read user buckets: ret=" << ret << dendl;
return ret;
}
} while (user_buckets.is_truncated());
- ret = store->ctl()->user->complete_flush_stats(user.get_user(), y);
+ ret = user->complete_flush_stats(y);
if (ret < 0) {
cerr << "ERROR: failed to complete syncing user stats: ret=" << ret << std::endl;
return ret;
return 0;
}
-int rgw_user_get_all_buckets_stats(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
- const rgw_user& user_id,
+int rgw_user_get_all_buckets_stats(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
+ rgw::sal::RGWUser* user,
map<string, cls_user_bucket_entry>& buckets_usage_map,
optional_yield y)
{
do {
rgw::sal::RGWBucketList buckets;
- ret = rgw_read_user_buckets(dpp, store, user_id, buckets, marker,
- string(), max_entries, false, y);
+ ret = user->list_buckets(dpp, marker, string(), max_entries, false, buckets, y);
if (ret < 0) {
ldpp_dout(dpp, 0) << "failed to read user buckets: ret=" << ret << dendl;
return ret;
init_default();
}
-int RGWUser::init(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *storage,
+int RGWUser::init(const DoutPrefixProvider *dpp, rgw::sal::RGWStore *storage,
RGWUserAdminOpState& op_state, optional_yield y)
{
init_default();
clear_populated();
}
-int RGWUser::init_storage(rgw::sal::RGWRadosStore *storage)
+int RGWUser::init_storage(rgw::sal::RGWStore *storage)
{
if (!storage) {
return -EINVAL;
}
store = storage;
- user_ctl = store->ctl()->user;
+ user_ctl = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->user;
clear_populated();
}
}
- rgw::sal::RGWRadosUser old_user(store, op_state.get_user_info());
- rgw::sal::RGWRadosUser new_user(store, op_state.get_new_uid());
- if (old_user.get_tenant() != new_user.get_tenant()) {
+ std::unique_ptr<rgw::sal::RGWUser> old_user = store->get_user(op_state.get_user_info().user_id);
+ std::unique_ptr<rgw::sal::RGWUser> new_user = store->get_user(op_state.get_new_uid());
+ if (old_user->get_tenant() != new_user->get_tenant()) {
set_err_msg(err_msg, "users have to be under the same tenant namespace "
- + old_user.get_tenant() + " != " + new_user.get_tenant());
+ + old_user->get_tenant() + " != " + new_user->get_tenant());
return -EINVAL;
}
// create a stub user and write only the uid index and buckets object
RGWUserInfo stub_user_info;
- stub_user_info.user_id = new_user.get_user();
+ stub_user_info.user_id = new_user->get_user();
RGWObjVersionTracker objv;
const bool exclusive = !op_state.get_overwrite_new_user(); // overwrite if requested
}
RGWAccessControlPolicy policy_instance;
- policy_instance.create_default(new_user.get_user(), old_user.get_display_name());
+ policy_instance.create_default(new_user->get_user(), old_user->get_display_name());
//unlink and link buckets to new user
string marker;
rgw::sal::RGWBucketList buckets;
do {
- ret = old_user.list_buckets(dpp, marker, "", max_buckets, false, buckets, y);
+ ret = old_user->list_buckets(dpp, marker, "", max_buckets, false, buckets, y);
if (ret < 0) {
set_err_msg(err_msg, "unable to list user buckets");
return ret;
return ret;
}
- ret = bucket->link(dpp, &new_user, y);
+ ret = bucket->link(dpp, new_user.get(), y);
if (ret < 0) {
set_err_msg(err_msg, "failed to link bucket " + bucket->get_name());
return ret;
}
- ret = bucket->chown(&new_user, &old_user, y, dpp);
+ ret = bucket->chown(dpp, new_user.get(), old_user.get(), y);
if (ret < 0) {
set_err_msg(err_msg, "failed to run bucket chown" + cpp_strerror(-ret));
return ret;
// update the 'stub user' with all of the other fields and rewrite all of the
// associated index objects
RGWUserInfo& user_info = op_state.get_user_info();
- user_info.user_id = new_user.get_user();
+ user_info.user_id = new_user->get_user();
op_state.objv = objv;
- rename_swift_keys(new_user.get_user(), user_info.swift_keys);
+ rename_swift_keys(new_user->get_user(), user_info.swift_keys);
return update(dpp, op_state, err_msg, y);
}
int ret;
bool purge_data = op_state.will_purge_data();
- rgw_user& uid = op_state.get_user_id();
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(op_state.get_user_id());
RGWUserInfo user_info = op_state.get_user_info();
if (!op_state.has_existing_user()) {
CephContext *cct = store->ctx();
size_t max_buckets = cct->_conf->rgw_list_buckets_max_chunk;
do {
- ret = rgw_read_user_buckets(dpp, store, uid, buckets, marker, string(),
- max_buckets, false, y);
+ ret = user->list_buckets(dpp, marker, string(), max_buckets, false, buckets, y);
if (ret < 0) {
set_err_msg(err_msg, "unable to read user bucket info");
return ret;
string marker;
CephContext *cct = store->ctx();
size_t max_buckets = cct->_conf->rgw_list_buckets_max_chunk;
+ std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(user_id);
do {
- ret = rgw_read_user_buckets(dpp, store, user_id, buckets, marker, string(),
- max_buckets, false, y);
+ ret = user->list_buckets(dpp, marker, string(), max_buckets, false, buckets, y);
if (ret < 0) {
set_err_msg(err_msg, "could not get buckets for uid: " + user_id.to_str());
return ret;
marker = iter->first;
}
- ret = store->getRados()->set_buckets_enabled(bucket_names, !suspended, dpp);
+ ret = store->set_buckets_enabled(dpp, bucket_names, !suspended);
if (ret < 0) {
set_err_msg(err_msg, "failed to modify bucket");
return ret;
op_state.max_entries = 1000;
}
- auto meta_mgr = store->ctl()->meta.mgr;
+ auto meta_mgr = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr;
int ret = meta_mgr->list_keys_init(metadata_key, op_state.marker, &handle);
if (ret < 0) {
return 0;
}
-int RGWUserAdminOp_User::list(rgw::sal::RGWRadosStore *store, RGWUserAdminOpState& op_state,
+int RGWUserAdminOp_User::list(rgw::sal::RGWStore *store, RGWUserAdminOpState& op_state,
RGWFormatterFlusher& flusher)
{
RGWUser user;
return 0;
}
-int RGWUserAdminOp_User::info(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store, RGWUserAdminOpState& op_state,
+int RGWUserAdminOp_User::info(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store, RGWUserAdminOpState& op_state,
RGWFormatterFlusher& flusher,
optional_yield y)
{
RGWUserInfo info;
RGWUser user;
+ std::unique_ptr<rgw::sal::RGWUser> ruser;
int ret = user.init(dpp, store, op_state, y);
if (ret < 0)
if (ret < 0)
return ret;
+ ruser = store->get_user(info.user_id);
+
if (op_state.sync_stats) {
- ret = rgw_user_sync_all_stats(dpp, store, info.user_id, y);
+ ret = rgw_user_sync_all_stats(dpp, store, ruser.get(), y);
if (ret < 0) {
return ret;
}
RGWStorageStats stats;
RGWStorageStats *arg_stats = NULL;
if (op_state.fetch_stats) {
- int ret = store->ctl()->user->read_stats(info.user_id, &stats, y);
+ int ret = ruser->read_stats(y, &stats);
if (ret < 0 && ret != -ENOENT) {
return ret;
}
return 0;
}
-int RGWUserAdminOp_User::create(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+int RGWUserAdminOp_User::create(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state,
RGWFormatterFlusher& flusher, optional_yield y)
{
return 0;
}
-int RGWUserAdminOp_User::modify(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+int RGWUserAdminOp_User::modify(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state,
RGWFormatterFlusher& flusher, optional_yield y)
{
return 0;
}
-int RGWUserAdminOp_User::remove(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, RGWUserAdminOpState& op_state,
+int RGWUserAdminOp_User::remove(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store, RGWUserAdminOpState& op_state,
RGWFormatterFlusher& flusher, optional_yield y)
{
RGWUserInfo info;
return ret;
}
-int RGWUserAdminOp_Subuser::create(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+int RGWUserAdminOp_Subuser::create(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state,
RGWFormatterFlusher& flusher,
optional_yield y)
return 0;
}
-int RGWUserAdminOp_Subuser::modify(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store, RGWUserAdminOpState& op_state,
+int RGWUserAdminOp_Subuser::modify(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store, RGWUserAdminOpState& op_state,
RGWFormatterFlusher& flusher, optional_yield y)
{
RGWUserInfo info;
return 0;
}
-int RGWUserAdminOp_Subuser::remove(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+int RGWUserAdminOp_Subuser::remove(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state,
RGWFormatterFlusher& flusher,
optional_yield y)
return 0;
}
-int RGWUserAdminOp_Key::create(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store, RGWUserAdminOpState& op_state,
+int RGWUserAdminOp_Key::create(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store, RGWUserAdminOpState& op_state,
RGWFormatterFlusher& flusher,
optional_yield y)
{
return 0;
}
-int RGWUserAdminOp_Key::remove(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+int RGWUserAdminOp_Key::remove(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state,
RGWFormatterFlusher& flusher,
optional_yield y)
return 0;
}
-int RGWUserAdminOp_Caps::add(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+int RGWUserAdminOp_Caps::add(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state,
RGWFormatterFlusher& flusher, optional_yield y)
{
}
-int RGWUserAdminOp_Caps::remove(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+int RGWUserAdminOp_Caps::remove(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state,
RGWFormatterFlusher& flusher, optional_yield y)
{
class RGWGetUserStats_CB;
namespace rgw { namespace sal {
-class RGWRadosStore;
+class RGWStore;
} }
/**
};
WRITE_CLASS_ENCODER(RGWUID)
-extern int rgw_user_sync_all_stats(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, const rgw_user& user_id, optional_yield y);
+extern int rgw_user_sync_all_stats(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store, rgw::sal::RGWUser* user, optional_yield y);
extern int rgw_user_get_all_buckets_stats(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,const rgw_user& user_id,
+ rgw::sal::RGWStore* store, rgw::sal::RGWUser* user,
map<string, cls_user_bucket_entry>& buckets_usage_map, optional_yield y);
/**
key_op = true;
}
- void set_user_id(rgw_user& id) {
+ void set_user_id(const rgw_user& id) {
if (id.empty())
return;
user_id = id;
}
- void set_new_user_id(rgw_user& id) {
+ void set_new_user_id(const rgw_user& id) {
if (id.empty())
return;
std::map<std::string, int, ltstr_nocase> key_type_map;
rgw_user user_id;
- rgw::sal::RGWRadosStore *store{nullptr};
+ rgw::sal::RGWStore *store{nullptr};
RGWUserCtl *user_ctl{nullptr};
map<std::string, RGWAccessKey> *swift_keys{nullptr};
RGWUser *user{nullptr};
rgw_user user_id;
- rgw::sal::RGWRadosStore *store{nullptr};
+ rgw::sal::RGWStore *store{nullptr};
RGWUserCtl *user_ctl{nullptr};
bool subusers_allowed{false};
private:
RGWUserInfo old_info;
- rgw::sal::RGWRadosStore *store{nullptr};
+ rgw::sal::RGWStore *store{nullptr};
RGWUserCtl *user_ctl{nullptr};
rgw_user user_id;
public:
RGWUser();
- int init(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *storage, RGWUserAdminOpState& op_state,
+ int init(const DoutPrefixProvider *dpp, rgw::sal::RGWStore *storage, RGWUserAdminOpState& op_state,
optional_yield y);
- int init_storage(rgw::sal::RGWRadosStore *storage);
+ int init_storage(rgw::sal::RGWStore *storage);
int init(const DoutPrefixProvider *dpp, RGWUserAdminOpState& op_state, optional_yield y);
int init_members(RGWUserAdminOpState& op_state);
- rgw::sal::RGWRadosStore *get_store() { return store; }
+ rgw::sal::RGWStore *get_store() { return store; }
RGWUserCtl *get_user_ctl() { return user_ctl; }
/* API Contracted Members */
class RGWUserAdminOp_User
{
public:
- static int list(rgw::sal::RGWRadosStore *store,
+ static int list(rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher);
- static int info(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int info(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
- static int create(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int create(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
- static int modify(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store,
+ static int modify(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher, optional_yield y);
- static int remove(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store,
+ static int remove(const DoutPrefixProvider *dpp, rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher, optional_yield y);
};
class RGWUserAdminOp_Subuser
{
public:
- static int create(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int create(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
- static int modify(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int modify(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
- static int remove(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int remove(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
};
class RGWUserAdminOp_Key
{
public:
- static int create(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store,
+ static int create(const DoutPrefixProvider *dpp, rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
- static int remove(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int remove(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
};
class RGWUserAdminOp_Caps
{
public:
- static int add(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int add(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
- static int remove(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int remove(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
};
return r;
}
-int RGWPeriod::update_sync_status(rgw::sal::RGWRadosStore *store, /* for now */
+int RGWPeriod::update_sync_status(rgw::sal::RGWStore *store, /* for now */
const RGWPeriod ¤t_period,
std::ostream& error_stream,
bool force_if_stale)
{
rgw_meta_sync_status status;
- int r = read_sync_status(store, &status);
+ int r = read_sync_status(static_cast<rgw::sal::RGWRadosStore*>(store), &status);
if (r < 0) {
ldout(cct, 0) << "period failed to read sync status: "
<< cpp_strerror(-r) << dendl;
return 0;
}
-int RGWPeriod::commit(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+int RGWPeriod::commit(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWRealm& realm, const RGWPeriod& current_period,
std::ostream& error_stream, optional_yield y,
bool force_if_stale)
const std::string get_period_oid_prefix() const;
// gather the metadata sync status for each shard; only for use on master zone
- int update_sync_status(rgw::sal::RGWRadosStore *store,
+ int update_sync_status(rgw::sal::RGWStore *store,
const RGWPeriod ¤t_period,
std::ostream& error_stream, bool force_if_stale);
int update(optional_yield y);
// commit a staging period; only for use on master zone
- int commit(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ int commit(const DoutPrefixProvider *dpp,
+ rgw::sal::RGWStore *store,
RGWRealm& realm, const RGWPeriod ¤t_period,
std::ostream& error_stream, optional_yield y,
bool force_if_stale = false);