]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: Add support for pool compression 57505/head
authorAishwarya Mathuria <amathuri@redhat.com>
Wed, 31 Jan 2024 09:20:44 +0000 (09:20 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Thu, 16 May 2024 11:44:38 +0000 (14:44 +0300)
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 <amathuri@redhat.com>
(cherry picked from commit ba4f62c49ecee26d98100bb5cdb15ecfe212f0be)

src/crimson/os/alienstore/alien_store.cc
src/crimson/os/alienstore/alien_store.h
src/crimson/os/cyanstore/cyan_collection.h
src/crimson/os/cyanstore/cyan_store.cc
src/crimson/os/cyanstore/cyan_store.h
src/crimson/os/futurized_store.h
src/crimson/os/seastore/seastore.cc
src/crimson/os/seastore/seastore.h
src/crimson/osd/osd.cc
src/crimson/osd/pg.cc
src/crimson/osd/pg.h

index bfa8dbf42e79dbdaa12d501f7a24b1eb3f88f258..2139a2dd25856d2bd7d315d0c2a473e2e4483f27 100644 (file)
@@ -294,6 +294,21 @@ seastar::future<std::vector<coll_core_t>> 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<AlienCollection*>(ch.get());
+    return store->set_collection_opts(c->collection, opts);
+  }).then([] (int r) {
+    assert(r==0);
+    return seastar::now();
+  });
+}
+
 AlienStore::read_errorator::future<ceph::bufferlist>
 AlienStore::read(CollectionRef ch,
                  const ghobject_t& oid,
@@ -557,6 +572,21 @@ seastar::future<store_statfs_t> AlienStore::stat() const
   });
 }
 
+seastar::future<store_statfs_t> 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<store_statfs_t>(std::move(st));
+    });
+  });
+}
+
 unsigned AlienStore::get_max_attr_name_length() const
 {
   logger().info("{}", __func__);
index 910bb153dcb486fa5bd87672581ed944bcb9e3c1..ad25d56c18fedd20db85145ff608fa7242baeb37 100644 (file)
@@ -75,6 +75,8 @@ public:
   seastar::future<CollectionRef> create_new_collection(const coll_t& cid) final;
   seastar::future<CollectionRef> open_collection(const coll_t& cid) final;
   seastar::future<std::vector<coll_core_t>> 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<store_statfs_t> stat() const final;
+  seastar::future<store_statfs_t> pool_statfs(int64_t pool_id) const final;
   unsigned get_max_attr_name_length() const final;
   seastar::future<struct stat> stat(
     CollectionRef,
index 068e427d8df2b6a2d267325111ea3c01d8e99251..ab021589d8436023ae39694fa0ffb975c701a913 100644 (file)
@@ -36,6 +36,8 @@ struct Collection final : public FuturizedCollection {
   std::map<std::string,bufferptr> xattr;
   bool exists = true;
 
+  pool_opts_t pool_opts;
+
   Collection(const coll_t& c);
   ~Collection() final;
 
index df68e8bd20f93a771130de1feb50ad0d175b8f72..7b945e5aa150290e9e5b64c78ab065dbfbc30bca 100644 (file)
@@ -71,6 +71,11 @@ seastar::future<store_statfs_t> CyanStore::stat() const
   });
 }
 
+seastar::future<store_statfs_t> 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<bool>(true);
 }
 
+seastar::future<>
+CyanStore::Shard::set_collection_opts(CollectionRef ch,
+                                      const pool_opts_t& opts)
+{
+  auto c = static_cast<Collection*>(ch.get());
+  logger().debug("{} {}", __func__, c->get_cid());
+  c->pool_opts = opts;
+  return seastar::now();
+}
+
 CyanStore::Shard::read_errorator::future<ceph::bufferlist>
 CyanStore::Shard::read(
   CollectionRef ch,
index 04df5c707a566d6b44db4e0b081361fe657f5419..3258deb231e89394a6b9fc0f1134533e375e7b13 100644 (file)
@@ -88,6 +88,10 @@ public:
 
     seastar::future<CollectionRef> 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<store_statfs_t> stat() const final;
 
+  seastar::future<store_statfs_t> pool_statfs(int64_t pool_id) const final;
+
   uuid_d get_fsid() const final;
 
   seastar::future<> write_meta(const std::string& key,
index 8398a5289b2dc0b6f4ca0f41e77ee2d2bd1ac68e..95d0d9b2d2995d00e26798d772fcb5046432807c 100644 (file)
@@ -102,6 +102,9 @@ public:
 
     virtual seastar::future<CollectionRef> 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<store_statfs_t> stat() const = 0;
 
+  virtual seastar::future<store_statfs_t> pool_statfs(int64_t pool_id) const = 0;
+
   virtual uuid_d get_fsid() const  = 0;
 
   virtual seastar::future<> write_meta(const std::string& key,
index ac38a978e0db6e7e58424dade9a75f8c9feea952..4a191e25bc59ba602d59ed11f49156adbd7e6d1b 100644 (file)
@@ -566,6 +566,12 @@ seastar::future<store_statfs_t> SeaStore::stat() const
   });
 }
 
+seastar::future<store_statfs_t> SeaStore::pool_statfs(int64_t pool_id) const
+{
+   //TODO
+   return SeaStore::stat();
+}
+
 TransactionManager::read_extent_iertr::future<std::optional<unsigned>>
 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<std::vector<coll_core_t>>
 SeaStore::Shard::list_collections()
 {
index 585ce735dd284997e0f3bb25bf72f8d89cc5e21f..b276d0506d5bc5cd34809b7fd62ea981a4b5a2ba 100644 (file)
@@ -158,6 +158,8 @@ public:
 
     seastar::future<CollectionRef> create_new_collection(const coll_t& cid) final;
     seastar::future<CollectionRef> 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<store_statfs_t> stat() const final;
+  seastar::future<store_statfs_t> pool_statfs(int64_t pool_id) const final;
 
   uuid_d get_fsid() const final {
     ceph_assert(seastar::this_shard_id() == primary_core);
index 939fbc59beb8cd6f820831550944bfba9dfcd2f2..77dfbd4b95028dc108a97e88d5c52ad03e151677 100644 (file)
@@ -934,13 +934,36 @@ seastar::future<MessageURef> 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<int64_t> 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<MessageURef>(std::move(m));
+    return std::make_pair(pool_set, std::move(m));
+  }).then([this] (auto message) mutable {
+    std::map<int64_t, store_statfs_t> 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<MessageURef>(std::move(msg));
+      });
+    });
   });
 }
 
index 5ab3bb5a302675db35beabb3f15c9d299981e356..b95c67919331ff27352b162808bebff2db691f18 100644 (file)
@@ -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
 {
index a81374be6bc6f1c5d9c69235963afda88089f8b6..4ac010bb417b1b46e98175c0b7146eed3b32ba92 100644 (file)
@@ -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
   }