Skip to content

Commit ba4f62c

Browse files
committed
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 <[email protected]>
1 parent 90760c8 commit ba4f62c

File tree

11 files changed

+119
-4
lines changed

11 files changed

+119
-4
lines changed

src/crimson/os/alienstore/alien_store.cc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,21 @@ seastar::future<std::vector<coll_core_t>> AlienStore::list_collections()
294294
});
295295
}
296296

297+
seastar::future<> AlienStore::set_collection_opts(CollectionRef ch,
298+
const pool_opts_t& opts)
299+
{
300+
logger().debug("{}", __func__);
301+
assert(tp);
302+
303+
return tp->submit(ch->get_cid().hash_to_shard(tp->size()), [=, this] {
304+
auto c = static_cast<AlienCollection*>(ch.get());
305+
return store->set_collection_opts(c->collection, opts);
306+
}).then([] (int r) {
307+
assert(r==0);
308+
return seastar::now();
309+
});
310+
}
311+
297312
AlienStore::read_errorator::future<ceph::bufferlist>
298313
AlienStore::read(CollectionRef ch,
299314
const ghobject_t& oid,
@@ -557,6 +572,21 @@ seastar::future<store_statfs_t> AlienStore::stat() const
557572
});
558573
}
559574

575+
seastar::future<store_statfs_t> AlienStore::pool_statfs(int64_t pool_id) const
576+
{
577+
logger().info("{}", __func__);
578+
assert(tp);
579+
return do_with_op_gate(store_statfs_t{}, [this, pool_id] (store_statfs_t &st) {
580+
return tp->submit([this, pool_id, &st]{
581+
bool per_pool_omap_stats = false;
582+
return store->pool_statfs(pool_id, &st, &per_pool_omap_stats);
583+
}).then([&st] (int r) {
584+
assert(r==0);
585+
return seastar::make_ready_future<store_statfs_t>(std::move(st));
586+
});
587+
});
588+
}
589+
560590
unsigned AlienStore::get_max_attr_name_length() const
561591
{
562592
logger().info("{}", __func__);

src/crimson/os/alienstore/alien_store.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class AlienStore final : public FuturizedStore,
7575
seastar::future<CollectionRef> create_new_collection(const coll_t& cid) final;
7676
seastar::future<CollectionRef> open_collection(const coll_t& cid) final;
7777
seastar::future<std::vector<coll_core_t>> list_collections() final;
78+
seastar::future<> set_collection_opts(CollectionRef c,
79+
const pool_opts_t& opts) final;
7880

7981
seastar::future<> do_transaction_no_callbacks(
8082
CollectionRef c,
@@ -90,6 +92,7 @@ class AlienStore final : public FuturizedStore,
9092
const std::string& key) final;
9193
uuid_d get_fsid() const final;
9294
seastar::future<store_statfs_t> stat() const final;
95+
seastar::future<store_statfs_t> pool_statfs(int64_t pool_id) const final;
9396
unsigned get_max_attr_name_length() const final;
9497
seastar::future<struct stat> stat(
9598
CollectionRef,

src/crimson/os/cyanstore/cyan_collection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ struct Collection final : public FuturizedCollection {
3636
std::map<std::string,bufferptr> xattr;
3737
bool exists = true;
3838

39+
pool_opts_t pool_opts;
40+
3941
Collection(const coll_t& c);
4042
~Collection() final;
4143

src/crimson/os/cyanstore/cyan_store.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ seastar::future<store_statfs_t> CyanStore::stat() const
7171
});
7272
}
7373

74+
seastar::future<store_statfs_t> CyanStore::pool_statfs(int64_t pool_id) const
75+
{
76+
return stat();
77+
}
78+
7479

