Compare commits

..

2 Commits

Author SHA1 Message Date
Vitaliy Filippov f7eb7621fc WIP Implement resizing partitions created with vitastor-disk
Test / test_dd (push) Successful in 11s Details
Test / test_root_node (push) Successful in 7s Details
Test / test_rebalance_verify_ec (push) Successful in 1m40s Details
Test / test_rebalance_verify_ec_imm (push) Successful in 1m42s Details
Test / test_write_no_same (push) Successful in 6s Details
Test / test_switch_primary (push) Successful in 31s Details
Test / test_write (push) Successful in 30s Details
Test / test_write_xor (push) Successful in 33s Details
Test / test_heal_pg_size_2 (push) Successful in 2m14s Details
Test / test_heal_ec (push) Failing after 2m19s Details
Test / test_heal_antietcd (push) Successful in 2m16s Details
Test / test_heal_csum_32k_dmj (push) Successful in 2m15s Details
Test / test_heal_csum_32k_dj (push) Successful in 2m19s Details
Test / test_heal_csum_4k_dmj (push) Successful in 2m11s Details
Test / test_heal_csum_32k (push) Successful in 2m17s Details
Test / test_heal_csum_4k_dj (push) Successful in 2m18s Details
Test / test_osd_tags (push) Successful in 6s Details
Test / test_snapshot_pool2 (push) Successful in 13s Details
Test / test_enospc (push) Successful in 10s Details
Test / test_enospc_imm (push) Successful in 9s Details
Test / test_enospc_xor (push) Successful in 13s Details
Test / test_enospc_imm_xor (push) Successful in 12s Details
Test / test_scrub_zero_osd_2 (push) Successful in 11s Details
Test / test_scrub (push) Successful in 14s Details
Test / test_scrub_xor (push) Successful in 14s Details
Test / test_scrub_pg_size_3 (push) Successful in 15s Details
Test / test_scrub_pg_size_6_pg_minsize_4_osd_count_6_ec (push) Successful in 14s Details
Test / test_scrub_ec (push) Successful in 14s Details
Test / test_nfs (push) Successful in 9s Details
Test / test_heal_csum_4k (push) Successful in 2m19s Details
2024-10-12 11:54:39 +03:00
Vitaliy Filippov 005f06bf25 Extract clear_osd_superblock() 2024-10-12 11:54:39 +03:00
2 changed files with 56 additions and 15 deletions

View File

@ -39,6 +39,8 @@ int disk_tool_t::resize_data(std::string device)
return 1;
}
dsk.close_all();
auto old_journal_device = dsk.journal_device;
auto old_meta_device = dsk.meta_device;
new_data_offset = dsk.data_offset;
new_meta_offset = dsk.meta_offset;
new_journal_len = dsk.journal_len;
@ -74,20 +76,59 @@ int disk_tool_t::resize_data(std::string device)
options = sb_params;
for (auto & kv: move_options)
options[kv.first] = kv.second;
if (orig_options.find("dry_run") != orig_options.end())
bool dry_run = orig_options.find("dry_run") != orig_options.end();
if (!json)
{
if (json)
printf("%s\n", json11::Json(options).dump().c_str());
else
{
std::string cmd = "vitastor-disk resize";
for (auto & kv: options)
cmd += " --"+kv.first+" "+kv.second;
printf("%s\n", cmd.c_str());
}
return 0;
std::string cmd;
for (auto & kv: move_options)
cmd += " --"+kv.first+" "+kv.second;
fprintf(stderr, "Running resize%s\n", cmd.c_str());
}
return raw_resize();
if (!dry_run && raw_resize() != 0)
return 1;
// Write new superblocks
json11::Json::object new_sb_params = sb["params"].object_items();
if (move_options.find("new_journal_device") != move_options.end())
new_sb_params["journal_device"] = move_options["new_journal_device"];
if (move_options.find("new_meta_device") != move_options.end())
new_sb_params["meta_device"] = move_options["new_meta_device"];
new_sb_params["data_offset"] = new_data_offset;
new_sb_params["meta_offset"] = new_meta_offset;
if (move_options.find("new_data_len") != move_options.end())
new_sb_params["data_size"] = stoull_full(move_options["new_data_len"]);
std::set<std::string> clear_superblocks, write_superblocks;
auto new_journal_device = move_options.find("new_journal_device") != move_options.end()
? move_options["new_journal_device"] : dsk.journal_device;
auto new_meta_device = move_options.find("new_meta_device") != move_options.end()
? move_options["new_meta_device"] : dsk.meta_device;
write_superblocks.insert(dsk.data_device);
write_superblocks.insert(new_journal_device);
write_superblocks.insert(new_meta_device);
if (write_superblocks.find(old_journal_device) == write_superblocks.end())
clear_superblocks.insert(old_journal_device);
if (write_superblocks.find(old_meta_device) == write_superblocks.end())
clear_superblocks.insert(old_meta_device);
for (auto & dev: clear_superblocks)
{
if (!json)
fprintf(stderr, "Clearing OSD superblock on %s\n", dev.c_str());
if (!dry_run && !clear_osd_superblock(dev))
return 1;
}
for (auto & dev: write_superblocks)
{
if (!json)
fprintf(stderr, "Writing new OSD superblock to %s\n", dev.c_str());
if (!dry_run && !write_osd_superblock(dev, new_sb_params))
return 1;
}
if (json)
{
printf("%s\n", json11::Json(json11::Json::object {
{ "new_sb_params", new_sb_params },
}).dump().c_str());
}
return 0;
}
int disk_tool_t::resize_parse_move_journal(std::map<std::string, std::string> & move_options)

View File

@ -384,6 +384,7 @@ int disk_tool_t::pre_exec_osd(std::string device)
int disk_tool_t::clear_osd_superblock(const std::string & dev)
{
uint8_t *buf = (uint8_t*)memalign_or_die(MEM_ALIGNMENT, 4096);
int fd = -1, r = open(dev.c_str(), O_DIRECT|O_RDWR);
if (r >= 0)
{
@ -404,6 +405,8 @@ int disk_tool_t::clear_osd_superblock(const std::string & dev)
}
if (fd >= 0)
close(fd);
free(buf);
buf = NULL;
return r;
}
@ -465,7 +468,6 @@ int disk_tool_t::purge_devices(const std::vector<std::string> & devices)
return 1;
}
// Destroy OSD superblocks
uint8_t *buf = (uint8_t*)memalign_or_die(MEM_ALIGNMENT, 4096);
for (auto & sb: superblocks)
{
for (auto dev_type: std::vector<std::string>{ "data", "meta", "journal" })
@ -523,7 +525,5 @@ int disk_tool_t::purge_devices(const std::vector<std::string> & devices)
}
}
}
free(buf);
buf = NULL;
return 0;
}