]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bio: Fix bio_first_folio() for SPARSEMEM without VMEMMAP
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 12 Jun 2025 14:41:25 +0000 (15:41 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 13 Jun 2025 12:19:34 +0000 (06:19 -0600)
It is possible for physically contiguous folios to have discontiguous
struct pages if SPARSEMEM is enabled and SPARSEMEM_VMEMMAP is not.
This is correctly handled by folio_page_idx(), so remove this open-coded
implementation.

Fixes: 640d1930bef4 (block: Add bio_for_each_folio_all())
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20250612144126.2849931-1-willy@infradead.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/bio.h

index 9c37c66ef9ca3682c8b6ba2c3d603de2b725174b..46ffac5caab788a1419701fb31c0053c2ef24a47 100644 (file)
@@ -291,7 +291,7 @@ static inline void bio_first_folio(struct folio_iter *fi, struct bio *bio,
 
        fi->folio = page_folio(bvec->bv_page);
        fi->offset = bvec->bv_offset +
-                       PAGE_SIZE * (bvec->bv_page - &fi->folio->page);
+                       PAGE_SIZE * folio_page_idx(fi->folio, bvec->bv_page);
        fi->_seg_count = bvec->bv_len;
        fi->length = min(folio_size(fi->folio) - fi->offset, fi->_seg_count);
        fi->_next = folio_next(fi->folio);