]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: fix lost error return value when reading a data page
authorFilipe Manana <fdmanana@suse.com>
Thu, 3 Feb 2022 15:36:43 +0000 (15:36 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 14 Mar 2022 12:13:50 +0000 (13:13 +0100)
At btrfs_do_readpage(), if we get an error when trying to lookup for an
extent map, we end up marking the page with the error bit, clearing
the uptodate bit on it, and doing everything else that should be done.
However we return success (0) to the caller, when we should return the
error encoded in the extent map pointer. So fix that by returning the
error encoded in the pointer.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c
fs/btrfs/inode.c

index 37589fd440b5ac94996db759ce882d7a20491a3b..8b6e9ca3170a953d3a3b375b92c8f5b3212cb05c 100644 (file)
@@ -3611,6 +3611,7 @@ int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,
                if (IS_ERR(em)) {
                        unlock_extent(tree, cur, end);
                        end_page_read(page, false, cur, end + 1 - cur);
+                       ret = PTR_ERR(em);
                        break;
                }
                extent_offset = cur - em->start;
index 1ce1ccf6d22c29e06d5fde5844d57b4ba043e15a..ffe327090277a1bfa86edb9d8ead72f8c7d4d358 100644 (file)
@@ -8118,8 +8118,13 @@ int btrfs_readpage(struct file *file, struct page *page)
        btrfs_lock_and_flush_ordered_range(inode, start, end, NULL);
 
        ret = btrfs_do_readpage(page, NULL, &bio_ctrl, 0, NULL);
-       if (bio_ctrl.bio)
-               ret = submit_one_bio(bio_ctrl.bio, 0, bio_ctrl.bio_flags);
+       if (bio_ctrl.bio) {
+               int ret2;
+
+               ret2 = submit_one_bio(bio_ctrl.bio, 0, bio_ctrl.bio_flags);
+               if (ret == 0)
+                       ret = ret2;
+       }
        return ret;
 }