Commit 09e44868 authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: do not abort transaction on failure to update log root

When syncing a log, if we fail to update a log root in the log root tree,
we are aborting the transaction if the failure was not -ENOSPC. This is
excessive because there is a chance that a transaction commit can succeed,
and therefore avoid to turn the filesystem into RO mode. All we need to be
careful about is to mark the log for a full commit, which we already do,
to make sure no one commits a super block pointing to an outdated log root
tree.

So don't abort the transaction if we fail to update a log root in the log
root tree, and log an error if the failure is not -ENOSPC, so that it does
not go completely unnoticed.

CC: stable@vger.kernel.org # 6.0+
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 16199ad9
...@@ -3044,15 +3044,12 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, ...@@ -3044,15 +3044,12 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
blk_finish_plug(&plug); blk_finish_plug(&plug);
btrfs_set_log_full_commit(trans); btrfs_set_log_full_commit(trans);
if (ret != -ENOSPC)
if (ret != -ENOSPC) { btrfs_err(fs_info,
btrfs_abort_transaction(trans, ret); "failed to update log for root %llu ret %d",
mutex_unlock(&log_root_tree->log_mutex); root->root_key.objectid, ret);
goto out;
}
btrfs_wait_tree_log_extents(log, mark); btrfs_wait_tree_log_extents(log, mark);
mutex_unlock(&log_root_tree->log_mutex); mutex_unlock(&log_root_tree->log_mutex);
ret = BTRFS_LOG_FORCE_COMMIT;
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment