Skip to content

Commit 70417d2

Browse files
authored
Merge pull request ceph#65872 from aainscow/tracker_73184
Relax scrub of shard sizes for upgraded EC pools
2 parents 022e052 + 9609410 commit 70417d2

File tree

9 files changed

+58
-17
lines changed

9 files changed

+58
-17
lines changed

src/osd/ECBackend.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,12 @@ class ECBackend : public ECCommon {
374374
ScrubMap::object &o
375375
);
376376

377-
uint64_t be_get_ondisk_size(uint64_t logical_size, shard_id_t shard_id
378-
) const {
377+
uint64_t be_get_ondisk_size(uint64_t logical_size, shard_id_t shard_id,
378+
bool object_is_legacy_ec) const {
379+
if (object_is_legacy_ec) {
380+
// In legacy EC, all shards were padded to the next chunk boundry.
381+
return sinfo.ro_offset_to_next_chunk_offset(logical_size);
382+
}
379383
return object_size_to_shard_size(logical_size, shard_id);
380384
}
381385
};

src/osd/ECSwitch.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,11 @@ class ECSwitch : public PGBackend
294294
}
295295

296296
uint64_t be_get_ondisk_size(uint64_t logical_size,
297-
shard_id_t shard_id) const final {
297+
shard_id_t shard_id,
298+
bool object_is_legacy_ec) const final {
298299
if (is_optimized())
299300
{
300-
return optimized.be_get_ondisk_size(logical_size, shard_id);
301+
return optimized.be_get_ondisk_size(logical_size, shard_id, object_is_legacy_ec);
301302
}
302303
return legacy.be_get_ondisk_size(logical_size);
303304
}

src/osd/PG.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,8 +1415,9 @@ class PG : public DoutPrefixProvider,
14151415
}
14161416

14171417
uint64_t logical_to_ondisk_size(uint64_t logical_size,
1418-
shard_id_t shard_id) const final {
1419-
return get_pgbackend()->be_get_ondisk_size(logical_size, shard_id_t(shard_id));
1418+
shard_id_t shard_id,
1419+
bool object_is_legacy_ec) const final {
1420+
return get_pgbackend()->be_get_ondisk_size(logical_size, shard_id_t(shard_id), object_is_legacy_ec);
14201421
}
14211422

14221423
bool ec_can_decode(const shard_id_set &available_shards) const final {

src/osd/PGBackend.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ typedef std::shared_ptr<const OSDMap> OSDMapRef;
625625
ScrubMapBuilder &pos);
626626

627627
virtual uint64_t be_get_ondisk_size(uint64_t logical_size,
628-
shard_id_t shard_id) const = 0;
628+
shard_id_t shard_id,
629+
bool object_is_legacy_ec) const = 0;
629630

630631
virtual int be_deep_scrub(
631632
[[maybe_unused]] const Scrub::ScrubCounterSet& io_counters,

src/osd/ReplicatedBackend.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ class ReplicatedBackend : public PGBackend {
476476
ScrubMap::object &o) override;
477477

478478
uint64_t be_get_ondisk_size(uint64_t logical_size,
479-
shard_id_t unused) const final {
479+
shard_id_t unused,
480+
bool unused2) const final {
480481
return logical_size;
481482
}
482483
};

src/osd/scrubber/scrub_backend.cc

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,29 @@ ScrubBackend::ScrubBackend(ScrubBeListener& scrubber,
116116
}
117117

118118
uint64_t ScrubBackend::logical_to_ondisk_size(uint64_t logical_size,
119-
shard_id_t shard_id) const
119+
shard_id_t shard_id,
120+
bool hinfo_present,
121+
uint64_t expected_size) const
120122
{
121-
return m_pg.logical_to_ondisk_size(logical_size, shard_id);
123+
uint64_t ondisk_size = m_pg.logical_to_ondisk_size(logical_size, shard_id, false);
124+
125+
if (!hinfo_present || ondisk_size == expected_size) {
126+
return ondisk_size;
127+
}
128+
129+
// This object does not match the expected size, but hinfo is present. In this
130+
// case there are valid reasons for the shard to be *either* size when using
131+
// optimised EC. The following function checks the expected size from legacy
132+
// EC.
133+
uint64_t legacy_ondisk_size = m_pg.logical_to_ondisk_size(logical_size, shard_id, true);
134+
if (expected_size == legacy_ondisk_size) {
135+
return legacy_ondisk_size;
136+
}
137+
138+
// If this return is reached, then the size is corrupt and what we return
139+
// here is relevant to the error message only. Return the non-legacy value
140+
// as it might be more useful in debug.
141+
return ondisk_size;
122142
}
123143

