]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: for cmp_fail error, return -MAX_ERRNO-index 47328/head
authorchunmei-liu <chunmei.liu@intel.com>
Thu, 28 Jul 2022 06:44:47 +0000 (23:44 -0700)
committerchunmei-liu <chunmei.liu@intel.com>
Thu, 28 Jul 2022 23:59:15 +0000 (16:59 -0700)
instead of cmp_fail error code.

Signed-off-by: chunmei-liu <chunmei.liu@intel.com>
src/crimson/common/errorator.h
src/crimson/osd/ops_executer.cc
src/crimson/osd/pg.cc
src/crimson/osd/pg_backend.cc

index 73c58b264f76792bc0551b87d47d4655cf9183f1..c6c1a8b476d33ce0b4fa82170e17ae6d3bac6729 100644 (file)
@@ -1147,7 +1147,8 @@ namespace ct_error {
   using enametoolong = ct_error_code<static_cast<int>(std::errc::filename_too_long)>;
   using eexist = ct_error_code<static_cast<int>(std::errc::file_exists)>;
   using edquot = ct_error_code<int(122)>;
-  using cmp_fail = ct_error_code<int(4095)>;
+  constexpr int cmp_fail_error_value = 4095;
+  using cmp_fail = ct_error_code<int(cmp_fail_error_value)>;
 
   struct pass_further_all {
     template <class ErrorT>
index a074d114ac924357abd641a781842ab2b5dd2e75..706105f091fddd683648298a5fde9ab7bc3600bf 100644 (file)
@@ -479,7 +479,11 @@ OpsExecuter::execute_op(OSDOp& osd_op)
   return do_execute_op(osd_op).handle_error_interruptible(
     osd_op_errorator::all_same_way([&osd_op](auto e, auto&& e_raw)
       -> OpsExecuter::osd_op_errorator::future<> {
-        osd_op.rval = -e.value();
+        // All ops except for CMPEXT should have rval set to -e.value(),
+        // CMPEXT sets rval itself and shouldn't be overridden.
+        if (e.value() != ct_error::cmp_fail_error_value) {
+          osd_op.rval = -e.value();
+        }
         if ((osd_op.op.flags & CEPH_OSD_OP_FLAG_FAILOK) &&
          e.value() != EAGAIN && e.value() != EINPROGRESS) {
           return osd_op_errorator::now();
index cac17c2f7aad637fc6678f80cb6afc87a6dfe178..98cb4e831c66ed8f4ad131f7d50d081c7159b1a2 100644 (file)
@@ -831,6 +831,17 @@ PG::do_osd_ops(
             m->ops.back().op.flags & CEPH_OSD_OP_FLAG_FAILOK) {
             reply->set_result(0);
           }
+          // For all ops except for CMPEXT, the correct error value is encoded
+          // in e.value(). For CMPEXT, osdop.rval has the actual error value.
+          if (e.value() == ct_error::cmp_fail_error_value) {
+            assert(!m->ops.empty());
+            for (auto &osdop : m->ops) {
+              if (osdop.rval < 0) {
+                reply->set_result(osdop.rval);
+                break;
+              }
+            }
+          }
           reply->set_enoent_reply_versions(
           peering_state.get_info().last_update,
           peering_state.get_info().last_user_version);
index 74e607bffe649e01dc8e96c6fcbd9f1011c50b42..5adcd112940db3283a57c6cf473dbcf62a9d0e90 100644 (file)
@@ -422,6 +422,8 @@ PGBackend::cmp_ext(const ObjectState& os, OSDOp& osd_op)
       char byte_from_disk = (index < read_bl.length() ? read_bl[index] : 0);
       if (byte_in_op != byte_from_disk) {
         logger().debug("cmp_ext: mismatch at {}", index);
+        // Unlike other ops, we set osd_op.rval here and return a different
+        // error code via ct_error::cmp_fail.
         osd_op.rval = -MAX_ERRNO - index;
         return crimson::ct_error::cmp_fail::make();
       }