Btrfs: complete page writeback before doing ordered extents

We can deadlock waiting for pages to end writeback because we are doing an
allocation while hold a tree lock since the ordered extent stuff will
require tree locks.  A quick easy way to fix this is to end page writeback
before we do our ordered io stuff, which works fine since we don't really
need the page for this to work.  Eventually we want to make this work happen
as soon as the io is completed and then push the ordered extent stuff off to
a worker thread, but at this stage we need this deadlock fixed with changing
as little as possible.  Thanks,

Signed-off-by: Josef Bacik <>
4 files changed