bluestore/bluefs: add expand_device for online device usage

adds support for expanding the device capacity while fs is online

Signed-off-by: Joshua Blanch <joshua.blanch@clyso.com>
This commit is contained in:
Joshua Blanch 2025-11-20 18:52:55 +00:00
parent 530faae4a5
commit d7bd19a508
2 changed files with 25 additions and 0 deletions

View File

@ -924,6 +924,29 @@ void BlueFS::_stop_alloc()
}
}
void BlueFS::expand_device(unsigned devid, uint64_t new_size, uint64_t old_size)
{
dout(10) << __func__ << " dev " << devid
<< " from 0x" << std::hex << old_size
<< " to 0x" << new_size << std::dec << dendl;
ceph_assert(devid < alloc.size());
ceph_assert(alloc[devid]);
ceph_assert(new_size > old_size);
alloc[devid]->expand(new_size);
auto aligned_size = p2align(new_size, alloc_size[devid]);
alloc[devid]->init_add_free(old_size, aligned_size - old_size);
uint64_t total = get_block_device_size(devid);
uint64_t free = get_free(devid);
ceph_assert(total > total - free);
dout(10) << __func__ << " dev " << devid
<< " added free space: 0x" << std::hex << old_size
<< "~0x" << (aligned_size - old_size) << std::dec << dendl;
}
int BlueFS::_read_and_check(uint8_t ndev, uint64_t off, uint64_t len,
ceph::buffer::list *pbl, IOContext *ioc, bool buffered)
{

View File

@ -901,6 +901,8 @@ public:
bool bdev_support_label(unsigned id);
BlockDevice* get_block_device(unsigned bdev) const;
void expand_device(unsigned devid, uint64_t new_size, uint64_t old_size);
// handler for discard event
void handle_discard(unsigned dev, interval_set<uint64_t>& to_release);