jbd2: Remove page size assumptions
authorRitesh Harjani (IBM) <ritesh.list@gmail.com>
Thu, 7 Sep 2023 13:47:32 +0000 (09:47 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 7 Sep 2023 19:17:02 +0000 (15:17 -0400)
commit147d4a092e9a726ce706dbf0d329d2b96a025459
tree82a9ce1e19bf13d0c8bd3b4937a2ffd0a214b4cc
parentf94cf2206b066bd6d761d3347fd35f77b828c376
jbd2: Remove page size assumptions

jbd2_alloc() allocates a buffer from slab when the block size is smaller
than PAGE_SIZE, and slab may be using a compound page.  Before commit
8147c4c4546f, we set b_page to the precise page containing the buffer
and this code worked well.  Now we set b_page to the head page of the
allocation, so we can no longer use offset_in_page().  While we could
do a 1:1 replacement with offset_in_folio(), use the more idiomatic
bh_offset() and the folio APIs to map the buffer.

This isn't enough to support a b_size larger than PAGE_SIZE on HIGHMEM
machines, but this is good enough to fix the actual bug we're seeing.

Fixes: 8147c4c4546f ("jbd2: use a folio in jbd2_journal_write_metadata_buffer()")
Reported-by: Zorro Lang <zlang@kernel.org>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
[converted to be more folio]
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
fs/jbd2/commit.c
fs/jbd2/transaction.c