mirror of
https://github.com/Zygo/bees.git
synced 2025-08-04 14:53:28 +02:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7283126e5c | ||
|
ac53e50d3e |
@@ -773,11 +773,42 @@ BeesResolveAddrResult::BeesResolveAddrResult()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BeesContext::wait_for_balance()
|
||||||
|
{
|
||||||
|
Timer balance_timer;
|
||||||
|
BEESNOTE("WORKAROUND: waiting for balance to stop");
|
||||||
|
while (true) {
|
||||||
|
btrfs_ioctl_balance_args args;
|
||||||
|
memset_zero<btrfs_ioctl_balance_args>(&args);
|
||||||
|
const int ret = ioctl(root_fd(), BTRFS_IOC_BALANCE_PROGRESS, &args);
|
||||||
|
if (ret < 0) {
|
||||||
|
// Either can't get balance status or not running, exit either way
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(args.state & BTRFS_BALANCE_STATE_RUNNING)) {
|
||||||
|
// Balance not running, doesn't matter if paused or cancelled
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BEESLOGDEBUG("WORKAROUND: Waiting " << balance_timer << "s for balance to stop");
|
||||||
|
sleep(BEES_BALANCE_POLL_INTERVAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BeesResolveAddrResult
|
BeesResolveAddrResult
|
||||||
BeesContext::resolve_addr_uncached(BeesAddress addr)
|
BeesContext::resolve_addr_uncached(BeesAddress addr)
|
||||||
{
|
{
|
||||||
THROW_CHECK1(invalid_argument, addr, !addr.is_magic());
|
THROW_CHECK1(invalid_argument, addr, !addr.is_magic());
|
||||||
THROW_CHECK0(invalid_argument, !!root_fd());
|
THROW_CHECK0(invalid_argument, !!root_fd());
|
||||||
|
|
||||||
|
// Is there a bug where resolve and balance cause a crash (BUG_ON at fs/btrfs/ctree.c:1227)?
|
||||||
|
// Apparently yes, and more than one.
|
||||||
|
// Wait for the balance to finish before we run LOGICAL_INO
|
||||||
|
wait_for_balance();
|
||||||
|
|
||||||
|
// Time how long this takes
|
||||||
Timer resolve_timer;
|
Timer resolve_timer;
|
||||||
|
|
||||||
// There is no performance benefit if we restrict the buffer size.
|
// There is no performance benefit if we restrict the buffer size.
|
||||||
|
12
src/bees.cc
12
src/bees.cc
@@ -667,6 +667,7 @@ bees_main(int argc, char *argv[])
|
|||||||
unsigned thread_min = 0;
|
unsigned thread_min = 0;
|
||||||
double load_target = 0;
|
double load_target = 0;
|
||||||
bool workaround_btrfs_send = false;
|
bool workaround_btrfs_send = false;
|
||||||
|
BeesRoots::ScanMode root_scan_mode = BeesRoots::SCAN_MODE_ZERO;
|
||||||
|
|
||||||
// Configure getopt_long
|
// Configure getopt_long
|
||||||
static const struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
@@ -735,7 +736,7 @@ bees_main(int argc, char *argv[])
|
|||||||
load_target = stod(optarg);
|
load_target = stod(optarg);
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
bc->roots()->set_scan_mode(static_cast<BeesRoots::ScanMode>(stoul(optarg)));
|
root_scan_mode = static_cast<BeesRoots::ScanMode>(stoul(optarg));
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
crucible::set_relative_path("");
|
crucible::set_relative_path("");
|
||||||
@@ -806,11 +807,16 @@ bees_main(int argc, char *argv[])
|
|||||||
BEESLOGNOTICE("setting worker thread pool maximum size to " << thread_count);
|
BEESLOGNOTICE("setting worker thread pool maximum size to " << thread_count);
|
||||||
TaskMaster::set_thread_count(thread_count);
|
TaskMaster::set_thread_count(thread_count);
|
||||||
|
|
||||||
|
// Set root path
|
||||||
|
string root_path = argv[optind++];
|
||||||
|
BEESLOGNOTICE("setting root path to '" << root_path << "'");
|
||||||
|
bc->set_root_path(root_path);
|
||||||
|
|
||||||
// Workaround for btrfs send
|
// Workaround for btrfs send
|
||||||
bc->roots()->set_workaround_btrfs_send(workaround_btrfs_send);
|
bc->roots()->set_workaround_btrfs_send(workaround_btrfs_send);
|
||||||
|
|
||||||
// Create a context and start crawlers
|
// Set root scan mode
|
||||||
bc->set_root_path(argv[optind++]);
|
bc->roots()->set_scan_mode(root_scan_mode);
|
||||||
|
|
||||||
BeesThread status_thread("status", [&]() {
|
BeesThread status_thread("status", [&]() {
|
||||||
bc->dump_status();
|
bc->dump_status();
|
||||||
|
@@ -117,6 +117,9 @@ const size_t BEES_TRANSID_FACTOR = 10;
|
|||||||
// The actual limit in LOGICAL_INO seems to be 2730, but let's leave a little headroom
|
// The actual limit in LOGICAL_INO seems to be 2730, but let's leave a little headroom
|
||||||
const size_t BEES_MAX_EXTENT_REF_COUNT = 2560;
|
const size_t BEES_MAX_EXTENT_REF_COUNT = 2560;
|
||||||
|
|
||||||
|
// Wait this long for a balance to stop
|
||||||
|
const double BEES_BALANCE_POLL_INTERVAL = 60.0;
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
const int FLAGS_OPEN_COMMON = O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC | O_NOATIME | O_LARGEFILE | O_NOCTTY;
|
const int FLAGS_OPEN_COMMON = O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC | O_NOATIME | O_LARGEFILE | O_NOCTTY;
|
||||||
const int FLAGS_OPEN_DIR = FLAGS_OPEN_COMMON | O_RDONLY | O_DIRECTORY;
|
const int FLAGS_OPEN_DIR = FLAGS_OPEN_COMMON | O_RDONLY | O_DIRECTORY;
|
||||||
@@ -716,6 +719,7 @@ class BeesContext : public enable_shared_from_this<BeesContext> {
|
|||||||
void set_root_fd(Fd fd);
|
void set_root_fd(Fd fd);
|
||||||
|
|
||||||
BeesResolveAddrResult resolve_addr_uncached(BeesAddress addr);
|
BeesResolveAddrResult resolve_addr_uncached(BeesAddress addr);
|
||||||
|
void wait_for_balance();
|
||||||
|
|
||||||
BeesFileRange scan_one_extent(const BeesFileRange &bfr, const Extent &e);
|
BeesFileRange scan_one_extent(const BeesFileRange &bfr, const Extent &e);
|
||||||
void rewrite_file_range(const BeesFileRange &bfr);
|
void rewrite_file_range(const BeesFileRange &bfr);
|
||||||
|
Reference in New Issue
Block a user