]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: introduce rollback_obc_if_modified without an error argument
authorSamuel Just <sjust@redhat.com>
Fri, 20 Sep 2024 19:56:17 +0000 (12:56 -0700)
committerSamuel Just <sjust@redhat.com>
Tue, 15 Oct 2024 03:37:26 +0000 (20:37 -0700)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/osd/ops_executer.h

index 185ead24e7550d4df69e032b76b7088a5e111ded..6986f49ea08a73b8f54fa954a7d63d7210c2a0e5 100644 (file)
@@ -551,6 +551,7 @@ OpsExecuter::flush_changes_n_do_ops_effects(
 
 template <class Func>
 struct OpsExecuter::RollbackHelper {
+  void rollback_obc_if_modified();
   void rollback_obc_if_modified(const std::error_code& e);
   seastar::lw_shared_ptr<OpsExecuter> ox;
   Func func;
@@ -562,6 +563,33 @@ OpsExecuter::create_rollbacker(Func&& func) {
   return {shared_from_this(), std::forward<Func>(func)};
 }
 
+template <class Func>
+void OpsExecuter::RollbackHelper<Func>::rollback_obc_if_modified()
+{
+  // Oops, an operation had failed. do_osd_ops() altogether with
+  // OpsExecuter already dropped the ObjectStore::Transaction if
+  // there was any. However, this is not enough to completely
+  // rollback as we gave OpsExecuter the very single copy of `obc`
+  // we maintain and we did it for both reading and writing.
+  // Now all modifications must be reverted.
+  //
+  // The conditional's purpose is to efficiently handle hot errors
+  // which may appear as a result of e.g. CEPH_OSD_OP_CMPXATTR or
+  // CEPH_OSD_OP_OMAP_CMP. These are read-like ops and clients
+  // typically append them before any write. If OpsExecuter hasn't
+  // seen any modifying operation, `obc` is supposed to be kept
+  // unchanged.
+  assert(ox);
+  const auto need_rollback = ox->has_seen_write();
+  crimson::get_logger(ceph_subsys_osd).debug(
+    "{}: object {} got error, need_rollback={}",
+    __func__,
+    ox->obc->get_oid(),
+    need_rollback);
+  if (need_rollback) {
+    func(ox->obc);
+  }
+}
 
 template <class Func>
 void OpsExecuter::RollbackHelper<Func>::rollback_obc_if_modified(