return 0;
}
+// returns true if specified device is attached
+bool BlueFS::is_device(unsigned id)
+{
+ return !(id >= MAX_BDEV || bdev[id] == nullptr);
+}
+
+// returns true if specified device is under full bluefs control
+// and hence can be expanded
+bool BlueFS::is_device_expandable(unsigned id)
+{
+ if (id >= MAX_BDEV || bdev[id] == nullptr) {
+ return false;
+ }
+ switch(id) {
+ case BDEV_WAL:
+ return true;
+
+ case BDEV_DB:
+ // true if DB volume is non-shared
+ return bdev[BDEV_SLOW] != nullptr;
+ }
+ return false;
+}
+
int BlueFS::mkfs(uuid_d osd_uuid)
{
std::unique_lock<std::mutex> l(lock);
/// get current extents that we own for given block device
int get_block_extents(unsigned id, interval_set<uint64_t> *extents);
+ // returns true if specified device is attached
+ bool is_device(unsigned id);
+
+ // returns true if specified device is under full bluefs control
+ // and hence can be expanded
+ bool is_device_expandable(unsigned id);
+
int open_for_write(
const string& dir,
const string& file,
cout << "start:" << std::endl;
fs->dump_block_extents(cout);
for (int devid : { BlueFS::BDEV_WAL, BlueFS::BDEV_DB }) {
+ if (!fs->is_device(devid)) {
+ continue;
+ }
+ if (!fs->is_device_expandable(devid)) {
+ cout << devid
+ << " : can't be expanded."
+ << std::endl;
+ continue;
+ }
interval_set<uint64_t> before;
fs->get_block_extents(devid, &before);
- if (before.empty()) continue;
+ ceph_assert(!before.empty());
uint64_t end = before.range_end();
uint64_t size = fs->get_block_device_size(devid);
if (end < size) {