From: Aishwarya Mathuria Date: Wed, 31 Jan 2024 09:20:44 +0000 (+0000) Subject: crimson: Add support for pool compression X-Git-Tag: v20.0.0~2121^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ba4f62c49ecee26d98100bb5cdb15ecfe212f0be;p=ceph.git crimson: Add support for pool compression 1. Send pool options to Bluestore which include compression options as well. 2. Add pool related stats to MPGStats so that they all compression details are available in 'ceph df detail' command. Fixes: https://tracker.ceph.com/issues/59242 Signed-off-by: Aishwarya Mathuria --- diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index bfa8dbf42e7..2139a2dd258 100644 --- a/src/crimson/os/alienstore/alien_store.cc +++ b/src/crimson/os/alienstore/alien_store.cc @@ -294,6 +294,21 @@ seastar::future> AlienStore::list_collections() }); } +seastar::future<> AlienStore::set_collection_opts(CollectionRef ch, + const pool_opts_t& opts) +{ + logger().debug("{}", __func__); + assert(tp); + + return tp->submit(ch->get_cid().hash_to_shard(tp->size()), [=, this] { + auto c = static_cast(ch.get()); + return store->set_collection_opts(c->collection, opts); + }).then([] (int r) { + assert(r==0); + return seastar::now(); + }); +} + AlienStore::read_errorator::future AlienStore::read(CollectionRef ch, const ghobject_t& oid, @@ -557,6 +572,21 @@ seastar::future AlienStore::stat() const }); } +seastar::future AlienStore::pool_statfs(int64_t pool_id) const +{ + logger().info("{}", __func__); + assert(tp); + return do_with_op_gate(store_statfs_t{}, [this, pool_id] (store_statfs_t &st) { + return tp->submit([this, pool_id, &st]{ + bool per_pool_omap_stats = false; + return store->pool_statfs(pool_id, &st, &per_pool_omap_stats); + }).then([&st] (int r) { + assert(r==0); + return seastar::make_ready_future(std::move(st)); + }); + }); +} + unsigned AlienStore::get_max_attr_name_length() const { logger().info("{}", __func__); diff --git a/src/crimson/os/alienstore/alien_store.h b/src/crimson/os/alienstore/alien_store.h index 910bb153dcb..ad25d56c18f 100644 --- a/src/crimson/os/alienstore/alien_store.h +++ b/src/crimson/os/alienstore/alien_store.h @@ -75,6 +75,8 @@ public: seastar::future create_new_collection(const coll_t& cid) final; seastar::future open_collection(const coll_t& cid) final; seastar::future> list_collections() final; + seastar::future<> set_collection_opts(CollectionRef c, + const pool_opts_t& opts) final; seastar::future<> do_transaction_no_callbacks( CollectionRef c, @@ -90,6 +92,7 @@ public: const std::string& key) final; uuid_d get_fsid() const final; seastar::future stat() const final; + seastar::future pool_statfs(int64_t pool_id) const final; unsigned get_max_attr_name_length() const final; seastar::future stat( CollectionRef, diff --git a/src/crimson/os/cyanstore/cyan_collection.h b/src/crimson/os/cyanstore/cyan_collection.h index 068e427d8df..ab021589d84 100644 --- a/src/crimson/os/cyanstore/cyan_collection.h +++ b/src/crimson/os/cyanstore/cyan_collection.h @@ -36,6 +36,8 @@ struct Collection final : public FuturizedCollection { std::map xattr; bool exists = true; + pool_opts_t pool_opts; + Collection(const coll_t& c); ~Collection() final; diff --git a/src/crimson/os/cyanstore/cyan_store.cc b/src/crimson/os/cyanstore/cyan_store.cc index df68e8bd20f..7b945e5aa15 100644 --- a/src/crimson/os/cyanstore/cyan_store.cc +++ b/src/crimson/os/cyanstore/cyan_store.cc @@ -71,6 +71,11 @@ seastar::future CyanStore::stat() const }); } +seastar::future CyanStore::pool_statfs(int64_t pool_id) const +{ + return stat(); +} + CyanStore::mkfs_ertr::future<> CyanStore::mkfs(uuid_d new_osd_fsid) { @@ -258,6 +263,16 @@ CyanStore::Shard::exists( return base_errorator::make_ready_future(true); } +seastar::future<> +CyanStore::Shard::set_collection_opts(CollectionRef ch, + const pool_opts_t& opts) +{ + auto c = static_cast(ch.get()); + logger().debug("{} {}", __func__, c->get_cid()); + c->pool_opts = opts; + return seastar::now(); +} + CyanStore::Shard::read_errorator::future CyanStore::Shard::read( CollectionRef ch, diff --git a/src/crimson/os/cyanstore/cyan_store.h b/src/crimson/os/cyanstore/cyan_store.h index 04df5c707a5..3258deb231e 100644 --- a/src/crimson/os/cyanstore/cyan_store.h +++ b/src/crimson/os/cyanstore/cyan_store.h @@ -88,6 +88,10 @@ public: seastar::future open_collection(const coll_t& cid) final; + seastar::future<> set_collection_opts( + CollectionRef c, + const pool_opts_t& opts) final; + seastar::future<> do_transaction_no_callbacks( CollectionRef ch, ceph::os::Transaction&& txn) final; @@ -202,6 +206,8 @@ public: seastar::future stat() const final; + seastar::future pool_statfs(int64_t pool_id) const final; + uuid_d get_fsid() const final; seastar::future<> write_meta(const std::string& key, diff --git a/src/crimson/os/futurized_store.h b/src/crimson/os/futurized_store.h index 8398a5289b2..95d0d9b2d29 100644 --- a/src/crimson/os/futurized_store.h +++ b/src/crimson/os/futurized_store.h @@ -102,6 +102,9 @@ public: virtual seastar::future open_collection(const coll_t& cid) = 0; + virtual seastar::future<> set_collection_opts(CollectionRef c, + const pool_opts_t& opts) = 0; + protected: virtual seastar::future<> do_transaction_no_callbacks( CollectionRef ch, @@ -181,6 +184,8 @@ public: virtual seastar::future stat() const = 0; + virtual seastar::future pool_statfs(int64_t pool_id) const = 0; + virtual uuid_d get_fsid() const = 0; virtual seastar::future<> write_meta(const std::string& key, diff --git a/src/crimson/os/seastore/seastore.cc b/src/crimson/os/seastore/seastore.cc index e29fd4c0ea6..953f935e4d5 100644 --- a/src/crimson/os/seastore/seastore.cc +++ b/src/crimson/os/seastore/seastore.cc @@ -566,6 +566,12 @@ seastar::future SeaStore::stat() const }); } +seastar::future SeaStore::pool_statfs(int64_t pool_id) const +{ + //TODO + return SeaStore::stat(); +} + TransactionManager::read_extent_iertr::future> SeaStore::Shard::get_coll_bits(CollectionRef ch, Transaction &t) const { @@ -779,6 +785,14 @@ SeaStore::Shard::open_collection(const coll_t& cid) }); } +seastar::future<> +SeaStore::Shard::set_collection_opts(CollectionRef c, + const pool_opts_t& opts) +{ + //TODO + return seastar::now(); +} + seastar::future> SeaStore::Shard::list_collections() { diff --git a/src/crimson/os/seastore/seastore.h b/src/crimson/os/seastore/seastore.h index 585ce735dd2..b276d0506d5 100644 --- a/src/crimson/os/seastore/seastore.h +++ b/src/crimson/os/seastore/seastore.h @@ -158,6 +158,8 @@ public: seastar::future create_new_collection(const coll_t& cid) final; seastar::future open_collection(const coll_t& cid) final; + seastar::future<> set_collection_opts(CollectionRef c, + const pool_opts_t& opts) final; seastar::future<> do_transaction_no_callbacks( CollectionRef ch, @@ -491,6 +493,7 @@ public: mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) final; seastar::future stat() const final; + seastar::future pool_statfs(int64_t pool_id) const final; uuid_d get_fsid() const final { ceph_assert(seastar::this_shard_id() == primary_core); diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 939fbc59beb..77dfbd4b950 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -934,13 +934,36 @@ seastar::future OSD::get_stats() ).then([this, m=std::move(m)](auto &&stats) mutable { min_last_epoch_clean = osdmap->get_epoch(); min_last_epoch_clean_pgs.clear(); + std::set pool_set; for (auto [pgid, stat] : stats) { min_last_epoch_clean = std::min(min_last_epoch_clean, stat.get_effective_last_epoch_clean()); min_last_epoch_clean_pgs.push_back(pgid); + int64_t pool_id = pgid.pool(); + pool_set.emplace(pool_id); } m->pg_stat = std::move(stats); - return seastar::make_ready_future(std::move(m)); + return std::make_pair(pool_set, std::move(m)); + }).then([this] (auto message) mutable { + std::map pool_stat; + auto pool_set = message.first; + auto m = std::move(message.second); + return seastar::do_with(std::move(m), + pool_stat, + pool_set, [this] (auto &&msg, + auto &pool_stat, + auto &pool_set) { + return seastar::do_for_each(pool_set, [this, &pool_stat] + (auto& pool_id) { + return store.pool_statfs(pool_id).then([pool_id, &pool_stat]( + store_statfs_t st) mutable { + pool_stat[pool_id] = st; + }); + }).then([&pool_stat, msg=std::move(msg)] () mutable { + msg->pool_stat = std::move(pool_stat); + return seastar::make_ready_future(std::move(msg)); + }); + }); }); } diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index 8c7dd32f19b..9ee8e12312b 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -663,6 +663,11 @@ seastar::future<> PG::read_state(crimson::os::FuturizedStore::Shard* store) PeeringState::Initialize()); return seastar::now(); + }).then([this, store]() { + logger().debug("{} setting collection options", __func__); + return store->set_collection_opts( + coll_ref, + get_pgpool().info.opts); }); } @@ -723,6 +728,16 @@ seastar::future<> PG::handle_initialize(PeeringCtx &rctx) }); } +void PG::init_collection_pool_opts() +{ + std::ignore = shard_services.get_store().set_collection_opts(coll_ref, get_pgpool().info.opts); +} + +void PG::on_pool_change() +{ + init_collection_pool_opts(); +} + void PG::print(ostream& out) const { diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 0552d49f2ad..062233c0334 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -311,9 +311,8 @@ public: unsigned get_target_pg_log_entries() const final; - void on_pool_change() final { - // Not needed yet - } + void init_collection_pool_opts(); + void on_pool_change(); void on_role_change() final { // Not needed yet }