@@ -229,8 +229,15 @@ void wait_on_extent_buffer_writeback(struct extent_buffer *eb);
static inline int num_extent_pages(const struct extent_buffer *eb)
{
- return (round_up(eb->start + eb->len, PAGE_SIZE) >> PAGE_SHIFT) -
- (eb->start >> PAGE_SHIFT);
+ /*
+ * For sectorsize == PAGE_SIZE case, since eb is always aligned to
+ * sectorsize, it's just (eb->len / PAGE_SIZE) >> PAGE_SHIFT.
+ *
+ * For sectorsize < PAGE_SIZE case, we only want to support 64K
+ * PAGE_SIZE, and ensured all tree blocks won't cross page boundary.
+ * So in that case we always got 1 page.
+ */
+ return (round_up(eb->len, PAGE_SIZE) >> PAGE_SHIFT);
}
static inline int extent_buffer_uptodate(const struct extent_buffer *eb)
For subpage sized extent buffer, we have ensured no extent buffer will cross page boundary, thus we would only need one page for any extent buffer. This patch will update the function num_extent_pages() to handle such case. Now num_extent_pages() would return 1 instead of for subpage sized extent buffer. Signed-off-by: Qu Wenruo <wqu@suse.com> --- fs/btrfs/extent_io.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)