OSDN Git Service

btrfs: reuse roots ulist on each leaf iteration for iterate_extent_inodes()
authorFilipe Manana <fdmanana@suse.com>
Tue, 1 Nov 2022 16:15:48 +0000 (16:15 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 5 Dec 2022 17:00:50 +0000 (18:00 +0100)
commit1baea6f18abf34037169d3b0c585356abb395376
treef0028743045c3e55dff4d78580155587fb916407
parenta2c8d27e5ee810b7149b42b88ddf7298e5b8dfe0
btrfs: reuse roots ulist on each leaf iteration for iterate_extent_inodes()

At iterate_extent_inodes() we collect a ulist of leaves for a given extent
with a call to btrfs_find_all_leafs() and then we enter a loop where we
iterate over all the collected leaves. Each iteration of that loop does a
call to btrfs_find_all_roots_safe(), to determine all roots from which a
leaf is accessible, and that results in allocating and releasing a ulist
to store the root IDs.

Instead of allocating and releasing the roots ulist on every iteration,
allocate a ulist before entering the loop and keep using it on each
iteration, reinitializing the ulist at the end of each iteration.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/backref.c