FAILED: patch "[PATCH] btrfs: add missing error handling when logging operation" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x d09c51521f22f9cbdfb1cf63e5c456077c622c84
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023071631-retake-dollar-89ea@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
d09c51521f22 ("btrfs: add missing error handling when logging operation while COWing extent buffer") 33cff222faff ("btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key()") 879b22219831 ("btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From d09c51521f22f9cbdfb1cf63e5c456077c622c84 Mon Sep 17 00:00:00 2001
From: Filipe Manana <[email protected]>
Date: Thu, 8 Jun 2023 11:27:37 +0100
Subject: [PATCH] btrfs: add missing error handling when logging operation
while COWing extent buffer
When COWing an extent buffer that is not the root node, we need to log in the tree mod log that we replaced a pointer in the parent node, otherwise a tree mod log user doing a search on the b+tree can return incorrect results (that miss something). We are doing the call to btrfs_tree_mod_log_insert_key() but we totally ignore its return value.
So fix this by adding the missing error handling, resulting in a transaction abort and freeing the COWed extent buffer.
fs/btrfs/ctree.c +8 -2
@@ -595,8 +595,14 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,add_root_to_dirty_list (root); }else {WARN_ON (trans->transid !=btrfs_header_generation (parent)); -btrfs_tree_mod_log_insert_key (parent, parent_slot, -BTRFS_MOD_LOG_KEY_REPLACE ); + ret =btrfs_tree_mod_log_insert_key (parent, parent_slot, +BTRFS_MOD_LOG_KEY_REPLACE ); +if (ret) { +btrfs_tree_unlock (cow); +free_extent_buffer (cow); +btrfs_abort_transaction (trans, ret); +return ret; + }btrfs_set_node_blockptr (parent, parent_slot, cow->start); btrfs_set_node_ptr_generation(parent, parent_slot,