Compare commits

..

No commits in common. "c72e8e649e9e57dda9883e316ea41303e9113ccf" and "a87e236c706392ba37f10573ed0fe3420d6663e8" have entirely different histories.

4 changed files with 8 additions and 33 deletions

View File

@ -224,10 +224,6 @@ int main(int argc, char *argv[])
cmd.push_back((char*)"dump-journal"); cmd.push_back((char*)"dump-journal");
aliased = true; aliased = true;
} }
else if (!strcmp(exe_name, "vitastor-disk-test"))
{
self.test_mode = true;
}
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
{ {
if (!strcmp(argv[i], "--all")) if (!strcmp(argv[i], "--all"))
@ -322,7 +318,6 @@ int main(int argc, char *argv[])
// First argument is an OSD device - take metadata layout parameters from it // First argument is an OSD device - take metadata layout parameters from it
if (self.dump_load_check_superblock(self.new_journal_device)) if (self.dump_load_check_superblock(self.new_journal_device))
return 1; return 1;
self.new_journal_device = self.dsk.journal_device;
self.new_journal_offset = self.dsk.journal_offset; self.new_journal_offset = self.dsk.journal_offset;
self.new_journal_len = self.dsk.journal_len; self.new_journal_len = self.dsk.journal_len;
} }
@ -388,7 +383,6 @@ int main(int argc, char *argv[])
// First argument is an OSD device - take metadata layout parameters from it // First argument is an OSD device - take metadata layout parameters from it
if (self.dump_load_check_superblock(self.new_meta_device)) if (self.dump_load_check_superblock(self.new_meta_device))
return 1; return 1;
self.new_meta_device = self.dsk.meta_device;
self.new_meta_offset = self.dsk.meta_offset; self.new_meta_offset = self.dsk.meta_offset;
self.new_meta_len = self.dsk.meta_len; self.new_meta_len = self.dsk.meta_len;
} }

View File

@ -41,7 +41,6 @@ struct disk_tool_t
/**** Parameters ****/ /**** Parameters ****/
std::map<std::string, std::string> options; std::map<std::string, std::string> options;
bool test_mode = false;
bool all, json, now; bool all, json, now;
bool dump_with_blocks, dump_with_data; bool dump_with_blocks, dump_with_data;
blockstore_disk_t dsk; blockstore_disk_t dsk;
@ -129,7 +128,6 @@ struct disk_tool_t
int prepare_one(std::map<std::string, std::string> options, int is_hdd = -1); int prepare_one(std::map<std::string, std::string> options, int is_hdd = -1);
int check_existing_partition(const std::string & dev); int check_existing_partition(const std::string & dev);
int fix_partition_type(const std::string & dev_by_uuid);
int prepare(std::vector<std::string> devices); int prepare(std::vector<std::string> devices);
std::vector<vitastor_dev_info_t> collect_devices(const std::vector<std::string> & devices); std::vector<vitastor_dev_info_t> collect_devices(const std::vector<std::string> & devices);
json11::Json add_partitions(vitastor_dev_info_t & devinfo, std::vector<std::string> sizes); json11::Json add_partitions(vitastor_dev_info_t & devinfo, std::vector<std::string> sizes);
@ -151,6 +149,6 @@ int write_zero(int fd, uint64_t offset, uint64_t size);
json11::Json read_parttable(std::string dev); json11::Json read_parttable(std::string dev);
uint64_t dev_size_from_parttable(json11::Json pt); uint64_t dev_size_from_parttable(json11::Json pt);
uint64_t free_from_parttable(json11::Json pt); uint64_t free_from_parttable(json11::Json pt);
int fix_partition_type_uuid(std::string dev_by_uuid, const std::string & type_uuid); int fix_partition_type(std::string dev_by_uuid);
std::string csum_type_str(uint32_t data_csum_type); std::string csum_type_str(uint32_t data_csum_type);
uint32_t csum_type_from_str(std::string data_csum_type); uint32_t csum_type_from_str(std::string data_csum_type);

View File

