Skip to content

Commit a37b3b9

Browse files
Darrick J. Wongcmaiolino
authored andcommitted
xfs: compute buffer address correctly in xmbuf_map_backing_mem
Prior to commit e614a00, xmbuf_map_backing_mem relied on folio_file_page to return the base page for the xmbuf's loff_t in the xfile, and set b_addr to the page_address of that base page. Now that folio_file_page has been removed from xmbuf_map_backing_mem, we always set b_addr to the folio_address of the folio. This is correct for the situation where the folio size matches the buffer size, but it's totally wrong if tmpfs uses large folios. We need to use offset_in_folio here. Found via xfs/801, which demonstrated evidence of corruption of an in-memory rmap btree block right after initializing an adjacent block. Fixes: e614a00 ("xfs: cleanup mapping tmpfs folios into the buffer cache") Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 845abeb commit a37b3b9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/xfs/xfs_buf_mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ xmbuf_map_backing_mem(
165165
folio_set_dirty(folio);
166166
folio_unlock(folio);
167167

168-
bp->b_addr = folio_address(folio);
168+
bp->b_addr = folio_address(folio) + offset_in_folio(folio, pos);
169169
return 0;
170170
}
171171

0 commit comments

Comments
 (0)