Qu Wenruo 63a6ce5a1a btrfs: set correct ram_bytes when splitting ordered extent
[BUG]
When running generic/287, the following file extent items can be
generated:

        item 16 key (258 EXTENT_DATA 2682880) itemoff 15305 itemsize 53
                generation 9 type 1 (regular)
                extent data disk byte 1378414592 nr 462848
                extent data offset 0 nr 462848 ram 2097152
                extent compression 0 (none)

Note that file extent item is not a compressed one, but its ram_bytes is
way larger than its disk_num_bytes.

According to btrfs on-disk scheme, ram_bytes should match disk_num_bytes
if it's not a compressed one.

[CAUSE]
Since commit b73a6fd1b1ef ("btrfs: split partial dio bios before
submit"), for partial dio writes, we would split the ordered extent.

However the function btrfs_split_ordered_extent() doesn't update the
ram_bytes even it has already shrunk the disk_num_bytes.

Originally the function btrfs_split_ordered_extent() is only introduced
for zoned devices in commit d22002fd37bd ("btrfs: zoned: split ordered
extent when bio is sent"), but later commit b73a6fd1b1ef ("btrfs: split
partial dio bios before submit") makes non-zoned btrfs affected.

Thankfully for un-compressed file extent, we do not really utilize the
ram_bytes member, thus it won't cause any real problem.

[FIX]
Also update btrfs_ordered_extent::ram_bytes inside
btrfs_split_ordered_extent().

Fixes: d22002fd37bd ("btrfs: zoned: split ordered extent when bio is sent")
CC: stable@vger.kernel.org # 5.15+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2024-04-30 12:03:44 +02:00
..
2024-01-11 20:11:35 -08:00
2024-01-11 20:11:35 -08:00
2023-10-30 09:47:13 -10:00
2023-11-07 12:11:26 -08:00
2024-02-25 09:53:13 -08:00
2024-03-01 12:22:30 -08:00
2023-11-07 12:11:26 -08:00
2024-02-25 02:10:32 -05:00
2023-12-29 11:58:34 -08:00
2024-01-10 17:44:36 -08:00
2024-02-07 17:48:15 +00:00
2024-01-11 20:11:35 -08:00
2024-01-10 17:44:36 -08:00
2024-02-12 07:15:45 -08:00
2024-01-10 17:44:36 -08:00
2023-10-30 09:47:13 -10:00
2024-01-06 23:49:50 +01:00
2024-01-11 10:07:29 -08:00
2024-02-16 10:20:35 +09:00
2023-12-21 13:17:54 +01:00
2023-10-30 19:28:19 -10:00
2023-10-30 19:28:19 -10:00
2024-02-09 23:31:16 -05:00
2024-01-24 13:32:29 -08:00
2024-01-11 20:11:35 -08:00
2023-12-12 14:24:14 +01:00
2024-01-11 20:00:22 -08:00
2024-01-11 20:11:35 -08:00
2024-01-19 09:10:23 -08:00
2024-01-11 20:11:35 -08:00
2024-01-19 09:10:23 -08:00
2023-11-25 02:49:43 -05:00
2024-01-08 11:11:51 -08:00
2024-01-10 17:44:36 -08:00
2024-01-08 10:57:34 -08:00
2024-01-17 13:03:37 -08:00