diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 29e6217a5cc..77b2c5c0768 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -570,12 +570,15 @@ int BlueFS::_replay(bool noop, bool to_stdout) log_seq = 0; FileRef log_file; - if (noop) { - log_file = new File; + log_file = _get_file(1); + if (!noop) { + log_file->fnode = super.log_fnode; } else { - log_file = _get_file(1); + // do not use fnode from superblock in 'noop' mode - log_file's one should + // be fine and up-to-date + assert(log_file->fnode.ino == 1); + assert(log_file->fnode.extents.size() != 0); } - log_file->fnode = super.log_fnode; dout(10) << __func__ << " log_fnode " << super.log_fnode << dendl; if (unlikely(to_stdout)) { std::cout << " log_fnode " << super.log_fnode << std::endl; @@ -950,19 +953,10 @@ int BlueFS::_replay(bool noop, bool to_stdout) return 0; } -int BlueFS::log_dump( - CephContext *cct, - const string& path, - const vector& devs) +int BlueFS::log_dump() { - int r = _open_super(); - if (r < 0) { - derr << __func__ << " failed to open super: " << cpp_strerror(r) << dendl; - return r; - } - // only dump log file's content - r = _replay(true, true); + int r = _replay(true, true); if (r < 0) { derr << __func__ << " failed to replay log: " << cpp_strerror(r) << dendl; return r; diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 5e147a8cc5c..4abacb672b8 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -340,10 +340,7 @@ public: int mount(); void umount(); - int log_dump( - CephContext *cct, - const string& path, - const vector& devs); + int log_dump(); void collect_metadata(map *pm, unsigned skip_bdev_id); void get_devices(set *ls); diff --git a/src/os/bluestore/bluefs_types.cc b/src/os/bluestore/bluefs_types.cc index a237eab5589..d1f5edf173c 100644 --- a/src/os/bluestore/bluefs_types.cc +++ b/src/os/bluestore/bluefs_types.cc @@ -25,7 +25,7 @@ void bluefs_extent_t::generate_test_instances(list& ls) ostream& operator<<(ostream& out, const bluefs_extent_t& e) { - return out << (int)e.bdev << ":0x" << std::hex << e.offset << "+" << e.length + return out << (int)e.bdev << ":0x" << std::hex << e.offset << "~" << e.length << std::dec; } diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index b756812ed23..b3209fbaf0d 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -134,26 +134,6 @@ void add_devices( } } -void log_dump( - CephContext *cct, - const string& path, - const vector& devs) -{ - validate_path(cct, path, true); - BlueFS *fs = new BlueFS(cct); - - add_devices(fs, cct, devs); - - int r = fs->log_dump(cct, path, devs); - if (r < 0) { - cerr << "log_dump failed" << ": " - << cpp_strerror(r) << std::endl; - exit(EXIT_FAILURE); - } - - delete fs; -} - BlueFS *open_bluefs( CephContext *cct, const string& path, @@ -173,6 +153,22 @@ BlueFS *open_bluefs( return fs; } +void log_dump( + CephContext *cct, + const string& path, + const vector& devs) +{ + BlueFS* fs = open_bluefs(cct, path, devs); + int r = fs->log_dump(); + if (r < 0) { + cerr << "log_dump failed" << ": " + << cpp_strerror(r) << std::endl; + exit(EXIT_FAILURE); + } + + delete fs; +} + void inferring_bluefs_devices(vector& devs, std::string& path) { cout << "inferring bluefs devices from bluestore path" << std::endl; @@ -333,8 +329,12 @@ int main(int argc, char **argv) if (r < 0) { cerr << "error from fsck: " << cpp_strerror(r) << std::endl; exit(EXIT_FAILURE); + } else if (r > 0) { + cerr << action << " found " << r << " error(s)" << std::endl; + exit(EXIT_FAILURE); + } else { + cout << action << " success" << std::endl; } - cout << action << " success" << std::endl; } else if (action == "prime-osd-dir") { bluestore_bdev_label_t label;