]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
Btrfs: fix file extent corruption
authorJosef Bacik <jbacik@fb.com>
Wed, 16 Nov 2016 14:13:39 +0000 (09:13 -0500)
committerDavid Sterba <dsterba@suse.com>
Wed, 30 Nov 2016 12:45:19 +0000 (13:45 +0100)
commit62fe51c1d0100ff07a761cd077872e01f2a2b8ca
treefe4ef2eb3c182ddc3cd6d8853aaa1ffba023e9ca
parentd2fbb2b589ece9060635b43c2b2333d0b0a0fbf2
Btrfs: fix file extent corruption

In order to do hole punching we have a block reserve to hold the reservation we
need to drop the extents in our range.  Since we could end up dropping a lot of
extents we set rsv->failfast so we can just loop around again and drop the
remaining of the range.  Unfortunately we unconditionally fill the hole extents
in and start from the last extent we encountered, which we may or may not have
dropped.  So this can result in overlapping file extent entries, which can be
tripped over in a variety of ways, either by hitting BUG_ON(!ret) in
fill_holes() after the search, or in btrfs_set_item_key_safe() in
btrfs_drop_extent() at a later time by an unrelated task.  Fix this by only
setting drop_end to the last extent we did actually drop.  This way our holes
are filled in properly for the range that we did drop, and the rest of the range
that remains to be dropped is actually dropped.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c