Skip to content

Commit df60540

Browse files
committed
osd: Install stub extent cache in OSD.
The extent cache in new EC is a per OSD-shard cache will caches reads used by read-modify-write to improve performance of sequential IO. We want to provide a single PR with all of EC in it, so this PR provides a non-functional stub to allow all the non-EC code to be installed. Signed-off-by: Alex Ainscow <[email protected]>
1 parent f3966ca commit df60540

File tree

10 files changed

+51
-12
lines changed

10 files changed

+51
-12
lines changed

src/osd/ECBackend.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ ECBackend::ECBackend(
128128
CephContext *cct,
129129
ErasureCodeInterfaceRef ec_impl,
130130
uint64_t stripe_width,
131-
ECSwitch *s)
131+
ECSwitch *s,
132+
ECExtentCache::LRU &ignored)
132133
: parent(pg), cct(cct), switcher(s),
133134
read_pipeline(cct, ec_impl, this->sinfo, get_parent()->get_eclistener()),
134135
rmw_pipeline(cct, ec_impl, this->sinfo, get_parent()->get_eclistener(), *this),

src/osd/ECBackend.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ class ECBackend : public ECCommon {
433433
CephContext *cct,
434434
ceph::ErasureCodeInterfaceRef ec_impl,
435435
uint64_t stripe_width,
436-
ECSwitch *s);
436+
ECSwitch *s,
437+
ECExtentCache::LRU &ignored);
437438

438439
int objects_get_attrs(
439440
const hobject_t &hoid,

src/osd/ECExtentCache.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
3+
// Temporary stubs
4+
class ECExtentCache {
5+
public:
6+
class LRU {
7+
public:
8+
LRU(uint64_t) {}
9+
};
10+
};

src/osd/ECSwitch.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ class ECSwitch : public PGBackend
4040
ObjectStore *store,
4141
CephContext *cct,
4242
ceph::ErasureCodeInterfaceRef ec_impl,
43-
uint64_t stripe_width) :
43+
uint64_t stripe_width,
44+
ECExtentCache::LRU &lru) :
4445
PGBackend(cct, pg, store, coll, ch),
4546
legacy(pg, cct, ec_impl, stripe_width, this),
46-
optimized(pg, cct, ec_impl, stripe_width, this),
47+
optimized(pg, cct, ec_impl, stripe_width, this, lru),
4748
is_optimized_actual(get_parent()->get_pool().allows_ecoptimizations()) {}
4849

4950
bool is_optimized() const

src/osd/OSD.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5220,7 +5220,7 @@ PG* OSD::_make_pg(
52205220
PG *pg;
52215221
if (pi.type == pg_pool_t::TYPE_REPLICATED ||
52225222
pi.type == pg_pool_t::TYPE_ERASURE)
5223-
pg = new PrimaryLogPG(&service, createmap, pool, ec_profile, pgid);
5223+
pg = new PrimaryLogPG(&service, createmap, pool, ec_profile, pgid, lookup_ec_extent_cache_lru(pgid));
52245224
else
52255225
ceph_abort();
52265226
return pg;
@@ -5307,6 +5307,13 @@ bool OSD::try_finish_pg_delete(PG *pg, unsigned old_pg_num)
53075307
return true;
53085308
}
53095309

