]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Preserve OSDOp information for historic ops 15265/head
authorGuo-Fu Tseng <david_tseng@bigtera.com>
Wed, 15 Feb 2017 05:59:10 +0000 (13:59 +0800)
committerGuo-Fu Tseng <david_tseng@bigtera.com>
Wed, 24 May 2017 09:10:51 +0000 (17:10 +0800)
clear_buffers() actually clears all OSDOp informations, so that we can
only see empty ops with `dump_historic_ops`. This commit keeps the op
information, and only minimal buffers for printing op information.

Signed-off-by: Guo-Fu Tseng <david_tseng@bigtera.com>
src/messages/MOSDOp.h
src/osd/osd_types.cc
src/osd/osd_types.h

index b6b87f131de1bbee56fd3dd13d146380147201c0..69d12a7a9df4cf4845c54270adb588157e820acf 100755 (executable)
@@ -559,7 +559,7 @@ struct ceph_osd_request_head {
   }
 
   void clear_buffers() override {
-    ops.clear();
+    OSDOp::clear_data(ops);
   }
 
   const char *get_type_name() const override { return "osd_op"; }
index fbebf058d2b5bac34b0f272f6ca499ea75142941..80cf7e3d401fdc5723f142d96039f05068ca079e 100644 (file)
@@ -5878,3 +5878,33 @@ ostream& operator<<(ostream& out, const store_statfs_t &s)
       << ")";
   return out;
 }
+
+void OSDOp::clear_data(vector<OSDOp>& ops)
+{
+  for (unsigned i = 0; i < ops.size(); i++) {
+    OSDOp& op = ops[i];
+    op.outdata.clear();
+    if (ceph_osd_op_type_attr(op.op.op) &&
+        op.op.xattr.name_len &&
+       op.indata.length() >= op.op.xattr.name_len) {
+      bufferptr bp(op.op.xattr.name_len);
+      bufferlist bl;
+      bl.append(bp);
+      bl.copy_in(0, op.op.xattr.name_len, op.indata);
+      op.indata.claim(bl);
+    } else if (ceph_osd_op_type_exec(op.op.op) &&
+               op.op.cls.class_len &&
+              op.indata.length() >
+                (op.op.cls.class_len + op.op.cls.method_len)) {
+      __u8 len = op.op.cls.class_len + op.op.cls.method_len;
+      bufferptr bp(len);
+      bufferlist bl;
+      bl.append(bp);
+      bl.copy_in(0, len, op.indata);
+      op.indata.claim(bl);
+    } else {
+      op.indata.clear();
+    }
+  }
+}
+
index 1cea9a6ba36010bb64da3a0bb0b29059aa60132d..a48f4c864e3d7ee90f565590fb84ab38781b2b9e 100644 (file)
@@ -4777,6 +4777,13 @@ struct OSDOp {
    * @param out [out] combined data buffer
    */
   static void merge_osd_op_vector_out_data(vector<OSDOp>& ops, bufferlist& out);
+
+  /**
+   * Clear data as much as possible, leave minimal data for historical op dump
+   *
+   * @param ops [in] vector of OSDOps
+   */
+  static void clear_data(vector<OSDOp>& ops);
 };
 
 ostream& operator<<(ostream& out, const OSDOp& op);