]> git.hungrycats.org Git - linux/commit
btrfs: introduce BTRFS_LOGICAL_INO_ARGS_SEARCH_COMMIT_ROOT to trade latency for accur...
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sun, 22 Mar 2020 20:57:42 +0000 (16:57 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sat, 1 Aug 2020 00:31:53 +0000 (20:31 -0400)
commit161ea35863271bfaeb5014b74d87ed11dbefd521
treea9ab83c719b243461c3916b7c9a1c72400a74aee
parent3d9d4ff1a39879010abfcd5c4f9d8f7a63e05afe
btrfs: introduce BTRFS_LOGICAL_INO_ARGS_SEARCH_COMMIT_ROOT to trade latency for accuracy (v2)

The LOGICAL_INO ioctl is a simple wrapper around an internal btrfs kernel
function which iterates over references to a data extent.  This function
can operate in two modes:

#1 joins the current transaction to get up to date information
on uncommitted references.  LOGICAL_INO can run for a long
time--seconds to minutes on deduped filesystems--and all that
time gets added to the latency of transaction commits. This slows
down other threads writing to the filesystem, as well as reducing
concurrency in LOGICAL_INO itself.

#2 doesn't join a transaction, and just searches commit roots
instead.  This loses access to backref data from uncommitted
references, but doesn't add latency to all other users of the
filesystem while it runs.

Userspace has no mechanism to prevent concurrent changes on the
filesystem, so userspace must tolerate out-of-date backref information
e.g.  looping removing extent refs until LOGICAL_INO gives no more
reachable references.  With a switch from the #1 mode to the #2 mode,
userspace must ensure a commit occurs between loops, either by calling
fssync itself, or by finding something else to do between loop iterations
until a commit occurs naturally.

This is a change in behavior, so we don't do it by default.  Add a new
flag SEARCH_COMMIT_ROOT for LOGICAL_INO_V2 so that users can request
the faster, lower-latency version.

Signed-off-by: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
(cherry picked from commit f35030f24f09ae428a3c069151ee8aaac5d5d041)
(cherry picked from commit 32c0c08a2c7cb65131c2679add5a302eb24c01f2)
(cherry picked from commit d753020b163b1b2ccba6fc39009a11e2c13633e4)
(cherry picked from commit 6c8b74540686d3096f8f0a85749eb71ae0c5e629)

v2: fixed logic to verify that all flags are supported.
(cherry picked from commit 403cd2651289de590d098dce433671eecc092cad)
fs/btrfs/ioctl.c
include/uapi/linux/btrfs.h