]> www.infradead.org Git - nvme.git/commit
btrfs: preallocate ulist memory for qgroup rsv
authorBoris Burkov <boris@bur.io>
Thu, 20 Jun 2024 17:33:10 +0000 (10:33 -0700)
committerDavid Sterba <dsterba@suse.com>
Thu, 11 Jul 2024 13:33:26 +0000 (15:33 +0200)
commit33336c1805d3a03240afda0bfb8c8d20395fb1d3
tree78fc6415f954e4e5297404af1ae93ae75b8a63a9
parent28cb13f29faf6290597b24b728dc3100c019356f
btrfs: preallocate ulist memory for qgroup rsv

When qgroups are enabled, during data reservation, we allocate the
ulist_nodes that track the exact reserved extents with GFP_ATOMIC
unconditionally. This is unnecessary, and we can follow the model
already employed by the struct extent_state we preallocate in the non
qgroups case, which should reduce the risk of allocation failures with
GFP_ATOMIC.

Add a prealloc node to struct ulist which ulist_add will grab when it is
present, and try to allocate it before taking the tree lock while we can
still take advantage of a less strict gfp mask. The lifetime of that
node belongs to the new prealloc field, until it is used, at which point
it belongs to the ulist linked list.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-io-tree.c
fs/btrfs/extent_io.h
fs/btrfs/ulist.c
fs/btrfs/ulist.h