]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/segment_cleaner: classify space into available, unreclaimable...
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 5 May 2022 03:12:45 +0000 (11:12 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 13 May 2022 07:51:20 +0000 (15:51 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/segment_cleaner.h

index edf64097d6290cc05e6cb7f81f3a9d9fc576a569..2bb1e8520ac7b63456b1155b7936b16e84a71e25 100644 (file)
@@ -117,6 +117,20 @@ public:
   std::size_t get_num_in_journal() const {
     return num_in_journal;
   }
+  std::size_t get_num_unreclaimable() const {
+    auto ret = num_in_journal + num_open;
+    if (ret > 0) {
+      // assume there is always 1 segment opened for journal (1 overlap)
+      return ret - 1;
+    } else {
+      return ret;
+    }
+  }
+  std::size_t get_num_reclaimable() const {
+    auto ret = num_open + num_closed;
+    assert(ret >= get_num_unreclaimable());
+    return ret - get_num_unreclaimable();
+  }
   std::size_t get_num_open() const {
     return num_open;
   }
@@ -135,6 +149,14 @@ public:
   std::size_t get_count_close() const {
     return count_close;
   }
+
+  /*
+   * Space classification
+   * - total = available + unavailable (unreclaimable + reclaimable)
+   *   - available: the available space for write, including open segments
+   *   - unreclaimable: in journal or still open, cannot be reclaimed
+   *   - reclaimable: closed and non-empty segments, can be reclaimed
+   */
   std::size_t get_total_bytes() const {
     return total_bytes;
   }
@@ -145,6 +167,17 @@ public:
     assert(total_bytes >= get_available_bytes());
     return total_bytes - get_available_bytes();
   }
+  std::size_t get_unavailable_unreclaimable_bytes() const {
+    auto ret = get_num_unreclaimable() * get_segment_size();
+    assert(ret >= avail_bytes_in_open);
+    return ret - avail_bytes_in_open;
+  }
+  std::size_t get_unavailable_reclaimable_bytes() const {
+    auto ret = get_num_reclaimable() * get_segment_size();
+    assert(ret + get_unavailable_unreclaimable_bytes() == get_unavailable_bytes());
+    return ret;
+  }
+
   journal_seq_t get_journal_head() const {
     if (unlikely(journal_segment_id == NULL_SEG_ID)) {
       return JOURNAL_SEQ_NULL;