summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-06-18 15:13:43 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-06-18 15:13:43 -0700
commitb89f47c84f014a529b34c4f93f413ff5d538fd2c (patch)
tree07111182f80f947b2622e059a8afbdcfc7295557
parente2af5fbe2555d734311bafe724afcae9936c89c0 (diff)
downloadceph-b89f47c84f014a529b34c4f93f413ff5d538fd2c.tar.gz
cls_statelog: fix a few issues
Issues that came up when developed the unitest Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/cls/statelog/cls_statelog.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/cls/statelog/cls_statelog.cc b/src/cls/statelog/cls_statelog.cc
index 251e7c904b4..d9e57b06ff7 100644
--- a/src/cls/statelog/cls_statelog.cc
+++ b/src/cls/statelog/cls_statelog.cc
@@ -43,8 +43,8 @@ static int write_statelog_entry(cls_method_context_t hctx, const string& index,
static void get_index_by_client(const string& client_id, const string& op_id, string& index)
{
- string s = statelog_index_by_client_prefix + "_";
- s.append(client_id + "_" + op_id);
+ index = statelog_index_by_client_prefix;
+ index.append(client_id + "_" + op_id);
}
static void get_index_by_client(cls_statelog_entry& entry, string& index)
@@ -57,7 +57,7 @@ static void get_index_by_object(const string& object, const string& op_id, strin
char buf[16];
snprintf(buf, sizeof(buf), "%d_", (int)object.size());
- index = statelog_index_by_object_prefix + "_" + buf + "_"; /* append object length to ensure uniqueness */
+ index = statelog_index_by_object_prefix + buf; /* append object length to ensure uniqueness */
index.append(object + "_" + op_id);
}
@@ -163,10 +163,12 @@ static int cls_statelog_list(cls_method_context_t hctx, bufferlist *in, bufferli
string from_index;
string match_prefix;
- if (op.object.empty()) {
+ if (!op.client_id.empty()) {
get_index_by_client(op.client_id, op.op_id, match_prefix);
- } else {
+ } else if (!op.object.empty()) {
get_index_by_object(op.object, op.op_id, match_prefix);
+ } else {
+ match_prefix = statelog_index_by_object_prefix;
}
if (op.marker.empty()) {
@@ -184,6 +186,7 @@ static int cls_statelog_list(cls_method_context_t hctx, bufferlist *in, bufferli
if (rc < 0)
return rc;
+CLS_LOG(0, "%s: %d from_index=%s match_prefix=%s", __FILE__, __LINE__, from_index.c_str(), match_prefix.c_str());
cls_statelog_list_ret ret;
list<cls_statelog_entry>& entries = ret.entries;
@@ -196,6 +199,7 @@ static int cls_statelog_list(cls_method_context_t hctx, bufferlist *in, bufferli
for (i = 0; i < max_entries && iter != keys.end(); ++i, ++iter) {
const string& index = iter->first;
marker = index;
+CLS_LOG(0, "%s: %d index=%s", __FILE__, __LINE__, index.c_str());
bufferlist& bl = iter->second;
bufferlist::iterator biter = bl.begin();