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

rgw: cleanup lc continuation #14906

Merged
merged 4 commits into from
May 11, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/cls/rgw/cls_rgw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3370,7 +3370,7 @@ static int rgw_cls_lc_get_next_entry(cls_method_context_t hctx, bufferlist *in,
try {
::decode(op, in_iter);
} catch (buffer::error& err) {
CLS_LOG(1, "ERROR: rgw_cls_lc_rm_entry(): failed to decode entry\n");
CLS_LOG(1, "ERROR: rgw_cls_lc_get_next_entry: failed to decode op\n");
return -EINVAL;
}

Expand Down Expand Up @@ -3403,10 +3403,11 @@ static int rgw_cls_lc_list_entries(cls_method_context_t hctx, bufferlist *in, bu
try {
::decode(op, in_iter);
} catch (buffer::error& err) {
CLS_LOG(1, "ERROR: rgw_cls_lc_rm_entry(): failed to decode entry\n");
CLS_LOG(1, "ERROR: rgw_cls_lc_list_entries(): failed to decode op\n");
return -EINVAL;
}
cls_rgw_lc_list_entries_ret op_ret;

cls_rgw_lc_list_entries_ret op_ret;
bufferlist::iterator iter;
map<string, bufferlist> vals;
string filter_prefix;
Expand Down Expand Up @@ -3437,7 +3438,7 @@ static int rgw_cls_lc_put_head(cls_method_context_t hctx, bufferlist *in, buffer
try {
::decode(op, in_iter);
} catch (buffer::error& err) {
CLS_LOG(1, "ERROR: rgw_cls_lc_set_entry(): failed to decode entry\n");
CLS_LOG(1, "ERROR: rgw_cls_lc_put_head(): failed to decode entry\n");
return -EINVAL;
}

Expand Down
26 changes: 6 additions & 20 deletions src/rgw/rgw_lc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#include <iostream>
#include <map>

#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string.hpp>

#include "common/Formatter.h"
#include <common/errno.h>
#include "auth/Crypto.h"
#include "cls/rgw/cls_rgw_client.h"
#include "cls/refcount/cls_refcount_client.h"
#include "cls/lock/cls_lock_client.h"
#include "rgw_common.h"
#include "rgw_bucket.h"
Expand Down Expand Up @@ -198,21 +200,6 @@ bool RGWLC::if_already_run_today(time_t& start_date)
return false;
}

static std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
std::stringstream ss(s);
std::string item;
while (std::getline(ss, item, delim)) {
elems.push_back(item);
}
return elems;
}

static std::vector<std::string> split(const std::string &s, char delim) {
std::vector<std::string> elems;
split(s, delim, elems);
return elems;
}

int RGWLC::bucket_lc_prepare(int index)
{
map<string, int > entries;
Expand Down Expand Up @@ -324,7 +311,7 @@ int RGWLC::bucket_lc_process(string& shard_id)
vector<rgw_bucket_dir_entry> objs;
RGWObjectCtx obj_ctx(store);
vector<std::string> result;
result = split(shard_id, ':');
boost::split(result, shard_id, boost::is_any_of(":"));
string bucket_tenant = result[0];
string bucket_name = result[1];
string bucket_id = result[2];
Expand Down Expand Up @@ -496,8 +483,7 @@ int RGWLC::bucket_lc_process(string& shard_id)
return ret;
}

int RGWLC::bucket_lc_post(int index, int max_lock_sec, cls_rgw_lc_obj_head& head,
pair<string, int >& entry, int& result)
int RGWLC::bucket_lc_post(int index, int max_lock_sec, pair<string, int >& entry, int& result)
{
utime_t lock_duration(cct->_conf->rgw_lc_lock_max_time, 0);

Expand Down Expand Up @@ -637,7 +623,7 @@ int RGWLC::process(int index, int max_lock_secs)
}
l.unlock(&store->lc_pool_ctx, obj_names[index]);
ret = bucket_lc_process(entry.first);
ret = bucket_lc_post(index, max_lock_secs, head, entry, ret);
bucket_lc_post(index, max_lock_secs, entry, ret);
return 0;
exit:
l.unlock(&store->lc_pool_ctx, obj_names[index]);
Expand Down
3 changes: 1 addition & 2 deletions src/rgw/rgw_lc.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ class RGWLC {
int list_lc_progress(const string& marker, uint32_t max_entries, map<string, int> *progress_map);
int bucket_lc_prepare(int index);
int bucket_lc_process(string& shard_id);
int bucket_lc_post(int index, int max_lock_sec, cls_rgw_lc_obj_head& head,
pair<string, int >& entry, int& result);
int bucket_lc_post(int index, int max_lock_sec, pair<string, int >& entry, int& result);
bool going_down();
void start_processor();
void stop_processor();
Expand Down