From: Adam Kupczyk Date: Fri, 2 Feb 2024 12:19:05 +0000 (+0000) Subject: os/bluestore: Fix write_bdev_label X-Git-Tag: v19.2.1~271^2~27 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=619cc7b14d2478f20aa1039bd9d317fc43bdd8d6;p=ceph.git os/bluestore: Fix write_bdev_label 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 (cherry picked from commit 28dbacf1745b8a5a63b22639e6730a9559b354b7) --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 4790732f6c280..f2349c3f32e54 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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) { diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index b27e2e8177319..4e35715c909c2 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2770,7 +2770,7 @@ public: CephContext* cct, const std::string &path, bluestore_bdev_label_t label, - std::vector locations = std::vector(BDEV_LABEL_POSITION)); + std::vector locations = std::vector({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);