Skip to content

Commit 6bf74cd

Browse files
author
Matthew Wilcox (Oracle)
committed
filemap: Don't release a locked folio
We must hold a reference over the call to filemap_release_folio(), otherwise the page cache will put the last reference to the folio before we unlock it, leading to splats like this: BUG: Bad page state in process u8:5 pfn:1ab1f4 page:ffffea0006ac7d00 refcount:0 mapcount:0 mapping:0000000000000000 index:0x28b1de pfn:0x1ab1f4 flags: 0x17ff80000040001(locked|reclaim|node=0|zone=2|lastcpupid=0xfff) raw: 017ff80000040001 dead000000000100 dead000000000122 0000000000000000 raw: 000000000028b1de 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: PAGE_FLAGS_CHECK_AT_FREE flag(s) set It's an error path, so it doesn't see much testing. Reported-by: Darrick J. Wong <[email protected]> Fixes: a42634a ("readahead: Use a folio in read_pages()") Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
1 parent 3d9f55c commit 6bf74cd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mm/readahead.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,14 @@ static void read_pages(struct readahead_control *rac)
164164
while ((folio = readahead_folio(rac)) != NULL) {
165165
unsigned long nr = folio_nr_pages(folio);
166166

167+
folio_get(folio);
167168
rac->ra->size -= nr;
168169
if (rac->ra->async_size >= nr) {
169170
rac->ra->async_size -= nr;
170171
filemap_remove_folio(folio);
171172
}
172173
folio_unlock(folio);
174+
folio_put(folio);
173175
}
174176
} else {
175177
while ((folio = readahead_folio(rac)) != NULL)

0 commit comments

Comments
 (0)