5310+
ECExtentCache::LRU &OSD::lookup_ec_extent_cache_lru(spg_t pgid) const
5311+
{
5312+
uint32_t shard_index = pgid.hash_to_shard(num_shards);
5313+
auto sdata = shards[shard_index];
5314+
return sdata->ec_extent_cache_lru;
5315+
}
5316+
53105317
PGRef OSD::_lookup_pg(spg_t pgid)
53115318
{
53125319
uint32_t shard_index = pgid.hash_to_shard(num_shards);
@@ -11066,7 +11073,9 @@ OSDShard::OSDShard(
1106611073
scheduler(ceph::osd::scheduler::make_scheduler(
1106711074
cct, osd->whoami, osd->num_shards, id, osd->store->is_rotational(),
1106811075
osd->store->get_type(), osd_op_queue, osd_op_queue_cut_off, osd->monc)),
11069-
context_queue(sdata_wait_lock, sdata_cond)
11076+
context_queue(sdata_wait_lock, sdata_cond),
11077+
ec_extent_cache_lru(cct->_conf.get_val<uint64_t>(
11078+
"ec_extent_cache_size"))
1107011079
{
1107111080
dout(0) << "using op scheduler " << *scheduler << dendl;
1107211081
}

src/osd/OSD.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,11 @@ struct OSDShard {
10211021

10221022
ContextQueue context_queue;
10231023

1024+
//This is an extent cache for the erasure coding. Specifically, this acts as
1025+
//a least-recently-used cache invalidator, allowing for cache shards to last
1026+
//longer than the most recent IO in each object.
1027+
ECExtentCache::LRU ec_extent_cache_lru;
1028+
10241029
void _attach_pg(OSDShardPGSlot *slot, PG *pg);
10251030
void _detach_pg(OSDShardPGSlot *slot);
10261031

@@ -1206,6 +1211,12 @@ class OSD : public Dispatcher,
12061211
*/
12071212
static CompatSet get_osd_compat_set();
12081213

1214+
/**
1215+
* lookup_ec_extent_cache_lru()
1216+
* @param pgid -
1217+
* @return extent cache for LRU
1218+
*/
1219+
ECExtentCache::LRU &lookup_ec_extent_cache_lru(spg_t pgid) const;
12091220

12101221
private:
12111222
class C_Tick;

src/osd/PGBackend.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,8 @@ PGBackend *PGBackend::build_pg_backend(
739739
coll_t coll,
740740
ObjectStore::CollectionHandle &ch,
741741
ObjectStore *store,
742-
CephContext *cct)
742+
CephContext *cct,
743+
ECExtentCache::LRU &ec_extent_cache_lru)
743744
{
744745
ErasureCodeProfile ec_profile = profile;
745746
switch (pool.type) {
@@ -763,7 +764,8 @@ PGBackend *PGBackend::build_pg_backend(
763764
store,
764765
cct,
765766
ec_impl,
766-
pool.stripe_width);
767+
pool.stripe_width,
768+
ec_extent_cache_lru);
767769
}
768770
default:
769771
ceph_abort();

src/osd/PGBackend.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "ECListener.h"
2222
#include "ECTypes.h"
23+
#include "ECExtentCache.h"
2324
#include "osd_types.h"
2425
#include "pg_features.h"
2526
#include "common/intrusive_timer.h"
@@ -618,7 +619,8 @@ typedef std::shared_ptr<const OSDMap> OSDMapRef;
618619
coll_t coll,
619620
ObjectStore::CollectionHandle &ch,
620621
ObjectStore *store,
621-
CephContext *cct);
622+
CephContext *cct,
623+
ECExtentCache::LRU &ec_extent_cache_lru);
622624
};
623625

624626
#endif

src/osd/PrimaryLogPG.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,11 +1772,12 @@ void PrimaryLogPG::release_object_locks(
17721772

17731773
PrimaryLogPG::PrimaryLogPG(OSDService *o, OSDMapRef curmap,
17741774
const PGPool &_pool,
1775-
const map<string,string>& ec_profile, spg_t p) :
1775+
const map<string,string>& ec_profile, spg_t p,
1776+
ECExtentCache::LRU &ec_extent_cache_lru) :
17761777
PG(o, curmap, _pool, p),
17771778
pgbackend(
17781779
PGBackend::build_pg_backend(
1779-
_pool.info, ec_profile, this, coll_t(p), ch, o->store, cct)),
1780+
_pool.info, ec_profile, this, coll_t(p), ch, o->store, cct, ec_extent_cache_lru)),
17801781
object_contexts(o->cct, o->cct->_conf->osd_pg_object_context_cache_count),
17811782
new_backfill(false),
17821783
temp_seq(0),

src/osd/PrimaryLogPG.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,8 @@ class PrimaryLogPG : public PG,
15281528
PrimaryLogPG(OSDService *o, OSDMapRef curmap,
15291529
const PGPool &_pool,
15301530
const std::map<std::string,std::string>& ec_profile,
1531-
spg_t p);
1531+
spg_t p,
1532+
ECExtentCache::LRU &ec_extent_cache_lru);
15321533
~PrimaryLogPG() override;
15331534

15341535
void do_command(

0 commit comments

Comments
 (0)