* `yes` (the default) prevents any thread from running dedupe while another thread is running `LOGICAL_INO`, and vice versa. The two ioctls never overlap.
* `no` removes the restriction: any thread may run either operation at any time. This is faster under high concurrency but unsafe on kernels affected by the bug.
+ * `auto` starts like `yes`, and switches to `no` once a `LOGICAL_INO` call has successfully walked the commit root (see `resolve.commit-root`). The bug needs `LOGICAL_INO` to walk the same trees dedupe is modifying, and commit-root walks do not. The restriction stays in place if `resolve.commit-root = no`, or if the kernel does not support commit-root walks.
Leave this enabled unless you have confirmed your kernel is not affected.
# bug triggered when both run concurrently. yes: no thread runs
# dedupe while another runs LOGICAL_INO (and vice versa). no: any
# thread may run either operation at any time (faster, but unsafe
- # on affected kernels).
+ # on affected kernels). auto: yes until a LOGICAL_INO call using
+ # the commit root succeeds, then no; stays yes if
+ # resolve.commit-root = no or the kernel lacks the flag.
workaround-clone-logical-ino = yes
BEESLOGWARN("LOGICAL_INO commit-root resolution rejected by this kernel, using live-root walks");
}
+ // thread.workaround-clone-logical-ino = auto: the kernel bug needs
+ // LOGICAL_INO walking the same live trees that dedupe is modifying.
+ // Once a walk with the COMMIT_ROOT flag has succeeded, every later
+ // walk uses the commit root too, so the serialization can go. Until
+ // then (support unknown, unsupported, or resolve.commit-root = no) it
+ // stays. The check runs before the next call rather than after the
+ // confirming one, so one extra call may still be serialized.
+ THROW_CHECK0(runtime_error, m_workaround_clone_logical_ino_auto);
+ if (*m_workaround_clone_logical_ino_auto && *m_resolve_commit_root
+ && !m_workaround_clone_logical_ino_released.load()
+ && BtrfsIoctlLogicalInoArgs::commit_root_confirmed()
+ && !m_workaround_clone_logical_ino_released.exchange(true)) {
+ MultiLocker::enable_locking(false);
+ BEESLOGINFO("LOGICAL_INO commit-root resolution confirmed, no longer serializing dedupe against it [thread.workaround-clone-logical-ino]");
+ }
+
return rv;
}
BEESLOGINFO("resolving refs against the "
<< (*m_resolve_commit_root ? "commit root" : "live root")
<< " [resolve.commit-root]");
+
+ // Workaround for the logical-ino-vs-clone kernel bug: serialize the
+ // dedupe ioctl against LOGICAL_INO. "auto" starts serialized and lets
+ // logical_ino() lift it once a commit-root walk has succeeded.
+ BEESTRACE("loading thread.workaround-clone-logical-ino");
+ const auto workaround_clone_logical_ino = m_config->get("thread.workaround-clone-logical-ino", [](const string &str) -> optional<bool> {
+ if (str == "auto") {
+ return nullopt;
+ }
+ return bees_parse_bool(str);
+ });
+ m_workaround_clone_logical_ino_auto = !workaround_clone_logical_ino;
+ MultiLocker::enable_locking(workaround_clone_logical_ino.value_or(true));
+ BEESLOGINFO("thread.workaround-clone-logical-ino = "
+ << (!workaround_clone_logical_ino ? "auto" : *workaround_clone_logical_ino ? "yes" : "no")
+ << " [thread.workaround-clone-logical-ino]");
+
}
void
bc->get_config().get("state.point.defer", bees_parse_bool));
}
- // Workaround for the logical-ino-vs-clone kernel bug: serialize the
- // dedupe ioctl against LOGICAL_INO unless the operator opts out.
- const bool workaround_clone_logical_ino = bc->get_config().get("thread.workaround-clone-logical-ino", bees_parse_bool);
- BEESLOGINFO("thread.workaround-clone-logical-ino = " << (workaround_clone_logical_ino ? "yes" : "no") << " [thread.workaround-clone-logical-ino]");
- MultiLocker::enable_locking(workaround_clone_logical_ino);
-
// Start crawlers
bc->start();
/// resolution. Empty until set_config() loads it; reading it before
/// then throws rather than silently picking a side.
optional<bool> m_resolve_commit_root;
+ /// thread.workaround-clone-logical-ino = auto: keep the dedupe vs
+ /// LOGICAL_INO serialization only until a commit-root walk succeeds.
+ /// Empty until set_config() loads it.
+ optional<bool> m_workaround_clone_logical_ino_auto;
+ /// Set once the auto workaround has been switched off.
+ atomic<bool> m_workaround_clone_logical_ino_released{false};
LRUCache<BeesResolveAddrResult, BeesAddress> m_resolve_cache; ///< Caches LOGICAL_INO results.
{ "verify-delay", Kind_Count },
{ "version", Kind_Free },
{ "workaround-btrfs-send", Kind_Bool },
- { "workaround-clone-logical-ino", Kind_Bool },
+ { "workaround-clone-logical-ino", Kind_Free },
{ "writeback-fsync", Kind_Bool },
{ "writeback-rate-max", Kind_Size },
{ "writeback-time", Kind_Duration },