]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: don't return VM_FAULT_SIGBUS on failure to set delalloc for mmap write
authorFilipe Manana <fdmanana@suse.com>
Wed, 14 May 2025 11:18:07 +0000 (12:18 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 16:24:37 +0000 (18:24 +0200)
If the call to btrfs_set_extent_delalloc() fails we are always returning
VM_FAULT_SIGBUS, which is odd since the error means "bad access" and the
most likely cause for btrfs_set_extent_delalloc() is -ENOMEM, which should
be translated to VM_FAULT_OOM.

Instead of returning VM_FAULT_SIGBUS return vmf_error(ret2), which gives
us a more appropriate return value, and we use that everywhere else too.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c

index 9ecb9f3bd057e1939e9a6e12889ff4a7d9832d46..f6b32f24185c4765905a3b0b1e3c4fcae1908db3 100644 (file)
@@ -1937,7 +1937,7 @@ again:
                                        &cached_state);
        if (ret2) {
                btrfs_unlock_extent(io_tree, page_start, page_end, &cached_state);
-               ret = VM_FAULT_SIGBUS;
+               ret = vmf_error(ret2);
                goto out_unlock;
        }