Qu Wenruo 257614301a btrfs: handle errors properly in update_inline_extent_backref()
[PROBLEM]
Inside function update_inline_extent_backref(), we have several
BUG_ON()s along with some ASSERT()s which can be triggered by corrupted
filesystem.

[ANAYLYSE]
Most of those BUG_ON()s and ASSERT()s are just a way of handling
unexpected on-disk data.

Although we have tree-checker to rule out obviously incorrect extent
tree blocks, it's not enough for these ones.  Thus we need proper error
handling for them.

[FIX]
Thankfully all the callers of update_inline_extent_backref() would
eventually handle the errror by aborting the current transaction.
So this patch would do the proper error handling by:

- Make update_inline_extent_backref() to return int
  The return value would be either 0 or -EUCLEAN.

- Replace BUG_ON()s and ASSERT()s with proper error handling
  This includes:
  * Dump the bad extent tree leaf
  * Output an error message for the cause
    This would include the extent bytenr, num_bytes (if needed), the bad
    values and expected good values.
  * Return -EUCLEAN

  Note here we remove all the WARN_ON()s, as eventually the transaction
  would be aborted, thus a backtrace would be triggered anyway.

- Better comments on why we expect refs == 1 and refs_to_mode == -1 for
  tree blocks

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-21 14:52:20 +02:00
..
2023-06-26 10:14:36 -07:00
2023-06-29 13:27:50 -07:00
\n
2023-06-29 13:39:51 -07:00
2023-07-05 14:14:37 -07:00
2023-07-19 11:00:27 -07:00
2023-08-07 18:42:04 +02:00
2023-06-27 17:10:27 -07:00
2023-06-26 11:52:12 -07:00
2023-07-03 12:56:23 -07:00
2023-07-01 14:38:25 -07:00
2023-07-01 14:38:25 -07:00
2023-08-03 09:26:34 -07:00
2023-07-07 14:59:38 -07:00
2023-06-27 21:21:32 -07:00
2023-03-14 12:56:30 -06:00
2023-06-05 16:50:30 +02:00
2023-08-16 00:26:07 -05:00
2023-06-15 13:37:53 +02:00
2023-06-26 11:52:12 -07:00
\n
2023-06-29 13:39:51 -07:00
2023-08-08 14:59:49 -07:00
2023-03-30 08:51:48 +02:00
2023-06-28 20:35:21 -07:00
\n
2023-06-29 13:39:51 -07:00
2023-06-26 09:50:21 -07:00
2023-05-17 09:16:59 +02:00
2023-06-26 09:50:21 -07:00
\n
2023-06-29 13:31:44 -07:00
2023-02-20 11:53:11 -08:00
2023-08-12 09:18:47 -07:00
2023-06-26 10:14:36 -07:00
2023-06-26 12:47:20 -07:00
2023-01-19 09:24:30 +01:00
2023-07-04 10:20:29 +02:00
2023-06-26 10:27:04 -07:00
2023-05-19 04:30:22 +02:00
2023-05-19 04:30:22 +02:00
2023-03-06 09:59:20 +01:00
2023-02-20 11:53:11 -08:00
\n
2023-06-29 13:39:51 -07:00
2023-02-20 11:53:11 -08:00