Skip to content

Commit

Permalink
Merge pull request #14906 from mikulely/lc-cleanup-2
Browse files Browse the repository at this point in the history
rgw: cleanup lc continuation

Reviewed-by: Daniel Gryniewicz <dang@redhat.com>
  • Loading branch information
cbodley committed May 11, 2017
2 parents 84fb0cd + 0211d1a commit 9fbea01
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 26 deletions.
9 changes: 5 additions & 4 deletions src/cls/rgw/cls_rgw.cc
Expand Up @@ -3373,7 +3373,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 @@ -3406,10 +3406,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 @@ -3440,7 +3441,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
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
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

0 comments on commit 9fbea01

Please sign in to comment.