From: Samuel Just Date: Sat, 2 Sep 2023 03:22:45 +0000 (+0000) Subject: crimson/osd: generalize PG::snaptrim_mutex to background_process_lock X-Git-Tag: v19.3.0~296^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1bda4f5dfb0aea1cd02baa592f8cd4b09153374f;p=ceph.git crimson/osd: generalize PG::snaptrim_mutex to background_process_lock We don't want scrub and snaptrimming running at the same time, use the same lock. Signed-off-by: Samuel Just --- diff --git a/src/crimson/osd/osd_operations/snaptrim_event.cc b/src/crimson/osd/osd_operations/snaptrim_event.cc index 20f7439f52f9..e90c7a213faf 100644 --- a/src/crimson/osd/osd_operations/snaptrim_event.cc +++ b/src/crimson/osd/osd_operations/snaptrim_event.cc @@ -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(wait_pg + return st_event.enter_stage(wait ).then_interruptible([this] { return mutex.lock(); }); @@ -115,7 +115,7 @@ SnapTrimEvent::start() return enter_stage( 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( 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::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(); diff --git a/src/crimson/osd/osd_operations/snaptrim_event.h b/src/crimson/osd/osd_operations/snaptrim_event.h index 12f244512ac3..39038c71ef91 100644 --- a/src/crimson/osd/osd_operations/snaptrim_event.h +++ b/src/crimson/osd/osd_operations/snaptrim_event.h @@ -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. diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index 013f564b5f12..5b7f1fd25781 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -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 PG::do_osd_ops_iertr::future> PG::do_osd_ops_execute( diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 4628b09b509a..7f734ecd5e77 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -542,18 +542,19 @@ public: private: - struct SnapTrimMutex { - struct WaitPG : OrderedConcurrentPhaseT { - static constexpr auto type_name = "SnapTrimEvent::wait_pg"; - } wait_pg; + struct BackgroundProcessLock { + struct Wait : OrderedConcurrentPhaseT { + 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>;