}
s->bucket_mtime = s->bucket->get_modification_time();
- s->bucket_attrs = s->bucket->get_attrs().attrs;
+ s->bucket_attrs = s->bucket->get_attrs();
ret = read_bucket_policy(store, s, s->bucket->get_info(),
- s->bucket->get_attrs().attrs,
+ s->bucket->get_attrs(),
s->bucket_acl.get(), s->bucket->get_key());
acct_acl_user = {
s->bucket->get_info().owner,
return -EINVAL;
}
- s->bucket_access_conf = get_public_access_conf_from_attr(s->bucket->get_attrs().attrs);
+ s->bucket_access_conf = get_public_access_conf_from_attr(s->bucket->get_attrs());
}
/* handle user ACL only for those APIs which support it */
if (op_ret < 0)
return op_ret;
rgw::sal::RGWAttrs attrs = s->object->get_attrs();
- auto tags = attrs.attrs.find(RGW_ATTR_TAGS);
- if (tags != attrs.attrs.end()){
+ auto tags = attrs.find(RGW_ATTR_TAGS);
+ if (tags != attrs.end()){
return rgw_iam_add_tags_from_bl(s, tags->second);
}
return 0;
// cache the objects tags into the requests
// use inside try/catch as "decode()" may throw
void populate_tags_in_request(req_state* s, const rgw::sal::RGWAttrs& attrs) {
- const auto attr_iter = attrs.attrs.find(RGW_ATTR_TAGS);
- if (attr_iter != attrs.attrs.end()) {
+ const auto attr_iter = attrs.find(RGW_ATTR_TAGS);
+ if (attr_iter != attrs.end()) {
auto bliter = attr_iter->second.cbegin();
decode(s->tagset, bliter);
}
// cache the objects metadata into the request
void populate_metadata_in_request(req_state* s, const rgw::sal::RGWAttrs& attrs) {
- for (auto& attr : attrs.attrs) {
+ for (auto& attr : attrs) {
if (boost::algorithm::starts_with(attr.first, RGW_ATTR_META_PREFIX)) {
std::string_view key(attr.first);
key.remove_prefix(sizeof(RGW_ATTR_PREFIX)-1);
}
attrs = s->object->get_attrs();
- auto tags = attrs.attrs.find(RGW_ATTR_TAGS);
- if(tags != attrs.attrs.end()){
+ auto tags = attrs.find(RGW_ATTR_TAGS);
+ if(tags != attrs.end()){
has_tags = true;
tags_bl.append(tags->second);
}
if (op_ret < 0)
return op_ret;
bool need_decompress;
- op_ret = rgw_compression_info_from_attrset(part->get_attrs().attrs, need_decompress, cs_info);
+ op_ret = rgw_compression_info_from_attrset(part->get_attrs(), need_decompress, cs_info);
if (op_ret < 0) {
ldpp_dout(this, 0) << "ERROR: failed to decode compression info" << dendl;
return -EIO;
}
}
- op_ret = rgw_policy_from_attrset(s->cct, part->get_attrs().attrs, &obj_policy);
+ op_ret = rgw_policy_from_attrset(s->cct, part->get_attrs(), &obj_policy);
if (op_ret < 0)
return op_ret;
}
bucket = tmp_bucket.get();
bucket_acl = &_bucket_acl;
- r = read_bucket_policy(store, s, tmp_bucket->get_info(), tmp_bucket->get_attrs().attrs, bucket_acl,
+ r = read_bucket_policy(store, s, tmp_bucket->get_info(), tmp_bucket->get_attrs(), bucket_acl,
tmp_bucket->get_key());
if (r < 0) {
ldpp_dout(this, 0) << "failed to read bucket ACL for bucket "
return r;
}
auto _bucket_policy = get_iam_policy_from_attr(
- s->cct, tmp_bucket->get_attrs().attrs, tmp_bucket->get_tenant());
+ s->cct, tmp_bucket->get_attrs(), tmp_bucket->get_tenant());
bucket_policy = _bucket_policy.get_ptr();
buckets[bucket_name].swap(tmp_bucket);
policies[bucket_name] = make_pair(bucket_acl, _bucket_policy);
}
/* end gettorrent */
- op_ret = rgw_compression_info_from_attrset(attrs.attrs, need_decompress, cs_info);
+ op_ret = rgw_compression_info_from_attrset(attrs, need_decompress, cs_info);
if (op_ret < 0) {
ldpp_dout(s, 0) << "ERROR: failed to decode compression info, cannot decompress" << dendl;
goto done_err;
}
/* Decode S3 objtags, if any */
- rgw_cond_decode_objtags(s, attrs.attrs);
+ rgw_cond_decode_objtags(s, attrs);
start = ofs;
op_ret = -EEXIST;
return;
} else {
- s->bucket_attrs = s->bucket->get_attrs().attrs;
+ s->bucket_attrs = s->bucket->get_attrs();
}
attrs.clear();
obj_size = obj->get_obj_size();
bool need_decompress;
- op_ret = rgw_compression_info_from_attrset(obj->get_attrs().attrs, need_decompress, cs_info);
+ op_ret = rgw_compression_info_from_attrset(obj->get_attrs(), need_decompress, cs_info);
if (op_ret < 0) {
ldpp_dout(s, 0) << "ERROR: failed to decode compression info" << dendl;
return -EIO;
auto attr_iter = obj->get_attrs().find(RGW_ATTR_MANIFEST);
op_ret = this->get_decrypt_filter(&decrypt,
filter,
- obj->get_attrs().attrs,
+ obj->get_attrs(),
attr_iter != obj->get_attrs().end() ? &(attr_iter->second) : nullptr);
if (decrypt != nullptr) {
filter = decrypt.get();
return;
}
- op_ret = rgw_get_request_metadata(s->cct, s->info, attrs.attrs, false);
+ op_ret = rgw_get_request_metadata(s->cct, s->info, attrs, false);
if (op_ret < 0) {
return;
}
/* It's supposed that following functions WILL NOT change any
* special attributes (like RGW_ATTR_ACL) if they are already
* present in attrs. */
- prepare_add_del_attrs(s->bucket_attrs, rmattr_names, attrs.attrs);
- populate_with_generic_attrs(s, attrs.attrs);
+ prepare_add_del_attrs(s->bucket_attrs, rmattr_names, attrs);
+ populate_with_generic_attrs(s, attrs);
/* According to the Swift's behaviour and its container_quota
* WSGI middleware implementation: anyone with write permissions
* is able to set the bucket quota. This stays in contrast to
* account quotas that can be set only by clients holding
* reseller admin privileges. */
- op_ret = filter_out_quota_info(attrs.attrs, rmattr_names, s->bucket->get_info().quota);
+ op_ret = filter_out_quota_info(attrs, rmattr_names, s->bucket->get_info().quota);
if (op_ret < 0) {
return op_ret;
}
}
/* Web site of Swift API. */
- filter_out_website(attrs.attrs, rmattr_names, s->bucket->get_info().website_conf);
+ filter_out_website(attrs, rmattr_names, s->bucket->get_info().website_conf);
s->bucket->get_info().has_website = !s->bucket->get_info().website_conf.is_empty();
/* Setting attributes also stores the provided bucket info. Due
return;
}
- op_ret = rgw_get_request_metadata(s->cct, s->info, attrs.attrs);
+ op_ret = rgw_get_request_metadata(s->cct, s->info, attrs);
if (op_ret < 0) {
return;
}
}
/* Filter currently existing attributes. */
- prepare_add_del_attrs(s->object->get_attrs().attrs, attrs.attrs, rmattrs.attrs);
- populate_with_generic_attrs(s, attrs.attrs);
- encode_delete_at_attr(delete_at, attrs.attrs);
+ prepare_add_del_attrs(s->object->get_attrs(), attrs, rmattrs);
+ populate_with_generic_attrs(s, attrs);
+ encode_delete_at_attr(delete_at, attrs);
if (dlo_manifest) {
- op_ret = encode_dlo_manifest_attr(dlo_manifest, attrs.attrs);
+ op_ret = encode_dlo_manifest_attr(dlo_manifest, attrs);
if (op_ret < 0) {
ldpp_dout(this, 0) << "bad user manifest: " << dlo_manifest << dendl;
return;
op_ret = 0;
if (check_obj_lock) {
- auto aiter = attrs.attrs.find(RGW_ATTR_OBJECT_RETENTION);
- if (aiter != attrs.attrs.end()) {
+ auto aiter = attrs.find(RGW_ATTR_OBJECT_RETENTION);
+ if (aiter != attrs.end()) {
RGWObjectRetention obj_retention;
try {
decode(obj_retention, aiter->second);
}
}
}
- aiter = attrs.attrs.find(RGW_ATTR_OBJECT_LEGAL_HOLD);
- if (aiter != attrs.attrs.end()) {
+ aiter = attrs.find(RGW_ATTR_OBJECT_LEGAL_HOLD);
+ if (aiter != attrs.end()) {
RGWObjectLegalHold obj_legal_hold;
try {
decode(obj_legal_hold, aiter->second);
}
if (multipart_delete) {
- const auto slo_attr = attrs.attrs.find(RGW_ATTR_SLO_MANIFEST);
+ const auto slo_attr = attrs.find(RGW_ATTR_SLO_MANIFEST);
- if (slo_attr != attrs.attrs.end()) {
+ if (slo_attr != attrs.end()) {
op_ret = handle_slo_manifest(slo_attr->second);
if (op_ret < 0) {
ldpp_dout(this, 0) << "ERROR: failed to handle slo manifest ret=" << op_ret << dendl;
// cache the objects tags and metadata into the requests
// so it could be used in the notification mechanism
try {
- populate_tags_in_request(s, attrs.attrs);
+ populate_tags_in_request(s, attrs);
} catch (buffer::error& err) {
ldpp_dout(this, 5) << "WARNING: failed to populate delete request with object tags: " << err.what() << dendl;
}
- populate_metadata_in_request(s, attrs.attrs);
+ populate_metadata_in_request(s, attrs);
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.attrs[RGW_ATTR_ETAG].to_str(), event_type, res);
+ 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);
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
rgw_placement_rule src_placement;
/* check source object permissions */
- op_ret = read_obj_policy(store, s, src_bucket->get_info(), src_bucket->get_attrs().attrs, &src_acl, &src_placement.storage_class,
+ op_ret = read_obj_policy(store, s, src_bucket->get_info(), src_bucket->get_attrs(), &src_acl, &src_placement.storage_class,
src_policy, src_bucket.get(), src_object.get());
if (op_ret < 0) {
return op_ret;
/* check dest bucket permissions */
op_ret = read_bucket_policy(store, s, dest_bucket->get_info(),
- dest_bucket->get_attrs().attrs,
+ dest_bucket->get_attrs(),
&dest_bucket_policy, dest_bucket->get_key());
if (op_ret < 0) {
return op_ret;
}
- auto dest_iam_policy = get_iam_policy_from_attr(s->cct, dest_bucket->get_attrs().attrs, dest_bucket->get_tenant());
+ auto dest_iam_policy = get_iam_policy_from_attr(s->cct, dest_bucket->get_attrs(), dest_bucket->get_tenant());
/* admin request overrides permission checks */
if (! s->auth.identity->is_admin_of(dest_policy.get_owner().get_id())){
if (dest_iam_policy != boost::none) {
dest_policy.encode(aclbl);
emplace_attr(RGW_ATTR_ACL, std::move(aclbl));
- op_ret = rgw_get_request_metadata(s->cct, s->info, attrs.attrs);
+ op_ret = rgw_get_request_metadata(s->cct, s->info, attrs);
if (op_ret < 0) {
return op_ret;
}
- populate_with_generic_attrs(s, attrs.attrs);
+ populate_with_generic_attrs(s, attrs);
return 0;
}
src_object->set_atomic(&obj_ctx);
dest_object->set_atomic(&obj_ctx);
- encode_delete_at_attr(delete_at, attrs.attrs);
+ encode_delete_at_attr(delete_at, attrs);
if (!s->system_request) { // no quota enforcement for system requests
// get src object size (cached in obj_ctx from verify_permission())
<< " ret=" << op_ret << dendl;
return;
}
- attrs = meta_obj->get_attrs().attrs;
+ attrs = meta_obj->get_attrs();
do {
op_ret = list_multipart_parts(store, s, upload_id, meta_oid, max_parts,
goto binfo_fail;
}
- if (!verify_permission(bucket->get_info(), bucket->get_attrs().attrs, bowner)) {
+ if (!verify_permission(bucket->get_info(), bucket->get_attrs(), bowner)) {
ret = -EACCES;
goto auth_fail;
}
if (! handle_file_verify_permission(bucket->get_info(),
obj->get_obj(),
- bucket->get_attrs().attrs, bowner)) {
+ bucket->get_attrs(), bowner)) {
ldpp_dout(this, 20) << "object creation unauthorized" << dendl;
op_ret = -EACCES;
return op_ret;
return;
}
rgw::sal::RGWAttrs attrs = s->object->get_attrs();
- auto aiter = attrs.attrs.find(RGW_ATTR_OBJECT_RETENTION);
- if (aiter != attrs.attrs.end()) {
+ auto aiter = attrs.find(RGW_ATTR_OBJECT_RETENTION);
+ if (aiter != attrs.end()) {
RGWObjectRetention old_obj_retention;
try {
decode(old_obj_retention, aiter->second);
return;
}
rgw::sal::RGWAttrs attrs = s->object->get_attrs();
- auto aiter = attrs.attrs.find(RGW_ATTR_OBJECT_RETENTION);
- if (aiter == attrs.attrs.end()) {
+ auto aiter = attrs.find(RGW_ATTR_OBJECT_RETENTION);
+ if (aiter == attrs.end()) {
op_ret = -ERR_NO_SUCH_OBJECT_LOCK_CONFIGURATION;
return;
}
<< " ret=" << op_ret << dendl;
return;
}
- auto aiter = s->object->get_attrs().attrs.find(RGW_ATTR_OBJECT_LEGAL_HOLD);
- if (aiter == s->object->get_attrs().attrs.end()) {
+ auto aiter = s->object->get_attrs().find(RGW_ATTR_OBJECT_LEGAL_HOLD);
+ if (aiter == s->object->get_attrs().end()) {
op_ret = -ERR_NO_SUCH_OBJECT_LOCK_CONFIGURATION;
return;
}
int ret = store->ctl()->bucket->read_bucket_info(info.bucket, &info, y,
RGWBucketCtl::BucketInstance::GetParams()
.set_mtime(&mtime)
- .set_attrs(&attrs.attrs)
+ .set_attrs(&attrs)
.set_bectx_params(bectx_params),
&ep_ot);
if (ret == 0) {
return get_bucket_info(y);
}
- return store->getRados()->get_bucket_instance_info(*rctx, info.bucket, info, NULL, &attrs.attrs, y);
+ return store->getRados()->get_bucket_instance_info(*rctx, info.bucket, info, NULL, &attrs, y);
}
int RGWRadosBucket::get_bucket_stats(RGWBucketInfo& bucket_info, int shard_id,
ep.owner = new_user->get_user();
ep.creation_time = get_creation_time();
ep.linked = true;
- map<string, bufferlist> ep_attrs;
+ RGWAttrs ep_attrs;
rgw_ep_info ep_data{ep, ep_attrs};
return store->ctl()->bucket->link_bucket(new_user->get_user(), info.bucket,
int RGWRadosBucket::put_instance_info(bool exclusive, ceph::real_time _mtime)
{
mtime = _mtime;
- return store->getRados()->put_bucket_instance_info(info, exclusive, mtime, &attrs.attrs);
+ return store->getRados()->put_bucket_instance_info(info, exclusive, mtime, &attrs);
}
/* Make sure to call get_bucket_info() if you need it first */
int RGWRadosBucket::set_instance_attrs(RGWAttrs& attrs, optional_yield y)
{
return store->ctl()->bucket->set_bucket_instance_attrs(get_info(),
- attrs.attrs, &get_info().objv_tracker, y);
+ attrs, &get_info().objv_tracker, y);
}
int RGWRadosBucket::try_refresh_info(ceph::real_time *pmtime)
{
- return store->getRados()->try_refresh_bucket_info(info, pmtime, &attrs.attrs);
+ return store->getRados()->try_refresh_bucket_info(info, pmtime, &attrs);
}
int RGWRadosBucket::set_acl(RGWAccessControlPolicy &acl, optional_yield y)
int RGWRadosObject::read_attrs(RGWRados::Object::Read &read_op, optional_yield y, rgw_obj *target_obj)
{
- read_op.params.attrs = &attrs.attrs;
+ read_op.params.attrs = &attrs;
read_op.params.target_obj = target_obj;
read_op.params.obj_size = &obj_size;
read_op.params.lastmod = &mtime;
int RGWRadosObject::set_obj_attrs(RGWObjectCtx* rctx, RGWAttrs* setattrs, RGWAttrs* delattrs, optional_yield y, rgw_obj* target_obj)
{
- map<string, bufferlist> empty;
+ RGWAttrs empty;
rgw_obj target = get_obj();
if (!target_obj)
return store->getRados()->set_attrs(rctx,
bucket->get_info(),
*target_obj,
- setattrs ? setattrs->attrs : empty,
- delattrs ? &delattrs->attrs : nullptr,
+ setattrs ? *setattrs : empty,
+ delattrs ? delattrs : nullptr,
y);
}
return r;
}
set_atomic(rctx);
- attrs.attrs[attr_name] = attr_val;
+ attrs[attr_name] = attr_val;
return set_obj_attrs(rctx, &attrs, nullptr, y, &target);
}
bufferlist bl;
set_atomic(rctx);
- rmattr.attrs[attr_name] = bl;
+ rmattr[attr_name] = bl;
return set_obj_attrs(rctx, nullptr, &rmattr, y);
}
const DoutPrefixProvider *dpp,
optional_yield y)
{
- map<string, bufferlist> attrset;
+ RGWAttrs attrset;
RGWRados::Object op_target(store->getRados(), dest_bucket->get_info(), rctx, get_obj());
RGWRados::Object::Read read_op(&op_target);
if (ret < 0)
return ret;
- attrset = attrs.attrs;
+ attrset = attrs;
attrset.erase(RGW_ATTR_ID_TAG);
attrset.erase(RGW_ATTR_TAIL_TAG);
}
bool RGWRadosObject::is_expired() {
- map<string, bufferlist>::iterator iter = attrs.find(RGW_ATTR_DELETE_AT);
+ auto iter = attrs.find(RGW_ATTR_DELETE_AT);
if (iter != attrs.end()) {
utime_t delete_at;
try {
int RGWRadosObject::omap_get_vals_by_keys(const std::string& oid,
const std::set<std::string>& keys,
- std::map<std::string, bufferlist> *vals)
+ RGWAttrs *vals)
{
int ret;
rgw_raw_obj head_obj;
parent_op.params.lastmod = params.lastmod;
parent_op.params.target_obj = params.target_obj;
parent_op.params.obj_size = &obj_size;
- parent_op.params.attrs = &source->get_attrs().attrs;
+ parent_op.params.attrs = &source->get_attrs();
int ret = parent_op.prepare(y);
if (ret < 0)
if_nomatch,
static_cast<RGWRados::AttrsMod>(attrs_mod),
copy_if_newer,
- attrs.attrs,
+ attrs,
category,
olh_epoch,
(delete_at ? *delete_at : real_time()),
static int rgw_op_get_bucket_policy_from_attr(RGWRadosStore *store,
RGWUser& user,
- map<string, bufferlist>& bucket_attrs,
+ RGWAttrs& bucket_attrs,
RGWAccessControlPolicy *policy)
{
- map<string, bufferlist>::iterator aiter = bucket_attrs.find(RGW_ATTR_ACL);
+ auto aiter = bucket_attrs.find(RGW_ATTR_ACL);
if (aiter != bucket_attrs.end()) {
int ret = decode_policy(store->ctx(), aiter->second, policy);
rgw_placement_rule& placement_rule,
string& swift_ver_location,
const RGWQuotaInfo * pquota_info,
- map<std::string, bufferlist>& attrs,
+ RGWAttrs& attrs,
RGWBucketInfo& info,
obj_version& ep_objv,
bool exclusive,
swift_ver_location = bucket->get_info().swift_ver_location;
}
placement_rule.inherit_from(bucket->get_info().placement_rule);
- int r = rgw_op_get_bucket_policy_from_attr(this, u, bucket->get_attrs().attrs,
+ int r = rgw_op_get_bucket_policy_from_attr(this, u, bucket->get_attrs(),
&old_policy);
if (r >= 0) {
if (old_policy.get_owner().get_id().compare(u.get_id()) != 0) {