Fix reference count lookup race
PATCH 1/1 Fix reference count lookup race
hello,
btrfs_lookup_extent_ref is used to check the reference count for a given extent, it returns the sum of the reference count recorded in BTRFS_EXTENT_ITEM and the reference count modifications queued up in the delayed back references. Since we can't get these two counts atomically, it's possible someone else jumps in and processes the delayed back references. This patch makes btrfs_lookup_extent_ref properly the race. Thank you,
Signed-off-by Yan Zheng <[email protected]>
---
fs/btrfs/ctree.h +0 -3
@@ -1704,9 +1704,6 @@ static inline struct dentry *fdentry(strint btrfs_run_delayed_refs (struct btrfs_trans_handle *trans,struct btrfs_root *root,unsigned long count);int btrfs_lookup_extent (struct btrfs_root *root,u64 start,u64 len); -int btrfs_lookup_extent_ref (struct btrfs_trans_handle *trans, -struct btrfs_root *root,u64 bytenr, -u64 num_bytes,u32 *refs);int btrfs_update_pinned_extents (struct btrfs_root *root,u64 bytenr,u64 num,int pin); int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans,
fs/btrfs/delayed-ref.c +43 -24
101 lines not on this page · raw message
fs/btrfs/delayed-ref.h +3 -1
@@ -144,7 +144,9 @@ int btrfs_delayed_ref_pending(struct btrint btrfs_lock_delayed_ref (struct btrfs_trans_handle *trans,struct btrfs_delayed_ref_node *ref,struct btrfs_delayed_ref_head **next_ret); -int btrfs_delayed_ref_count_mod (struct btrfs_trans_handle *trans,u64 bytenr); +int btrfs_lookup_extent_ref (struct btrfs_trans_handle *trans, +struct btrfs_root *root,u64 bytenr, +u64 num_bytes,u32 *refs);/* * a node might live in a head or a regular ref, this lets you
fs/btrfs/extent-tree.c +1 -54
109 lines not on this page · raw message