diff mbox series

[15/18] btrfs: convert BUG() for pending_del_nr into an ASSERT

Message ID ae5ba0416e8d9c8153b4f48ea8960262fc5cc560.1638569556.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series Truncate cleanups and preparation work | expand

Commit Message

Josef Bacik Dec. 3, 2021, 10:18 p.m. UTC
This is a logic correctness check, convert it into an ASSERT() instead
of a BUG().

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/inode-item.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c
index 652b7069f63d..9c44cf30d930 100644
--- a/fs/btrfs/inode-item.c
+++ b/fs/btrfs/inode-item.c
@@ -655,6 +655,9 @@  int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
 		else
 			control->last_size = new_size;
 		if (del_item) {
+			ASSERT(!pending_del_nr ||
+			       ((path->slots[0] + 1) == pending_del_slot));
+
 			if (!pending_del_nr) {
 				/* no pending yet, add ourselves */
 				pending_del_slot = path->slots[0];
@@ -664,8 +667,6 @@  int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
 				/* hop on the pending chunk */
 				pending_del_nr++;
 				pending_del_slot = path->slots[0];
-			} else {
-				BUG();
 			}
 		} else {
 			break;