Skip to content

Commit

Permalink
rgw: fix ECANCELED handling in rgw_get_system_obj()
Browse files Browse the repository at this point in the history
Fixes: http://tracker.ceph.com/issues/17996

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
  • Loading branch information
yehudasa committed Mar 31, 2017
1 parent 5233aa0 commit d3d64ed
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cls/version/cls_version_types.h
Expand Up @@ -31,6 +31,11 @@ struct obj_version {
ver++;
}

void clear() {
ver = 0;
tag.clear();
}

bool empty() {
return tag.empty();
}
Expand Down
5 changes: 5 additions & 0 deletions src/rgw/rgw_rados.cc
Expand Up @@ -8793,6 +8793,11 @@ void RGWRados::Object::invalidate_state()
ctx.invalidate(obj);
}

void RGWRados::SystemObject::invalidate_state()
{
ctx.invalidate(obj);
}

int RGWRados::Object::prepare_atomic_modification(ObjectWriteOperation& op, bool reset_obj, const string *ptag,
const char *if_match, const char *if_nomatch, bool removal_op)
{
Expand Down
2 changes: 2 additions & 0 deletions src/rgw/rgw_rados.h
Expand Up @@ -2278,6 +2278,8 @@ class RGWRados
public:
SystemObject(RGWRados *_store, RGWObjectCtx& _ctx, rgw_obj& _obj) : store(_store), ctx(_ctx), obj(_obj), state(NULL) {}

void invalidate_state();

RGWRados *get_store() { return store; }
rgw_obj& get_obj() { return obj; }
RGWObjectCtx& get_ctx() { return ctx; }
Expand Down
13 changes: 13 additions & 0 deletions src/rgw/rgw_tools.cc
Expand Up @@ -47,6 +47,11 @@ int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_bucket& bu
int request_len = READ_CHUNK_LEN;
rgw_obj obj(bucket, key);

obj_version original_readv;
if (objv_tracker && !objv_tracker->read_version.empty()) {
original_readv = objv_tracker->read_version;
}

do {
RGWRados::SystemObject source(rgwstore, obj_ctx, obj);
RGWRados::SystemObject::Read rop(&source);
Expand All @@ -64,6 +69,14 @@ int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_bucket& bu
ret = rop.read(0, request_len - 1, bl, objv_tracker);
if (ret == -ECANCELED) {
/* raced, restart */
if (!original_readv.empty()) {
/* we were asked to read a specific obj_version, failed */
return ret;
}
if (objv_tracker) {
objv_tracker->read_version.clear();
}
source.invalidate_state();
continue;
}
if (ret < 0)
Expand Down

0 comments on commit d3d64ed

Please sign in to comment.