Btrfs: make fsync work after cloning into a file
authorFilipe Manana <fdmanana@gmail.com>
Mon, 9 Jun 2014 02:48:05 +0000 (03:48 +0100)
committerChris Mason <clm@fb.com>
Tue, 10 Jun 2014 00:21:16 +0000 (17:21 -0700)
commit7ffbb598a059b73487909619d73150f99b50337a
treeba975f1810eb340b07143eea3a284861cad0ff4b
parentcd857dd6bc2ae9ecea14e75a34e8a8fdc158e307
Btrfs: make fsync work after cloning into a file

When cloning into a file, we were correctly replacing the extent
items in the target range and removing the extent maps. However
we weren't replacing the extent maps with new ones that point to
the new extents - as a consequence, an incremental fsync (when the
inode doesn't have the full sync flag) was a NOOP, since it relies
on the existence of extent maps in the modified list of the inode's
extent map tree, which was empty. Therefore add new extent maps to
reflect the target clone range.

A test case for xfstests follows.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/ctree.h
fs/btrfs/file-item.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c