]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls_rgw: dir_suggest entries bucket index logging
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 9 Jun 2016 21:22:07 +0000 (14:22 -0700)
committerAbhishek Lekshmanan <abhishek@suse.com>
Thu, 14 Jul 2016 08:06:58 +0000 (10:06 +0200)
Fixes: http://tracker.ceph.com/issues/16222
Log entries that were set through the dir_suggest mechanism in
the bucket index log.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit ae00c5529219d81987425160dbb2a4e937661a6c)

src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_types.h
src/rgw/rgw_rados.cc

index 146da9c55a6d932a736646a578e06b54b7238fb7..46c2a3f9b49fc60b0dd08a33f79837128b4bcbe1 100644 (file)
@@ -1933,12 +1933,22 @@ int rgw_dir_suggest_changes(cls_method_context_t hctx, bufferlist *in, bufferlis
       }
       struct rgw_bucket_category_stats& stats =
           header.stats[cur_change.meta.category];
+      bool log_op = (op & CEPH_RGW_DIR_SUGGEST_LOG_OP) != 0;
+      op &= CEPH_RGW_DIR_SUGGEST_OP_MASK;
       switch(op) {
       case CEPH_RGW_REMOVE:
         CLS_LOG(10, "CEPH_RGW_REMOVE name=%s instance=%s\n", cur_change.key.name.c_str(), cur_change.key.instance.c_str());
        ret = cls_cxx_map_remove_key(hctx, cur_change_key);
        if (ret < 0)
          return ret;
+        if (log_op && cur_disk.exists) {
+          ret = log_index_operation(hctx, cur_disk.key, CLS_RGW_OP_DEL, cur_disk.tag, cur_disk.meta.mtime,
+                                    cur_disk.ver, CLS_RGW_STATE_COMPLETE, header.ver, header.max_marker, 0, NULL, NULL);
+          if (ret < 0) {
+            CLS_LOG(0, "ERROR: %s(): failed to log operation ret=%d", __func__, ret);
+            return ret;
+          }
+        }
         break;
       case CEPH_RGW_UPDATE:
         CLS_LOG(10, "CEPH_RGW_UPDATE name=%s instance=%s total_entries: %" PRId64 " -> %" PRId64 "\n",
@@ -1953,9 +1963,18 @@ int rgw_dir_suggest_changes(cls_method_context_t hctx, bufferlist *in, bufferlis
         ret = cls_cxx_map_set_val(hctx, cur_change_key, &cur_state_bl);
         if (ret < 0)
          return ret;
+        if (log_op) {
+          ret = log_index_operation(hctx, cur_change.key, CLS_RGW_OP_ADD, cur_change.tag, cur_change.meta.mtime,
+                                    cur_change.ver, CLS_RGW_STATE_COMPLETE, header.ver, header.max_marker, 0, NULL, NULL);
+          if (ret < 0) {
+            CLS_LOG(0, "ERROR: %s(): failed to log operation ret=%d", __func__, ret);
+            return ret;
+          }
+        }
         break;
       }
     }
+
   }
 
   if (header_changed) {
index a7d3b7af91c1910f31be49ee62d0ec298523c81e..08dd5c2f869f1f5721959b744f958e2c5b1bf283 100644 (file)
@@ -12,6 +12,8 @@
 #define CEPH_RGW_REMOVE 'r'
 #define CEPH_RGW_UPDATE 'u'
 #define CEPH_RGW_TAG_TIMEOUT 60*60*24
+#define CEPH_RGW_DIR_SUGGEST_LOG_OP  0x80
+#define CEPH_RGW_DIR_SUGGEST_OP_MASK 0x7f
 
 class JSONObj;
 
index 6dfc5630c3078b74b1fc694a40fcbe403ddd67dd..47577e85e7f953a62a23c1159e83938e085bf486 100644 (file)
@@ -11284,6 +11284,8 @@ int RGWRados::remove_objs_from_index(rgw_bucket& bucket, list<rgw_obj_key>& oid_
   librados::IoCtx index_ctx;
   string dir_oid;
 
+  uint8_t suggest_flag = (get_zone().log_data ? CEPH_RGW_DIR_SUGGEST_LOG_OP : 0);
+
   int r = open_bucket_index(bucket, index_ctx, dir_oid);
   if (r < 0)
     return r;
@@ -11298,7 +11300,7 @@ int RGWRados::remove_objs_from_index(rgw_bucket& bucket, list<rgw_obj_key>& oid_
     rgw_bucket_dir_entry entry;
     entry.ver.epoch = (uint64_t)-1; // ULLONG_MAX, needed to that objclass doesn't skip out request
     key.transform(&entry.key);
-    updates.append(CEPH_RGW_REMOVE);
+    updates.append(CEPH_RGW_REMOVE | suggest_flag);
     ::encode(entry, updates);
   }
 
@@ -11315,6 +11317,8 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx,
                                RGWObjEnt& object,
                                bufferlist& suggested_updates)
 {
+  uint8_t suggest_flag = (get_zone().log_data ? CEPH_RGW_DIR_SUGGEST_LOG_OP : 0);
+
   rgw_obj obj;
   std::string oid, instance, loc, ns;
   rgw_obj_key key;
@@ -11411,7 +11415,7 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx,
   list_state.meta.owner_display_name = owner.get_display_name();
 
   list_state.exists = true;
-  cls_rgw_encode_suggestion(CEPH_RGW_UPDATE, list_state, suggested_updates);
+  cls_rgw_encode_suggestion(CEPH_RGW_UPDATE | suggest_flag, list_state, suggested_updates);
   return 0;
 }