Skip to content

Commit 3375baa

Browse files
authored
Merge pull request ceph#62556 from aainscow/ec_pr_and_prereqs
osd: Optimised EC Reviewed-by: Radoslaw Zarzynski <[email protected]> Reviewed-by: Laura Flores <[email protected]>
2 parents 4fe79d9 + 9e2841a commit 3375baa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+10069
-4510
lines changed

src/common/bitset_set.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,9 @@ class bitset_set {
260260

261261
/** @return true if the container contains Key k. */
262262
bool contains(KeyT k) const {
263-
ceph_assert(unsigned_cast(k) < max_bits);
264-
ceph_assert(int(k) >= 0);
263+
if (unsigned_cast(k) >= max_bits) {
264+
return false;
265+
}
265266
return (words[int(k) / bits_per_uint64_t]
266267
& 1ULL << (int(k) % bits_per_uint64_t));
267268
}

src/common/interval_map.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ class interval_map {
209209
}
210210
return ret;
211211
}
212-
template<bool strict = true>
213-
void to_interval_set(interval_set<K, C, strict> &set) const {
212+
template<template<typename, typename, typename ...> class ISC = std::map, bool strict = true>
213+
void to_interval_set(interval_set<K, ISC, strict> &set) const {
214214
for (auto &&i: *this) {
215215
set.insert(i.get_off(), i.get_len());
216216
}

src/common/options/global.yaml.in

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,6 +2703,15 @@ options:
27032703
services:
27042704
- mon
27052705
with_legacy: true
2706+
- name: osd_pool_default_flag_ec_optimizations
2707+
type: bool
2708+
level: advanced
2709+
desc: Control whether to create new erasure coded pools with EC optimizations turned on by default.
2710+
fmt_desc: Set the ``allow_ec_optimizations`` flag on new erasure coded pools.
2711+
default: false
2712+
services:
2713+
- mon
2714+
with_legacy: true
27062715
- name: osd_pool_default_hit_set_bloom_fpp
27072716
type: float
27082717
level: advanced
@@ -6765,3 +6774,15 @@ options:
67656774
The format is ``{file}:{line} [, {file}:{line}]``
67666775
level: dev
67676776
with_legacy: false
6777+
- name: ec_extent_cache_size
6778+
type: uint
6779+
level: advanced
6780+
desc: Size of per-shard extent cache
6781+
default: 10485760
6782+
services:
6783+
- osd
6784+
- name: ec_pdw_write_mode
6785+
type: uint
6786+
level: dev
6787+
default: 0
6788+
desc: When EC writes should generate PDWs (development only) 0=optimal 1=never 2=when possible

src/crimson/osd/pg.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,10 @@ class PG : public boost::intrusive_ref_counter<
478478
void trim(const pg_log_entry_t &entry) override {
479479
// TODO
480480
}
481+
void partial_write(pg_info_t *info, const pg_log_entry_t &entry) override {
482+
// TODO
483+
ceph_assert(entry.written_shards.empty() && info->partial_writes_last_complete.empty());
484+
}
481485
};
482486
PGLog::LogEntryHandlerRef get_log_handler(
483487
ceph::os::Transaction &t) final {

src/crimson/osd/scrub/pg_scrubber.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ chunk_validation_policy_t PGScrubber::get_policy() const
145145
{
146146
return chunk_validation_policy_t{
147147
pg.get_primary(),
148-
std::nullopt /* stripe_info, populate when EC is implemented */,
149148
crimson::common::local_conf().get_val<Option::size_t>(
150149
"osd_max_object_size"),
151150
crimson::common::local_conf().get_val<std::string>(

src/crimson/osd/scrub/scrub_validator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
#include "common/config_proxy.h"
1010
#include "common/scrub_types.h"
1111
#include "crimson/common/log.h"
12-
#include "osd/ECUtil.h"
1312
#include "osd/osd_types.h"
1413

1514
namespace crimson::osd::scrub {
1615

1716
struct chunk_validation_policy_t {
1817
pg_shard_t primary;
19-
std::optional<ECUtil::stripe_info_t> stripe_info;
2018

2119
// osd_max_object_size
2220
size_t max_object_size;
@@ -31,11 +29,13 @@ struct chunk_validation_policy_t {
3129

3230

3331
bool is_ec() const {
34-
return !!stripe_info;
32+
// FIXME: See scrub_backend in classic for reference.
33+
return false;
3534
}
3635

3736
size_t logical_to_ondisk_size(size_t size) const {
38-
return stripe_info ? stripe_info->logical_to_next_chunk_offset(size) : size;
37+
// FIXME: See scrub_backend in classic for how to handle EC.
38+
return size;
3939
}
4040
};
4141

src/erasure-code/ErasureCodeInterface.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,10 @@ namespace ceph {
677677
* clay). Other plugins will not process the overhead of stub sub-chunks.
678678
*/
679679
FLAG_EC_PLUGIN_REQUIRE_SUB_CHUNKS = 1<<5,
680+
/* Optimized EC is supported only if this flag is set. All other flags
681+
* are irrelevant if this flag is false.
682+
*/
683+
FLAG_EC_PLUGIN_OPTIMIZED_SUPPORTED = 1<<6,
680684
};
681685
static const char *get_optimization_flag_name(const plugin_flags flag) {
682686
switch (flag) {
@@ -686,6 +690,7 @@ namespace ceph {
686690
case FLAG_EC_PLUGIN_ZERO_PADDING_OPTIMIZATION: return "zeropadding";
687691
case FLAG_EC_PLUGIN_PARITY_DELTA_OPTIMIZATION: return "paritydelta";
688692
case FLAG_EC_PLUGIN_REQUIRE_SUB_CHUNKS: return "requiresubchunks";
693+
case FLAG_EC_PLUGIN_OPTIMIZED_SUPPORTED: return "optimizedsupport";
689694
default: return "???";
690695
}
691696
}

src/erasure-code/isa/ErasureCodeIsa.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@
2626
#define CEPH_ERASURE_CODE_ISA_L_H
2727

2828
// -----------------------------------------------------------------------------
29+
#include <string_view>
2930
#include "erasure-code/ErasureCode.h"
3031
#include "ErasureCodeIsaTableCache.h"
3132
// -----------------------------------------------------------------------------
3233

34+
using namespace std::literals;
35+
3336
#define EC_ISA_ADDRESS_ALIGNMENT 32u
3437

3538
#define is_aligned(POINTER, BYTE_COUNT) \
@@ -51,6 +54,7 @@ class ErasureCodeIsa : public ceph::ErasureCode {
5154

5255
ErasureCodeIsaTableCache &tcache;
5356
const char *technique;
57+
uint64_t flags;
5458

5559
ErasureCodeIsa(const char *_technique,
5660
ErasureCodeIsaTableCache &_tcache) :
@@ -60,6 +64,15 @@ class ErasureCodeIsa : public ceph::ErasureCode {
6064
tcache(_tcache),
6165
technique(_technique)
6266
{
67+
flags = FLAG_EC_PLUGIN_PARTIAL_READ_OPTIMIZATION |
68+
FLAG_EC_PLUGIN_PARTIAL_WRITE_OPTIMIZATION |
69+
FLAG_EC_PLUGIN_ZERO_INPUT_ZERO_OUTPUT_OPTIMIZATION |
70+
FLAG_EC_PLUGIN_PARITY_DELTA_OPTIMIZATION;
71+
72+
if (technique == "reed_sol_van"sv ||
73+
technique == "default"sv) {
74+
flags |= FLAG_EC_PLUGIN_OPTIMIZED_SUPPORTED;
75+
}
6376
}
6477

6578

@@ -68,10 +81,7 @@ class ErasureCodeIsa : public ceph::ErasureCode {
6881
}
6982

7083
uint64_t get_supported_optimizations() const override {
71-
return FLAG_EC_PLUGIN_PARTIAL_READ_OPTIMIZATION |
72-
FLAG_EC_PLUGIN_PARTIAL_WRITE_OPTIMIZATION |
73-
FLAG_EC_PLUGIN_ZERO_INPUT_ZERO_OUTPUT_OPTIMIZATION |
74-
FLAG_EC_PLUGIN_PARITY_DELTA_OPTIMIZATION;
84+
return flags;
7585
}
7686

7787
unsigned int

src/erasure-code/jerasure/ErasureCodeJerasure.h

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
#ifndef CEPH_ERASURE_CODE_JERASURE_H
1919
#define CEPH_ERASURE_CODE_JERASURE_H
2020

21+
#include <string_view>
22+
2123
#include "erasure-code/ErasureCode.h"
2224

25+
using namespace std::literals;
26+
2327
class ErasureCodeJerasure : public ceph::ErasureCode {
2428
public:
2529
int k;
@@ -32,28 +36,33 @@ class ErasureCodeJerasure : public ceph::ErasureCode {
3236
std::string rule_root;
3337
std::string rule_failure_domain;
3438
bool per_chunk_alignment;
39+
uint64_t flags;
40+
41+
explicit ErasureCodeJerasure(const char *_technique)
42+
: k(0),
43+
DEFAULT_K("2"),
44+
m(0),
45+
DEFAULT_M("1"),
46+
w(0),
47+
DEFAULT_W("8"),
48+
technique(_technique),
49+
per_chunk_alignment(false) {
50+
flags = FLAG_EC_PLUGIN_PARTIAL_READ_OPTIMIZATION |
51+
FLAG_EC_PLUGIN_PARTIAL_WRITE_OPTIMIZATION |
52+
FLAG_EC_PLUGIN_ZERO_INPUT_ZERO_OUTPUT_OPTIMIZATION |
53+
FLAG_EC_PLUGIN_PARITY_DELTA_OPTIMIZATION;
3554

36-
explicit ErasureCodeJerasure(const char *_technique) :
37-
k(0),
38-
DEFAULT_K("2"),
39-
m(0),
40-
DEFAULT_M("1"),
41-
w(0),
42-
DEFAULT_W("8"),
43-
technique(_technique),
44-
per_chunk_alignment(false)
45-
{}
55+
if (technique == "reed_sol_van"sv) {
56+
flags |= FLAG_EC_PLUGIN_OPTIMIZED_SUPPORTED;
57+
}
58+
}
4659

4760
~ErasureCodeJerasure() override {}
4861

4962
uint64_t get_supported_optimizations() const override {
50-
return FLAG_EC_PLUGIN_PARTIAL_READ_OPTIMIZATION |
51-
FLAG_EC_PLUGIN_PARTIAL_WRITE_OPTIMIZATION |
52-
FLAG_EC_PLUGIN_ZERO_INPUT_ZERO_OUTPUT_OPTIMIZATION |
53-
FLAG_EC_PLUGIN_PARITY_DELTA_OPTIMIZATION;
63+
return flags;
5464
}
5565

56-
5766
unsigned int get_chunk_count() const override {
5867
return k + m;
5968
}

src/include/mempool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ namespace mempool {
178178
f(osdmap_mapping) \
179179
f(pgmap) \
180180
f(mds_co) \
181+
f(ec_extent_cache) \
181182
f(unittest_1) \
182183
f(unittest_2)
183184

0 commit comments

Comments
 (0)