Skip to contentSkip to conversation

FAILED: patch "[PATCH] btrfs: free qgroup rsv on io failure" failed to apply to 5.10-stable tree

PATCH [email protected] 1 participant 1 message Sep 16, 2023

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.10-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.10.y
git checkout FETCH_HEAD
git cherry-pick -x e28b02118b94e42be3355458a2406c6861e2dd32
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023091632-graceful-actress-f418@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^..

Possible dependencies:

e28b02118b94 ("btrfs: free qgroup rsv on io failure")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From e28b02118b94e42be3355458a2406c6861e2dd32 Mon Sep 17 00:00:00 2001
From: Boris Burkov <[email protected]>
Date: Fri, 21 Jul 2023 09:02:06 -0700
Subject: [PATCH] btrfs: free qgroup rsv on io failure

If we do a write whose bio suffers an error, we will never reclaim the qgroup reserved space for it. We allocate the space in the write_iter codepath, then release the reservation as we allocate the ordered extent, but we only create a delayed ref if the ordered extent finishes. If it has an error, we simply leak the rsv. This is apparent in running any error injecting (dmerror) fstests like btrfs/146 or btrfs/160. Such tests fail due to dmesg on umount complaining about the leaked qgroup data space.

When we clean up other aspects of space on failed ordered_extents, also free the qgroup rsv.

fs/btrfs/inode.c +7 -0
index 5508597be614..8e53df3516c2 100644
@@ -3358,6 +3358,13 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
 			btrfs_free_reserved_extent(fs_info,
 					ordered_extent->disk_bytenr,
 					ordered_extent->disk_num_bytes, 1);
+			/*
+			 * Actually free the qgroup rsv which was released when
+			 * the ordered extent was created.
+			 */
+			btrfs_qgroup_free_refroot(fs_info, inode->root->root_key.objectid,
+						  ordered_extent->qgroup_rsv,
+						  BTRFS_QGROUP_RSV_DATA);
 		}
 	}