]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: generalize PG::snaptrim_mutex to background_process_lock
authorSamuel Just <sjust@redhat.com>
Sat, 2 Sep 2023 03:22:45 +0000 (03:22 +0000)
committerSamuel Just <sjust@redhat.com>
Mon, 11 Dec 2023 04:10:18 +0000 (04:10 +0000)
We don't want scrub and snaptrimming running at the same time,
use the same lock.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/osd/osd_operations/snaptrim_event.cc
src/crimson/osd/osd_operations/snaptrim_event.h
src/crimson/osd/pg.cc
src/crimson/osd/pg.h

index 20f7439f52f903f7ecf0ebb06a924637569a492f..e90c7a213faf5a876828939ea4d554f505dee6bb 100644 (file)
@@ -31,9 +31,9 @@ namespace crimson {
 namespace crimson::osd {
 
 PG::interruptible_future<>
-PG::SnapTrimMutex::lock(SnapTrimEvent &st_event) noexcept
+PG::BackgroundProcessLock::lock_with_op(SnapTrimEvent &st_event) noexcept
 {
-  return st_event.enter_stage<interruptor>(wait_pg
+  return st_event.enter_stage<interruptor>(wait
   ).then_interruptible([this] {
     return mutex.lock();
   });
@@ -115,7 +115,7 @@ SnapTrimEvent::start()
       return enter_stage<interruptor>(
         client_pp().get_obc);
     }).then_interruptible([this] {
-      return pg->snaptrim_mutex.lock(*this);
+      return pg->background_process_lock.lock_with_op(*this);
     }).then_interruptible([this] {
       return enter_stage<interruptor>(
         client_pp().process);
@@ -147,7 +147,7 @@ SnapTrimEvent::start()
         if (to_trim.empty()) {
           // the legit ENOENT -> done
           logger().debug("{}: to_trim is empty! Stopping iteration", *this);
-         pg->snaptrim_mutex.unlock();
+         pg->background_process_lock.unlock();
           return snap_trim_iertr::make_ready_future<seastar::stop_iteration>(
             seastar::stop_iteration::yes);
         }
@@ -171,7 +171,7 @@ SnapTrimEvent::start()
           logger().debug("{}: awaiting completion", *this);
           return subop_blocker.wait_completion();
         }).finally([this] {
-         pg->snaptrim_mutex.unlock();
+         pg->background_process_lock.unlock();
        }).si_then([this] {
           if (!needs_pause) {
             return interruptor::now();
index 12f244512ac3400598793eed23eef8e560f3a661..39038c71ef91d4b58df23c9081f7784a29018458 100644 (file)
@@ -104,12 +104,12 @@ public:
     CommonPGPipeline::GetOBC::BlockingEvent,
     CommonPGPipeline::Process::BlockingEvent,
     WaitSubop::BlockingEvent,
-    PG::SnapTrimMutex::WaitPG::BlockingEvent,
+    PG::BackgroundProcessLock::Wait::BlockingEvent,
     WaitTrimTimer::BlockingEvent,
     CompletionEvent
   > tracking_events;
 
-  friend class PG::SnapTrimMutex;
+  friend class PG::BackgroundProcessLock;
 };
 
 // remove single object. a SnapTrimEvent can create multiple subrequests.
index 013f564b5f12aaabe440abc863585bfea4ecd468..5b7f1fd2578141035c1fb5f1bd22a71dc6a5d03c 100644 (file)
@@ -801,6 +801,12 @@ PG::interruptible_future<> PG::repair_object(
   return std::move(fut);
 }
 
+PG::interruptible_future<>
+PG::BackgroundProcessLock::lock() noexcept
+{
+  return interruptor::make_interruptible(mutex.lock());
+}
+
 template <class Ret, class SuccessFunc, class FailureFunc>
 PG::do_osd_ops_iertr::future<PG::pg_rep_op_fut_t<Ret>>
 PG::do_osd_ops_execute(
index 4628b09b509a1d552212f189bb890e6f353f6782..7f734ecd5e778b4e5646e93dbd4e5e629b9d5bd5 100644 (file)
@@ -542,18 +542,19 @@ public:
 
 private:
 
-  struct SnapTrimMutex {
-    struct WaitPG : OrderedConcurrentPhaseT<WaitPG> {
-      static constexpr auto type_name = "SnapTrimEvent::wait_pg";
-    } wait_pg;
+  struct BackgroundProcessLock {
+    struct Wait : OrderedConcurrentPhaseT<Wait> {
+      static constexpr auto type_name = "PG::BackgroundProcessLock::wait";
+    } wait;
     seastar::shared_mutex mutex;
 
-    interruptible_future<> lock(SnapTrimEvent &st_event) noexcept;
+    interruptible_future<> lock_with_op(SnapTrimEvent &st_event) noexcept;
+    interruptible_future<> lock() noexcept;
 
     void unlock() noexcept {
       mutex.unlock();
     }
-  } snaptrim_mutex;
+  } background_process_lock;
 
   using do_osd_ops_ertr = crimson::errorator<
    crimson::ct_error::eagain>;