.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);
#pragma once
+#include <algorithm>
#include <cstdint>
#include <map>
#include <optional>
return fmt::format("{}.{}", oid_prefix, part_num);
}
- std::optional<std::string>
- apply_update(const update& update) {
+ void apply_update(const update& update) {
if (update.tail_part_num()) {
tail_part_num = *update.tail_part_num();
}
}
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()) {
if (update.head_part_num()) {
head_part_num = *update.head_part_num();
}
-
- return std::nullopt;
}
};
WRITE_CLASS_ENCODER(info)
<< " 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 {};