// match up with bluestore. the slow device is always the second
// one (when a dedicated block.db device is present and used at
// bdev 0). the wal device is always last.
- if (boost::algorithm::ends_with(dirname, ".slow")) {
+ if (boost::algorithm::ends_with(dirname, ".slow") && slow_total) {
res = BlueFS::BDEV_SLOW;
- }
- else if (boost::algorithm::ends_with(dirname, ".wal")) {
+ } else if (boost::algorithm::ends_with(dirname, ".wal") && wal_total) {
res = BlueFS::BDEV_WAL;
}
}
db->submit_transaction_sync(txn);
}
+void BlueStore::inject_bluefs_file(std::string_view dir, std::string_view name, size_t new_size)
+{
+ ceph_assert(bluefs);
+
+ BlueFS::FileWriter* p_handle = nullptr;
+ auto ret = bluefs->open_for_write(dir, name, &p_handle, false);
+ ceph_assert(ret == 0);
+
+ std::string s('0', new_size);
+ bufferlist bl;
+ bl.append(s);
+ p_handle->append(bl);
+
+ bluefs->fsync(p_handle);
+ bluefs->close_writer(p_handle);
+}
+
void BlueStore::collect_metadata(map<string,string> *pm)
{
dout(10) << __func__ << dendl;
void RocksDBBlueFSVolumeSelector::get_paths(const std::string& base, paths& res) const
{
- res.emplace_back(base, l_totals[LEVEL_DB - LEVEL_FIRST]);
- res.emplace_back(base + ".slow", l_totals[LEVEL_SLOW - LEVEL_FIRST]);
+ auto db_size = l_totals[LEVEL_DB - LEVEL_FIRST];
+ res.emplace_back(base, db_size);
+ auto slow_size = l_totals[LEVEL_SLOW - LEVEL_FIRST];
+ if (slow_size == 0) {
+ slow_size = db_size;
+ }
+ res.emplace_back(base + ".slow", slow_size);
}
void* RocksDBBlueFSVolumeSelector::get_hint_by_dir(std::string_view dirname) const {
}
}
+TEST_P(StoreTestSpecificAUSize, BluefsWriteInSingleDiskEnvTest) {
+ if (string(GetParam()) != "bluestore")
+ return;
+
+ g_conf().apply_changes(nullptr);
+
+ StartDeferred(0x1000);
+
+ BlueStore* bstore = dynamic_cast<BlueStore*> (store.get());
+ ceph_assert(bstore);
+ bstore->inject_bluefs_file("db.slow", "store_test_injection_slow", 1 << 20ul);
+ bstore->inject_bluefs_file("db.wal", "store_test_injection_wal", 1 << 20ul);
+ bstore->inject_bluefs_file("db", "store_test_injection_wal", 1 << 20ul);
+
+ AdminSocket* admin_socket = g_ceph_context->get_admin_socket();
+ ceph_assert(admin_socket);
+
+ ceph::bufferlist in, out;
+ ostringstream err;
+ auto r = admin_socket->execute_command(
+ { "{\"prefix\": \"bluefs stats\"}" },
+ in, err, &out);
+ if (r != 0) {
+ cerr << "failure querying: " << cpp_strerror(r) << std::endl;
+ } else {
+ std::cout << std::string(out.c_str(), out.length()) << std::endl;
+ }
+}
+
+TEST_P(StoreTestSpecificAUSize, BluefsWriteInNoWalDiskEnvTest) {
+ if (string(GetParam()) != "bluestore")
+ return;
+
+ SetVal(g_conf(), "bluestore_block_db_path", "db");
+ SetVal(g_conf(), "bluestore_block_db_size", stringify(1ull << 31).c_str());
+ SetVal(g_conf(), "bluestore_block_db_create", "true");
+
+ g_conf().apply_changes(nullptr);
+
+ StartDeferred(0x1000);
+
+ BlueStore* bstore = dynamic_cast<BlueStore*> (store.get());
+ ceph_assert(bstore);
+ bstore->inject_bluefs_file("db.slow", "store_test_injection_slow", 1 << 20ul);
+ bstore->inject_bluefs_file("db.wal", "store_test_injection_wal", 1 << 20ul);
+ bstore->inject_bluefs_file("db", "store_test_injection_wal", 1 << 20ul);
+
+ AdminSocket* admin_socket = g_ceph_context->get_admin_socket();
+ ceph_assert(admin_socket);
+
+ ceph::bufferlist in, out;
+ ostringstream err;
+ auto r = admin_socket->execute_command(
+ { "{\"prefix\": \"bluefs stats\"}" },
+ in, err, &out);
+ if (r != 0) {
+ cerr << "failure querying: " << cpp_strerror(r) << std::endl;
+ }
+ else {
+ std::cout << std::string(out.c_str(), out.length()) << std::endl;
+ }
+}
+
#endif // WITH_BLUESTORE
int main(int argc, char **argv) {