Skip to content

Commit

Permalink
tools/ceph-bluestore-tool: update size label on bluefs expand
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
  • Loading branch information
ifed01 committed May 24, 2018
1 parent ffac450 commit 71c3b58
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/os/bluestore/bluestore_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,28 @@ void validate_path(CephContext *cct, const string& path, bool bluefs)
}
}

const char* find_device_path(
int id,
CephContext *cct,
const vector<string>& devs)
{
for (auto& i : devs) {
bluestore_bdev_label_t label;
int r = BlueStore::_read_bdev_label(cct, i, &label);
if (r < 0) {
cerr << "unable to read label for " << i << ": "
<< cpp_strerror(r) << std::endl;
exit(EXIT_FAILURE);
}
if ((id == BlueFS::BDEV_SLOW && label.description == "main") ||
(id == BlueFS::BDEV_DB && label.description == "bluefs db") ||
(id == BlueFS::BDEV_WAL && label.description == "bluefs wal")) {
return i.c_str();
}
}
return nullptr;
}

void add_devices(
BlueFS *fs,
CephContext *cct,
Expand Down Expand Up @@ -483,6 +505,27 @@ int main(int argc, char **argv)
cout << "expanding dev " << devid << " from 0x" << std::hex
<< end << " to 0x" << size << std::dec << std::endl;
fs->add_block_extent(devid, end, size-end);
const char* path = find_device_path(devid, cct.get(), devs);
if (path == nullptr) {
cerr << "Can't find device path for dev " << devid << std::endl;
continue;
}
bluestore_bdev_label_t label;
int r = BlueStore::_read_bdev_label(cct.get(), path, &label);
if (r < 0) {
cerr << "unable to read label for " << path << ": "
<< cpp_strerror(r) << std::endl;
continue;
}
label.size = size;
r = BlueStore::_write_bdev_label(cct.get(), path, label);
if (r < 0) {
cerr << "unable to write label for " << path << ": "
<< cpp_strerror(r) << std::endl;
continue;
}
cout << "dev " << devid << " size label updated to "
<< size << std::endl;
}
}
delete fs;
Expand Down

0 comments on commit 71c3b58

Please sign in to comment.