entry.name = op.name;
entry.epoch = 0;
entry.exists = false;
+ entry.locator = op.locator;
}
// fill in proper state
entry.name = op.name;
entry.epoch = op.epoch;
entry.meta = op.meta;
+ entry.locator = op.locator;
ondisk = false;
}
} else {
struct rgw_bucket_dir_entry {
std::string name;
uint64_t epoch;
+ std::string locator;
bool exists;
struct rgw_bucket_dir_entry_meta meta;
map<string, struct rgw_bucket_pending_info> pending_map;
epoch(0), exists(false) {}
void encode(bufferlist &bl) const {
- __u8 struct_v = 1;
+ __u8 struct_v = 2;
+ if (!locator.size()) {
+ struct_v = 1; // don't waste space encoding it
+ }
::encode(struct_v, bl);
::encode(name, bl);
::encode(epoch, bl);
::encode(exists, bl);
::encode(meta, bl);
::encode(pending_map, bl);
+ if (locator.size()) {
+ ::encode(locator, bl);
+ }
}
void decode(bufferlist::iterator &bl) {
__u8 struct_v;
::decode(exists, bl);
::decode(meta, bl);
::decode(pending_map, bl);
+ if (struct_v >= 2) {
+ ::decode(locator, bl);
+ }
}
};
WRITE_CLASS_ENCODER(rgw_bucket_dir_entry)
uint8_t op;
string name;
string tag;
+ string locator;
void encode(bufferlist &bl) const {
- __u8 struct_v = 1;
+ __u8 struct_v = 2;
+ if (!locator.size()) {
+ struct_v = 1; // don't waste the encoding space
+ }
::encode(struct_v, bl);
::encode(op, bl);
::encode(name, bl);
::encode(tag, bl);
+ if (locator.size()) {
+ ::encode(locator, bl);
+ }
}
void decode(bufferlist::iterator &bl) {
__u8 struct_v;
::decode(op, bl);
::decode(name, bl);
::decode(tag, bl);
+ if (struct_v >= 2) {
+ ::decode(locator, bl);
+ }
}
};
WRITE_CLASS_ENCODER(rgw_cls_obj_prepare_op)
{
uint8_t op;
string name;
+ string locator;
uint64_t epoch;
struct rgw_bucket_dir_entry_meta meta;
string tag;
void encode(bufferlist &bl) const {
- __u8 struct_v = 1;
+ __u8 struct_v = 2;
+ if (!locator.size()) {
+ struct_v = 1; // don't waste the encoding space
+ }
::encode(struct_v, bl);
::encode(op, bl);
::encode(name, bl);
::encode(epoch, bl);
::encode(meta, bl);
::encode(tag, bl);
- }
+ if (locator.size()) {
+ ::encode(locator, bl);
+ }
+ }
void decode(bufferlist::iterator &bl) {
__u8 struct_v;
::decode(struct_v, bl);
::decode(epoch, bl);
::decode(meta, bl);
::decode(tag, bl);
+ if (struct_v >= 2) {
+ ::decode(locator, bl);
+ }
}
};
WRITE_CLASS_ENCODER(rgw_cls_obj_complete_op)
return 0;
string tag;
- r = prepare_update_index(NULL, bucket, obj.object, tag);
+ r = prepare_update_index(NULL, bucket, obj, tag);
if (r < 0)
return r;
string tag;
op.remove();
if (sync) {
- r = prepare_update_index(state, bucket, obj.object, tag);
+ r = prepare_update_index(state, bucket, obj, tag);
if (r < 0)
return r;
r = io_ctx.operate(oid, &op);
return r;
}
-int RGWRados::prepare_update_index(RGWObjState *state, rgw_bucket& bucket, string& oid, string& tag)
+int RGWRados::prepare_update_index(RGWObjState *state, rgw_bucket& bucket,
+ rgw_obj& obj, string& tag)
{
if (state && state->obj_tag.length()) {
int len = state->obj_tag.length();
} else {
append_rand_alpha(tag, tag, 32);
}
- int ret = cls_obj_prepare_op(bucket, CLS_RGW_OP_ADD, tag, oid);
+ int ret = cls_obj_prepare_op(bucket, CLS_RGW_OP_ADD, tag,
+ obj.object, obj.key);
return ret;
}
string tag;
uint64_t epoch = 0;
- int ret = prepare_update_index(state, bucket, dst_obj.object, tag);
+ int ret = prepare_update_index(state, bucket, dst_obj, tag);
if (ret < 0)
goto done;
return r;
}
-int RGWRados::cls_obj_prepare_op(rgw_bucket& bucket, uint8_t op, string& tag, string& name)
+int RGWRados::cls_obj_prepare_op(rgw_bucket& bucket, uint8_t op, string& tag,
+ string& name, string& locator)
{
if (bucket.marker.empty()) {
if (bucket.name[0] == '.')
call.op = op;
call.tag = tag;
call.name = name;
+ call.locator = locator;
::encode(call, in);
r = io_ctx.exec(oid, "rgw", "bucket_prepare_op", in, out);
return r;
virtual int get_bucket_info(string& bucket_name, RGWBucketInfo& info);
int cls_rgw_init_index(rgw_bucket& bucket, string& oid);
- int cls_obj_prepare_op(rgw_bucket& bucket, uint8_t op, string& tag, string& name);
+ int cls_obj_prepare_op(rgw_bucket& bucket, uint8_t op, string& tag,
+ string& name, string& locator);
int cls_obj_complete_op(rgw_bucket& bucket, uint8_t op, string& tag, uint64_t epoch,
RGWObjEnt& ent, RGWObjCategory category);
int cls_obj_complete_add(rgw_bucket& bucket, string& tag, uint64_t epoch, RGWObjEnt& ent, RGWObjCategory category);
map<string, RGWObjEnt>& m, bool *is_truncated,
string *last_entry = NULL);
int cls_bucket_head(rgw_bucket& bucket, struct rgw_bucket_dir_header& header);
- int prepare_update_index(RGWObjState *state, rgw_bucket& bucket, string& oid, string& tag);
+ int prepare_update_index(RGWObjState *state, rgw_bucket& bucket,
+ rgw_obj& oid, string& tag);
int complete_update_index(rgw_bucket& bucket, string& oid, string& tag, uint64_t epoch, uint64_t size,
utime_t& ut, string& etag, bufferlist *acl_bl, RGWObjCategory category);
int complete_update_index_del(rgw_bucket& bucket, string& oid, string& tag, uint64_t epoch) {