@@ -116,9 +116,29 @@ ScrubBackend::ScrubBackend(ScrubBeListener& scrubber,
116116}
117117
118118uint64_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
124144uint32_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 }
0 commit comments