Skip to content

Commit 717beb9

Browse files
masonclkdave
authored andcommitted
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: a528a24 (btrfs: change return type of btrfs_page_mkwrite to vm_fault_t) Signed-off-by: Chris Mason <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 6f7de19 commit 717beb9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/btrfs/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9005,13 +9005,14 @@ vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf)
90059005

90069006
unlock_extent_cached(io_tree, page_start, page_end, &cached_state);
90079007

9008-
out_unlock:
90099008
if (!ret2) {
90109009
btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, true);
90119010
sb_end_pagefault(inode->i_sb);
90129011
extent_changeset_free(data_reserved);
90139012
return VM_FAULT_LOCKED;
90149013
}
9014+
9015+
out_unlock:
90159016
unlock_page(page);
90169017
out:
90179018
btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, (ret != 0));

0 commit comments

Comments
 (0)