crimson/common/operation: generalized for multiple reactors

Signed-off-by: Samuel Just <sjust@redhat.com>
This commit is contained in:
Samuel Just 2022-09-01 16:08:08 -07:00
parent 5544b2ebd8
commit 6e2d58a92d
2 changed files with 22 additions and 0 deletions

View File

@ -414,7 +414,16 @@ protected:
return opl.empty();
});
}
public:
OperationRegistryT(core_id_t core) {
// Use core to initialize upper 8 bits of counters to ensure that
// ids generated by different cores are disjoint
op_id_counters.fill(
static_cast<id_t>(core) <<
(std::numeric_limits<id_t>::digits - 8));
}
template <size_t REGISTRY_INDEX>
const op_list& get_registry() const {
static_assert(
@ -428,6 +437,18 @@ public:
REGISTRY_INDEX < std::tuple_size<decltype(registries)>::value);
return registries[REGISTRY_INDEX];
}
/// Removes op from registry
void remove_from_registry(Operation &op) {
const auto op_type = op.get_type();
registries[op_type].erase(op_list::s_iterator_to(op));
}
/// Adds op to registry
void add_to_registry(Operation &op) {
const auto op_type = op.get_type();
registries[op_type].push_back(op);
}
};
class PipelineExitBarrierI {

View File

@ -38,6 +38,7 @@ void OSDOperationRegistry::do_stop()
}
OSDOperationRegistry::OSDOperationRegistry()
: OperationRegistryT(seastar::this_shard_id())
{
constexpr auto historic_reg_index =
static_cast<size_t>(OperationTypeCode::historic_client_request);