diff mbox series

[7/9] btrfs: use assertion instead of BUG_ON when adding/removing to delalloc list

Message ID d5c32d0109f92b848b6a0054571ef48b82bd77ac.1707491248.git.fdmanana@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: cleanups and minor performance change to setting/clearing delalloc | expand

Commit Message

Filipe Manana Feb. 9, 2024, 6 p.m. UTC
From: Filipe Manana <fdmanana@suse.com>

When adding or removing and inode to/from the root's delalloc list,
instead of using a BUG_ON() to validate list emptiness, use ASSERT()
since this is to check logic errors rather than real errors.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Qu Wenruo Feb. 10, 2024, 7:48 a.m. UTC | #1
On 2024/2/10 04:30, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> When adding or removing and inode to/from the root's delalloc list,
> instead of using a BUG_ON() to validate list emptiness, use ASSERT()
> since this is to check logic errors rather than real errors.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>   fs/btrfs/inode.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index c7a5fb1f8b3e..fe962a6045fd 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -2400,7 +2400,7 @@ static void btrfs_add_delalloc_inode(struct btrfs_inode *inode)
>   	root->nr_delalloc_inodes++;
>   	if (root->nr_delalloc_inodes == 1) {
>   		spin_lock(&fs_info->delalloc_root_lock);
> -		BUG_ON(!list_empty(&root->delalloc_root));
> +		ASSERT(list_empty(&root->delalloc_root));
>   		list_add_tail(&root->delalloc_root, &fs_info->delalloc_roots);
>   		spin_unlock(&fs_info->delalloc_root_lock);
>   	}
> @@ -2426,7 +2426,7 @@ void __btrfs_del_delalloc_inode(struct btrfs_inode *inode)
>   		if (!root->nr_delalloc_inodes) {
>   			ASSERT(list_empty(&root->delalloc_inodes));
>   			spin_lock(&fs_info->delalloc_root_lock);
> -			BUG_ON(list_empty(&root->delalloc_root));
> +			ASSERT(!list_empty(&root->delalloc_root));
>   			list_del_init(&root->delalloc_root);
>   			spin_unlock(&fs_info->delalloc_root_lock);
>   		}
diff mbox series

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c7a5fb1f8b3e..fe962a6045fd 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2400,7 +2400,7 @@  static void btrfs_add_delalloc_inode(struct btrfs_inode *inode)
 	root->nr_delalloc_inodes++;
 	if (root->nr_delalloc_inodes == 1) {
 		spin_lock(&fs_info->delalloc_root_lock);
-		BUG_ON(!list_empty(&root->delalloc_root));
+		ASSERT(list_empty(&root->delalloc_root));
 		list_add_tail(&root->delalloc_root, &fs_info->delalloc_roots);
 		spin_unlock(&fs_info->delalloc_root_lock);
 	}
@@ -2426,7 +2426,7 @@  void __btrfs_del_delalloc_inode(struct btrfs_inode *inode)
 		if (!root->nr_delalloc_inodes) {
 			ASSERT(list_empty(&root->delalloc_inodes));
 			spin_lock(&fs_info->delalloc_root_lock);
-			BUG_ON(list_empty(&root->delalloc_root));
+			ASSERT(!list_empty(&root->delalloc_root));
 			list_del_init(&root->delalloc_root);
 			spin_unlock(&fs_info->delalloc_root_lock);
 		}