Message ID | fbc35af56c5b21fbceba9c0c1038a03907361427.1694174371.git.fdmanana@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: updates to delayed refs accounting and space reservation | expand |
On Fri, Sep 08, 2023 at 01:09:06PM +0100, fdmanana@kernel.org wrote: > From: Filipe Manana <fdmanana@suse.com> > > When running delayed references, at btrfs_run_delayed_refs(), we have this > logic to run any new delayed references that might have been added just > after we ran all delayed references. This logic grabs the first delayed > reference, then locks it to wait for any contention on it before running > all new delayed references. This however is pointless and not necessary > because at __btrfs_run_delayed_refs() when we start running delayed > references, we pick the first reference with btrfs_obtain_ref_head() and > then we will lock it (with btrfs_delayed_ref_lock()). > > So remove the duplicate and unnecessary logic at btrfs_run_delayed_refs(). > > Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Thanks, Josef
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 07d3896e6824..929fbb620d68 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2135,9 +2135,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, unsigned long count) { struct btrfs_fs_info *fs_info = trans->fs_info; - struct rb_node *node; struct btrfs_delayed_ref_root *delayed_refs; - struct btrfs_delayed_ref_head *head; int ret; int run_all = count == (unsigned long)-1; @@ -2166,25 +2164,16 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, btrfs_create_pending_block_groups(trans); spin_lock(&delayed_refs->lock); - node = rb_first_cached(&delayed_refs->href_root); - if (!node) { + if (RB_EMPTY_ROOT(&delayed_refs->href_root.rb_root)) { spin_unlock(&delayed_refs->lock); - goto out; + return 0; } - head = rb_entry(node, struct btrfs_delayed_ref_head, - href_node); - refcount_inc(&head->refs); spin_unlock(&delayed_refs->lock); - /* Mutex was contended, block until it's released and retry. */ - mutex_lock(&head->mutex); - mutex_unlock(&head->mutex); - - btrfs_put_delayed_ref_head(head); cond_resched(); goto again; } -out: + return 0; }