Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luminous: failed CompleteMultipartUpload request does not release lock #18430

Merged
merged 1 commit into from Oct 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 39 additions & 17 deletions src/rgw/rgw_op.cc
Expand Up @@ -5343,22 +5343,16 @@ void RGWCompleteMultipart::execute()
from deleting the parts*/
rgw_pool meta_pool;
rgw_raw_obj raw_obj;
librados::ObjectWriteOperation op;
librados::IoCtx ioctx;
rados::cls::lock::Lock l("RGWCompleteMultipart");
int max_lock_secs_mp = s->cct->_conf->get_val<int64_t>("rgw_mp_lock_max_time");
int max_lock_secs_mp =
s->cct->_conf->get_val<int64_t>("rgw_mp_lock_max_time");
utime_t dur(max_lock_secs_mp, 0);

op.assert_exists();
store->obj_to_raw((s->bucket_info).placement_rule, meta_obj, &raw_obj);
store->get_obj_data_pool((s->bucket_info).placement_rule,meta_obj,&meta_pool);
store->open_pool_ctx(meta_pool, ioctx);

const string raw_meta_oid = raw_obj.oid;
utime_t time(max_lock_secs_mp, 0);
l.set_duration(time);
l.lock_exclusive(&op);
op_ret = ioctx.operate(raw_meta_oid, &op);
store->get_obj_data_pool((s->bucket_info).placement_rule,
meta_obj,&meta_pool);
store->open_pool_ctx(meta_pool, serializer.ioctx);

op_ret = serializer.try_lock(raw_obj.oid, dur);
if (op_ret < 0) {
dout(0) << "RGWCompleteMultipart::execute() failed to acquire lock " << dendl;
op_ret = -ERR_INTERNAL_ERROR;
Expand Down Expand Up @@ -5515,13 +5509,41 @@ void RGWCompleteMultipart::execute()
// remove the upload obj
int r = store->delete_obj(*static_cast<RGWObjectCtx *>(s->obj_ctx),
s->bucket_info, meta_obj, 0);
if (r < 0) {
ldout(store->ctx(), 0) << "WARNING: failed to remove object " << meta_obj << dendl;
r = l.unlock(&ioctx, raw_meta_oid);
if (r >= 0) {
/* serializer's exclusive lock is released */
serializer.clear_locked();
} else {
ldout(store->ctx(), 0) << "WARNING: failed to remove object "
<< meta_obj << dendl;
}
}

int RGWCompleteMultipart::MPSerializer::try_lock(
const std::string& _oid,
utime_t dur)
{
oid = _oid;
op.assert_exists();
lock.set_duration(dur);
lock.lock_exclusive(&op);
int ret = ioctx.operate(oid, &op);
if (! ret) {
locked = true;
}
return ret;
}

void RGWCompleteMultipart::complete()
{
/* release exclusive lock iff not already */
if (unlikely(serializer.locked)) {
int r = serializer.unlock();
if (r < 0) {
ldout(store->ctx(), 0) << "WARNING: failed to unlock " << raw_meta_oid << dendl;
ldout(store->ctx(), 0) << "WARNING: failed to unlock "
<< serializer.oid << dendl;
}
}
send_response();
}

int RGWAbortMultipart::verify_permission()
Expand Down
24 changes: 24 additions & 0 deletions src/rgw/rgw_op.h
Expand Up @@ -42,6 +42,8 @@
#include "rgw_lc.h"
#include "rgw_torrent.h"
#include "rgw_tag.h"
#include "cls/lock/cls_lock_client.h"
#include "cls/rgw/cls_rgw_client.h"

#include "include/assert.h"

Expand Down Expand Up @@ -1594,6 +1596,27 @@ class RGWCompleteMultipart : public RGWOp {
char *data;
int len;

struct MPSerializer {
librados::IoCtx ioctx;
rados::cls::lock::Lock lock;
librados::ObjectWriteOperation op;
std::string oid;
bool locked;

MPSerializer() : lock("RGWCompleteMultipart"), locked(false)
{}

int try_lock(const std::string& oid, utime_t dur);

int unlock() {
return lock.unlock(&ioctx, oid);
}

void clear_locked() {
locked = false;
}
} serializer;

public:
RGWCompleteMultipart() {
data = NULL;
Expand All @@ -1606,6 +1629,7 @@ class RGWCompleteMultipart : public RGWOp {
int verify_permission() override;
void pre_exec() override;
void execute() override;
void complete() override;

virtual int get_params() = 0;
void send_response() override = 0;
Expand Down