David Sterba 6140ba8a0a btrfs: switch btrfs_root::delayed_nodes_tree to xarray from radix-tree
The radix-tree has been superseded by the xarray
(https://lwn.net/Articles/745073), this patch converts the
btrfs_root::delayed_nodes, the APIs are used in a simple way.

First idea is to do xa_insert() but this would require GFP_ATOMIC
allocation which we want to avoid if possible. The preload mechanism of
radix-tree can be emulated within the xarray API.

- xa_reserve() with GFP_NOFS outside of the lock, the reserved entry
  is inserted atomically at most once

- xa_store() under a lock, in case something races in we can detect that
  and xa_load() returns a valid pointer

All uses of xa_load() must check for a valid pointer in case they manage
to get between the xa_reserve() and xa_store(), this is handled in
btrfs_get_delayed_node().

Otherwise the functionality is equivalent, xarray implements the
radix-tree and there should be no performance difference.

The patch continues the efforts started in 253bf57555e451 ("btrfs: turn
delayed_nodes_tree into an XArray") and fixes the problems with locking
and GFP flags 088aea3b97e0ae ("Revert "btrfs: turn delayed_nodes_tree
into an XArray"").

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-12-15 23:01:03 +01:00
..
2023-01-19 09:24:28 +01:00
2023-01-19 09:24:27 +01:00
2023-10-30 10:42:06 -10:00
2023-10-30 10:42:06 -10:00
2023-12-15 23:00:04 +01:00
2023-12-15 20:27:04 +01:00
2023-11-28 11:16:04 -08:00
2023-08-24 16:20:18 -07:00
2023-12-15 23:00:04 +01:00
2023-10-30 10:42:06 -10:00
2023-12-15 23:00:04 +01:00
2023-11-24 18:50:53 +01:00
2023-12-15 20:27:04 +01:00
2023-10-12 16:44:18 +02:00
2023-12-14 11:53:00 -08:00
2023-12-15 23:00:04 +01:00
2023-12-15 23:00:04 +01:00