Patch "btrfs: abort transaction at update_ref_for_cow() when ref count is zero" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    btrfs: abort transaction at update_ref_for_cow() when ref count is zero

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     btrfs-abort-transaction-at-update_ref_for_cow-when-r.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 900381c5b94bbbed02019ca472e70b35c02776d8
Author: Filipe Manana <fdmanana@xxxxxxxx>
Date:   Thu Jun 8 11:27:45 2023 +0100

    btrfs: abort transaction at update_ref_for_cow() when ref count is zero
    
    [ Upstream commit eced687e224eb3cc5a501cf53ad9291337c8dbc5 ]
    
    At update_ref_for_cow() we are calling btrfs_handle_fs_error() if we find
    that the extent buffer has an unexpected ref count of zero, however we can
    simply use btrfs_abort_transaction(), which achieves the same purposes: to
    turn the fs to error state, abort the current transaction and turn the fs
    to RO mode as well. Besides that, btrfs_abort_transaction() also prints a
    stack trace which makes it more useful.
    
    Also, as this is a very unexpected situation, indicating a serious
    corruption/inconsistency, tag the if branch as 'unlikely', set the error
    code to -EUCLEAN instead of -EROFS, and log an explicit message.
    
    Reviewed-by: Qu Wenruo <wqu@xxxxxxxx>
    Signed-off-by: Filipe Manana <fdmanana@xxxxxxxx>
    Reviewed-by: David Sterba <dsterba@xxxxxxxx>
    Signed-off-by: David Sterba <dsterba@xxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 1a327eb3580b4..66f52dff277d9 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -309,9 +309,13 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
 					       &refs, &flags);
 		if (ret)
 			return ret;
-		if (refs == 0) {
-			ret = -EROFS;
-			btrfs_handle_fs_error(fs_info, ret, NULL);
+		if (unlikely(refs == 0)) {
+			btrfs_crit(fs_info,
+		"found 0 references for tree block at bytenr %llu level %d root %llu",
+				   buf->start, btrfs_header_level(buf),
+				   btrfs_root_id(root));
+			ret = -EUCLEAN;
+			btrfs_abort_transaction(trans, ret);
 			return ret;
 		}
 	} else {



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux