]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: bucket index log fixes
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 12 Apr 2013 21:12:38 +0000 (14:12 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 8 May 2013 17:57:46 +0000 (10:57 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_types.cc
src/cls/rgw/cls_rgw_types.h

index 0c0f4f7398e612a6e2225605d91541867c5f6f1c..ad2ab155346589bacc0c226fb88dd96e81265c89 100644 (file)
@@ -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;
 
index 286f677180558aa868d2895849c2ac859296fff8..07098be86817ab29e41303b36509dedbbaa9d1cd 100644 (file)
@@ -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)
index 1af0a8e29b3c2c3736b96915d67c472fe42d0bad..430b1df662ccfc85591c8363f4ba39bb4f8f8b41 100644 (file)
@@ -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;