Skip to content

Commit 5630e76

Browse files
authored
Merge pull request ceph#56277 from amathuria/wip-amat-crimson-fix-pool-compression
crimson: Add support for pool compression Reviewed-by: Samuel Just <[email protected]> Reviewed-by: chunmei-liu <[email protected]>
2 parents 0196c19 + ba4f62c commit 5630e76

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
@@ -954,13 +954,36 @@ seastar::future<MessageURef> OSD::get_stats()
954954
).then([this, m=std::move(m)](auto &&stats) mutable {
955955
min_last_epoch_clean = osdmap->get_epoch();
956956
min_last_epoch_clean_pgs.clear();
957+
std::set<int64_t> pool_set;
957958
for (auto [pgid, stat] : stats) {
958959
min_last_epoch_clean = std::min(min_last_epoch_clean,
959960
stat.get_effective_last_epoch_clean());
960961
min_last_epoch_clean_pgs.push_back(pgid);
962+
int64_t pool_id = pgid.pool();
963+
pool_set.emplace(pool_id);
961964
}
962965
m->pg_stat = std::move(stats);
963-
return seastar::make_ready_future<MessageURef>(std::move(m));
966+
return std::make_pair(pool_set, std::move(m));
967+
}).then([this] (auto message) mutable {
968+
std::map<int64_t, store_statfs_t> pool_stat;
969+
auto pool_set = message.first;
970+
auto m = std::move(message.second);
971+
return seastar::do_with(std::move(m),
972+
pool_stat,
973+
pool_set, [this] (auto &&msg,
974+
auto &pool_stat,
975+
auto &pool_set) {
976+
return seastar::do_for_each(pool_set, [this, &pool_stat]
977+
(auto& pool_id) {
978+
return store.pool_statfs(pool_id).then([pool_id, &pool_stat](
979+
store_statfs_t st) mutable {
980+
pool_stat[pool_id] = st;
981+
});
982+
}).then([&pool_stat, msg=std::move(msg)] () mutable {
983+
msg->pool_stat = std::move(pool_stat);
984+
return seastar::make_ready_future<MessageURef>(std::move(msg));
985+
});
986+
});
964987
});
965988
}
966989

src/crimson/osd/pg.cc

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

674674
return seastar::now();
675+
}).then([this, store]() {
676+
logger().debug("{} setting collection options", __func__);
677+
return store->set_collection_opts(
678+
coll_ref,
679+
get_pgpool().info.opts);
675680
});
676681
}
677682

@@ -732,6 +737,16 @@ seastar::future<> PG::handle_initialize(PeeringCtx &rctx)
732737
});
733738
}
734739

740+
void PG::init_collection_pool_opts()
741+
{
742+
std::ignore = shard_services.get_store().set_collection_opts(coll_ref, get_pgpool().info.opts);
743+
}
744+
745+
void PG::on_pool_change()
746+
{
747+
init_collection_pool_opts();
748+
}
749+
735750

736751
void PG::print(ostream& out) const
737752
{

0 commit comments

Comments
 (0)