aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/delayed-ref.h
diff options
context:
space:
mode:
authorGravatar Boris Burkov <boris@bur.io> 2023-06-28 11:00:15 -0700
committerGravatar David Sterba <dsterba@suse.com> 2023-10-12 16:44:11 +0200
commitcecbb533b5fcec4ff77e786b7f94457f6cacd9e7 (patch)
tree731c0375171c69611c727aa2adc612447434f557 /fs/btrfs/delayed-ref.h
parentbtrfs: add helper for inline owner ref lookup (diff)
downloadlinux-cecbb533b5fcec4ff77e786b7f94457f6cacd9e7.tar.gz
linux-cecbb533b5fcec4ff77e786b7f94457f6cacd9e7.tar.bz2
linux-cecbb533b5fcec4ff77e786b7f94457f6cacd9e7.zip
btrfs: record simple quota deltas in delayed refs
At the moment that we run delayed refs, we make the final ref-count based decision on creating/removing extent (and metadata) items. Therefore, it is exactly the spot to hook up simple quotas. There are a few important subtleties to the fields we must collect to accurately track simple quotas, particularly when removing an extent. When removing a data extent, the ref could be in any tree (due to reflink, for example) and so we need to recover the owning root id from the owner ref item. When removing a metadata extent, we know the owning root from the owner field in the header when we create the delayed ref, so we can recover it from there. We must also be careful to handle reservations properly to not leaked reserved space. The happy path is freeing the reservation when the simple quota delta runs on a data extent. If that doesn't happen, due to refs canceling out or some error, the ref head already has the must_insert_reserved machinery to handle this, so we piggy back on that and use it to clean up the reserved data. Signed-off-by: Boris Burkov <boris@bur.io> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/delayed-ref.h')
-rw-r--r--fs/btrfs/delayed-ref.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
index 47e4bdf4fb30..3b4f71dc30be 100644
--- a/fs/btrfs/delayed-ref.h
+++ b/fs/btrfs/delayed-ref.h
@@ -117,6 +117,12 @@ struct btrfs_delayed_ref_head {
u64 owning_root;
/*
+ * Track reserved bytes when setting must_insert_reserved. On success
+ * or cleanup, we will need to free the reservation.
+ */
+ u64 reserved_bytes;
+
+ /*
* when a new extent is allocated, it is just reserved in memory
* The actual extent isn't inserted into the extent allocation tree
* until the delayed ref is processed. must_insert_reserved is