diff --git a/src/common/fs_manager.cpp b/src/common/fs_manager.cpp index 1b633b1d24..4544c00985 100644 --- a/src/common/fs_manager.cpp +++ b/src/common/fs_manager.cpp @@ -298,6 +298,7 @@ dir_node *fs_manager::find_best_dir_for_new_replica(const gpid &pid) const for (const auto &dn : _dir_nodes) { // Do not allocate new replica on dir_node which is not NORMAL. if (dn->status != disk_status::NORMAL) { + LOG_INFO("skip the {} state dir_node({})", enum_to_string(dn->status), dn->tag); continue; } CHECK(!dn->has(pid), "gpid({}) already exists in dir_node({})", pid, dn->tag); @@ -440,6 +441,7 @@ dir_node *fs_manager::find_replica_dir(absl::string_view app_type, gpid pid) for (const auto &dn : _dir_nodes) { // Skip IO error dir_node. if (dn->status == disk_status::IO_ERROR) { + LOG_INFO("skip the {} state dir_node({})", enum_to_string(dn->status), dn->tag); continue; } const auto dir = dn->replica_dir(app_type, pid); @@ -498,6 +500,7 @@ dir_node *fs_manager::create_child_replica_dir(absl::string_view app_type, for (const auto &dn : _dir_nodes) { // Skip non-available dir_node. if (dn->status != disk_status::NORMAL) { + LOG_INFO("skip the {} state dir_node({})", enum_to_string(dn->status), dn->tag); continue; } child_dir = dn->replica_dir(app_type, child_pid); diff --git a/src/meta/test/misc/misc.cpp b/src/meta/test/misc/misc.cpp index 149f0735e1..ef85d7e998 100644 --- a/src/meta/test/misc/misc.cpp +++ b/src/meta/test/misc/misc.cpp @@ -27,6 +27,7 @@ #include "misc.h" #include +#include // IWYU pragma: no_include #include #include @@ -50,6 +51,7 @@ #include "runtime/rpc/dns_resolver.h" // IWYU pragma: keep #include "runtime/rpc/rpc_address.h" #include "runtime/rpc/rpc_host_port.h" +#include "utils/filesystem.h" #include "utils/fmt_logging.h" #include "utils/rand.h" @@ -195,15 +197,13 @@ void generate_node_fs_manager(const app_mapper &apps, int total_disks) { nfm.clear(); - const char *prefix = "/home/work/"; - char pid_dir[256]; + std::string prefix; + CHECK(dsn::utils::filesystem::get_current_directory(prefix), ""); std::vector data_dirs(total_disks); std::vector tags(total_disks); for (int i = 0; i < data_dirs.size(); ++i) { - snprintf(pid_dir, 256, "%sdisk%d", prefix, i + 1); - data_dirs[i] = pid_dir; - snprintf(pid_dir, 256, "disk%d", i + 1); - tags[i] = pid_dir; + data_dirs[i] = fmt::format("{}disk{}", prefix, i + 1); + tags[i] = fmt::format("disk{}", i + 1); } for (const auto &kv : nodes) { @@ -215,15 +215,13 @@ void generate_node_fs_manager(const app_mapper &apps, manager.initialize(data_dirs, tags); ns.for_each_partition([&](const dsn::gpid &pid) { const config_context &cc = *get_config_context(apps, pid); - snprintf(pid_dir, - 256, - "%s%s/%d.%d.test", - prefix, - cc.find_from_serving(ns.host_port())->disk_tag.c_str(), - pid.get_app_id(), - pid.get_partition_index()); - LOG_DEBUG("concat pid_dir({}) of node({})", pid_dir, ns.host_port()); - manager.add_replica(pid, pid_dir); + const auto dir = fmt::format("{}{}/{}.{}.test", + prefix, + cc.find_from_serving(ns.host_port())->disk_tag, + pid.get_app_id(), + pid.get_partition_index()); + LOG_DEBUG("concat {} of node({})", dir, ns.host_port()); + manager.add_replica(pid, dir); return true; }); }