124144
uint32_t ScrubBackend::generate_zero_buffer_crc(shard_id_t shard_id,
@@ -819,7 +839,9 @@ shard_as_auth_t ScrubBackend::possible_auth_shard(const hobject_t& obj,
819839
}
820840
}
821841

822-
uint64_t ondisk_size = logical_to_ondisk_size(oi.size, srd.shard);
842+
uint64_t ondisk_size = logical_to_ondisk_size(oi.size, srd.shard,
843+
smap_obj.attrs.contains(ECUtil::get_hinfo_key()),
844+
smap_obj.size);
823845
if (test_error_cond(smap_obj.size != ondisk_size, shard_info,
824846
&shard_info_wrapper::set_obj_size_info_mismatch)) {
825847

@@ -1500,7 +1522,9 @@ bool ScrubBackend::compare_obj_details(pg_shard_t auth_shard,
15001522
// ------------------------------------------------------------------------
15011523

15021524
// sizes:
1503-
uint64_t oi_size = logical_to_ondisk_size(auth_oi.size, shard.shard);
1525+
uint64_t oi_size = logical_to_ondisk_size(auth_oi.size, shard.shard,
1526+
candidate.attrs.contains(ECUtil::get_hinfo_key()),
1527+
candidate.size);
15041528
if (oi_size != candidate.size) {
15051529
fmt::format_to(std::back_inserter(out),
15061530
"{}size {} != size {} from auth oi {}",
@@ -1682,12 +1706,17 @@ void ScrubBackend::scrub_snapshot_metadata(ScrubMap& map, const pg_shard_t &srd)
16821706
}
16831707

16841708
if (oi) {
1685-
if (logical_to_ondisk_size(oi->size, srd.shard) != p->second.size) {
1709+
bool has_hinfo = p->second.attrs.contains(
1710+
ECLegacy::ECUtilL::get_hinfo_key());
1711+
if (logical_to_ondisk_size(oi->size, srd.shard, has_hinfo, p->second.size)
1712+
!= p->second.size) {
16861713
clog.error() << m_mode_desc << " " << m_pg_id << " " << soid
16871714
<< " : on disk size (" << p->second.size
16881715
<< ") does not match object info size (" << oi->size
16891716
<< ") adjusted for ondisk to ("
1690-
<< logical_to_ondisk_size(oi->size, srd.shard) << ")";
1717+
<< logical_to_ondisk_size(oi->size, srd.shard,
1718+
has_hinfo, p->second.size)
1719+
<< ")";
16911720
soid_error.set_size_mismatch();
16921721
this_chunk->m_error_counts.shallow_errors++;
16931722
}

src/osd/scrubber/scrub_backend.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,9 @@ class ScrubBackend {
557557

558558
// accessing the PG backend for this translation service
559559
uint64_t logical_to_ondisk_size(uint64_t logical_size,
560-
shard_id_t shard_id) const;
560+
shard_id_t shard_id,
561+
bool object_is_legacy_ec = false,
562+
uint64_t expected_size = 0) const;
561563
uint32_t generate_zero_buffer_crc(shard_id_t shard_id, int length) const;
562564
};
563565

src/osd/scrubber_common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ struct PgScrubBeListener {
267267

268268
// query the PG backend for the on-disk size of an object
269269
virtual uint64_t logical_to_ondisk_size(uint64_t logical_size,
270-
shard_id_t shard_id) const = 0;
270+
shard_id_t shard_id,
271+
bool object_is_legacy_ec) const = 0;
271272

272273
// used to verify our "cleanliness" before scrubbing
273274
virtual bool is_waiting_for_unreadable_object() const = 0;

src/test/osd/test_scrubber_be.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ class TestPg : public PgScrubBeListener {
9696
const pg_info_t& get_pg_info(ScrubberPasskey) const final { return m_info; }
9797

9898
uint64_t logical_to_ondisk_size(uint64_t logical_size,
99-
shard_id_t shard_id) const final
99+
shard_id_t shard_id,
100+
bool unused) const final
100101
{
101102
return logical_size;
102103
}

0 commit comments

Comments
 (0)