]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: max_device -> DEVICE_ID_MAX, clarify users
authorSamuel Just <sjust@redhat.com>
Wed, 6 Oct 2021 01:14:54 +0000 (18:14 -0700)
committerXuehan Xu <xxhdx1985126@gmail.com>
Sun, 10 Oct 2021 06:22:10 +0000 (14:22 +0800)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/seastore/extent_reader.h
src/crimson/os/seastore/seastore_types.h
src/crimson/os/seastore/segment_cleaner.h

index 32aa1db517d301d729cdf8ebebc4dcee44ccb1ec..66dd6db2b482b1c310e7825d41c1a6e2301c1068 100644 (file)
@@ -16,7 +16,7 @@ class ExtentReader {
 public:
   using read_ertr = SegmentManager::read_ertr;
   ExtentReader() {
-    segment_managers.resize(max_devices, nullptr);
+    segment_managers.resize(DEVICE_ID_MAX, nullptr);
   }
   using read_segment_header_ertr = crimson::errorator<
     crimson::ct_error::enoent,
index 40009f73dff51015d97fe4a35ba3bf243a46a91d..9ea13afa5d1835d6cc144f79b449bcb76453fc6c 100644 (file)
@@ -38,10 +38,12 @@ struct seastore_meta_t {
 
 // 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;
@@ -94,13 +96,12 @@ public:
     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]]
index 014003c97f9fe65b925503100fc9f96e25ab860e..cae8628b75cbf00f246866d92cd8a70e25cf5fd2 100644 (file)
@@ -122,8 +122,8 @@ public:
       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();
@@ -206,7 +206,7 @@ public:
     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<
@@ -227,33 +227,31 @@ public:
   }
   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();
   }