mirror of
https://github.com/ceph/ceph
synced 2025-01-19 09:32:00 +00:00
rgw: obj_stat() returns object version (epoch), use it
We now pass the object version returned by obj_stat. We use that epoch for setting the object version through the index suggestion mechanism. This was broken by a recent change that switched from reading the obj stats by (wrongly) calling directly to ioctx->stat() to calling get_obj_state(). Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
parent
15e97d7307
commit
08e9fc02fe
@ -1215,7 +1215,7 @@ int RGWRados::copy_obj(void *ctx,
|
||||
|
||||
ret = rgwstore->put_obj_meta(ctx, dest_obj, end + 1, NULL, attrset, category, false, NULL, &first_chunk, &manifest);
|
||||
if (mtime)
|
||||
obj_stat(ctx, dest_obj, NULL, mtime, NULL, NULL);
|
||||
obj_stat(ctx, dest_obj, NULL, mtime, NULL, NULL, NULL);
|
||||
|
||||
finish_get_obj(&handle);
|
||||
|
||||
@ -1504,7 +1504,7 @@ int RGWRados::get_obj_state(RGWRadosCtx *rctx, rgw_obj& obj, RGWObjState **state
|
||||
if (s->has_attrs)
|
||||
return 0;
|
||||
|
||||
int r = obj_stat(rctx, obj, &s->size, &s->mtime, &s->attrset, (s->prefetch_data ? &s->data : NULL));
|
||||
int r = obj_stat(rctx, obj, &s->size, &s->mtime, &s->epoch, &s->attrset, (s->prefetch_data ? &s->data : NULL));
|
||||
if (r == -ENOENT) {
|
||||
s->exists = false;
|
||||
s->has_attrs = true;
|
||||
@ -2401,7 +2401,7 @@ int RGWRados::read(void *ctx, rgw_obj& obj, off_t ofs, size_t size, bufferlist&
|
||||
return r;
|
||||
}
|
||||
|
||||
int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, map<string, bufferlist> *attrs, bufferlist *first_chunk)
|
||||
int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, uint64_t *epoch, map<string, bufferlist> *attrs, bufferlist *first_chunk)
|
||||
{
|
||||
rgw_bucket bucket;
|
||||
std::string oid, key;
|
||||
@ -2425,6 +2425,10 @@ int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime,
|
||||
}
|
||||
bufferlist outbl;
|
||||
r = io_ctx.operate(oid, &op, &outbl);
|
||||
|
||||
if (epoch)
|
||||
*epoch = io_ctx.get_last_version();
|
||||
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -2976,9 +2980,10 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx,
|
||||
object.mtime = astate->mtime;
|
||||
|
||||
// encode suggested updates
|
||||
list_state.epoch = io_ctx.get_last_version();
|
||||
list_state.epoch = astate->epoch;
|
||||
list_state.meta.size = object.size;
|
||||
list_state.meta.mtime.set_from_double(double(object.mtime));
|
||||
list_state.meta.category = main_category;
|
||||
list_state.exists = true;
|
||||
cls_rgw_encode_suggestion(CEPH_RGW_UPDATE, list_state, suggested_updates);
|
||||
return 0;
|
||||
|
@ -119,6 +119,7 @@ struct RGWObjState {
|
||||
bool exists;
|
||||
uint64_t size;
|
||||
time_t mtime;
|
||||
uint64_t epoch;
|
||||
bufferlist obj_tag;
|
||||
bool fake_tag;
|
||||
RGWObjManifest manifest;
|
||||
@ -129,7 +130,7 @@ struct RGWObjState {
|
||||
bool prefetch_data;
|
||||
|
||||
map<string, bufferlist> attrset;
|
||||
RGWObjState() : is_atomic(false), has_attrs(0), exists(false), fake_tag(false), has_manifest(false), prefetch_data(false) {}
|
||||
RGWObjState() : is_atomic(false), has_attrs(0), exists(false), epoch(0), fake_tag(false), has_manifest(false), prefetch_data(false) {}
|
||||
|
||||
bool get_attr(string name, bufferlist& dest) {
|
||||
map<string, bufferlist>::iterator iter = attrset.find(name);
|
||||
@ -144,6 +145,7 @@ struct RGWObjState {
|
||||
has_attrs = false;
|
||||
exists = false;
|
||||
fake_tag = false;
|
||||
epoch = 0;
|
||||
size = 0;
|
||||
mtime = 0;
|
||||
obj_tag.clear();
|
||||
@ -525,7 +527,8 @@ public:
|
||||
*/
|
||||
virtual int read(void *ctx, rgw_obj& obj, off_t ofs, size_t size, bufferlist& bl);
|
||||
|
||||
virtual int obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, map<string, bufferlist> *attrs, bufferlist *first_chunk);
|
||||
virtual int obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime,
|
||||
uint64_t *epoch, map<string, bufferlist> *attrs, bufferlist *first_chunk);
|
||||
|
||||
virtual bool supports_omap() { return true; }
|
||||
virtual int omap_get_all(rgw_obj& obj, bufferlist& header, std::map<string, bufferlist>& m);
|
||||
|
Loading…
Reference in New Issue
Block a user