diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-04-12 14:12:38 -0700 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-05-08 10:57:46 -0700 |
commit | 2a16bafdd96207c3bc95582158fd909d6bfb0477 (patch) | |
tree | 010318856d261a3503806d7bc17e31bace624107 | |
parent | 871b40137cfe23345201222b7fc947315dd8a94a (diff) | |
download | ceph-2a16bafdd96207c3bc95582158fd909d6bfb0477.tar.gz |
rgw: bucket index log fixes
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/cls/rgw/cls_rgw.cc | 18 | ||||
-rw-r--r-- | src/cls/rgw/cls_rgw_types.cc | 21 | ||||
-rw-r--r-- | src/cls/rgw/cls_rgw_types.h | 3 |
3 files changed, 25 insertions, 17 deletions
diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index 0c0f4f7398e..ad2ab155346 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -106,18 +106,21 @@ static void bi_log_index_key(cls_method_context_t hctx, string& key, string& id, key.append(id); } -static int log_index_operation(cls_method_context_t hctx, string& obj, RGWModifyOp op, rgw_bucket_entry_ver& ver, RGWPendingState state, uint64_t index_ver) +static int log_index_operation(cls_method_context_t hctx, string& obj, RGWModifyOp op, + string& tag, utime_t& timestamp, + rgw_bucket_entry_ver& ver, RGWPendingState state, uint64_t index_ver) { bufferlist bl; struct rgw_bi_log_entry entry; entry.object = obj; - entry.timestamp = ceph_clock_now(g_ceph_context); + entry.timestamp = timestamp; entry.op = op; entry.ver = ver; entry.state = state; entry.index_ver = index_ver; + entry.tag = tag; string key; bi_log_index_key(hctx, key, entry.id, index_ver); @@ -413,7 +416,7 @@ int rgw_bucket_prepare_op(cls_method_context_t hctx, bufferlist *in, bufferlist return -EINVAL; } - rc = log_index_operation(hctx, op.name, op.op, entry.ver, info.state, header.ver); + rc = log_index_operation(hctx, op.name, op.op, op.tag, entry.meta.mtime, entry.ver, info.state, header.ver); if (rc < 0) return rc; @@ -525,7 +528,7 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist bufferlist op_bl; if (cancel) { - rc = log_index_operation(hctx, op.name, op.op, entry.ver, CLS_RGW_STATE_COMPLETE, header.ver); + rc = log_index_operation(hctx, op.name, op.op, op.tag, entry.meta.mtime, entry.ver, CLS_RGW_STATE_COMPLETE, header.ver); if (rc < 0) return rc; @@ -542,6 +545,7 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist unaccount_entry(header, entry); } + entry.ver = op.ver; switch ((int)op.op) { case CLS_RGW_OP_DEL: if (ondisk) { @@ -567,7 +571,6 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist struct rgw_bucket_category_stats& stats = header.stats[meta.category]; entry.meta = meta; entry.name = op.name; - entry.ver = op.ver; entry.exists = true; stats.num_entries++; stats.total_size += meta.size; @@ -581,7 +584,7 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist break; } - rc = log_index_operation(hctx, op.name, op.op, entry.ver, CLS_RGW_STATE_COMPLETE, header.ver); + rc = log_index_operation(hctx, op.name, op.op, op.tag, entry.meta.mtime, entry.ver, CLS_RGW_STATE_COMPLETE, header.ver); if (rc < 0) return rc; @@ -599,7 +602,8 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist CLS_LOG(0, "rgw_bucket_complete_op(): entry.name=%s entry.meta.category=%d\n", remove_entry.name.c_str(), remove_entry.meta.category); unaccount_entry(header, remove_entry); - rc = log_index_operation(hctx, op.name, CLS_RGW_OP_DEL, remove_entry.ver, CLS_RGW_STATE_COMPLETE, header.ver); + rc = log_index_operation(hctx, op.name, CLS_RGW_OP_DEL, op.tag, remove_entry.meta.mtime, + remove_entry.ver, CLS_RGW_STATE_COMPLETE, header.ver); if (rc < 0) continue; diff --git a/src/cls/rgw/cls_rgw_types.cc b/src/cls/rgw/cls_rgw_types.cc index 286f6771805..07098be8681 100644 --- a/src/cls/rgw/cls_rgw_types.cc +++ b/src/cls/rgw/cls_rgw_types.cc @@ -69,7 +69,7 @@ void rgw_bucket_dir_entry::generate_test_instances(list<rgw_bucket_dir_entry*>& } void rgw_bucket_entry_ver::dump(Formatter *f) const { - f->dump_unsigned("pool", pool); + f->dump_int("pool", pool); f->dump_unsigned("epoch", epoch); } @@ -98,15 +98,8 @@ void rgw_bucket_dir_entry::dump(Formatter *f) const void rgw_bi_log_entry::dump(Formatter *f) const { - f->dump_string("id", id); - f->dump_string("object", object); - - f->dump_int("index_ver", index_ver); - f->dump_stream("timestamp") << timestamp; - f->open_object_section("ver"); - ver.dump(f); - f->close_section(); - + f->dump_string("op_id", id); + f->dump_string("op_tag", tag); switch (op) { case CLS_RGW_OP_ADD: f->dump_string("op", "write"); @@ -125,6 +118,8 @@ void rgw_bi_log_entry::dump(Formatter *f) const break; } + f->dump_string("object", object); + switch (state) { case CLS_RGW_STATE_PENDING_MODIFY: f->dump_string("state", "pending"); @@ -136,6 +131,12 @@ void rgw_bi_log_entry::dump(Formatter *f) const f->dump_string("state", "invalid"); break; } + + f->dump_int("index_ver", index_ver); + f->dump_stream("timestamp") << timestamp; + f->open_object_section("ver"); + ver.dump(f); + f->close_section(); } void rgw_bucket_category_stats::generate_test_instances(list<rgw_bucket_category_stats*>& o) diff --git a/src/cls/rgw/cls_rgw_types.h b/src/cls/rgw/cls_rgw_types.h index 1af0a8e29b3..430b1df662c 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -247,6 +247,7 @@ struct rgw_bi_log_entry { RGWModifyOp op; RGWPendingState state; uint64_t index_ver; + string tag; rgw_bi_log_entry() : op(CLS_RGW_OP_UNKNOWN), index_ver(0) {} @@ -256,6 +257,7 @@ struct rgw_bi_log_entry { ::encode(object, bl); ::encode(timestamp, bl); ::encode(ver, bl); + ::encode(tag, bl); uint8_t c = (uint8_t)op; ::encode(c, bl); c = (uint8_t)state; @@ -269,6 +271,7 @@ struct rgw_bi_log_entry { ::decode(object, bl); ::decode(timestamp, bl); ::decode(ver, bl); + ::decode(tag, bl); uint8_t c; ::decode(c, bl); op = (RGWModifyOp)c; |