diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 53022bcbf78d7d..ea930b93b35f85 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4173,6 +4173,14 @@ static int extent_write_cache_pages(struct address_space *mapping, */ scanned = 1; index = 0; + + /* + * If we're looping we could run into a page that is locked by a + * writer and that writer could be waiting on writeback for a + * page in our current bio, and thus deadlock, so flush the + * write bio here. + */ + flush_write_bio(epd); goto retry; }