return 0;
}
+int BlueStore::read_bdev_label_at_pos(
+ CephContext* cct,
+ const std::string &bdev_path,
+ uint64_t disk_position,
+ bluestore_bdev_label_t *label)
+{
+ unique_ptr<BlockDevice> bdev(BlockDevice::create(
+ cct, bdev_path, nullptr, nullptr, nullptr, nullptr));
+ if (!bdev) {
+ return -EIO;
+ }
+ bdev->set_no_exclusive_lock();
+ int r = bdev->open(bdev_path);
+ if (r < 0)
+ return r;
+ r = _read_bdev_label(cct, bdev.get(), bdev_path, label, disk_position);
+ bdev->close();
+ return r;
+}
+
int BlueStore::read_bdev_label(
CephContext* cct,
const std::string &path,
#define META_POOL_ID ((uint64_t)-1ull)
using bptr_c_it_t = buffer::ptr::const_iterator;
+extern const std::vector<uint64_t> bdev_label_positions;
+
class BlueStore : public ObjectStore,
public md_config_obs_t {
// -----------------------------------------------------
_wctx_finish(&txc, c, o, &wctx, nullptr);
}
- static int debug_read_bdev_label(
- CephContext* cct, BlockDevice* bdev, const std::string &path,
- bluestore_bdev_label_t *label, uint64_t disk_position) {
- return _read_bdev_label(cct, bdev, path, label, disk_position);
- }
static int debug_write_bdev_label(
CephContext* cct, BlockDevice* bdev, const std::string &path,
const bluestore_bdev_label_t& label, uint64_t disk_position) {
return _write_bdev_label(cct, bdev, path, label,
std::vector<uint64_t>({disk_position}));
}
+ static int read_bdev_label_at_pos(
+ CephContext* cct,
+ const std::string &bdev_path,
+ uint64_t disk_position,
+ bluestore_bdev_label_t *label);
static int read_bdev_label(
CephContext* cct,
const std::string &path,
string resharding_ctrl;
int log_level = 30;
bool fsck_deep = false;
+ uint64_t disk_offset;
po::options_description po_options("Options");
po_options.add_options()
("help,h", "produce help message")
("resharding-ctrl", po::value<string>(&resharding_ctrl), "gives control over resharding procedure details")
("op", po::value<string>(&action_aux),
"--command alias, ignored if the latter is present")
+ ("offset", po::value<uint64_t>(&disk_offset), "disk location")
;
po::options_description po_positional("Positional options");
po_positional.add_options()
"bluefs-bdev-new-wal, "
"bluefs-bdev-migrate, "
"show-label, "
+ "show-label-at, "
"set-label-key, "
"rm-label-key, "
"prime-osd-dir, "
if (devs.empty())
inferring_bluefs_devices(devs, path);
}
+ if (action == "show-label-at") {
+ if (devs.empty()) {
+ cerr << "must specify bluestore raw device" << std::endl;
+ exit(EXIT_FAILURE);
+ }
+ }
if (action == "bluefs-export" ||
action == "bluefs-import" ||
action == "bluefs-log-dump") {
exit(EXIT_FAILURE);
}
}
+ else if (action == "show-label-at") {
+ JSONFormatter jf(true);
+ bluestore_bdev_label_t label;
+ bool valid_offset = false;
+ for (auto o : bdev_label_positions) {
+ if (disk_offset == o) {
+ valid_offset = true;
+ break;
+ }
+ }
+ if (!valid_offset) {
+ cerr << "Suspicious offset: " << disk_offset
+ << ", expected locations: " << bdev_label_positions
+ << std::endl;
+ }
+ int r = BlueStore::read_bdev_label_at_pos(cct.get(), devs[0], disk_offset, &label);
+ if (r < 0) {
+ cerr << "unable to read label for " << devs[0] << ": "
+ << cpp_strerror(r) << std::endl;
+ exit(EXIT_FAILURE);
+ }
+ jf.open_object_section(devs[0].c_str());
+ label.dump(&jf);
+ jf.open_array_section("locations");
+ jf.dump_format("", "0x%llx", disk_offset);
+ jf.close_section();
+ jf.close_section();
+ jf.flush(cout);
+ }
else if (action == "set-label-key") {
bluestore_bdev_label_t label;
std::vector<uint64_t> valid_positions;
}
bool read_bdev_label(bluestore_bdev_label_t* label, uint64_t position) {
string bdev_path = get_data_dir() + "/block";
- unique_ptr<BlockDevice> bdev(BlockDevice::create(
- g_ceph_context, bdev_path, nullptr, nullptr, nullptr, nullptr));
- int r = bdev->open(bdev_path);
- if (r < 0)
- return r;
- r = BlueStore::debug_read_bdev_label(g_ceph_context, bdev.get(), bdev_path, label, position);
- bdev->close();
+ int r = BlueStore::read_bdev_label_at_pos(g_ceph_context, bdev_path, position, label);
return r;
}
bool write_bdev_label(const bluestore_bdev_label_t& label, uint64_t position) {