]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore/segment_cleaner: check for null in SpaceTrackerSimple constructor
authorSamuel Just <sjust@redhat.com>
Fri, 8 Oct 2021 05:01:12 +0000 (22:01 -0700)
committerXuehan Xu <xxhdx1985126@gmail.com>
Sun, 10 Oct 2021 06:22:10 +0000 (14:22 +0800)
Since we're passing a sparse pointer vector, we need to check for null
in every user.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/seastore/segment_cleaner.h

index 4e79785c52aeb3bb83a437c824ed8d93320723f3..8fe3e60691710fab8dfb6afd2930c44e8c4c5636 100644 (file)
@@ -384,6 +384,12 @@ class SpaceTrackerSimple : public SpaceTrackerI {
 public:
   SpaceTrackerSimple(std::vector<SegmentManager*> sms) {
     for (auto sm : sms) {
+      if (!sm) {
+       // sms is a vector that is indexed by device id and
+       // always has "max_device" elements, some of which
+       // may be null.
+       continue;
+      }
       live_bytes_by_segment.add_segment_manager(
        *sm,
        segment_space_tracker_t{});