Skip to content

Commit

Permalink
os/bluestore: force multiple directories usage for bluefs no matter what
Browse files Browse the repository at this point in the history
amount of volumes is configured.

This allows both coalescence and split for BlueFS backing volumes.

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
  • Loading branch information
ifed01 committed Aug 14, 2018
1 parent ced971a commit 1bd27c1
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -4938,6 +4938,8 @@ int BlueStore::_open_db(bool create, bool to_repair_db)
dout(10) << __func__ << " do_bluefs = " << do_bluefs << dendl;

map<string,string> kv_options;
// force separate wal dir for all new deployments.
kv_options["separate_wal_dir"] = 1;
rocksdb::Env *env = NULL;
if (do_bluefs) {
dout(10) << __func__ << " initializing bluefs" << dendl;
Expand Down Expand Up @@ -5055,12 +5057,10 @@ int BlueStore::_open_db(bool create, bool to_repair_db)
bluefs->get_block_device_size(BlueFS::BDEV_WAL) -
BDEV_LABEL_BLOCK_SIZE);
}
kv_options["separate_wal_dir"] = "1";
bluefs_single_shared_device = false;
} else {
r = -errno;
if (::lstat(bfn.c_str(), &st) == -1) {
kv_options.erase("separate_wal_dir");
r = 0;
} else {
derr << __func__ << " " << bfn << " symlink exists but target unusable: "
Expand Down Expand Up @@ -5111,24 +5111,30 @@ int BlueStore::_open_db(bool create, bool to_repair_db)

if (create) {
env->CreateDir(fn);
if (kv_options.count("separate_wal_dir"))
env->CreateDir(fn + ".wal");
if (kv_options.count("rocksdb_db_paths"))
env->CreateDir(fn + ".slow");
}
} else if (create) {
int r = ::mkdir(fn.c_str(), 0755);
if (r < 0)
r = -errno;
if (r < 0 && r != -EEXIST) {
derr << __func__ << " failed to create " << fn << ": " << cpp_strerror(r)
<< dendl;
return r;
env->CreateDir(fn + ".wal");
env->CreateDir(fn + ".slow");
} else {
std::vector<std::string> res;
// check for dir presence
auto r = env->GetChildren(fn+".wal", &res);
if (r == rocksdb::Status::NotFound()) {
kv_options.erase("separate_wal_dir");
}
}
} else {
string walfn = path + "/db.wal";

if (create) {
int r = ::mkdir(fn.c_str(), 0755);
if (r < 0)
r = -errno;
if (r < 0 && r != -EEXIST) {
derr << __func__ << " failed to create " << fn << ": " << cpp_strerror(r)
<< dendl;
return r;
}

// wal_dir, too!
if (kv_options.count("separate_wal_dir")) {
string walfn = path + "/db.wal";
// wal_dir, too!
r = ::mkdir(walfn.c_str(), 0755);
if (r < 0)
r = -errno;
Expand All @@ -5138,6 +5144,12 @@ int BlueStore::_open_db(bool create, bool to_repair_db)
<< dendl;
return r;
}
} else {
struct stat st;
r = ::stat(walfn.c_str(), &st);
if (r < 0 && errno == ENOENT) {
kv_options.erase("separate_wal_dir");
}
}
}

Expand Down

0 comments on commit 1bd27c1

Please sign in to comment.