]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Fix write_bdev_label
authorAdam Kupczyk <akupczyk@ibm.com>
Fri, 2 Feb 2024 12:19:05 +0000 (12:19 +0000)
committerPere Diaz Bou <pere-altea@hotmail.com>
Fri, 23 Aug 2024 09:49:24 +0000 (11:49 +0200)
Fix default value of parameter 'location'.
It should consist of one element BDEV_LABEL_POSITION (0),
not just create with size 0.

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
(cherry picked from commit 28dbacf1745b8a5a63b22639e6730a9559b354b7)

src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 4790732f6c280b3fffc8032e07e53ed117c06b4a..f2349c3f32e5486c5b26b7bfb5864ef851f90507 100644 (file)
@@ -6509,10 +6509,7 @@ int BlueStore::_write_bdev_label(
   }
   bl.rebuild_aligned_size_and_memory(BDEV_LABEL_BLOCK_SIZE, BDEV_LABEL_BLOCK_SIZE, IOV_MAX);
   int r = 0;
-  if (std::find(locations.begin(), locations.end(), BDEV_LABEL_POSITION) ==
-      locations.end()) {
-    locations.push_back(BDEV_LABEL_POSITION);
-  }
+  ceph_assert(locations.size() > 0);
   struct stat st;
   r = ::fstat(fd, &st);
   if (r < 0) {
index b27e2e81773195e4fd3c9d476c47e0d6fe93171d..4e35715c909c28d67a46dd7655fae48c18e455e1 100644 (file)
@@ -2770,7 +2770,7 @@ public:
     CephContext* cct,
     const std::string &path,
     bluestore_bdev_label_t label,
-    std::vector<uint64_t> locations = std::vector<uint64_t>(BDEV_LABEL_POSITION));
+    std::vector<uint64_t> locations = std::vector<uint64_t>({BDEV_LABEL_POSITION}));
   static int _read_bdev_label(
     CephContext* cct, const std::string &path,
     bluestore_bdev_label_t *label, uint64_t disk_position = BDEV_LABEL_POSITION);