Compare commits

..

2 Commits

Author SHA1 Message Date
Vitaliy Filippov d1dc11aad0 Extract clear_osd_superblock()
Test / test_rebalance_verify_ec (push) Has been skipped Details
Test / test_rebalance_verify_ec_imm (push) Has been skipped Details
Test / test_dd (push) Has been skipped Details
Test / test_root_node (push) Has been skipped Details
Test / test_switch_primary (push) Has been skipped Details
Test / test_write (push) Has been skipped Details
Test / test_write_xor (push) Has been skipped Details
Test / test_write_no_same (push) Has been skipped Details
Test / test_heal_pg_size_2 (push) Has been skipped Details
Test / test_heal_ec (push) Has been skipped Details
Test / test_heal_antietcd (push) Has been skipped Details
Test / test_heal_csum_32k_dmj (push) Has been skipped Details
Test / test_heal_csum_32k_dj (push) Has been skipped Details
Test / test_heal_csum_32k (push) Has been skipped Details
Test / test_heal_csum_4k_dmj (push) Has been skipped Details
Test / test_heal_csum_4k_dj (push) Has been skipped Details
Test / test_heal_csum_4k (push) Has been skipped Details
Test / test_snapshot_pool2 (push) Has been skipped Details
Test / test_osd_tags (push) Has been skipped Details
Test / test_enospc (push) Has been skipped Details
Test / test_enospc_xor (push) Has been skipped Details
Test / test_enospc_imm (push) Has been skipped Details
Test / test_enospc_imm_xor (push) Has been skipped Details
Test / test_scrub (push) Has been skipped Details
Test / test_scrub_zero_osd_2 (push) Has been skipped Details
Test / test_scrub_xor (push) Has been skipped Details
Test / test_scrub_pg_size_3 (push) Has been skipped Details
Test / test_scrub_pg_size_6_pg_minsize_4_osd_count_6_ec (push) Has been skipped Details
Test / test_scrub_ec (push) Has been skipped Details
Test / test_nfs (push) Has been skipped Details
2024-10-12 11:18:22 +03:00
Vitaliy Filippov c69183ac92 WIP Implement resizing partitions created with vitastor-disk
Test / test_root_node (push) Has been cancelled Details
Test / test_switch_primary (push) Has been cancelled Details
Test / test_interrupted_rebalance_ec (push) Has been cancelled Details
Test / test_write (push) Has been cancelled Details
Test / test_interrupted_rebalance_ec_imm (push) Has been cancelled Details
Test / test_write_xor (push) Has been cancelled Details
Test / test_failure_domain (push) Has been cancelled Details
Test / test_write_no_same (push) Has been cancelled Details
Test / test_heal_pg_size_2 (push) Has been cancelled Details
Test / test_heal_ec (push) Has been cancelled Details
Test / test_heal_antietcd (push) Has been cancelled Details
Test / test_heal_csum_32k_dmj (push) Has been cancelled Details
Test / test_heal_csum_32k_dj (push) Has been cancelled Details
Test / test_heal_csum_32k (push) Has been cancelled Details
Test / test_heal_csum_4k_dmj (push) Has been cancelled Details
Test / test_heal_csum_4k_dj (push) Has been cancelled Details
Test / test_heal_csum_4k (push) Has been cancelled Details
Test / test_snapshot_pool2 (push) Has been cancelled Details
Test / test_osd_tags (push) Has been cancelled Details
Test / test_enospc (push) Has been cancelled Details
Test / test_enospc_xor (push) Has been cancelled Details
Test / test_enospc_imm (push) Has been cancelled Details
Test / test_enospc_imm_xor (push) Has been cancelled Details
Test / test_scrub (push) Has been cancelled Details
Test / test_scrub_zero_osd_2 (push) Has been cancelled Details
Test / test_scrub_xor (push) Has been cancelled Details
Test / test_scrub_pg_size_3 (push) Has been cancelled Details
Test / test_scrub_pg_size_6_pg_minsize_4_osd_count_6_ec (push) Has been cancelled Details
Test / test_scrub_ec (push) Has been cancelled Details
Test / test_nfs (push) Has been cancelled Details
2024-10-12 11:12:47 +03:00
2 changed files with 15 additions and 56 deletions

View File

@ -39,8 +39,6 @@ int disk_tool_t::resize_data(std::string device)
return 1; return 1;
} }
dsk.close_all(); dsk.close_all();
auto old_journal_device = dsk.journal_device;
auto old_meta_device = dsk.meta_device;
new_data_offset = dsk.data_offset; new_data_offset = dsk.data_offset;
new_meta_offset = dsk.meta_offset; new_meta_offset = dsk.meta_offset;
new_journal_len = dsk.journal_len; new_journal_len = dsk.journal_len;
@ -76,60 +74,21 @@ int disk_tool_t::resize_data(std::string device)
options = sb_params; options = sb_params;
for (auto & kv: move_options) for (auto & kv: move_options)
options[kv.first] = kv.second; options[kv.first] = kv.second;
bool dry_run = orig_options.find("dry_run") != orig_options.end(); if (orig_options.find("dry_run") != orig_options.end())
if (!json)
{ {
std::string cmd;
for (auto & kv: move_options)
cmd += " --"+kv.first+" "+kv.second;
fprintf(stderr, "Running resize%s\n", cmd.c_str());
}
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) if (json)
printf("%s\n", json11::Json(options).dump().c_str());
else
{ {
printf("%s\n", json11::Json(json11::Json::object { std::string cmd = "vitastor-disk resize";
{ "new_sb_params", new_sb_params }, for (auto & kv: options)
}).dump().c_str()); cmd += " --"+kv.first+" "+kv.second;
printf("%s\n", cmd.c_str());
} }
return 0; return 0;
} }
return raw_resize();
}
int disk_tool_t::resize_parse_move_journal(std::map<std::string, std::string> & move_options) int disk_tool_t::resize_parse_move_journal(std::map<std::string, std::string> & move_options)
{ {

View File

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