// identifies a specific physical device within seastore
using device_id_t = uint8_t;
+
// order of device_id_t
constexpr uint16_t DEVICE_ID_LEN_BITS = 4;
-// maximum devices supported
-constexpr uint16_t max_devices = 1 << DEVICE_ID_LEN_BITS;
+
+// maximum number of devices supported
+constexpr uint16_t DEVICE_ID_MAX = (1 << DEVICE_ID_LEN_BITS);
// segment ids without a device id encapsulated
using device_segment_id_t = uint32_t;
return std::numeric_limits<internal_segment_id_t>::max() - 6;
}
-
segment_id_t() = default;
segment_id_t(device_id_t id, device_segment_id_t segment)
: segment(make_internal(segment, id)) {
// only lower 4 bits are effective, and we have to reserve 0x0F for
// special XXX_SEG_IDs
- assert(id < 15);
+ assert(id < DEVICE_ID_MAX);
}
[[gnu::always_inline]]
auto& sm_info = segment_info_set->sm_info_vec[sm_id];
if (iter == sm_info->segment_infos.end()) {
device_id_t t_sm_id = sm_id;
- while (++t_sm_id < max_devices && !segment_info_set->sm_info_vec[t_sm_id]);
- if (t_sm_id < max_devices) {
+ while (++t_sm_id < DEVICE_ID_MAX && !segment_info_set->sm_info_vec[t_sm_id]);
+ if (t_sm_id < DEVICE_ID_MAX) {
auto& sm = segment_info_set->sm_info_vec[t_sm_id];
assert(sm);
iter = sm->segment_infos.begin();
SegmentInfoT&& segment_info)
{
if (!sm_info_vec.size()) {
- sm_info_vec.resize(max_devices);
+ sm_info_vec.resize(DEVICE_ID_MAX);
}
device_id_t d_id = segment_manager.get_device_id();
sm_info_vec[segment_manager.get_device_id()] = std::make_optional<
}
auto begin() {
device_id_t sm_id = 0;
- for (;sm_id < max_devices && !sm_info_vec[sm_id];
- sm_id ++);
- return iterator<false>(sm_id, this);
+ for (; sm_id < DEVICE_ID_MAX && !sm_info_vec[sm_id]; ++sm_id);
+ return iterator<false>(sm_id, *this);
}
auto begin() const {
device_id_t sm_id = 0;
- for (;sm_id < max_devices && !sm_info_vec[sm_id];
- sm_id ++);
- return iterator<true>(sm_id, this);
+ for (; sm_id < DEVICE_ID_MAX && !sm_info_vec[sm_id]; ++sm_id);
+ return iterator<true>(sm_id, *this);
}
auto end() {
- device_id_t sm_id = max_devices - 1;
- for (;!sm_info_vec[sm_id];
- sm_id --);
+ auto sm_id = DEVICE_ID_MAX;
+ for (; !sm_info_vec[sm_id]; --sm_id);
return iterator<false>(sm_id, this, true);
}
auto end() const {
- device_id_t sm_id = max_devices - 1;
- for (;!sm_info_vec[sm_id];
- sm_id --);
+ auto sm_id = DEVICE_ID_MAX;
+ for (; !sm_info_vec[sm_id]; --sm_id);
return iterator<true>(sm_id, this, true);
}
auto find_begin(device_id_t id) {
+ assert(sm_info_vec[id]);
auto& sm_info = sm_info_vec[id];
return sm_info->segment_infos.begin();
}
auto find_end(device_id_t id) {
+ assert(sm_info_vec[id]);
auto& sm_info = sm_info_vec[id];
return sm_info->segment_infos.end();
}