On Wed, Jun 19, 2024 at 08:04:20AM +0530, Kundan Kumar wrote: > if (mark_dirty) { > folio_lock(fi.folio); > folio_mark_dirty(fi.folio); > folio_unlock(fi.folio); > } > - page = folio_page(fi.folio, fi.offset / PAGE_SIZE); > - nr_pages = (fi.offset + fi.length - 1) / PAGE_SIZE - > - fi.offset / PAGE_SIZE + 1; > - do { > - bio_release_page(bio, page++); > - } while (--nr_pages != 0); > + bio_release_folio(bio, fi.folio, 1); ... no, call bio_release_folio(bio, fi.folio, nr_pages); > @@ -1372,6 +1364,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) > } else > bio_iov_add_folio(bio, folio, len, folio_offset); > > + if (num_pages > 1) > + bio_release_folio(bio, folio, num_pages - 1); > + ... and drop this hunk.