]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: zoned: fix double counting of split ordered extent
authorNaohiro Aota <naohiro.aota@wdc.com>
Mon, 6 Sep 2021 15:04:28 +0000 (00:04 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:41:43 +0000 (13:41 +0200)
commit09c4f334e56abe5308069c3863c9a3d199572d97
tree390b94b9402d5d6276771f5e53b8c7419d4658dd
parent5c8a3170518698e3eda207793bc91e9ee851dec8
btrfs: zoned: fix double counting of split ordered extent

commit f79645df806565a03abb2847a1d20e6930b25e7e upstream.

btrfs_add_ordered_extent_*() add num_bytes to fs_info->ordered_bytes.
Then, splitting an ordered extent will call btrfs_add_ordered_extent_*()
again for split extents, leading to double counting of the region of
a split extent. These leaked bytes are finally reported at unmount time
as follow:

  BTRFS info (device dm-1): at unmount dio bytes count 364544

Fix the double counting by subtracting split extent's size from
fs_info->ordered_bytes.

Fixes: d22002fd37bd ("btrfs: zoned: split ordered extent when bio is sent")
CC: stable@vger.kernel.org # 5.12+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/ordered-data.c