From: Adam C. Emerson Date: Wed, 30 Nov 2022 21:45:49 +0000 (-0500) Subject: cls/fifo: Merge duplicate journal entries X-Git-Tag: v17.2.6~116^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b0f13acfe59aac76ec3641f1455e12a98da0fe6c;p=ceph.git cls/fifo: Merge duplicate journal entries Since we no longer use tags, journal entries are just an operation and a part number. If an entry being added is already in the journal, skip it. Fixes: https://tracker.ceph.com/issues/57562 Signed-off-by: Adam C. Emerson (cherry picked from commit ade8909991682da9f665e75c16f1662f98f1e51a) Fixes: https://tracker.ceph.com/issues/58402 Signed-off-by: Adam C. Emerson --- diff --git a/src/cls/fifo/cls_fifo.cc b/src/cls/fifo/cls_fifo.cc index 5e2e2d42f857..5fe3404b9959 100644 --- a/src/cls/fifo/cls_fifo.cc +++ b/src/cls/fifo/cls_fifo.cc @@ -342,15 +342,7 @@ int update_meta(cls_method_context_t hctx, ceph::buffer::list* in, .journal_entries_rm( std::move(op.journal_entries_rm)); - auto err = header.apply_update(u); - if (err) { - std::ostringstream ss; - ss << u; - CLS_ERR("%s: %s: %s", __PRETTY_FUNCTION__, err->c_str(), - ss.str().c_str()); - return -EINVAL; - } - + header.apply_update(u); r = write_header(hctx, header); if (r < 0) { CLS_ERR("%s: failed to write header: r=%d", __PRETTY_FUNCTION__, r); diff --git a/src/cls/fifo/cls_fifo_types.h b/src/cls/fifo/cls_fifo_types.h index b3875e63cc00..b8f6ceec87be 100644 --- a/src/cls/fifo/cls_fifo_types.h +++ b/src/cls/fifo/cls_fifo_types.h @@ -15,6 +15,7 @@ #pragma once +#include #include #include #include @@ -363,8 +364,7 @@ struct info { return fmt::format("{}.{}", oid_prefix, part_num); } - std::optional - apply_update(const update& update) { + void apply_update(const update& update) { if (update.tail_part_num()) { tail_part_num = *update.tail_part_num(); } @@ -378,16 +378,13 @@ struct info { } for (const auto& entry : update.journal_entries_add()) { - auto iter = journal.find(entry.part_num); - if (iter != journal.end() && - iter->second.op == entry.op) { - /* don't allow multiple concurrent (same) operations on the same part, - racing clients should use objv to avoid races anyway */ - return fmt::format("multiple concurrent operations on same part are not " - "allowed, part num={}", entry.part_num); + if (std::find_if(journal.begin(), journal.end(), + [&entry](const auto &x) { return x.second == entry; }) + != journal.end()) { + continue; + } else { + journal.emplace(entry.part_num, entry); } - - journal.emplace(entry.part_num, entry); } for (const auto& entry : update.journal_entries_rm()) { @@ -397,8 +394,6 @@ struct info { if (update.head_part_num()) { head_part_num = *update.head_part_num(); } - - return std::nullopt; } }; WRITE_CLASS_ENCODER(info) diff --git a/src/rgw/cls_fifo_legacy.cc b/src/rgw/cls_fifo_legacy.cc index 6bff07e28697..42e1af391e5d 100644 --- a/src/rgw/cls_fifo_legacy.cc +++ b/src/rgw/cls_fifo_legacy.cc @@ -423,13 +423,7 @@ int FIFO::apply_update(const DoutPrefixProvider *dpp, << " version mismatch, canceling: tid=" << tid << dendl; return -ECANCELED; } - auto err = info->apply_update(update); - if (err) { - ldpp_dout(dpp, -1) << __PRETTY_FUNCTION__ << ":" << __LINE__ - << " error applying update: " << *err << " tid=" << tid << dendl; - return -ECANCELED; - } - + info->apply_update(update); ++info->version.ver; return {};