set_quota_info(bucket->get_info().quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects);
- r = bucket->put_instance_info(dpp(), false, real_time());
+ r = bucket->put_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 ret = bucket->put_instance_info(dpp(), false, real_time());
+ int ret = bucket->put_info(dpp(), false, real_time());
if (ret < 0) {
cerr << "failed to store bucket info: " << cpp_strerror(-ret) << std::endl;
return -ret;
bucket = op_state.get_bucket()->clone();
bucket->get_info().quota = op_state.quota;
- int r = bucket->put_instance_info(dpp, false, real_time());
+ int r = bucket->put_info(dpp, false, real_time());
if (r < 0) {
set_err_msg(err_msg, "ERROR: failed writing bucket instance info: " + cpp_strerror(-r));
return r;
bucket->get_info().flags |= BUCKET_DATASYNC_DISABLED;
}
- int r = bucket->put_instance_info(dpp, false, real_time());
+ int r = bucket->put_info(dpp, false, real_time());
if (r < 0) {
set_err_msg(err_msg, "ERROR: failed writing bucket instance info:" + cpp_strerror(-r));
return r;
exclusive = true;
}
- r = loc_bucket->put_instance_info(dpp, exclusive, ceph::real_time());
+ r = loc_bucket->put_info(dpp, exclusive, ceph::real_time());
if (r < 0) {
set_err_msg(err, "ERROR: failed writing bucket instance info: " + cpp_strerror(-r));
return r;
attrs[RGW_ATTR_LC] = std::move(lc_bl);
int ret =
- bucket->set_instance_attrs(this, attrs, null_yield);
+ bucket->merge_and_store_attrs(this, attrs, null_yield);
if (ret < 0)
return ret;
{
rgw::sal::Attrs attrs = bucket_attrs;
attrs.erase(RGW_ATTR_LC);
- int ret = bucket->set_instance_attrs(this, attrs, null_yield);
+ int ret = bucket->merge_and_store_attrs(this, attrs, null_yield);
rgw_bucket& b = bucket->get_key();
op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this, y] {
rgw::sal::Attrs attrs = s->bucket->get_attrs();
attrs[RGW_ATTR_TAGS] = tags_bl;
- return s->bucket->set_instance_attrs(this, attrs, y);
+ return s->bucket->merge_and_store_attrs(this, attrs, y);
});
}
op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this, y] {
rgw::sal::Attrs attrs = s->bucket->get_attrs();
attrs.erase(RGW_ATTR_TAGS);
- op_ret = s->bucket->set_instance_attrs(this, attrs, y);
+ op_ret = s->bucket->merge_and_store_attrs(this, attrs, y);
if (op_ret < 0) {
ldpp_dout(this, 0) << "RGWDeleteBucketTags() failed to remove RGW_ATTR_TAGS on bucket="
<< s->bucket->get_name()
s->bucket->get_info().set_sync_policy(std::move(sync_policy));
- int ret = s->bucket->put_instance_info(this, false, real_time());
+ int ret = s->bucket->put_info(this, false, real_time());
if (ret < 0) {
ldpp_dout(this, 0) << "ERROR: put_bucket_instance_info (bucket=" << s->bucket << ") returned ret=" << ret << dendl;
return ret;
s->bucket->get_info().set_sync_policy(std::move(sync_policy));
- int ret = s->bucket->put_instance_info(this, false, real_time());
+ int ret = s->bucket->put_info(this, false, real_time());
if (ret < 0) {
ldpp_dout(this, 0) << "ERROR: put_bucket_instance_info (bucket=" << s->bucket << ") returned ret=" << ret << dendl;
return ret;
return op_ret;
}
s->bucket->set_attrs(rgw::sal::Attrs(s->bucket_attrs));
- return s->bucket->put_instance_info(this, false, real_time());
+ return s->bucket->put_info(this, false, real_time());
});
if (!modified) {
op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this] {
s->bucket->get_info().has_website = true;
s->bucket->get_info().website_conf = website_conf;
- op_ret = s->bucket->put_instance_info(this, false, real_time());
+ op_ret = s->bucket->put_info(this, false, real_time());
return op_ret;
});
op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this] {
s->bucket->get_info().has_website = false;
s->bucket->get_info().website_conf = RGWBucketWebsiteConf();
- op_ret = s->bucket->put_instance_info(this, false, real_time());
+ op_ret = s->bucket->put_info(this, false, real_time());
return op_ret;
});
if (op_ret < 0) {
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 = s->bucket->set_instance_attrs(this, attrs, y);
+ op_ret = s->bucket->merge_and_store_attrs(this, attrs, y);
} while (op_ret == -ECANCELED && tries++ < 20);
/* Restore the proper return code. */
/* Setting attributes also stores the provided bucket info. Due
* to this fact, the new quota settings can be serialized with
* the same call. */
- op_ret = s->bucket->set_instance_attrs(this, attrs, s->yield);
+ op_ret = s->bucket->merge_and_store_attrs(this, attrs, s->yield);
return op_ret;
});
}
} else {
map<string,bufferlist> attrs = s->bucket_attrs;
attrs[RGW_ATTR_ACL] = bl;
- op_ret = s->bucket->set_instance_attrs(this, attrs, y);
+ op_ret = s->bucket->merge_and_store_attrs(this, attrs, y);
}
if (op_ret == -ECANCELED) {
op_ret = 0; /* lost a race, but it's ok because acls are immutable */
op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this] {
rgw::sal::Attrs attrs(s->bucket_attrs);
attrs[RGW_ATTR_CORS] = cors_bl;
- return s->bucket->set_instance_attrs(this, attrs, s->yield);
+ return s->bucket->merge_and_store_attrs(this, attrs, s->yield);
});
}
rgw::sal::Attrs attrs(s->bucket_attrs);
attrs.erase(RGW_ATTR_CORS);
- op_ret = s->bucket->set_instance_attrs(this, attrs, s->yield);
+ op_ret = s->bucket->merge_and_store_attrs(this, attrs, s->yield);
if (op_ret < 0) {
ldpp_dout(this, 0) << "RGWLC::RGWDeleteCORS() failed to set attrs on bucket=" << s->bucket->get_name()
<< " returned err=" << op_ret << dendl;
return;
s->bucket->get_info().requester_pays = requester_pays;
- op_ret = s->bucket->put_instance_info(this, false, real_time());
+ op_ret = s->bucket->put_info(this, false, real_time());
if (op_ret < 0) {
ldpp_dout(this, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket->get_name()
<< " returned err=" << op_ret << dendl;
rgw::sal::Attrs a(attrs);
op_ret = s->object->set_obj_attrs(this, s->obj_ctx, &a, nullptr, y);
} else {
- op_ret = s->bucket->set_instance_attrs(this, attrs, y);
+ op_ret = s->bucket->merge_and_store_attrs(this, attrs, y);
}
} /* RGWSetAttrs::execute() */
s->bucket->get_info().mdsearch_config = mdsearch_config;
- op_ret = s->bucket->put_instance_info(this, false, real_time());
+ op_ret = s->bucket->put_info(this, false, real_time());
if (op_ret < 0) {
ldpp_dout(this, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket->get_name()
<< " returned err=" << op_ret << dendl;
{
s->bucket->get_info().mdsearch_config.clear();
- op_ret = s->bucket->put_instance_info(this, false, real_time());
+ op_ret = s->bucket->put_info(this, false, real_time());
if (op_ret < 0) {
ldpp_dout(this, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket->get_name()
<< " returned err=" << op_ret << dendl;
op_ret = retry_raced_bucket_write(this, s->bucket.get(), [&p, this, &attrs] {
attrs[RGW_ATTR_IAM_POLICY].clear();
attrs[RGW_ATTR_IAM_POLICY].append(p.text);
- op_ret = s->bucket->set_instance_attrs(this, attrs, s->yield);
+ op_ret = s->bucket->merge_and_store_attrs(this, attrs, s->yield);
return op_ret;
});
} catch (rgw::IAM::PolicyParseException& e) {
op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this] {
rgw::sal::Attrs attrs(s->bucket_attrs);
attrs.erase(RGW_ATTR_IAM_POLICY);
- op_ret = s->bucket->set_instance_attrs(this, attrs, s->yield);
+ op_ret = s->bucket->merge_and_store_attrs(this, attrs, s->yield);
return op_ret;
});
}
op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this] {
s->bucket->get_info().obj_lock = obj_lock;
- op_ret = s->bucket->put_instance_info(this, false, real_time());
+ op_ret = s->bucket->put_info(this, false, real_time());
return op_ret;
});
return;
op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this, &bl] {
rgw::sal::Attrs attrs(s->bucket_attrs);
attrs[RGW_ATTR_PUBLIC_ACCESS] = bl;
- return s->bucket->set_instance_attrs(this, attrs, s->yield);
+ return s->bucket->merge_and_store_attrs(this, attrs, s->yield);
});
}
op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this] {
rgw::sal::Attrs attrs(s->bucket_attrs);
attrs.erase(RGW_ATTR_PUBLIC_ACCESS);
- op_ret = s->bucket->set_instance_attrs(this, attrs, s->yield);
+ op_ret = s->bucket->merge_and_store_attrs(this, attrs, s->yield);
return op_ret;
});
}
rgw::sal::Attrs attrs = s->bucket->get_attrs();
attrs[RGW_ATTR_BUCKET_ENCRYPTION_POLICY] = conf_bl;
attrs[RGW_ATTR_BUCKET_ENCRYPTION_KEY_ID] = key_id_bl;
- return s->bucket->set_instance_attrs(this, attrs, y);
+ return s->bucket->merge_and_store_attrs(this, attrs, y);
});
}
rgw::sal::Attrs attrs = s->bucket->get_attrs();
attrs.erase(RGW_ATTR_BUCKET_ENCRYPTION_POLICY);
attrs.erase(RGW_ATTR_BUCKET_ENCRYPTION_KEY_ID);
- op_ret = s->bucket->set_instance_attrs(this, attrs, y);
+ op_ret = s->bucket->merge_and_store_attrs(this, attrs, y);
return op_ret;
});
}
virtual int update_container_stats(const DoutPrefixProvider* dpp) = 0;
virtual int check_bucket_shards(const DoutPrefixProvider* dpp) = 0;
virtual int chown(const DoutPrefixProvider* dpp, User* new_user, User* 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 put_info(const DoutPrefixProvider* dpp, bool exclusive, ceph::real_time mtime) = 0;
virtual int remove_metadata(const DoutPrefixProvider* dpp, RGWObjVersionTracker* objv, optional_yield y) = 0;
virtual bool is_owner(User* user) = 0;
virtual User* get_owner(void) { return owner; };
virtual ACLOwner get_acl_owner(void) { return ACLOwner(info.owner); };
virtual int check_empty(const DoutPrefixProvider* dpp, optional_yield y) = 0;
virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) = 0;
- virtual int set_instance_attrs(const DoutPrefixProvider* dpp, Attrs& attrs, optional_yield y) = 0;
+ /** Set the attributes in attrs, leaving any other existing attrs set, and
+ * write them to the backing store; a merge operation */
+ virtual int merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new_attrs, optional_yield y) {
+ for(auto& it : new_attrs) {
+ attrs[it.first] = it.second;
+ }
+ return 0;
+ }
virtual int try_refresh_info(const DoutPrefixProvider* dpp, ceph::real_time* pmtime) = 0;
virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
bool* is_truncated, RGWUsageIter& usage_iter,
return ret;
}
- int DBBucket::put_instance_info(const DoutPrefixProvider *dpp, bool exclusive, ceph::real_time _mtime)
+ int DBBucket::put_info(const DoutPrefixProvider *dpp, bool exclusive, ceph::real_time _mtime)
{
int ret;
return 0;
}
- int DBBucket::set_instance_attrs(const DoutPrefixProvider *dpp, Attrs& attrs, optional_yield y)
+ int DBBucket::merge_and_store_attrs(const DoutPrefixProvider *dpp, Attrs& new_attrs, optional_yield y)
{
int ret = 0;
+ Bucket::merge_and_store_attrs(dpp, new_attrs, y);
+
/* XXX: handle has_instance_obj like in set_bucket_instance_attrs() */
- ret = store->getDB()->update_bucket(dpp, "attrs", info, false, nullptr, &attrs, nullptr, &get_info().objv_tracker);
+ ret = store->getDB()->update_bucket(dpp, "attrs", info, false, nullptr, &new_attrs, nullptr, &get_info().objv_tracker);
return ret;
}
virtual int update_container_stats(const DoutPrefixProvider *dpp) override;
virtual int check_bucket_shards(const DoutPrefixProvider *dpp) override;
virtual int chown(const DoutPrefixProvider *dpp, User* new_user, User* 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 put_info(const DoutPrefixProvider *dpp, bool exclusive, ceph::real_time mtime) override;
virtual int remove_metadata(const DoutPrefixProvider* dpp, RGWObjVersionTracker* objv, optional_yield y) override;
virtual bool is_owner(User* user) override;
virtual int check_empty(const DoutPrefixProvider *dpp, optional_yield y) override;
virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) override;
- virtual int set_instance_attrs(const DoutPrefixProvider *dpp, Attrs& attrs, optional_yield y) override;
+ virtual int merge_and_store_attrs(const DoutPrefixProvider *dpp, Attrs& attrs, optional_yield y) override;
virtual int try_refresh_info(const DoutPrefixProvider *dpp, ceph::real_time *pmtime) override;
virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
bool *is_truncated, RGWUsageIter& usage_iter,
old_user->get_display_name(), *marker, y, dpp);
}
-int RadosBucket::put_instance_info(const DoutPrefixProvider* dpp, bool exclusive, ceph::real_time _mtime)
+int RadosBucket::put_info(const DoutPrefixProvider* dpp, bool exclusive, ceph::real_time _mtime)
{
mtime = _mtime;
return store->getRados()->put_bucket_instance_info(info, exclusive, mtime, &attrs, dpp);
user_quota, bucket_quota, obj_size, y, check_size_only);
}
-int RadosBucket::set_instance_attrs(const DoutPrefixProvider* dpp, Attrs& attrs, optional_yield y)
+int RadosBucket::merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new_attrs, optional_yield y)
{
- return store->ctl()->bucket->set_bucket_instance_attrs(get_info(),
- attrs, &get_info().objv_tracker, y, dpp);
+ Bucket::merge_and_store_attrs(dpp, new_attrs, y);
+ return store->ctl()->bucket->set_bucket_instance_attrs(get_info(),
+ new_attrs, &get_info().objv_tracker, y, dpp);
}
int RadosBucket::try_refresh_info(const DoutPrefixProvider* dpp, ceph::real_time* pmtime)
virtual int update_container_stats(const DoutPrefixProvider* dpp) override;
virtual int check_bucket_shards(const DoutPrefixProvider* dpp) override;
virtual int chown(const DoutPrefixProvider* dpp, User* new_user, User* 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 put_info(const DoutPrefixProvider* dpp, bool exclusive, ceph::real_time mtime) override;
virtual int remove_metadata(const DoutPrefixProvider* dpp, RGWObjVersionTracker* objv, optional_yield y) override;
virtual bool is_owner(User* user) override;
virtual int check_empty(const DoutPrefixProvider* dpp, optional_yield y) override;
virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) override;
- virtual int set_instance_attrs(const DoutPrefixProvider* dpp, Attrs& attrs, optional_yield y) override;
+ virtual int merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& attrs, optional_yield y) override;
virtual int try_refresh_info(const DoutPrefixProvider* dpp, ceph::real_time* pmtime) override;
virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
bool* is_truncated, RGWUsageIter& usage_iter,