@@ -876,8 +876,10 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
pinned[0] = grab_cache_page(inode->i_mapping, first_index);
if (!PageUptodate(pinned[0])) {
ret = btrfs_readpage(NULL, pinned[0]);
- if (ret)
+ if (ret) {
+ kfree(pages);
return ret;
+ }
wait_on_page_locked(pinned[0]);
} else {
unlock_page(pinned[0]);
@@ -891,6 +893,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
if (ret) {
if (pinned[0])
page_cache_release(pinned[0]);
+ kfree(pages);
return ret;
}
wait_on_page_locked(pinned[1]);
@@ -965,8 +968,10 @@ again:
dirty_pages, pos,
copied);
if (ret) {
+ WARN_ON(1);
btrfs_delalloc_release_space(inode,
dirty_pages << PAGE_CACHE_SHIFT);
+ btrfs_drop_pages(pages, num_pages);
break;
}
}