Skip to content

Commit e9d3ea8

Browse files
committed
tools/ceph-bluestore-tool: introduce bluefs-super-dump command.
This is a rework of Adam's commit: ceph@c8e57c4 Signed-off-by: Igor Fedotov <[email protected]>
1 parent effaa68 commit e9d3ea8

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

src/os/bluestore/BlueFS.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,26 @@ int BlueFS::_replay(bool noop, bool to_stdout)
18611861
return 0;
18621862
}
18631863

1864+
int BlueFS::super_dump()
1865+
{
1866+
// only dump superblock's content
1867+
_init_logger();
1868+
int r = _open_super();
1869+
if (r < 0) {
1870+
derr << __func__ << " failed to open super: " << cpp_strerror(r) << dendl;
1871+
return r;
1872+
}
1873+
ceph::JSONFormatter f(true);
1874+
f.open_object_section("superblock");
1875+
super.dump(&f);
1876+
f.close_section();
1877+
f.flush(std::cout);
1878+
1879+
_shutdown_logger();
1880+
super = bluefs_super_t();
1881+
return r;
1882+
}
1883+
18641884
int BlueFS::log_dump()
18651885
{
18661886
// only dump log file's content

src/os/bluestore/BlueFS.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ class BlueFS {
687687
int prepare_new_device(int id, const bluefs_layout_t& layout);
688688

689689
int log_dump();
690+
int super_dump();
690691

691692
void collect_metadata(std::map<std::string,std::string> *pm, unsigned skip_bdev_id);
692693
void get_devices(std::set<std::string> *ls);

src/os/bluestore/bluestore_tool.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,25 @@ void log_dump(
214214
delete fs;
215215
}
216216

217+
void super_dump(
218+
CephContext *cct,
219+
const string& path,
220+
const vector<string>& devs)
221+
{
222+
validate_path(cct, path, true);
223+
BlueFS *fs = new BlueFS(cct);
224+
225+
add_devices(fs, cct, devs);
226+
int r = fs->super_dump();
227+
if (r < 0) {
228+
cerr << "super_dump failed" << ": "
229+
<< cpp_strerror(r) << std::endl;
230+
exit(EXIT_FAILURE);
231+
}
232+
233+
delete fs;
234+
}
235+
217236
void inferring_bluefs_devices(vector<string>& devs, std::string& path)
218237
{
219238
cout << "inferring bluefs devices from bluestore path" << std::endl;
@@ -340,6 +359,7 @@ int main(int argc, char **argv)
340359
"set-label-key, "
341360
"rm-label-key, "
342361
"prime-osd-dir, "
362+
"bluefs-super-dump, "
343363
"bluefs-log-dump, "
344364
"free-dump, "
345365
"free-score, "
@@ -513,6 +533,7 @@ int main(int argc, char **argv)
513533
}
514534
if (action == "bluefs-export" ||
515535
action == "bluefs-import" ||
536+
action == "bluefs-super-dump" ||
516537
action == "bluefs-log-dump") {
517538
if (path.empty()) {
518539
cerr << "must specify bluestore path" << std::endl;
@@ -1001,6 +1022,8 @@ int main(int argc, char **argv)
10011022
delete fs;
10021023
} else if (action == "bluefs-log-dump") {
10031024
log_dump(cct.get(), path, devs);
1025+
} else if (action == "bluefs-super-dump") {
1026+
super_dump(cct.get(), path, devs);
10041027
} else if (action == "bluefs-bdev-new-db" || action == "bluefs-bdev-new-wal") {
10051028
map<string, int> cur_devs_map;
10061029
bool need_db = action == "bluefs-bdev-new-db";

0 commit comments

Comments
 (0)