--- /dev/null
+From 2b084d8205949dd804e279df8e68531da78be1e8 Mon Sep 17 00:00:00 2001
+From: Haisu Wang <haisuwang@tencent.com>
+Date: Fri, 25 Oct 2024 14:54:40 +0800
+Subject: btrfs: fix the length of reserved qgroup to free
+
+From: Haisu Wang <haisuwang@tencent.com>
+
+commit 2b084d8205949dd804e279df8e68531da78be1e8 upstream.
+
+The dealloc flag may be cleared and the extent won't reach the disk in
+cow_file_range when errors path. The reserved qgroup space is freed in
+commit 30479f31d44d ("btrfs: fix qgroup reserve leaks in
+cow_file_range"). However, the length of untouched region to free needs
+to be adjusted with the correct remaining region size.
+
+Fixes: 30479f31d44d ("btrfs: fix qgroup reserve leaks in cow_file_range")
+CC: stable@vger.kernel.org # 6.11+
+Reviewed-by: Qu Wenruo <wqu@suse.com>
+Reviewed-by: Boris Burkov <boris@bur.io>
+Signed-off-by: Haisu Wang <haisuwang@tencent.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/btrfs/inode.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/btrfs/inode.c
++++ b/fs/btrfs/inode.c
+@@ -1442,7 +1442,7 @@ out_unlock:
+ clear_bits |= EXTENT_CLEAR_DATA_RESV;
+ extent_clear_unlock_delalloc(inode, start, end, locked_page,
+ clear_bits, page_ops);
+- btrfs_qgroup_free_data(inode, NULL, start, cur_alloc_size, NULL);
++ btrfs_qgroup_free_data(inode, NULL, start, end - start + 1, NULL);
+ }
+ return ret;
+ }
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- drivers/md/md-bitmap.c | 5 ++---
+ drivers/md/md-bitmap.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
-diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
-index e18e21b24210d..02629516748e4 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
-@@ -2029,9 +2029,8 @@ int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
+@@ -2029,9 +2029,8 @@ int md_bitmap_get_stats(struct bitmap *b
if (!bitmap)
return -ENOENT;
return -EINVAL;
sb = kmap_local_page(bitmap->storage.sb_page);
stats->sync_size = le64_to_cpu(sb->sync_size);
---
-2.39.5
-
wifi-wl1251-fix-memory-leak-in-wl1251_tx_work.patch
scsi-iscsi-fix-missing-scsi_host_put-in-error-path.patch
md-raid10-fix-missing-discard-io-accounting.patch
-md-use-separate-work_struct-for-md_start_sync.patch
-md-factor-out-a-helper-from-mddev_put.patch
md-md-bitmap-fix-stats-collection-for-external-bitma.patch
rdma-usnic-fix-passing-zero-to-ptr_err-in-usnic_ib_p.patch
rdma-hns-fix-wrong-maximum-dma-segment-size.patch
smb-server-fix-potential-null-ptr-deref-of-lease_ctx_info-in-smb2_open.patch
cifs-use-origin-fullpath-for-automounts.patch
net-sched-act_mirred-don-t-override-retval-if-we-already-lost-the-skb.patch
+btrfs-fix-the-length-of-reserved-qgroup-to-free.patch
bpf-avoid-holding-freeze_mutex-during-mmap-operation.patch
bpf-prevent-tail-call-between-progs-attached-to-different-hooks.patch
blk-cgroup-support-to-track-if-policy-is-online.patch