Merge PR #23517 into master

* refs/pull/23517/head:
	os/bluestore: uniform loging format for bluefs_extent_t.
	os/bluestore_tool: handle fsck's returned  status properly.
	os/bluestore_tool: fix multiple extents handling in BlueFS::log_dump

Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2018-08-13 13:00:32 -05:00
commit 58a45f13a4
4 changed files with 32 additions and 41 deletions

View File

@ -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<string>& 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;

View File

@ -340,10 +340,7 @@ public:
int mount();
void umount();
int log_dump(
CephContext *cct,
const string& path,
const vector<string>& devs);
int log_dump();
void collect_metadata(map<string,string> *pm, unsigned skip_bdev_id);
void get_devices(set<string> *ls);

View File

@ -25,7 +25,7 @@ void bluefs_extent_t::generate_test_instances(list<bluefs_extent_t*>& 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;
}

View File

@ -134,26 +134,6 @@ void add_devices(
}
}
void log_dump(
CephContext *cct,
const string& path,
const vector<string>& 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<string>& 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<string>& 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;