summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorBoris Burkov <boris@bur.io>2023-07-21 09:02:06 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-09-19 12:30:24 +0200
commitb5cd2c8a07c61040ef7418f2188dbced4d206f7b (patch)
tree025f874e19f110fe9ab55531aa9f483be1496960 /fs/btrfs/inode.c
parent6fd4d27daccbcd0e79d9f7eb58a4d21dbbd3158a (diff)
downloadlinux-stable-b5cd2c8a07c61040ef7418f2188dbced4d206f7b.tar.gz
linux-stable-b5cd2c8a07c61040ef7418f2188dbced4d206f7b.tar.bz2
linux-stable-b5cd2c8a07c61040ef7418f2188dbced4d206f7b.zip
btrfs: free qgroup rsv on io failure
commit e28b02118b94e42be3355458a2406c6861e2dd32 upstream. 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. Reviewed-by: Josef Bacik <josef@toxicpanda.com> CC: stable@vger.kernel.org # 5.10+ Signed-off-by: Boris Burkov <boris@bur.io> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index aa090b0b5d29..db2b33a822fc 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3359,6 +3359,13 @@ out:
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);
}
}