From 636e69267e509536651d4f8309d399eed709cccc Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Sun, 15 Nov 2020 17:49:44 -0500 Subject: [PATCH] resolve: add bees.h constants for balance and logical_ino serialization Make these workarounds configurable in src/bees.h instead of #if 0 code blocks. Someday we'll make the constants in bees.h configurable through a file or similar. Signed-off-by: Zygo Blaxell --- src/bees-context.cc | 20 ++++++++++++++------ src/bees.h | 6 ++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/bees-context.cc b/src/bees-context.cc index a464f56..3f2407d 100644 --- a/src/bees-context.cc +++ b/src/bees-context.cc @@ -803,6 +803,10 @@ BeesResolveAddrResult::BeesResolveAddrResult() void BeesContext::wait_for_balance() { + if (!BEES_SERIALIZE_BALANCE) { + return; + } + Timer balance_timer; BEESNOTE("WORKAROUND: waiting for balance to stop"); while (true) { @@ -845,17 +849,21 @@ BeesContext::resolve_addr_uncached(BeesAddress addr) // transaction latency, competing threads, and freeze/SIGSTOP // pausing the bees process. -#if 0 - // There can be only one of these running at a time, or the slow - // backrefs bug will kill the whole system. Also it looks like there + // There can be only one of these running at a time, or some lingering + // backref bug will kill the whole system. Also it looks like there // are so many locks held while LOGICAL_INO runs that there is no // point in trying to run two of them on the same filesystem. // ...but it works most of the time, and the performance hit from // not running resolve in multiple threads is significant. - BEESNOTE("waiting to resolve addr " << addr); + // But "most of the time" really just means "between forced reboots", + // and with recent improvements in kernel uptime, this is now in the + // top 3 crash causes. static mutex s_resolve_mutex; - unique_lock lock(s_resolve_mutex); -#endif + unique_lock lock(s_resolve_mutex, defer_lock); + if (BEES_SERIALIZE_RESOLVE) { + BEESNOTE("waiting to resolve addr " << addr); + lock.lock(); + } // 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. diff --git a/src/bees.h b/src/bees.h index f836ede..8a6fc10 100644 --- a/src/bees.h +++ b/src/bees.h @@ -116,6 +116,12 @@ const size_t BEES_TRANSID_FACTOR = 10; // Wait this long for a balance to stop const double BEES_BALANCE_POLL_INTERVAL = 60.0; +// Workaround for backref bugs +const bool BEES_SERIALIZE_RESOLVE = false; + +// Workaround for tree mod log bugs +const bool BEES_SERIALIZE_BALANCE = false; + // Flags 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;