Skip to content

Commit e28b021

Browse files
boryaskdave
authored andcommitted
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. Reviewed-by: Josef Bacik <[email protected]> CC: [email protected] # 5.10+ Signed-off-by: Boris Burkov <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 75d305c commit e28b021

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/btrfs/inode.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3358,6 +3358,13 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
33583358
btrfs_free_reserved_extent(fs_info,
33593359
ordered_extent->disk_bytenr,
33603360
ordered_extent->disk_num_bytes, 1);
3361+
/*
3362+
* Actually free the qgroup rsv which was released when
3363+
* the ordered extent was created.
3364+
*/
3365+
btrfs_qgroup_free_refroot(fs_info, inode->root->root_key.objectid,
3366+
ordered_extent->qgroup_rsv,
3367+
BTRFS_QGROUP_RSV_DATA);
33613368
}
33623369
}
33633370

0 commit comments

Comments
 (0)