From: Samuel Just Date: Tue, 30 Jun 2020 21:17:00 +0000 (-0700) Subject: crimson/os/seastore: move LogicalCachedExtent to cached_extent.h X-Git-Tag: v16.1.0~1513^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=89a2ea65fbd3340b05fcf2ab89131320b8c81760;p=ceph.git crimson/os/seastore: move LogicalCachedExtent to cached_extent.h Signed-off-by: Samuel Just --- diff --git a/src/crimson/os/seastore/cached_extent.cc b/src/crimson/os/seastore/cached_extent.cc index e901913975a..cbe730871e6 100644 --- a/src/crimson/os/seastore/cached_extent.cc +++ b/src/crimson/os/seastore/cached_extent.cc @@ -65,4 +65,21 @@ CachedExtent::~CachedExtent() } } +std::ostream &operator<<(std::ostream &out, const LBAPin &rhs) +{ + return out << "LBAPin(" << rhs.get_laddr() << "~" << rhs.get_length() + << "->" << rhs.get_paddr(); +} + +std::ostream &operator<<(std::ostream &out, const lba_pin_list_t &rhs) +{ + bool first = true; + out << '['; + for (auto &i: rhs) { + out << (first ? "" : ",") << *i; + first = false; + } + return out << ']'; +} + } diff --git a/src/crimson/os/seastore/cached_extent.h b/src/crimson/os/seastore/cached_extent.h index 7ab52f0fa63..66d8e46858c 100644 --- a/src/crimson/os/seastore/cached_extent.h +++ b/src/crimson/os/seastore/cached_extent.h @@ -495,5 +495,86 @@ public: } }; +class LBAPin; +using LBAPinRef = std::unique_ptr; +class LBAPin { +public: + virtual extent_len_t get_length() const = 0; + virtual paddr_t get_paddr() const = 0; + virtual laddr_t get_laddr() const = 0; + virtual LBAPinRef duplicate() const = 0; + + virtual ~LBAPin() {} +}; +std::ostream &operator<<(std::ostream &out, const LBAPin &rhs); + +using lba_pin_list_t = std::list; + +std::ostream &operator<<(std::ostream &out, const lba_pin_list_t &rhs); + + +/** + * LogicalCachedExtent + * + * CachedExtent with associated lba mapping. + * + * Users of TransactionManager should be using extents derived from + * LogicalCachedExtent. + */ +class LogicalCachedExtent : public CachedExtent { +public: + template + LogicalCachedExtent(T&&... t) : CachedExtent(std::forward(t)...) {} + + void set_pin(LBAPinRef &&pin) { this->pin = std::move(pin); } + + LBAPin &get_pin() { + assert(pin); + return *pin; + } + + laddr_t get_laddr() const { + assert(pin); + return pin->get_laddr(); + } + + void apply_delta_and_adjust_crc( + paddr_t base, const ceph::bufferlist &bl) final { + apply_delta(bl); + set_last_committed_crc(get_crc32c()); + } +protected: + virtual void apply_delta(const ceph::bufferlist &bl) = 0; + +private: + LBAPinRef pin; +}; + +using LogicalCachedExtentRef = TCachedExtentRef; +struct ref_laddr_cmp { + using is_transparent = laddr_t; + bool operator()(const LogicalCachedExtentRef &lhs, + const LogicalCachedExtentRef &rhs) const { + return lhs->get_laddr() < rhs->get_laddr(); + } + bool operator()(const laddr_t &lhs, + const LogicalCachedExtentRef &rhs) const { + return lhs < rhs->get_laddr(); + } + bool operator()(const LogicalCachedExtentRef &lhs, + const laddr_t &rhs) const { + return lhs->get_laddr() < rhs; + } +}; + +using lextent_set_t = addr_extent_set_base_t< + laddr_t, + LogicalCachedExtentRef, + ref_laddr_cmp + >; + +template +using lextent_list_t = addr_extent_list_base_t< + laddr_t, TCachedExtentRef>; } diff --git a/src/crimson/os/seastore/lba_manager.cc b/src/crimson/os/seastore/lba_manager.cc index 2fe1345cf8f..73411dcf7e3 100644 --- a/src/crimson/os/seastore/lba_manager.cc +++ b/src/crimson/os/seastore/lba_manager.cc @@ -15,24 +15,3 @@ LBAManagerRef create_lba_manager( } } - -namespace crimson::os::seastore { - -std::ostream &operator<<(std::ostream &out, const LBAPin &rhs) -{ - return out << "LBAPin(" << rhs.get_laddr() << "~" << rhs.get_length() - << "->" << rhs.get_paddr(); -} - -std::ostream &operator<<(std::ostream &out, const lba_pin_list_t &rhs) -{ - bool first = true; - out << '['; - for (auto &i: rhs) { - out << (first ? "" : ",") << *i; - first = false; - } - return out << ']'; -} - -}; diff --git a/src/crimson/os/seastore/lba_manager.h b/src/crimson/os/seastore/lba_manager.h index 4a6f2e95476..fc5d4a27140 100644 --- a/src/crimson/os/seastore/lba_manager.h +++ b/src/crimson/os/seastore/lba_manager.h @@ -23,23 +23,6 @@ namespace crimson::os::seastore { -class LBAPin; -using LBAPinRef = std::unique_ptr; -class LBAPin { -public: - virtual extent_len_t get_length() const = 0; - virtual paddr_t get_paddr() const = 0; - virtual laddr_t get_laddr() const = 0; - virtual LBAPinRef duplicate() const = 0; - - virtual ~LBAPin() {} -}; -std::ostream &operator<<(std::ostream &out, const LBAPin &rhs); - -using lba_pin_list_t = std::list; - -std::ostream &operator<<(std::ostream &out, const lba_pin_list_t &rhs); - /** * Abstract interface for managing the logical to physical mapping */ diff --git a/src/crimson/os/seastore/transaction_manager.h b/src/crimson/os/seastore/transaction_manager.h index b93019701bd..149b7049618 100644 --- a/src/crimson/os/seastore/transaction_manager.h +++ b/src/crimson/os/seastore/transaction_manager.h @@ -28,70 +28,6 @@ namespace crimson::os::seastore { class Journal; -/** - * LogicalCachedExtent - * - * CachedExtent with associated lba mapping. - * - * Users of TransactionManager should be using extents derived from - * LogicalCachedExtent. - */ -class LogicalCachedExtent : public CachedExtent { -public: - template - LogicalCachedExtent(T&&... t) : CachedExtent(std::forward(t)...) {} - - void set_pin(LBAPinRef &&pin) { this->pin = std::move(pin); } - - LBAPin &get_pin() { - assert(pin); - return *pin; - } - - laddr_t get_laddr() const { - assert(pin); - return pin->get_laddr(); - } - - void apply_delta_and_adjust_crc( - paddr_t base, const ceph::bufferlist &bl) final { - apply_delta(bl); - set_last_committed_crc(get_crc32c()); - } -protected: - virtual void apply_delta(const ceph::bufferlist &bl) = 0; - -private: - LBAPinRef pin; -}; - -using LogicalCachedExtentRef = TCachedExtentRef; -struct ref_laddr_cmp { - using is_transparent = laddr_t; - bool operator()(const LogicalCachedExtentRef &lhs, - const LogicalCachedExtentRef &rhs) const { - return lhs->get_laddr() < rhs->get_laddr(); - } - bool operator()(const laddr_t &lhs, - const LogicalCachedExtentRef &rhs) const { - return lhs < rhs->get_laddr(); - } - bool operator()(const LogicalCachedExtentRef &lhs, - const laddr_t &rhs) const { - return lhs->get_laddr() < rhs; - } -}; - -using lextent_set_t = addr_extent_set_base_t< - laddr_t, - LogicalCachedExtentRef, - ref_laddr_cmp - >; - -template -using lextent_list_t = addr_extent_list_base_t< - laddr_t, TCachedExtentRef>; - /** * TransactionManager *