OSDN Git Service

Merge tag 'v4.4.214' into 10
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / fs / btrfs / extent_io.c
index 315f211..9ab5056 100644 (file)
@@ -4153,6 +4153,14 @@ retry:
                 */
                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(data);
                goto retry;
        }
        btrfs_add_delayed_iput(inode);
@@ -4937,12 +4945,14 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
                return eb;
        eb = alloc_dummy_extent_buffer(fs_info, start);
        if (!eb)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
        eb->fs_info = fs_info;
 again:
        ret = radix_tree_preload(GFP_NOFS & ~__GFP_HIGHMEM);
-       if (ret)
+       if (ret) {
+               exists = ERR_PTR(ret);
                goto free_eb;
+       }
        spin_lock(&fs_info->buffer_lock);
        ret = radix_tree_insert(&fs_info->buffer_radix,
                                start >> PAGE_CACHE_SHIFT, eb);