mirror of
https://github.com/ceph/ceph
synced 2025-01-02 17:12:31 +00:00
rgw: keep objv_tracker on bucket info
This ties it to the specific object instance info. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
parent
e053d1718d
commit
dab57ef883
@ -495,7 +495,7 @@ int bucket_stats(rgw_bucket& bucket, Formatter *formatter)
|
||||
{
|
||||
RGWBucketInfo bucket_info;
|
||||
time_t mtime;
|
||||
int r = store->get_bucket_info(NULL, bucket.name, bucket_info, NULL, &mtime);
|
||||
int r = store->get_bucket_info(NULL, bucket.name, bucket_info, &mtime);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -536,7 +536,7 @@ static int init_bucket(string& bucket_name, rgw_bucket& bucket)
|
||||
{
|
||||
if (!bucket_name.empty()) {
|
||||
RGWBucketInfo bucket_info;
|
||||
int r = store->get_bucket_info(NULL, bucket_name, bucket_info, NULL, NULL);
|
||||
int r = store->get_bucket_info(NULL, bucket_name, bucket_info, NULL);
|
||||
if (r < 0) {
|
||||
cerr << "could not get bucket info for bucket=" << bucket_name << std::endl;
|
||||
return r;
|
||||
|
@ -231,9 +231,8 @@ void check_bad_user_bucket_mapping(RGWRados *store, const string& user_id, bool
|
||||
rgw_bucket& bucket = bucket_ent.bucket;
|
||||
|
||||
RGWBucketInfo bucket_info;
|
||||
RGWObjVersionTracker objv_tracker;
|
||||
time_t mtime;
|
||||
int r = store->get_bucket_info(NULL, bucket.name, bucket_info, &objv_tracker, &mtime);
|
||||
int r = store->get_bucket_info(NULL, bucket.name, bucket_info, &mtime);
|
||||
if (r < 0) {
|
||||
ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket << dendl;
|
||||
continue;
|
||||
@ -376,8 +375,7 @@ int RGWBucket::init(RGWRados *storage, RGWBucketAdminOpState& op_state)
|
||||
return -EINVAL;
|
||||
|
||||
if (!bucket_name.empty()) {
|
||||
RGWObjVersionTracker objv_tracker;
|
||||
int r = store->get_bucket_info(NULL, bucket_name, bucket_info, &objv_tracker, NULL);
|
||||
int r = store->get_bucket_info(NULL, bucket_name, bucket_info, NULL);
|
||||
if (r < 0) {
|
||||
ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket_name << dendl;
|
||||
return r;
|
||||
@ -866,9 +864,8 @@ static int bucket_stats(RGWRados *store, std::string& bucket_name, Formatter *f
|
||||
rgw_bucket bucket;
|
||||
map<RGWObjCategory, RGWBucketStats> stats;
|
||||
|
||||
RGWObjVersionTracker objv_tracker;
|
||||
time_t mtime;
|
||||
int r = store->get_bucket_info(NULL, bucket_name, bucket_info, &objv_tracker, &mtime);
|
||||
int r = store->get_bucket_info(NULL, bucket_name, bucket_info, &mtime);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -1310,7 +1307,7 @@ class RGWBucketMetadataHandler : public RGWMetadataHandler {
|
||||
|
||||
int init_bucket(RGWRados *store, string& bucket_name, rgw_bucket& bucket, RGWObjVersionTracker *objv_tracker) {
|
||||
RGWBucketInfo bucket_info;
|
||||
int r = store->get_bucket_info(NULL, bucket_name, bucket_info, objv_tracker, NULL);
|
||||
int r = store->get_bucket_info(NULL, bucket_name, bucket_info, NULL);
|
||||
if (r < 0) {
|
||||
cerr << "could not get bucket info for bucket=" << bucket_name << std::endl;
|
||||
return r;
|
||||
@ -1326,14 +1323,13 @@ public:
|
||||
int get(RGWRados *store, string& entry, RGWMetadataObject **obj) {
|
||||
RGWBucketCompleteInfo bci;
|
||||
|
||||
RGWObjVersionTracker objv_tracker;
|
||||
time_t mtime;
|
||||
|
||||
int ret = store->get_bucket_info(NULL, entry, bci.info, &objv_tracker, &mtime, &bci.attrs);
|
||||
int ret = store->get_bucket_info(NULL, entry, bci.info, &mtime, &bci.attrs);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
RGWBucketMetadataObject *mdo = new RGWBucketMetadataObject(bci, objv_tracker.read_version, mtime);
|
||||
RGWBucketMetadataObject *mdo = new RGWBucketMetadataObject(bci, bci.info.objv_tracker.read_version, mtime);
|
||||
|
||||
*obj = mdo;
|
||||
|
||||
@ -1346,7 +1342,9 @@ public:
|
||||
|
||||
time_t orig_mtime;
|
||||
|
||||
int ret = store->get_bucket_info(NULL, entry, old_bci.info, &objv_tracker, &orig_mtime, &old_bci.attrs);
|
||||
old_bci.info.objv_tracker = objv_tracker;
|
||||
|
||||
int ret = store->get_bucket_info(NULL, entry, old_bci.info, &orig_mtime, &old_bci.attrs);
|
||||
if (ret < 0 && ret != -ENOENT)
|
||||
return ret;
|
||||
|
||||
@ -1364,13 +1362,16 @@ public:
|
||||
/* existing bucket, keep its placement pools */
|
||||
bci.info.bucket.data_pool = old_bci.info.bucket.data_pool;
|
||||
bci.info.bucket.index_pool = old_bci.info.bucket.index_pool;
|
||||
bci.info.objv_tracker = old_bci.info.objv_tracker;
|
||||
}
|
||||
|
||||
#warning need to take care of different routes here
|
||||
ret = store->put_bucket_info(entry, bci.info, false, &objv_tracker, mtime, &bci.attrs, false);
|
||||
ret = store->put_bucket_info(entry, bci.info, false, &bci.info.objv_tracker, mtime, &bci.attrs, false);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
objv_tracker = bci.info.objv_tracker;
|
||||
|
||||
ret = store->init_bucket_index(bci.info.bucket);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
@ -595,6 +595,39 @@ inline ostream& operator<<(ostream& out, const rgw_bucket &b) {
|
||||
return out;
|
||||
}
|
||||
|
||||
struct RGWObjVersionTracker {
|
||||
obj_version read_version;
|
||||
obj_version write_version;
|
||||
|
||||
obj_version *version_for_read() {
|
||||
return &read_version;
|
||||
}
|
||||
|
||||
obj_version *version_for_write() {
|
||||
if (write_version.ver == 0)
|
||||
return NULL;
|
||||
|
||||
return &write_version;
|
||||
}
|
||||
|
||||
obj_version *version_for_check() {
|
||||
if (read_version.ver == 0)
|
||||
return NULL;
|
||||
|
||||
return &read_version;
|
||||
}
|
||||
|
||||
void prepare_op_for_read(librados::ObjectReadOperation *op);
|
||||
void prepare_op_for_write(librados::ObjectWriteOperation *op);
|
||||
|
||||
void apply_write() {
|
||||
read_version = write_version;
|
||||
write_version = obj_version();
|
||||
}
|
||||
|
||||
void generate_new_write_ver(CephContext *cct);
|
||||
};
|
||||
|
||||
enum RGWBucketFlags {
|
||||
BUCKET_SUSPENDED = 0x1,
|
||||
};
|
||||
@ -608,6 +641,7 @@ struct RGWBucketInfo
|
||||
time_t creation_time;
|
||||
string placement_rule;
|
||||
bool has_instance_obj;
|
||||
RGWObjVersionTracker objv_tracker; /* we don't need to serialize this, for runtime tracking */
|
||||
|
||||
void encode(bufferlist& bl) const {
|
||||
ENCODE_START(8, 4, bl);
|
||||
@ -690,39 +724,6 @@ struct RGWEnv;
|
||||
|
||||
class RGWClientIO;
|
||||
|
||||
struct RGWObjVersionTracker {
|
||||
obj_version read_version;
|
||||
obj_version write_version;
|
||||
|
||||
obj_version *version_for_read() {
|
||||
return &read_version;
|
||||
}
|
||||
|
||||
obj_version *version_for_write() {
|
||||
if (write_version.ver == 0)
|
||||
return NULL;
|
||||
|
||||
return &write_version;
|
||||
}
|
||||
|
||||
obj_version *version_for_check() {
|
||||
if (read_version.ver == 0)
|
||||
return NULL;
|
||||
|
||||
return &read_version;
|
||||
}
|
||||
|
||||
void prepare_op_for_read(librados::ObjectReadOperation *op);
|
||||
void prepare_op_for_write(librados::ObjectWriteOperation *op);
|
||||
|
||||
void apply_write() {
|
||||
read_version = write_version;
|
||||
write_version = obj_version();
|
||||
}
|
||||
|
||||
void generate_new_write_ver(CephContext *cct);
|
||||
};
|
||||
|
||||
struct req_info {
|
||||
RGWEnv *env;
|
||||
XMLArgs args;
|
||||
|
@ -332,7 +332,7 @@ static int rgw_build_policies(RGWRados *store, struct req_state *s, bool only_bu
|
||||
|
||||
RGWBucketInfo source_info;
|
||||
|
||||
ret = store->get_bucket_info(s->obj_ctx, copy_source_str, source_info, NULL, NULL);
|
||||
ret = store->get_bucket_info(s->obj_ctx, copy_source_str, source_info, NULL);
|
||||
if (ret == 0) {
|
||||
string& region = source_info.region;
|
||||
s->local_source = (region.empty() && store->region.is_master) ||
|
||||
@ -342,7 +342,7 @@ static int rgw_build_policies(RGWRados *store, struct req_state *s, bool only_bu
|
||||
|
||||
if (s->bucket_name_str.size()) {
|
||||
s->bucket_exists = true;
|
||||
ret = store->get_bucket_info(s->obj_ctx, s->bucket_name_str, s->bucket_info, &s->objv_tracker, NULL, &s->bucket_attrs);
|
||||
ret = store->get_bucket_info(s->obj_ctx, s->bucket_name_str, s->bucket_info, NULL, &s->bucket_attrs);
|
||||
if (ret < 0) {
|
||||
if (ret != -ENOENT) {
|
||||
ldout(s->cct, 0) << "NOTICE: couldn't get bucket from bucket_name (name=" << s->bucket_name_str << ")" << dendl;
|
||||
@ -561,7 +561,7 @@ int RGWGetObj::handle_user_manifest(const char *prefix)
|
||||
if (bucket_name.compare(s->bucket.name) != 0) {
|
||||
RGWBucketInfo bucket_info;
|
||||
map<string, bufferlist> bucket_attrs;
|
||||
int r = store->get_bucket_info(NULL, bucket_name, bucket_info, &s->objv_tracker, NULL, &bucket_attrs);
|
||||
int r = store->get_bucket_info(NULL, bucket_name, bucket_info, NULL, &bucket_attrs);
|
||||
if (r < 0) {
|
||||
ldout(s->cct, 0) << "could not get bucket info for bucket=" << bucket_name << dendl;
|
||||
return r;
|
||||
@ -1515,7 +1515,7 @@ int RGWCopyObj::verify_permission()
|
||||
|
||||
map<string, bufferlist> src_attrs;
|
||||
|
||||
ret = store->get_bucket_info(s->obj_ctx, src_bucket_name, src_bucket_info, NULL, NULL, &src_attrs);
|
||||
ret = store->get_bucket_info(s->obj_ctx, src_bucket_name, src_bucket_info, NULL, &src_attrs);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@ -1543,7 +1543,7 @@ int RGWCopyObj::verify_permission()
|
||||
if (src_bucket_name.compare(dest_bucket_name) == 0) { /* will only happen if s->local_source */
|
||||
dest_bucket_info = src_bucket_info;
|
||||
} else {
|
||||
ret = store->get_bucket_info(s->obj_ctx, dest_bucket_name, dest_bucket_info, NULL, NULL, &dest_attrs);
|
||||
ret = store->get_bucket_info(s->obj_ctx, dest_bucket_name, dest_bucket_info, NULL, &dest_attrs);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
@ -1814,8 +1814,7 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
|
||||
|
||||
index_ctx.remove(dir_oid);
|
||||
/* we need to updated objv_tracker, but we don't want the old cruft there */
|
||||
objv_tracker = RGWObjVersionTracker();
|
||||
r = get_bucket_info(NULL, bucket.name, info, &objv_tracker, NULL);
|
||||
r = get_bucket_info(NULL, bucket.name, info, NULL);
|
||||
if (r < 0) {
|
||||
if (r == -ENOENT) {
|
||||
continue;
|
||||
@ -2830,8 +2829,7 @@ int RGWRados::set_bucket_owner(rgw_bucket& bucket, ACLOwner& owner)
|
||||
{
|
||||
RGWBucketInfo info;
|
||||
map<string, bufferlist> attrs;
|
||||
RGWObjVersionTracker objv_tracker;
|
||||
int r = get_bucket_info(NULL, bucket.name, info, &objv_tracker, NULL, &attrs);
|
||||
int r = get_bucket_info(NULL, bucket.name, info, NULL, &attrs);
|
||||
if (r < 0) {
|
||||
ldout(cct, 0) << "NOTICE: get_bucket_info on bucket=" << bucket.name << " returned err=" << r << dendl;
|
||||
return r;
|
||||
@ -2839,7 +2837,7 @@ int RGWRados::set_bucket_owner(rgw_bucket& bucket, ACLOwner& owner)
|
||||
|
||||
info.owner = owner.get_id();
|
||||
|
||||
r = put_bucket_info(bucket.name, info, false, &objv_tracker, 0, &attrs, false);
|
||||
r = put_bucket_info(bucket.name, info, false, &info.objv_tracker, 0, &attrs, false);
|
||||
if (r < 0) {
|
||||
ldout(cct, 0) << "NOTICE: put_bucket_info on bucket=" << bucket.name << " returned err=" << r << dendl;
|
||||
return r;
|
||||
@ -2863,9 +2861,8 @@ int RGWRados::set_buckets_enabled(vector<rgw_bucket>& buckets, bool enabled)
|
||||
ldout(cct, 20) << "disabling bucket name=" << bucket.name << dendl;
|
||||
|
||||
RGWBucketInfo info;
|
||||
RGWObjVersionTracker objv_tracker;
|
||||
map<string, bufferlist> attrs;
|
||||
int r = get_bucket_info(NULL, bucket.name, info, &objv_tracker, NULL, &attrs);
|
||||
int r = get_bucket_info(NULL, bucket.name, info, NULL, &attrs);
|
||||
if (r < 0) {
|
||||
ldout(cct, 0) << "NOTICE: get_bucket_info on bucket=" << bucket.name << " returned err=" << r << ", skipping bucket" << dendl;
|
||||
ret = r;
|
||||
@ -2877,7 +2874,7 @@ int RGWRados::set_buckets_enabled(vector<rgw_bucket>& buckets, bool enabled)
|
||||
info.flags |= BUCKET_SUSPENDED;
|
||||
}
|
||||
|
||||
r = put_bucket_info(bucket.name, info, false, &objv_tracker, 0, &attrs, false);
|
||||
r = put_bucket_info(bucket.name, info, false, &info.objv_tracker, 0, &attrs, false);
|
||||
if (r < 0) {
|
||||
ldout(cct, 0) << "NOTICE: put_bucket_info on bucket=" << bucket.name << " returned err=" << r << ", skipping bucket" << dendl;
|
||||
ret = r;
|
||||
@ -2890,7 +2887,7 @@ int RGWRados::set_buckets_enabled(vector<rgw_bucket>& buckets, bool enabled)
|
||||
int RGWRados::bucket_suspended(rgw_bucket& bucket, bool *suspended)
|
||||
{
|
||||
RGWBucketInfo bucket_info;
|
||||
int ret = get_bucket_info(NULL, bucket.name, bucket_info, NULL, NULL);
|
||||
int ret = get_bucket_info(NULL, bucket.name, bucket_info, NULL);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -4469,7 +4466,7 @@ void RGWRados::get_bucket_meta_oid(rgw_bucket& bucket, string& oid)
|
||||
oid = ".bucket.meta." + bucket.bucket_id;
|
||||
}
|
||||
|
||||
int RGWRados::get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& info, RGWObjVersionTracker *objv_tracker,
|
||||
int RGWRados::get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& info,
|
||||
time_t *pmtime, map<string, bufferlist> *pattrs)
|
||||
{
|
||||
bufferlist bl;
|
||||
@ -4510,7 +4507,7 @@ int RGWRados::get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& inf
|
||||
|
||||
bufferlist epbl;
|
||||
|
||||
ret = rgw_get_system_obj(this, ctx, zone.domain_root, oid, epbl, objv_tracker, pmtime, pattrs);
|
||||
ret = rgw_get_system_obj(this, ctx, zone.domain_root, oid, epbl, &info.objv_tracker, pmtime, pattrs);
|
||||
if (ret < 0) {
|
||||
info.bucket.name = bucket_name; /* only init this field */
|
||||
return ret;
|
||||
|
@ -1269,7 +1269,7 @@ public:
|
||||
int decode_policy(bufferlist& bl, ACLOwner *owner);
|
||||
int get_bucket_stats(rgw_bucket& bucket, uint64_t *bucket_ver, uint64_t *master_ver, map<RGWObjCategory, RGWBucketStats>& stats);
|
||||
void get_bucket_meta_oid(rgw_bucket& bucket, string& oid);
|
||||
virtual int get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& info, RGWObjVersionTracker *objv_tracker,
|
||||
virtual int get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& info,
|
||||
time_t *pmtime, map<string, bufferlist> *pattrs = NULL);
|
||||
virtual int put_bucket_info(string& bucket_name, RGWBucketInfo& info, bool exclusive, RGWObjVersionTracker *objv_tracker,
|
||||
time_t mtime, map<string, bufferlist> *pattrs, bool create_entry_point);
|
||||
|
Loading…
Reference in New Issue
Block a user