Skip to content

Commit

Permalink
btrfs: introduce helper to handle page status update in end_bio_exten…
Browse files Browse the repository at this point in the history
…t_readpage()

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>
  • Loading branch information
Qu Wenruo authored and David Sterba committed Dec 8, 2020
1 parent 94e8c95 commit e09caaf
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2842,6 +2842,17 @@ static void endio_readpage_release_extent(struct processed_extent *processed,
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
Expand Down Expand Up @@ -2964,14 +2975,11 @@ static void end_bio_extent_readpage(struct bio *bio)
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);
}
Expand Down

0 comments on commit e09caaf

Please sign in to comment.