diff options
author | Chris Mason <clm@fb.com> | 2018-06-25 13:03:41 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-06-28 05:30:50 -0400 |
commit | 717beb96d969561cff53aad2f09547db20ee6ffd (patch) | |
tree | ba39d7f889f9c954a19779139a0739b6530bb5a6 | |
parent | 6f7de19ed3d4d3526ca5eca428009f97cf969c2f (diff) |
Btrfs: fix regression in btrfs_page_mkwrite() from vm_fault_t conversion
The vm_fault_t conversion commit introduced a ret2 variable for tracking
the integer return values from internal btrfs functions. It was
sometimes returning VM_FAULT_LOCKED for pages that were actually invalid
and had been removed from the radix. Something like this:
ret2 = btrfs_delalloc_reserve_space() // returns zero on success
lock_page(page)
if (page->mapping != inode->i_mapping)
goto out_unlock;
...
out_unlock:
if (!ret2) {
...
return VM_FAULT_LOCKED;
}
This ends up triggering this WARNING in btrfs_destroy_inode()
WARN_ON(BTRFS_I(inode)->block_rsv.size);
xfstests generic/095 was able to reliably reproduce the errors.
Since out_unlock: is only used for errors, this fix moves it below the
if (!ret2) check we use to return VM_FAULT_LOCKED for success.
Fixes: a528a2415087 (btrfs: change return type of btrfs_page_mkwrite to vm_fault_t)
Signed-off-by: Chris Mason <clm@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/inode.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a6bf9e2ff68f..f21f4223d03b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -9005,13 +9005,14 @@ again: | |||
9005 | 9005 | ||
9006 | unlock_extent_cached(io_tree, page_start, page_end, &cached_state); | 9006 | unlock_extent_cached(io_tree, page_start, page_end, &cached_state); |
9007 | 9007 | ||
9008 | out_unlock: | ||
9009 | if (!ret2) { | 9008 | if (!ret2) { |
9010 | btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, true); | 9009 | btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, true); |
9011 | sb_end_pagefault(inode->i_sb); | 9010 | sb_end_pagefault(inode->i_sb); |
9012 | extent_changeset_free(data_reserved); | 9011 | extent_changeset_free(data_reserved); |
9013 | return VM_FAULT_LOCKED; | 9012 | return VM_FAULT_LOCKED; |
9014 | } | 9013 | } |
9014 | |||
9015 | out_unlock: | ||
9015 | unlock_page(page); | 9016 | unlock_page(page); |
9016 | out: | 9017 | out: |
9017 | btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, (ret != 0)); | 9018 | btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, (ret != 0)); |