diff options
author | Wang Shilong <wangsl.fnst@cn.fujitsu.com> | 2014-07-17 11:44:14 +0800 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-08-19 08:52:13 -0700 |
commit | e2eca69dc6c09d968d69312b9899968a9b03a4a9 (patch) | |
tree | ead85388bdf5792288398011b47ad23b1215ab2c /fs/btrfs | |
parent | 9a025a0860ccc0f02af153c966bc1f83e5d9fc62 (diff) | |
download | op-kernel-dev-e2eca69dc6c09d968d69312b9899968a9b03a4a9.zip op-kernel-dev-e2eca69dc6c09d968d69312b9899968a9b03a4a9.tar.gz |
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>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/inode.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 73fadc7..a3c6e76 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6275,6 +6275,8 @@ next: goto not_found; if (start + len <= found_key.offset) goto not_found; + if (start > found_key.offset) + goto next; em->start = start; em->orig_start = start; em->len = found_key.offset - start; |