#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"
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);
}
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);
}