summaryrefslogtreecommitdiff
path: root/include/uapi/linux
diff options
context:
space:
mode:
authorJoanne Koong <joannelkoong@gmail.com>2026-09-22 13:12:57 -0700
committerDavid Sterba <dsterba@suse.com>2026-11-09 17:59:31 +0100
commitf20ec1d9e53807b1193fba74d40db9ddecd24b4c (patch)
tree4c00b998799f34a8b8950c3de747d328b33e14a4 /include/uapi/linux
parent7475ea8b58616b33c04afb976cf0fbaad9dd63fb (diff)
downloadlinux-next-f20ec1d9e53807b1193fba74d40db9ddecd24b4c.tar.gz
linux-next-f20ec1d9e53807b1193fba74d40db9ddecd24b4c.zip
btrfs: add LOGICAL_INO_V2 flag for avoiding the tree modification log
At Meta, we use the LOGICAL_INO_V2 ioctl to estimate sharing-aware space usage. We sample the logical address space and resolve each sample back to the inodes which reference it. The measurement is statistical, so with enough samples it gives good bounds on real usage. Currently in the LOGICAL_INO_V2 ioctl path, iterate_extent_inodes() (which can walk backrefs either against the current trees or against the commit roots) acquires a tree modification log sequence number when walking the current trees, since those trees are being modified while the walk is in progress. The log is then enabled filesystem wide for as long as any such walk is running, and is only disabled again once the last walk has finished. While it is enabled the cost impacts the whole filesystem, not only the caller. Modifications of interior nodes of the extent tree and of subvolume trees have to be recorded, serialized on a single filesystem wide lock. Delayed refs with a sequence number at or above the oldest active one can not be run (the run path bails out with -EAGAIN in btrfs_run_delayed_refs_for_head()), and metadata refs above it can not be merged, so they accumulate and that work is deferred to transaction commit. Currently, userspace has no way to ask for anything cheaper. Whenever a transaction is running, the walk uses the tree modification log, even if the caller would tolerate results that could be up to one commit interval stale. Give userspace this option by adding BTRFS_LOGICAL_INO_ARGS_COMMIT_ROOT, which makes the backref walk use the commit roots and therefore never enables the tree modification log. Behavior is unchanged unless the flag gets explicitly passed by userspace. iterate_extent_inodes() already takes a search_commit_root argument for this, which scrub, send and the data relocation warning path all pass as true. The flag simply plumbs it through to userspace. Assisted-by: LLM Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Joanne Koong <joannelkoong@gmail.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'include/uapi/linux')
-rw-r--r--include/uapi/linux/btrfs.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
index 0a13baf3d8d1..b6f196bfa600 100644
--- a/include/uapi/linux/btrfs.h
+++ b/include/uapi/linux/btrfs.h
@@ -732,6 +732,16 @@ struct btrfs_ioctl_logical_ino_args {
*/
#define BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET (1ULL << 0)
+/*
+ * Resolve backrefs against the commit roots instead of the current trees.
+ *
+ * Resolving against the current trees is more expensive for the filesystem as
+ * a whole, not only for the caller. Callers that do not need to observe the
+ * currently running transaction should set this. The result can be up to one
+ * commit interval stale.
+ */
+#define BTRFS_LOGICAL_INO_ARGS_COMMIT_ROOT (1ULL << 1)
+
enum btrfs_dev_stat_values {
/* disk I/O failure stats */
BTRFS_DEV_STAT_WRITE_ERRS, /* EIO or EREMOTEIO from lower layers */