@ -159,11 +159,7 @@ int disk_tool_t::prepare_one(std::map<std::string, std::string> options, int is_
return 1; return 1;
} }
std::string osd_num_str; std::string osd_num_str;
if (test_mode && options.find("osd_num") != options.end()) if (shell_exec({ "vitastor-cli", "alloc-osd" }, "", &osd_num_str, NULL) != 0)
{
osd_num_str = options["osd_num"];
}
else if (shell_exec({ "vitastor-cli", "alloc-osd" }, "", &osd_num_str, NULL) != 0)
{ {
dsk.close_all(); dsk.close_all();
return 1; return 1;
@ -203,14 +199,11 @@ int disk_tool_t::prepare_one(std::map<std::string, std::string> options, int is_
if (sep_j) if (sep_j)
desc += (sep_m ? " and journal on " : " with journal on ") + realpath_str(options["journal_device"]); desc += (sep_m ? " and journal on " : " with journal on ") + realpath_str(options["journal_device"]);
fprintf(stderr, "Initialized OSD %ju on %s\n", osd_num, desc.c_str()); fprintf(stderr, "Initialized OSD %ju on %s\n", osd_num, desc.c_str());
if (!test_mode || options.find("no_init") == options.end())
{
if (shell_exec({ "systemctl", "enable", "--now", "vitastor-osd@"+std::to_string(osd_num) }, "", NULL, NULL) != 0) if (shell_exec({ "systemctl", "enable", "--now", "vitastor-osd@"+std::to_string(osd_num) }, "", NULL, NULL) != 0)
{ {
fprintf(stderr, "Failed to enable systemd unit vitastor-osd@%ju\n", osd_num); fprintf(stderr, "Failed to enable systemd unit vitastor-osd@%ju\n", osd_num);
return 1; return 1;
} }
}
return 0; return 0;
} }
@ -236,16 +229,6 @@ int disk_tool_t::check_existing_partition(const std::string & dev)
return 0; return 0;
} }
int disk_tool_t::fix_partition_type(const std::string & dev)
{
std::string type_uuid = VITASTOR_PART_TYPE;
if (test_mode && options.find("part_type_uuid") != options.end())
{
type_uuid = options["part_type_uuid"];
}
return fix_partition_type_uuid(dev, type_uuid);
}
std::vector<vitastor_dev_info_t> disk_tool_t::collect_devices(const std::vector<std::string> & devices) std::vector<vitastor_dev_info_t> disk_tool_t::collect_devices(const std::vector<std::string> & devices)
{ {
std::vector<vitastor_dev_info_t> devinfo; std::vector<vitastor_dev_info_t> devinfo;

View File

@ -343,7 +343,7 @@ uint64_t free_from_parttable(json11::Json pt)
return free; return free;
} }
int fix_partition_type_uuid(std::string dev_by_uuid, const std::string & type_uuid) int fix_partition_type(std::string dev_by_uuid)
{ {
auto uuid = strtolower(dev_by_uuid.substr(dev_by_uuid.rfind('/')+1)); auto uuid = strtolower(dev_by_uuid.substr(dev_by_uuid.rfind('/')+1));
std::string parent_dev = get_parent_device(realpath_str(dev_by_uuid, false)); std::string parent_dev = get_parent_device(realpath_str(dev_by_uuid, false));
@ -356,7 +356,7 @@ int fix_partition_type_uuid(std::string dev_by_uuid, const std::string & type_uu
for (const auto & part: pt["partitions"].array_items()) for (const auto & part: pt["partitions"].array_items())
{ {
bool this_part = (strtolower(part["uuid"].string_value()) == uuid); bool this_part = (strtolower(part["uuid"].string_value()) == uuid);
if (this_part && strtolower(part["type"].string_value()) == type_uuid) if (this_part && strtolower(part["type"].string_value()) == "e7009fac-a5a1-4d72-af72-53de13059903")
{ {
// Already correct type // Already correct type
return 0; return 0;
@ -369,7 +369,7 @@ int fix_partition_type_uuid(std::string dev_by_uuid, const std::string & type_uu
{ {
script += (first ? "" : ", ")+kv.first+"="+ script += (first ? "" : ", ")+kv.first+"="+
(kv.first == "type" && this_part (kv.first == "type" && this_part
? type_uuid ? "e7009fac-a5a1-4d72-af72-53de13059903"
: (kv.second.is_string() ? kv.second.string_value() : kv.second.dump())); : (kv.second.is_string() ? kv.second.string_value() : kv.second.dump()));
first = false; first = false;
} }