]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix wrong extent mapping for DirectIO
authorWang Shilong <wangsl.fnst@cn.fujitsu.com>
Thu, 17 Jul 2014 03:44:14 +0000 (11:44 +0800)
committerChris Mason <clm@fb.com>
Tue, 19 Aug 2014 15:52:13 +0000 (08:52 -0700)
commit96dbea16ea6d559350f0e7d7ff14695283b98c4c
treeead85388bdf5792288398011b47ad23b1215ab2c
parent4a321d867a0a8ae276550b108221d2f555c8d3e6
Btrfs: fix wrong extent mapping for DirectIO

btrfs_next_leaf() will use current leaf's last key to search
and then return a bigger one. So it may still return a file extent
item that is smaller than expected value and we will
get an overflow here for @em->len.

This is easy to reproduce for Btrfs Direct writting, it did not
cause any problem, because writting will re-insert right mapping later.

However, by hacking code to make DIO support compression, wrong extent
mapping is kept and it encounter merging failure(EEXIST) quickly.

Fix this problem by looping to find next file extent item that is bigger
than @start or we could not find anything more.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/inode.c