]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: use proper device when updating DB/WAL label while
authorIgor Fedotov <ifedotov@croit.io>
Mon, 17 Feb 2025 19:04:18 +0000 (22:04 +0300)
committerIgor Fedotov <igor.fedotov@croit.io>
Tue, 15 Apr 2025 09:04:23 +0000 (12:04 +0300)
expanding.

Fixes: https://tracker.ceph.com/issues/69999
Signed-off-by: Igor Fedotov <igor.fedotov@croit.io>
(cherry picked from commit ba3e4d2c9daf6b3af8340607e722f31b83e69db8)

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

index ac8f38e897d7cf68deb31b4b11b595afe49cab4b..f0e37b4f7d70cfd194afc13d56d1a163255b3b15 100644 (file)
@@ -8894,19 +8894,25 @@ string BlueStore::get_device_path(unsigned id)
   return res;
 }
 
-int BlueStore::_set_bdev_label_size(const string& path, uint64_t size)
+int BlueStore::_set_bdev_label_size(unsigned id, uint64_t size)
 {
-  bluestore_bdev_label_t label;
-  int r = _read_bdev_label(cct, bdev, path, &label);
-  if (r < 0) {
-    derr << "unable to read label for " << path << ": "
-          << cpp_strerror(r) << dendl;
-  } else {
-    label.size = size;
-    r = _write_bdev_label(cct, bdev, path, label);
+  ceph_assert(bluefs);
+  BlockDevice* my_bdev = bluefs->get_block_device(id);
+  int r = -1;
+  if (my_bdev != nullptr) {
+    string my_path = get_device_path(id);
+    bluestore_bdev_label_t label;
+    r = _read_bdev_label(cct, my_bdev, my_path, &label);
     if (r < 0) {
-      derr << "unable to write label for " << path << ": "
+      derr << "unable to read label for " << my_path << ": "
             << cpp_strerror(r) << dendl;
+    } else {
+      label.size = size;
+      r = _write_bdev_label(cct, my_bdev, my_path, label);
+      if (r < 0) {
+        derr << "unable to write label for " << my_path << ": "
+              << cpp_strerror(r) << dendl;
+      }
     }
   }
   return r;
@@ -8931,18 +8937,10 @@ int BlueStore::expand_devices(ostream& out)
       // no bdev
       continue;
     }
-
     out << devid
        <<" : expanding " << " to 0x" << size << std::dec << std::endl;
-    string p = get_device_path(devid);
-    const char* path = p.c_str();
-    if (path == nullptr) {
-      derr << devid
-           <<": can't find device path " << dendl;
-      continue;
-    }
     if (bluefs->bdev_support_label(devid)) {
-      if (_set_bdev_label_size(p, size) >= 0) {
+      if (_set_bdev_label_size(devid, size) >= 0) {
         out << devid
           << " : size label updated to " << size
           << std::endl;
index 368c842d4cdad89c1dedbc322a6416cb722fd1f3..ed768cddb0268a7ac96b1989328583f3dd7c0e90 100644 (file)
@@ -2804,7 +2804,7 @@ private:
     std::vector<uint64_t>* out_valid_positions = nullptr,
     bool* out_is_multi = nullptr,
     int64_t* out_epoch = nullptr);
-  int _set_bdev_label_size(const std::string& path, uint64_t size);
+  int _set_bdev_label_size(unsigned id, uint64_t size);
   void _main_bdev_label_try_reserve();
   void _main_bdev_label_remove(Allocator* alloc);