/// whether it does.
static bool commit_root_supported();
+ /// True once a call with BTRFS_LOGICAL_INO_ARGS_COMMIT_ROOT
+ /// has succeeded in this process, proving the kernel walked
+ /// the commit root. False while support is unknown and when
+ /// it is proven absent.
+ static bool commit_root_confirmed();
+
struct BtrfsInodeOffsetRootSpan {
using iterator = BtrfsInodeOffsetRoot*;
using const_iterator = const BtrfsInodeOffsetRoot*;
// FS_IOC_FIEMAP
#include <linux/fs.h>
+#include <atomic>
#include <cassert>
#include <cstddef>
#include <iostream>
/// supported once a call with it succeeds, and known unsupported only
/// when a call with it fails with EINVAL and an immediate repeat of the
/// same call without it succeeds. A kernel will not learn the flag
- /// while this process runs, so both conclusions are permanent. Raced
- /// like bili_version below, and harmlessly: racing threads can only
- /// repeat a probe, and every probe on one kernel reaches the same answer.
+ /// while this process runs, so both conclusions are permanent. Racing
+ /// threads can only repeat a probe, and every probe on one kernel
+ /// reaches the same answer. Atomic because other threads read the
+ /// answer through commit_root_supported() and commit_root_confirmed().
enum BiliCommitRoot {
BILI_COMMIT_ROOT_UNKNOWN,
BILI_COMMIT_ROOT_SUPPORTED,
BILI_COMMIT_ROOT_UNSUPPORTED,
};
- static BiliCommitRoot bili_commit_root = BILI_COMMIT_ROOT_UNKNOWN;
+ static atomic<BiliCommitRoot> bili_commit_root(BILI_COMMIT_ROOT_UNKNOWN);
bool
BtrfsIoctlLogicalInoArgs::commit_root_supported()
return bili_commit_root != BILI_COMMIT_ROOT_UNSUPPORTED;
}
+ bool
+ BtrfsIoctlLogicalInoArgs::commit_root_confirmed()
+ {
+ return bili_commit_root == BILI_COMMIT_ROOT_SUPPORTED;
+ }
+
bool
BtrfsIoctlLogicalInoArgs::do_ioctl_nothrow(int fd)
{