Commit 6822b3f
btrfs: do not BUG_ON after failure to migrate space during truncation
During truncation we reserve 2 metadata units when starting a transaction
(reserved space goes to fs_info->trans_block_rsv) and then attempt to
migrate 1 unit (min_size bytes) from fs_info->trans_block_rsv into the
local block reserve. If we ever fail we trigger a BUG_ON(), which should
never happen, because we reserved 2 units. However if we happen to fail
for some reason, we don't need to be so dire and hit a BUG_ON(), we can
just error out the truncation and, since this is highly unexpected,
surround the error check with WARN_ON(), to get an informative stack
trace and tag the branh as 'unlikely'. Also make the 'min_size' variable
const, since it's not supposed to ever change and any accidental change
could possibly make the space migration not so unlikely to fail.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>1 parent df9f278 commit 6822b3f
1 file changed
Lines changed: 18 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8344 | 8344 | | |
8345 | 8345 | | |
8346 | 8346 | | |
8347 | | - | |
| 8347 | + | |
8348 | 8348 | | |
8349 | 8349 | | |
8350 | 8350 | | |
| |||
8401 | 8401 | | |
8402 | 8402 | | |
8403 | 8403 | | |
8404 | | - | |
| 8404 | + | |
| 8405 | + | |
| 8406 | + | |
| 8407 | + | |
| 8408 | + | |
| 8409 | + | |
| 8410 | + | |
| 8411 | + | |
| 8412 | + | |
8405 | 8413 | | |
8406 | 8414 | | |
8407 | 8415 | | |
| |||
8449 | 8457 | | |
8450 | 8458 | | |
8451 | 8459 | | |
8452 | | - | |
| 8460 | + | |
| 8461 | + | |
| 8462 | + | |
| 8463 | + | |
| 8464 | + | |
| 8465 | + | |
| 8466 | + | |
| 8467 | + | |
8453 | 8468 | | |
8454 | 8469 | | |
8455 | 8470 | | |
| |||
0 commit comments