Skip to content

Commit 63a6ce5

Browse files
adam900710kdave
authored andcommitted
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 b73a6fd ("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 d22002f ("btrfs: zoned: split ordered extent when bio is sent"), but later commit b73a6fd ("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: d22002f ("btrfs: zoned: split ordered extent when bio is sent") CC: [email protected] # 5.15+ Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 0f2b809 commit 63a6ce5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/btrfs/ordered-data.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ struct btrfs_ordered_extent *btrfs_split_ordered_extent(
11881188
ordered->disk_bytenr += len;
11891189
ordered->num_bytes -= len;
11901190
ordered->disk_num_bytes -= len;
1191+
ordered->ram_bytes -= len;
11911192

11921193
if (test_bit(BTRFS_ORDERED_IO_DONE, &ordered->flags)) {
11931194
ASSERT(ordered->bytes_left == 0);

0 commit comments

Comments
 (0)