7580
CyanStore::mkfs_ertr::future<> CyanStore::mkfs(uuid_d new_osd_fsid)
7681
{
@@ -258,6 +263,16 @@ CyanStore::Shard::exists(
258263
return base_errorator::make_ready_future<bool>(true);
259264
}
260265

266+
seastar::future<>
267+
CyanStore::Shard::set_collection_opts(CollectionRef ch,
268+
const pool_opts_t& opts)
269+
{
270+
auto c = static_cast<Collection*>(ch.get());
271+
logger().debug("{} {}", __func__, c->get_cid());
272+
c->pool_opts = opts;
273+
return seastar::now();
274+
}
275+
261276
CyanStore::Shard::read_errorator::future<ceph::bufferlist>
262277
CyanStore::Shard::read(
263278
CollectionRef ch,

src/crimson/os/cyanstore/cyan_store.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ class CyanStore final : public FuturizedStore {
8888

8989
seastar::future<CollectionRef> open_collection(const coll_t& cid) final;
9090

91+
seastar::future<> set_collection_opts(
92+
CollectionRef c,
93+
const pool_opts_t& opts) final;
94+
9195
seastar::future<> do_transaction_no_callbacks(
9296
CollectionRef ch,
9397
ceph::os::Transaction&& txn) final;
@@ -202,6 +206,8 @@ class CyanStore final : public FuturizedStore {
202206

203207
seastar::future<store_statfs_t> stat() const final;
204208

209+
seastar::future<store_statfs_t> pool_statfs(int64_t pool_id) const final;
210+
205211
uuid_d get_fsid() const final;
206212

207213
seastar::future<> write_meta(const std::string& key,

src/crimson/os/futurized_store.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ class FuturizedStore {
102102

103103
virtual seastar::future<CollectionRef> open_collection(const coll_t& cid) = 0;
104104

105+
virtual seastar::future<> set_collection_opts(CollectionRef c,
106+
const pool_opts_t& opts) = 0;
107+
105108
protected:
106109
virtual seastar::future<> do_transaction_no_callbacks(
107110
CollectionRef ch,
@@ -181,6 +184,8 @@ class FuturizedStore {
181184

182185
virtual seastar::future<store_statfs_t> stat() const = 0;
183186

187+
virtual seastar::future<store_statfs_t> pool_statfs(int64_t pool_id) const = 0;
188+
184189
virtual uuid_d get_fsid() const = 0;
185190

186191
virtual seastar::future<> write_meta(const std::string& key,

src/crimson/os/seastore/seastore.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,12 @@ seastar::future<store_statfs_t> SeaStore::stat() const
566566
});
567567
}
568568

569+
seastar::future<store_statfs_t> SeaStore::pool_statfs(int64_t pool_id) const
570+
{
571+
//TODO
572+
return SeaStore::stat();
573+
}
574+
569575
TransactionManager::read_extent_iertr::future<std::optional<unsigned>>
570576
SeaStore::Shard::get_coll_bits(CollectionRef ch, Transaction &t) const
571577
{
@@ -779,6 +785,14 @@ SeaStore::Shard::open_collection(const coll_t& cid)
779785
});
780786
}
781787

788+
seastar::future<>
789+
SeaStore::Shard::set_collection_opts(CollectionRef c,
790+
const pool_opts_t& opts)
791+
{
792+
//TODO
793+
return seastar::now();
794+
}
795+
782796
seastar::future<std::vector<coll_core_t>>
783797
SeaStore::Shard::list_collections()
784798
{

src/crimson/os/seastore/seastore.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ class SeaStore final : public FuturizedStore {
158158

159159
seastar::future<CollectionRef> create_new_collection(const coll_t& cid) final;
160160
seastar::future<CollectionRef> open_collection(const coll_t& cid) final;
161+
seastar::future<> set_collection_opts(CollectionRef c,
162+
const pool_opts_t& opts) final;
161163

162164
seastar::future<> do_transaction_no_callbacks(
163165
CollectionRef ch,
@@ -491,6 +493,7 @@ class SeaStore final : public FuturizedStore {
491493

492494
mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) final;
493495
seastar::future<store_statfs_t> stat() const final;
496+
seastar::future<store_statfs_t> pool_statfs(int64_t pool_id) const final;
494497

495498
uuid_d get_fsid() const final {
496499
ceph_assert(seastar::this_shard_id() == primary_core);

src/crimson/osd/osd.cc

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,13 +934,36 @@ seastar::future<MessageURef> OSD::get_stats()
934934
).then([this, m=std::move(m)](auto &&stats) mutable {
935935
min_last_epoch_clean = osdmap->get_epoch();
936936
min_last_epoch_clean_pgs.clear();
937+
std::set<int64_t> pool_set;
937938
for (auto [pgid, stat] : stats) {
938939
min_last_epoch_clean = std::min(min_last_epoch_clean,
939940
stat.get_effective_last_epoch_clean());
940941
min_last_epoch_clean_pgs.push_back(pgid);
942+
int64_t pool_id = pgid.pool();
943+
pool_set.emplace(pool_id);
941944
}
942945
m->pg_stat = std::move(stats);
943-
return seastar::make_ready_future<MessageURef>(std::move(m));
946+
return std::make_pair(pool_set, std::move(m));
947+
}).then([this] (auto message) mutable {
948+
std::map<int64_t, store_statfs_t> pool_stat;
949+
auto pool_set = message.first;
950+
auto m = std::move(message.second);
951+
return seastar::do_with(std::move(m),
952+
pool_stat,
953+
pool_set, [this] (auto &&msg,
954+
auto &pool_stat,
955+
auto &pool_set) {
956+
return seastar::do_for_each(pool_set, [this, &pool_stat]
957+
(auto& pool_id) {
958+
return store.pool_statfs(pool_id).then([pool_id, &pool_stat](
959+
store_statfs_t st) mutable {
960+
pool_stat[pool_id] = st;
961+
});
962+
}).then([&pool_stat, msg=std::move(msg)] () mutable {
963+
msg->pool_stat = std::move(pool_stat);
964+
return seastar::make_ready_future<MessageURef>(std::move(msg));
965+
});
966+
});
944967
});
945968
}
946969

src/crimson/osd/pg.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,11 @@ seastar::future<> PG::read_state(crimson::os::FuturizedStore::Shard* store)
663663
PeeringState::Initialize());
664664

665665
return seastar::now();
666+
}).then([this, store]() {
667+
logger().debug("{} setting collection options", __func__);
668+
return store->set_collection_opts(
669+
coll_ref,
670+
get_pgpool().info.opts);
666671
});
667672
}
668673

@@ -723,6 +728,16 @@ seastar::future<> PG::handle_initialize(PeeringCtx &rctx)
723728
});
724729
}
725730

731+
void PG::init_collection_pool_opts()
732+
{
733+
std::ignore = shard_services.get_store().set_collection_opts(coll_ref, get_pgpool().info.opts);
734+
}
735+
736+
void PG::on_pool_change()
737+
{
738+
init_collection_pool_opts();
739+
}
740+
726741

727742
void PG::print(ostream& out) const
728743
{

0 commit comments

Comments
 (0)