Skip to content

Commit

Permalink
block: Fix page refcounts for unaligned buffers in __bio_release_pages()
Browse files Browse the repository at this point in the history
[ Upstream commit 38b4353 ]

Fix an incorrect number of pages being released for buffers that do not
start at the beginning of a page.

Fixes: 1b151e2 ("block: Remove special-casing of compound pages")
Cc: stable@vger.kernel.org
Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
Tested-by: Greg Edwards <gedwards@ddn.com>
Link: https://lore.kernel.org/r/86e592a9-98d4-4cff-a646-0c0084328356@cybernetics.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
abattersby authored and gregkh committed Apr 3, 2024
1 parent ae27f51 commit c9d3d2f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,18 +1152,19 @@ void __bio_release_pages(struct bio *bio, bool mark_dirty)

bio_for_each_folio_all(fi, bio) {
struct page *page;
size_t done = 0;
size_t nr_pages;

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++);
done += PAGE_SIZE;
} while (done < fi.length);
} while (--nr_pages != 0);
}
}
EXPORT_SYMBOL_GPL(__bio_release_pages);
Expand Down

0 comments on commit c9d3d2f

Please sign in to comment.