Skip to content

Commit 31a2b10

Browse files
committed
osd: Add ECTypes and add ec_align_t to it
Move out the common types for new and old EC into ECTypes. These are mainly for use in interfaces, with ECUtils reerved for utilities. More will be added later. Signed-off-by: Alex Ainscow <[email protected]>
1 parent 482ec83 commit 31a2b10

File tree

9 files changed

+46
-30
lines changed

9 files changed

+46
-30
lines changed

src/osd/ECBackendL.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "messages/MOSDECSubOpRead.h"
2424
#include "messages/MOSDECSubOpReadReply.h"
2525
#include "ECMsgTypes.h"
26+
#include "ECTypes.h"
2627

2728
#include "PrimaryLogPG.h"
2829
#include "osd_tracer.h"
@@ -195,8 +196,8 @@ struct RecoveryMessages {
195196
const map<pg_shard_t, vector<pair<int, int>>> &need,
196197
bool attrs)
197198
{
198-
list<ECCommonL::ec_align_t> to_read;
199-
to_read.emplace_back(ECCommonL::ec_align_t{off, len, 0});
199+
list<ec_align_t> to_read;
200+
to_read.emplace_back(ec_align_t{off, len, 0});
200201
ceph_assert(!recovery_reads.count(hoid));
201202
want_to_read.insert(make_pair(hoid, std::move(_want_to_read)));
202203
recovery_reads.insert(
@@ -463,7 +464,7 @@ struct RecoveryReadCompleter : ECCommonL::ReadCompleter {
463464
void finish_single_request(
464465
const hobject_t &hoid,
465466
ECCommonL::read_result_t &res,
466-
list<ECCommonL::ec_align_t>,
467+
list<ec_align_t>,
467468
set<int> wanted_to_read) override
468469
{
469470
if (!(res.r == 0 && res.errors.empty())) {
@@ -1567,7 +1568,7 @@ int ECBackendL::objects_read_sync(
15671568

15681569
void ECBackendL::objects_read_async(
15691570
const hobject_t &hoid,
1570-
const list<pair<ECCommonL::ec_align_t,
1571+
const list<pair<ec_align_t,
15711572
pair<bufferlist*, Context*>>> &to_read,
15721573
Context *on_complete,
15731574
bool fast_read)
@@ -1599,14 +1600,14 @@ void ECBackendL::objects_read_async(
15991600
struct cb {
16001601
ECBackendL *ec;
16011602
hobject_t hoid;
1602-
list<pair<ECCommonL::ec_align_t,
1603+
list<pair<ec_align_t,
16031604
pair<bufferlist*, Context*> > > to_read;
16041605
unique_ptr<Context> on_complete;
16051606
cb(const cb&) = delete;
16061607
cb(cb &&) = default;
16071608
cb(ECBackendL *ec,
16081609
const hobject_t &hoid,
1609-
const list<pair<ECCommonL::ec_align_t,
1610+
const list<pair<ec_align_t,
16101611
pair<bufferlist*, Context*> > > &to_read,
16111612
Context *on_complete)
16121613
: ec(ec),
@@ -1680,7 +1681,7 @@ void ECBackendL::objects_read_async(
16801681

16811682
void ECBackendL::objects_read_and_reconstruct(
16821683
const map<hobject_t,
1683-
std::list<ECBackendL::ec_align_t>
1684+
std::list<ec_align_t>
16841685
> &reads,
16851686
bool fast_read,
16861687
GenContextURef<ECCommonL::ec_extents_t &&> &&func)

src/osd/ECBackendL.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ class ECBackendL : public PGBackend, public ECCommonL {
140140
* check_recovery_sources.
141141
*/
142142
void objects_read_and_reconstruct(
143-
const std::map<hobject_t, std::list<ECCommonL::ec_align_t>> &reads,
143+
const std::map<hobject_t, std::list<ec_align_t>> &reads,
144144
bool fast_read,
145145
GenContextURef<ECCommonL::ec_extents_t &&> &&func) override;
146146

147147
void objects_read_async(
148148
const hobject_t &hoid,
149-
const std::list<std::pair<ECCommonL::ec_align_t,
149+
const std::list<std::pair<ec_align_t,
150150
std::pair<ceph::buffer::list*, Context*>>> &to_read,
151151
Context *on_complete,
152152
bool fast_read = false) override;

src/osd/ECCommonL.cc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ ostream &operator<<(ostream &lhs, const ECCommonL::RMWPipeline::pipeline_state_t
7777
return lhs; // unreachable
7878
}
7979

80-
ostream &operator<<(ostream &lhs, const ECCommonL::ec_align_t &rhs)
81-
{
82-
return lhs << rhs.offset << ","
83-
<< rhs.size << ","
84-
<< rhs.flags;
85-
}
86-
8780
ostream &operator<<(ostream &lhs, const ECCommonL::ec_extent_t &rhs)
8881
{
8982
return lhs << rhs.err << ","
@@ -517,7 +510,7 @@ struct ClientReadCompleter : ECCommonL::ReadCompleter {
517510
void finish_single_request(
518511
const hobject_t &hoid,
519512
ECCommonL::read_result_t &res,
520-
list<ECCommonL::ec_align_t> to_read,
513+
list<ec_align_t> to_read,
521514
set<int> wanted_to_read) override
522515
{
523516
auto* cct = read_pipeline.cct;
@@ -606,7 +599,7 @@ static ostream& _prefix(std::ostream *_dout, ClientReadCompleter *read_completer
606599
}
607600

608601
void ECCommonL::ReadPipeline::objects_read_and_reconstruct(
609-
const map<hobject_t, std::list<ECCommonL::ec_align_t>> &reads,
602+
const map<hobject_t, std::list<ec_align_t>> &reads,
610603
bool fast_read,
611604
GenContextURef<ECCommonL::ec_extents_t &&> &&func)
612605
{

src/osd/ECCommonL.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "common/sharedptr_registry.hpp"
2222
#include "erasure-code/ErasureCodeInterface.h"
2323
#include "ECUtilL.h"
24+
#include "ECTypes.h"
2425
#if WITH_SEASTAR
2526
#include "ECExtentCacheL.h"
2627
#include "crimson/osd/object_context.h"
@@ -209,12 +210,6 @@ struct ECListener {
209210
};
210211

211212
struct ECCommonL {
212-
struct ec_align_t {
213-
uint64_t offset;
214-
uint64_t size;
215-
uint32_t flags;
216-
};
217-
friend std::ostream &operator<<(std::ostream &lhs, const ec_align_t &rhs);
218213

219214
struct ec_extent_t {
220215
int err;
@@ -285,7 +280,7 @@ struct ECCommonL {
285280
virtual void finish_single_request(
286281
const hobject_t &hoid,
287282
read_result_t &res,
288-
std::list<ECCommonL::ec_align_t> to_read,
283+
std::list<ec_align_t> to_read,
289284
std::set<int> wanted_to_read) = 0;
290285

291286
virtual void finish(int priority) && = 0;

src/osd/ECTypes.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2+
// vim: ts=8 sw=2 smarttab
3+
/*
4+
* Ceph - scalable distributed file system
5+
*
6+
* Copyright (C) 2013 Inktank Storage, Inc.
7+
*
8+
* This is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU Lesser General Public
10+
* License version 2.1, as published by the Free Software
11+
* Foundation. See file COPYING.
12+
*
13+
*/
14+
15+
#pragma once
16+
17+
struct ec_align_t {
18+
uint64_t offset;
19+
uint64_t size;
20+
uint32_t flags;
21+
friend std::ostream &operator<<(std::ostream &lhs, const ec_align_t &rhs) {
22+
return lhs << rhs.offset << ","
23+
<< rhs.size << ","
24+
<< rhs.flags;
25+
}
26+
};
27+

src/osd/PGBackend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ typedef std::shared_ptr<const OSDMap> OSDMapRef;
585585

586586
virtual void objects_read_async(
587587
const hobject_t &hoid,
588-
const std::list<std::pair<ECCommonL::ec_align_t,
588+
const std::list<std::pair<ec_align_t,
589589
std::pair<ceph::buffer::list*, Context*> > > &to_read,
590590
Context *on_complete, bool fast_read = false) = 0;
591591

src/osd/PrimaryLogPG.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,11 @@ void PrimaryLogPG::OpContext::start_async_reads(PrimaryLogPG *pg)
295295
pair<bufferlist*, Context*> > > in;
296296
in.swap(pending_async_reads);
297297
// TODO: drop the converter
298-
list<pair<ECCommonL::ec_align_t,
298+
list<pair<ec_align_t,
299299
pair<bufferlist*, Context*> > > in_native;
300300
for (auto [align_tuple, ctx_pair] : in) {
301301
in_native.emplace_back(
302-
ECCommonL::ec_align_t{
302+
ec_align_t{
303303
align_tuple.get<0>(), align_tuple.get<1>(), align_tuple.get<2>()
304304
},
305305
std::move(ctx_pair));

src/osd/ReplicatedBackend.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ int ReplicatedBackend::objects_readv_sync(
297297

298298
void ReplicatedBackend::objects_read_async(
299299
const hobject_t &hoid,
300-
const list<pair<ECCommonL::ec_align_t,
300+
const list<pair<ec_align_t,
301301
pair<bufferlist*, Context*> > > &to_read,
302302
Context *on_complete,
303303
bool fast_read)

src/osd/ReplicatedBackend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class ReplicatedBackend : public PGBackend {
148148

149149
void objects_read_async(
150150
const hobject_t &hoid,
151-
const std::list<std::pair<ECCommonL::ec_align_t,
151+
const std::list<std::pair<ec_align_t,
152152
std::pair<ceph::buffer::list*, Context*> > > &to_read,
153153
Context *on_complete,
154154
bool fast_read = false) override;

0 commit comments

Comments
 (0)