Commit 8ab1b16
mm: fix filemap_get_folios_contig returning batches of identical folios
filemap_get_folios_contig() is supposed to return distinct folios found
within [start, end]. Large folios in the Xarray become multi-index
entries. xas_next() can iterate through the sub-indexes before finding a
sibling entry and breaking out of the loop.
This can result in a returned folio_batch containing an indeterminate
number of duplicate folios, which forces the callers to skeptically handle
the returned batch. This is inefficient and incurs a large maintenance
overhead.
We can fix this by calling xas_advance() after we have successfully adding
a folio to the batch to ensure our Xarray is positioned such that it will
correctly find the next folio - similar to filemap_get_read_batch().
Link: https://lkml.kernel.org/r/Z-8s1-kiIDkzgRbc@fedora
Fixes: 35b4714 ("filemap: add filemap_get_folios_contig()")
Signed-off-by: Vishal Moola (Oracle) <[email protected]>
Reported-by: Qu Wenruo <[email protected]>
Closes: https://lkml.kernel.org/r/[email protected]
Tested-by: Qu Wenruo <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vivek Kasireddy <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>1 parent 9e2bd67 commit 8ab1b16
1 file changed
+1
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2244 | 2244 | | |
2245 | 2245 | | |
2246 | 2246 | | |
| 2247 | + | |
2247 | 2248 | | |
2248 | 2249 | | |
2249 | 2250 | | |
| |||
0 commit comments