btrfs: assert delayed node locked when removing delayed item
authorFilipe Manana <fdmanana@suse.com>
Mon, 28 Aug 2023 08:06:44 +0000 (09:06 +0100)
committerDavid Sterba <dsterba@suse.com>
Fri, 8 Sep 2023 12:20:40 +0000 (14:20 +0200)
commita57c2d4e46f519b24558ae0752c17eec416ac72a
treec90bcac5a57122d0234e0a8880706bd7f588f2d1
parent2c58c3931ede7cd08cbecf1f1a4acaf0a04a41a9
btrfs: assert delayed node locked when removing delayed item

When removing a delayed item, or releasing which will remove it as well,
we will modify one of the delayed node's rbtrees and item counter if the
delayed item is in one of the rbtrees. This require having the delayed
node's mutex locked, otherwise we will race with other tasks modifying
the rbtrees and the counter.

This is motivated by a previous version of another patch actually calling
btrfs_release_delayed_item() after unlocking the delayed node's mutex and
against a delayed item that is in a rbtree.

So assert at __btrfs_remove_delayed_item() that the delayed node's mutex
is locked.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/delayed-inode.c