Btrfs: remove transaction from send
authorJosef Bacik <jbacik@fb.com>
Thu, 13 Mar 2014 19:42:13 +0000 (15:42 -0400)
committerChris Mason <clm@fb.com>
Mon, 7 Apr 2014 00:39:30 +0000 (17:39 -0700)
commit9e351cc862b098d8ec8f8022d110932490794925
tree97320881e91cfc1190a35516bb4bcfb2c95698e4
parenta26e8c9f75b0bfd8cccc9e8f110737b136eb5994
Btrfs: remove transaction from send

Lets try this again.  We can deadlock the box if we send on a box and try to
write onto the same fs with the app that is trying to listen to the send pipe.
This is because the writer could get stuck waiting for a transaction commit
which is being blocked by the send.  So fix this by making sure looking at the
commit roots is always going to be consistent.  We do this by keeping track of
which roots need to have their commit roots swapped during commit, and then
taking the commit_root_sem and swapping them all at once.  Then make sure we
take a read lock on the commit_root_sem in cases where we search the commit root
to make sure we're always looking at a consistent view of the commit roots.
Previously we had problems with this because we would swap a fs tree commit root
and then swap the extent tree commit root independently which would cause the
backref walking code to screw up sometimes.  With this patch we no longer
deadlock and pass all the weird send/receive corner cases.  Thanks,

Reportedy-by: Hugo Mills <hugo@carfax.org.uk>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/backref.c
fs/btrfs/ctree.c
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/extent-tree.c
fs/btrfs/inode-map.c
fs/btrfs/send.c
fs/btrfs/transaction.c
fs/btrfs/transaction.h