From: Adam Kupczyk Date: Fri, 2 Feb 2024 12:19:05 +0000 (+0000) Subject: os/bluestore: Fix write_bdev_label X-Git-Tag: v20.0.0~1321^2~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=28dbacf1745b8a5a63b22639e6730a9559b354b7;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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 2ae3dc550272..e97a86ab1ff4 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -6526,10 +6526,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 599bd42f317a..9b9b3f8bbbc2 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2757,7 +2757,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);