From: Aishwarya Mathuria Date: Wed, 31 Jan 2024 09:20:44 +0000 (+0000) Subject: crimson: Add support for pool compression X-Git-Tag: v19.1.1~345^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=362711ba11be0b477bd61fa9f4bb2f490ab0ac03;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 (cherry picked from commit ba4f62c49ecee26d98100bb5cdb15ecfe212f0be) --- diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index bfa8dbf42e79d..2139a2dd25856 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 910bb153dcb48..ad25d56c18fed 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 068e427d8df2b..ab021589d8436 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 df68e8bd20f93..7b945e5aa1502 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 04df5c707a566..3258deb231e89 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 8398a5289b2dc..95d0d9b2d2995 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 ac38a978e0db6..4a191e25bc59b 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 585ce735dd284..b276d0506d5bc 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 939fbc59beb8c..77dfbd4b95028 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 5ab3bb5a30267..b95c67919331f 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -672,6 +672,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); }); } @@ -732,6 +737,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 a81374be6bc6f..4ac010bb417b1 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -309,9 +309,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 }