Skip to content

Commit 16199ad

Browse files
fdmananakdave
authored andcommitted
btrfs: do not abort transaction on failure to write log tree when syncing log
When syncing the log, if we fail to write log tree extent buffers, we mark the log for a full commit and abort the transaction. However we don't need to abort the transaction, all we really need to do is to make sure no one can commit a superblock pointing to new log tree roots. Just because we got a failure writing extent buffers for a log tree, it does not mean we will also fail to do a transaction commit. One particular case is if due to a bug somewhere, when writing log tree extent buffers, the tree checker detects some corruption and the writeout fails because of that. Aborting the transaction can be very disruptive for a user, specially if the issue happened on a root filesystem. One example is the scenario in the Link tag below, where an isolated corruption on log tree leaves was causing transaction aborts when syncing the log. Link: https://lore.kernel.org/linux-btrfs/[email protected]/ CC: [email protected] # 5.15+ Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 94cd63a commit 16199ad

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

fs/btrfs/disk-io.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,14 @@ static int csum_one_extent_buffer(struct extent_buffer *eb)
367367
btrfs_print_tree(eb, 0);
368368
btrfs_err(fs_info, "block=%llu write time tree block corruption detected",
369369
eb->start);
370-
WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
370+
/*
371+
* Be noisy if this is an extent buffer from a log tree. We don't abort
372+
* a transaction in case there's a bad log tree extent buffer, we just
373+
* fallback to a transaction commit. Still we want to know when there is
374+
* a bad log tree extent buffer, as that may signal a bug somewhere.
375+
*/
376+
WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG) ||
377+
btrfs_header_owner(eb) == BTRFS_TREE_LOG_OBJECTID);
371378
return ret;
372379
}
373380

fs/btrfs/tree-log.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,7 +2980,6 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
29802980
ret = 0;
29812981
if (ret) {
29822982
blk_finish_plug(&plug);
2983-
btrfs_abort_transaction(trans, ret);
29842983
btrfs_set_log_full_commit(trans);
29852984
mutex_unlock(&root->log_mutex);
29862985
goto out;
@@ -3112,7 +3111,6 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
31123111
goto out_wake_log_root;
31133112
} else if (ret) {
31143113
btrfs_set_log_full_commit(trans);
3115-
btrfs_abort_transaction(trans, ret);
31163114
mutex_unlock(&log_root_tree->log_mutex);
31173115
goto out_wake_log_root;
31183116
}

0 commit comments

Comments
 (0)