]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
btrfs: introduce helper to handle page status update in end_bio_extent_readpage()
authorQu Wenruo <wqu@suse.com>
Fri, 13 Nov 2020 12:51:29 +0000 (20:51 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 8 Dec 2020 14:54:13 +0000 (15:54 +0100)
Introduce a new helper to handle update page status in
end_bio_extent_readpage(). This will be later used for subpage support
where the page status update can be more complex than now.

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

index 519f74502a3ed19d39b36bc2f39097a5d91fd133..4bc6beaff562077d273b1f123d18c3083e2a9520 100644 (file)
@@ -2842,6 +2842,17 @@ update:
        processed->uptodate = uptodate;
 }
 
+static void endio_readpage_update_page_status(struct page *page, bool uptodate)
+{
+       if (uptodate) {
+               SetPageUptodate(page);
+       } else {
+               ClearPageUptodate(page);
+               SetPageError(page);
+       }
+       unlock_page(page);
+}
+
 /*
  * after a readpage IO is done, we need to:
  * clear the uptodate bits on error
@@ -2964,14 +2975,11 @@ readpage_ok:
                        off = offset_in_page(i_size);
                        if (page->index == end_index && off)
                                zero_user_segment(page, off, PAGE_SIZE);
-                       SetPageUptodate(page);
-               } else {
-                       ClearPageUptodate(page);
-                       SetPageError(page);
                }
-               unlock_page(page);
                offset += len;
 
+               /* Update page status and unlock */
+               endio_readpage_update_page_status(page, uptodate);
                endio_readpage_release_extent(&processed, BTRFS_I(inode),
                                              start, end, uptodate);
        }