]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: check completion state and rework finish_set_dedup
authormyoungwon oh <ohmyoungwon@gmail.com>
Sat, 31 Oct 2020 07:16:20 +0000 (16:16 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Sat, 31 Oct 2020 07:54:14 +0000 (16:54 +0900)
make finish_set_dedup() to handle all error or success cases

Signed-off-by: Myoungwon Oh <myoungwon.oh@samsumg.com>
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h

index bf03127293a6406e7581c373d58277f7652d893f..18fc19f73b6bf9fb8851fc303e3503ae8a0336d4 100644 (file)
@@ -10000,29 +10000,7 @@ struct C_SetDedupChunks : public Context {
     if (last_peering_reset != pg->get_last_peering_reset()) {
       return;
     }
-    auto it = pg->manifest_ops.find(oid);
-    if (it == pg->manifest_ops.end()) {
-      // raced with cancel_manifest_ops
-      return;
-    }
-    // check if the previous op returns fail
-    if (it->second->results[0] < 0) {
-      return;
-    }
-
-    it->second->results[offset] = r;
-    if (last_peering_reset == pg->get_last_peering_reset() &&
-       r >= 0) {
-      if (it->second->num_chunks != it->second->results.size()) {
-       // there are on-going works
-       return;
-      }
-      pg->finish_set_dedup(oid, r, tid);
-    } else {
-      // if any failure occurs, put a mark on the results to recognize the failure
-      it->second->results[0] = r;
-    }
-    pg->manifest_ops.erase(it);
+    pg->finish_set_dedup(oid, r, tid, offset);
   }
 };
 
@@ -10171,16 +10149,32 @@ hobject_t PrimaryLogPG::get_fpoid_from_chunk(const hobject_t soid, bufferlist& c
   return target;
 }
 
-void PrimaryLogPG::finish_set_dedup(hobject_t oid, int r, ceph_tid_t tid)
+void PrimaryLogPG::finish_set_dedup(hobject_t oid, int r, ceph_tid_t tid, uint64_t offset)
 {
   dout(10) << __func__ << " " << oid << " tid " << tid
           << " " << cpp_strerror(r) << dendl;
   map<hobject_t,ManifestOpRef>::iterator p = manifest_ops.find(oid);
   if (p == manifest_ops.end()) {
-    dout(10) << __func__ << " no flush_op found" << dendl;
+    dout(10) << __func__ << " no manifest_op found" << dendl;
     return;
   }
   ManifestOpRef mop = p->second;
+  mop->results[offset] = r;
+  if (r < 0) {
+    // if any failure occurs, put a mark on the results to recognize the failure
+    mop->results[0] = r;
+  }
+  if (mop->results[0] < 0) {
+    // check if the previous op returns fail
+    if (mop->num_chunks == mop->results.size()) {
+      manifest_ops.erase(oid);
+    }
+    return;
+  }
+  if (mop->num_chunks != mop->results.size()) {
+    // there are on-going works
+    return;
+  }
   ObjectContextRef obc = get_object_context(oid, false);
   if (!obc) {
     if (mop->op)
@@ -10238,6 +10232,8 @@ void PrimaryLogPG::finish_set_dedup(hobject_t oid, int r, ceph_tid_t tid)
   }
   if (mop->op)
     osd->reply_op_error(mop->op, r);
+
+  manifest_ops.erase(oid);
 }
 
 int PrimaryLogPG::start_flush(
index 9c8899a89b5a78077d834242dff7baa55979c06b..b30ee3fccd0cfa5956fdbde169ed15205d7d1ab9 100644 (file)
@@ -1512,7 +1512,7 @@ protected:
   int do_cdc(const object_info_t& oi, bufferlist& bl, vector<pair<uint64_t, uint64_t>>& chunks);
   int start_dedup(OpRequestRef op, ObjectContextRef obc);
   hobject_t get_fpoid_from_chunk(const hobject_t soid, bufferlist& chunk);
-  void finish_set_dedup(hobject_t oid, int r, ceph_tid_t tid);
+  void finish_set_dedup(hobject_t oid, int r, ceph_tid_t tid, uint64_t offset);
 
   friend struct C_ProxyChunkRead;
   friend class PromoteManifestCallback;