From 806aa2596040ddb44d778bc8c06848a9e42e239b Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Wed, 26 Oct 2022 18:46:37 +0000 Subject: [PATCH] crimson/osd: bring the skeleton of SnapTrimEvent Signed-off-by: Radoslaw Zarzynski --- src/crimson/osd/CMakeLists.txt | 1 + src/crimson/osd/osd_operation.h | 2 + .../osd/osd_operations/snaptrim_event.cc | 36 ++++++++++++++ .../osd/osd_operations/snaptrim_event.h | 49 +++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 src/crimson/osd/osd_operations/snaptrim_event.cc create mode 100644 src/crimson/osd/osd_operations/snaptrim_event.h diff --git a/src/crimson/osd/CMakeLists.txt b/src/crimson/osd/CMakeLists.txt index 7cdb27d2e19..3b7c7a3f58e 100644 --- a/src/crimson/osd/CMakeLists.txt +++ b/src/crimson/osd/CMakeLists.txt @@ -26,6 +26,7 @@ add_executable(crimson-osd osd_operations/logmissing_request_reply.cc osd_operations/background_recovery.cc osd_operations/recovery_subrequest.cc + osd_operations/snaptrim_event.cc pg_recovery.cc recovery_backend.cc replicated_recovery_backend.cc diff --git a/src/crimson/osd/osd_operation.h b/src/crimson/osd/osd_operation.h index dbc13c20c6e..f0f668c1c8b 100644 --- a/src/crimson/osd/osd_operation.h +++ b/src/crimson/osd/osd_operation.h @@ -46,6 +46,7 @@ enum class OperationTypeCode { historic_client_request, logmissing_request, logmissing_request_reply, + snaptrim_event, last_op }; @@ -62,6 +63,7 @@ static constexpr const char* const OP_NAMES[] = { "historic_client_request", "logmissing_request", "logmissing_request_reply", + "snaptrim_event", }; // prevent the addition of OperationTypeCode-s with no matching OP_NAMES entry: diff --git a/src/crimson/osd/osd_operations/snaptrim_event.cc b/src/crimson/osd/osd_operations/snaptrim_event.cc new file mode 100644 index 00000000000..d3fd67e45ae --- /dev/null +++ b/src/crimson/osd/osd_operations/snaptrim_event.cc @@ -0,0 +1,36 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include "crimson/osd/osd_operations/snaptrim_event.h" +#include "crimson/osd/pg.h" + +namespace { + seastar::logger& logger() { + return crimson::get_logger(ceph_subsys_osd); + } +} + +namespace crimson::osd { + +void SnapTrimEvent::print(std::ostream &lhs) const +{ + lhs << "SnapTrimEvent(" + << "pgid=" << pg->get_pgid() + << " snapid=" << snapid + << ")"; +} + +void SnapTrimEvent::dump_detail(Formatter *f) const +{ + f->open_object_section("SnapTrimEvent"); + f->dump_stream("pgid") << pg->get_pgid(); + f->close_section(); +} + +seastar::future<> SnapTrimEvent::start() +{ + logger().debug("{}", __func__); + return seastar::now(); +} + +} // namespace crimson::osd diff --git a/src/crimson/osd/osd_operations/snaptrim_event.h b/src/crimson/osd/osd_operations/snaptrim_event.h new file mode 100644 index 00000000000..bcb20e48ddd --- /dev/null +++ b/src/crimson/osd/osd_operations/snaptrim_event.h @@ -0,0 +1,49 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#pragma once + +#include +#include + +#include "crimson/osd/osdmap_gate.h" +#include "crimson/osd/osd_operation.h" +#include "crimson/osd/osd_operations/background_recovery.h" +#include "osd/osd_types.h" +#include "osd/PGPeeringEvent.h" +#include "osd/PeeringState.h" + +namespace ceph { + class Formatter; +} + +namespace crimson::osd { + +class OSD; +class ShardServices; +class PG; + +class SnapTrimEvent final : public PhasedOperationT { +public: + static constexpr OperationTypeCode type = OperationTypeCode::snaptrim_event; + + SnapTrimEvent(Ref pg, snapid_t snapid) + : pg(std::move(pg)), + snapid(snapid) {} + + void print(std::ostream &) const final; + void dump_detail(ceph::Formatter* f) const final; + seastar::future<> start(); + seastar::future<> with_pg( + ShardServices &shard_services, Ref pg); + +private: + Ref pg; + const snapid_t snapid; +}; + +} // namespace crimson::osd + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : fmt::ostream_formatter {}; +#endif