Skip to content

Commit e587f12

Browse files
fdmananagregkh
authored andcommitted
btrfs: abort transaction in the process_one_buffer() log tree walk callback
[ Upstream commit e6dd405b6671b9753b98d8bdf76f8f0ed36c11cd ] In the process_one_buffer() log tree walk callback we return errors to the log tree walk caller and then the caller aborts the transaction, if we have one, or turns the fs into error state if we don't have one. While this reduces code it makes it harder to figure out where exactly an error came from. So add the transaction aborts after every failure inside the process_one_buffer() callback, so that it helps figuring out why failures happen. Reviewed-by: Boris Burkov <[email protected]> Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent b64764e commit e587f12

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

fs/btrfs/tree-log.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ static int process_one_buffer(struct btrfs_root *log,
347347
struct extent_buffer *eb,
348348
struct walk_control *wc, u64 gen, int level)
349349
{
350+
struct btrfs_trans_handle *trans = wc->trans;
350351
struct btrfs_fs_info *fs_info = log->fs_info;
351352
int ret = 0;
352353

@@ -361,18 +362,29 @@ static int process_one_buffer(struct btrfs_root *log,
361362
};
362363

363364
ret = btrfs_read_extent_buffer(eb, &check);
364-
if (ret)
365+
if (ret) {
366+
if (trans)
367+
btrfs_abort_transaction(trans, ret);
368+
else
369+
btrfs_handle_fs_error(fs_info, ret, NULL);
365370
return ret;
371+
}
366372
}
367373

368374
if (wc->pin) {
369-
ret = btrfs_pin_extent_for_log_replay(wc->trans, eb);
370-
if (ret)
375+
ASSERT(trans != NULL);
376+
ret = btrfs_pin_extent_for_log_replay(trans, eb);
377+
if (ret) {
378+
btrfs_abort_transaction(trans, ret);
371379
return ret;
380+
}
372381

373382
if (btrfs_buffer_uptodate(eb, gen, 0) &&
374-
btrfs_header_level(eb) == 0)
383+
btrfs_header_level(eb) == 0) {
375384
ret = btrfs_exclude_logged_extents(eb);
385+
if (ret)
386+
btrfs_abort_transaction(trans, ret);
387+
}
376388
}
377389
return ret;
378390
}

0 commit comments

Comments
 (0)