]> git-server-git.apps.pok.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)
committerAdam Kupczyk <akupczyk@ibm.com>
Mon, 22 Jul 2024 12:28:50 +0000 (12:28 +0000)
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>
src/os/bluestore/BlueStore.cc

index dd30c0acacfa7d0ead7c552423ed1a8f3558751f..314c42020c45182a4becf36ef3a8ac819ef2a81f 100644 (file)
@@ -30,6 +30,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"
@@ -6011,14 +6012,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);
   }
@@ -6027,20 +6030,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);
 }