]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Adapt read_meta / write_meta
authorAdam Kupczyk <akupczyk@ibm.com>
Tue, 30 Jan 2024 07:06:52 +0000 (07:06 +0000)
committerPere Diaz Bou <pere-altea@hotmail.com>
Fri, 23 Aug 2024 09:49:23 +0000 (11:49 +0200)
Modified to align with multi label properly.
Now functions still cache, but use read_main_bdev_label.

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

src/os/bluestore/BlueStore.cc

index adddc9e7389ef1a935888839c6d0fec0677a0ab7..b0c3c5b278533b048ea128282619e91e000799c4 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "BlueStore.h"
 #include "bluestore_common.h"
+#include "os/bluestore/bluestore_types.h"
 #include "simple_bitmap.h"
 #include "os/kv.h"
 #include "include/compat.h"
@@ -6005,14 +6006,16 @@ int BlueStore::_set_cache_sizes()
 int BlueStore::write_meta(const std::string& key, const std::string& value)
 {
   string p = path + "/block";
-  if (!bdev_label_valid) {
-    int r = _read_bdev_label(cct, p, &bdev_label);
-    if (r == 0) {
-      bdev_label_valid = true;
-    }
+  if (bdev_label_valid_locations.empty()) {
+    int r = _read_main_bdev_label(cct, p, &bdev_label,
+      &bdev_label_valid_locations, &bdev_label_multi, &bdev_label_epoch);
+    ceph_assert(r == 0);
   }
-  if (bdev_label_valid) {
+  if (!bdev_label_valid_locations.empty()) {
     bdev_label.meta[key] = value;
+    if (bdev_label_multi) {
+      bdev_label.meta["epoch"] = std::to_string(bdev_label_epoch);
+    }
     int r = _write_bdev_label(cct, p, bdev_label);
     ceph_assert(r == 0);
   }
@@ -6021,20 +6024,20 @@ int BlueStore::write_meta(const std::string& key, const std::string& value)
 
 int BlueStore::read_meta(const std::string& key, std::string *value)
 {
-  if (!bdev_label_valid) {
-    string p = path + "/block";
-    int r = _read_bdev_label(cct, p, &bdev_label);
-    if (r < 0) {
-      return ObjectStore::read_meta(key, value);
-    }
-    bdev_label_valid = true;
+  string p = path + "/block";
+  if (bdev_label_valid_locations.empty()) {
+    int r = _read_main_bdev_label(cct, p, &bdev_label,
+      &bdev_label_valid_locations, &bdev_label_multi, &bdev_label_epoch);
+    ceph_assert(r == 0);
   }
-  auto i = bdev_label.meta.find(key);
-  if (i == bdev_label.meta.end()) {
-    return ObjectStore::read_meta(key, value);
+  if (!bdev_label_valid_locations.empty()) {
+    auto i = bdev_label.meta.find(key);
+    if (i != bdev_label.meta.end()) {
+      *value = i->second;
+      return 0;
+    }
   }
-  *value = i->second;
-  return 0;
+  return ObjectStore::read_meta(key, value);
 }