Skip to content

Commit

Permalink
Merge pull request ceph#1105 from ceph/wip-7168
Browse files Browse the repository at this point in the history
Reviewed-by: Josh Durgin <[email protected]>
  • Loading branch information
jdurgin committed Jan 28, 2014
2 parents 120b3fb + 86c1548 commit b135128
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/rgw/rgw_rados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,9 @@ int RGWRados::put_obj_meta_impl(void *ctx, rgw_obj& obj, uint64_t size,
return r;

r = io_ctx.operate(oid, &op);
if (r < 0)
if (r < 0) /* we can expect to get -ECANCELED if object was replaced under,
or -ENOENT if was removed, or -EEXIST if it did not exist
before and now it does */
goto done_cancel;

if (objv_tracker) {
Expand Down Expand Up @@ -2410,11 +2412,17 @@ int RGWRados::put_obj_meta_impl(void *ctx, rgw_obj& obj, uint64_t size,
if (ret < 0) {
ldout(cct, 0) << "ERROR: complete_update_index_cancel() returned ret=" << ret << dendl;
}
/* we lost in a race, object was already overwritten, we
/* we lost in a race. There are a few options:
* - existing object was rewritten (ECANCELED)
* - non existing object was created (EEXIST)
* - object was removed (ENOENT)
* should treat it as a success
*/
if (r == -ECANCELED)
if ((r == -ECANCELED || r == -ENOENT) ||
(!(flags & PUT_OBJ_EXCL) && r == -EEXIST)) {
r = 0;
}

return r;
}

Expand Down Expand Up @@ -3519,8 +3527,12 @@ int RGWRados::prepare_atomic_for_write_impl(RGWRadosCtx *rctx, rgw_obj& obj,
}

if (reset_obj) {
op.create(false);
op.remove();
if (state->exists) {
op.create(false);
op.remove();
} else {
op.create(true);
}
}

if (ptag) {
Expand Down

0 comments on commit b135128

Please sign in to comment.