From 1ae8eb68c21b7df0bc7c38035176f2447dffaed2 Mon Sep 17 00:00:00 2001 From: Tim Serong Date: Wed, 8 Mar 2023 13:45:57 +1100 Subject: [PATCH] osd: use fmt::format_to(...) to fix FTBFS on gcc 13 Without this the build will fail on gcc 13 with errors like: src/osd/scrubber/scrub_backend.cc:1309:14: error: call of overloaded 'format_to(std::back_insert_iterator >, const char [35], const char*, const uint64_t&, const uint64_t&, pg_shard_t&)' is ambiguous 1309 | format_to(std::back_inserter(out), | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ 1310 | "{}size {} != size {} from shard {}", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1311 | sep(error), | ~~~~~~~~~~~ 1312 | candidate.size, | ~~~~~~~~~~~~~~~ 1313 | auth.size, | ~~~~~~~~~~ 1314 | auth_shard); | ~~~~~~~~~~~ /usr/include/fmt/core.h:3233:17: note: candidate: 'OutputIt fmt::v9::format_to(OutputIt, format_string, T&& ...) [with OutputIt = std::back_insert_iterator >; T = {const char*, const long unsigned int&, const long unsigned int&, pg_shard_t&}; typename std::enable_if::value, int>::type = 0; format_string = basic_format_string]' 3233 | FMT_INLINE auto format_to(OutputIt out, format_string fmt, T&&... args) | ^~~~~~~~~ /usr/include/c++/13/format:3761:5: note: candidate: '_Out std::format_to(_Out, format_string<_Args ...>, _Args&& ...) [with _Out = back_insert_iterator >; _Args = {const char*, const long unsigned int&, const long unsigned int&, pg_shard_t&}; format_string<_Args ...> = basic_format_string]' 3761 | format_to(_Out __out, format_string<_Args...> __fmt, _Args&&... __args) | ^~~~~~~~~ Fixes: https://tracker.ceph.com/issues/58477 Signed-off-by: Tim Serong --- src/osd/scrubber/scrub_backend.cc | 107 +++++++++++++++++------------- src/osd/scrubber/scrub_backend.h | 18 ++--- 2 files changed, 70 insertions(+), 55 deletions(-) diff --git a/src/osd/scrubber/scrub_backend.cc b/src/osd/scrubber/scrub_backend.cc index a560838e78910..e25c5b99da09c 100644 --- a/src/osd/scrubber/scrub_backend.cc +++ b/src/osd/scrubber/scrub_backend.cc @@ -1171,23 +1171,23 @@ bool ScrubBackend::compare_obj_details(pg_shard_t auth_shard, if (auth.digest_present && candidate.digest_present && auth.digest != candidate.digest) { - format_to(std::back_inserter(out), - "data_digest {:#x} != data_digest {:#x} from shard {}", - candidate.digest, - auth.digest, - auth_shard); + fmt::format_to(std::back_inserter(out), + "data_digest {:#x} != data_digest {:#x} from shard {}", + candidate.digest, + auth.digest, + auth_shard); error = true; obj_result.set_data_digest_mismatch(); } if (auth.omap_digest_present && candidate.omap_digest_present && auth.omap_digest != candidate.omap_digest) { - format_to(std::back_inserter(out), - "{}omap_digest {:#x} != omap_digest {:#x} from shard {}", - sep(error), - candidate.omap_digest, - auth.omap_digest, - auth_shard); + fmt::format_to(std::back_inserter(out), + "{}omap_digest {:#x} != omap_digest {:#x} from shard {}", + sep(error), + candidate.omap_digest, + auth.omap_digest, + auth_shard); obj_result.set_omap_digest_mismatch(); } @@ -1195,24 +1195,24 @@ bool ScrubBackend::compare_obj_details(pg_shard_t auth_shard, if (m_is_replicated) { if (auth_oi.is_data_digest() && candidate.digest_present && auth_oi.data_digest != candidate.digest) { - format_to(std::back_inserter(out), - "{}data_digest {:#x} != data_digest {:#x} from auth oi {}", - sep(error), - candidate.digest, - auth_oi.data_digest, - auth_oi); + fmt::format_to(std::back_inserter(out), + "{}data_digest {:#x} != data_digest {:#x} from auth oi {}", + sep(error), + candidate.digest, + auth_oi.data_digest, + auth_oi); shard_result.set_data_digest_mismatch_info(); } // for replicated: if (auth_oi.is_omap_digest() && candidate.omap_digest_present && auth_oi.omap_digest != candidate.omap_digest) { - format_to(std::back_inserter(out), - "{}omap_digest {:#x} != omap_digest {:#x} from auth oi {}", - sep(error), - candidate.omap_digest, - auth_oi.omap_digest, - auth_oi); + fmt::format_to(std::back_inserter(out), + "{}omap_digest {:#x} != omap_digest {:#x} from auth oi {}", + sep(error), + candidate.omap_digest, + auth_oi.omap_digest, + auth_oi); shard_result.set_omap_digest_mismatch_info(); } } @@ -1241,7 +1241,9 @@ bool ScrubBackend::compare_obj_details(pg_shard_t auth_shard, auth_bl.push_back(auth_attr->second); if (!can_bl.contents_equal(auth_bl)) { - format_to(std::back_inserter(out), "{}object info inconsistent ", sep(error)); + fmt::format_to(std::back_inserter(out), + "{}object info inconsistent ", + sep(error)); obj_result.set_object_info_inconsistency(); } } @@ -1261,7 +1263,9 @@ bool ScrubBackend::compare_obj_details(pg_shard_t auth_shard, auth_bl.push_back(auth_attr->second); if (!can_bl.contents_equal(auth_bl)) { - format_to(std::back_inserter(out), "{}snapset inconsistent ", sep(error)); + fmt::format_to(std::back_inserter(out), + "{}snapset inconsistent ", + sep(error)); obj_result.set_snapset_inconsistency(); } } @@ -1284,7 +1288,9 @@ bool ScrubBackend::compare_obj_details(pg_shard_t auth_shard, auth_bl.push_back(auth_hi->second); if (!can_bl.contents_equal(auth_bl)) { - format_to(std::back_inserter(out), "{}hinfo inconsistent ", sep(error)); + fmt::format_to(std::back_inserter(out), + "{}hinfo inconsistent ", + sep(error)); obj_result.set_hinfo_inconsistency(); } } @@ -1296,22 +1302,22 @@ bool ScrubBackend::compare_obj_details(pg_shard_t auth_shard, uint64_t oi_size = logical_to_ondisk_size(auth_oi.size); if (oi_size != candidate.size) { - format_to(std::back_inserter(out), - "{}size {} != size {} from auth oi {}", - sep(error), - candidate.size, - oi_size, - auth_oi); + fmt::format_to(std::back_inserter(out), + "{}size {} != size {} from auth oi {}", + sep(error), + candidate.size, + oi_size, + auth_oi); shard_result.set_size_mismatch_info(); } if (auth.size != candidate.size) { - format_to(std::back_inserter(out), - "{}size {} != size {} from shard {}", - sep(error), - candidate.size, - auth.size, - auth_shard); + fmt::format_to(std::back_inserter(out), + "{}size {} != size {} from shard {}", + sep(error), + candidate.size, + auth.size, + auth_shard); obj_result.set_size_mismatch(); } @@ -1320,11 +1326,11 @@ bool ScrubBackend::compare_obj_details(pg_shard_t auth_shard, if (candidate.size > m_conf->osd_max_object_size && !obj_result.has_size_too_large()) { - format_to(std::back_inserter(out), - "{}size {} > {} is too large", - sep(error), - candidate.size, - m_conf->osd_max_object_size); + fmt::format_to(std::back_inserter(out), + "{}size {} > {} is too large", + sep(error), + candidate.size, + m_conf->osd_max_object_size); obj_result.set_size_too_large(); } @@ -1340,10 +1346,16 @@ bool ScrubBackend::compare_obj_details(pg_shard_t auth_shard, auto cand = candidate.attrs.find(k); if (cand == candidate.attrs.end()) { - format_to(std::back_inserter(out), "{}attr name mismatch '{}'", sep(error), k); + fmt::format_to(std::back_inserter(out), + "{}attr name mismatch '{}'", + sep(error), + k); obj_result.set_attr_name_mismatch(); } else if (cand->second.cmp(v)) { - format_to(std::back_inserter(out), "{}attr value mismatch '{}'", sep(error), k); + fmt::format_to(std::back_inserter(out), + "{}attr value mismatch '{}'", + sep(error), + k); obj_result.set_attr_value_mismatch(); } } @@ -1356,7 +1368,10 @@ bool ScrubBackend::compare_obj_details(pg_shard_t auth_shard, auto in_auth = auth.attrs.find(k); if (in_auth == auth.attrs.end()) { - format_to(std::back_inserter(out), "{}attr name mismatch '{}'", sep(error), k); + fmt::format_to(std::back_inserter(out), + "{}attr name mismatch '{}'", + sep(error), + k); obj_result.set_attr_name_mismatch(); } } diff --git a/src/osd/scrubber/scrub_backend.h b/src/osd/scrubber/scrub_backend.h index 3e644b241ff9f..ffb41c27e37ba 100644 --- a/src/osd/scrubber/scrub_backend.h +++ b/src/osd/scrubber/scrub_backend.h @@ -183,20 +183,20 @@ struct fmt::formatter { // note: 'if' chain, as hard to consistently (on all compilers) avoid some // warnings for a switch plus multiple return paths if (as_auth.possible_auth == shard_as_auth_t::usable_t::not_usable) { - return format_to(ctx.out(), - "{{shard-not-usable:{}}}", - as_auth.error_text); + return fmt::format_to(ctx.out(), + "{{shard-not-usable:{}}}", + as_auth.error_text); } if (as_auth.possible_auth == shard_as_auth_t::usable_t::not_found) { - return format_to(ctx.out(), "{{shard-not-found}}"); + return fmt::format_to(ctx.out(), "{{shard-not-found}}"); } - return format_to(ctx.out(), - "{{shard-usable: soid:{} {{txt:{}}} }}", - as_auth.oi.soid, - as_auth.error_text); + return fmt::format_to(ctx.out(), + "{{shard-usable: soid:{} {{txt:{}}} }}", + as_auth.oi.soid, + as_auth.error_text); } else { - return format_to( + return fmt::format_to( ctx.out(), "usable:{} soid:{} {{txt:{}}}", (as_auth.possible_auth == shard_as_auth_t::usable_t::usable) ? "yes" -- 2.47.3