Skip to contentSkip to conversation

iomap: wait for batched folios to be stable in __iomap_get_folio

PATCH Applied Christoph Hellwig 4 participants 7 messages Jan 13 – Jan 14

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iomap: wait for batched folios to be stable in __iomap_get_folio

__iomap_get_folio needs to wait for writeback to finish if the file requires folios to be stable for writes. For the regular path this is taken care of by __filemap_get_folio, but for the newly added batch lookup it has to be done manually.

This fixes xfs/131 failures when running on PI-capable hardware.

Fixes 395ed1ef0012 ("iomap: optional zero range dirty folio processing")
---
 fs/iomap/buffered-io.c | 1 +
 1 file changed, 1 insertion(+)
fs/iomap/buffered-io.c +1 -0
index fd9a2cf95620..6beb876658c0 100644
@@ -851,6 +851,7 @@ static struct folio *__iomap_get_folio(struct iomap_iter *iter,
 		}
 
 		folio_get(folio);
+		folio_wait_stable(folio);
 		return folio;
 	}
 
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Christoph Hellwig

__iomap_get_folio needs to wait for writeback to finish if the file requires folios to be stable for writes. For the regular path this is taken care of by __filemap_get_folio, but for the newly added batch lookup it has to be done manually.

This fixes xfs/131 failures when running on PI-capable hardware.

Fixes 395ed1ef0012 ("iomap: optional zero range dirty folio processing")
---
 fs/iomap/buffered-io.c | 1 +
 1 file changed, 1 insertion(+)
fs/iomap/buffered-io.c +0 -0
index fd9a2cf95620..6beb876658c0 100644

fs/iomap/buffered-io.c static struct folio *__iomap_get_folio(struct iomap_iter *iter, · line 854

Quoted 4 lines
fs/iomap/buffered-io.c +1 -0
@@ -851,6 +851,7 @@ static struct folio *__iomap_get_folio(struct iomap_iter *iter,
 		}
 
 		folio_get(folio);
+		folio_wait_stable(folio);

Heh, oops. That's a little too easy to miss. :(

I wonder if we ought to have a filemap_fbatch_next() that would take care of the relocking, revalidation, and stabilization... but this spot fix is good as-is.

--D

Quoted 6 lines
fs/iomap/buffered-io.c +0 -0
 		return folio;
 	}
 
Signature · 1 line
2.47.3
#2 lore raw
Quoted 3 lines · Darrick J. Wong

I wonder if we ought to have a filemap_fbatch_next() that would take care of the relocking, revalidation, and stabilization... but this spot fix is good as-is.

Let's wait until we have another user or two. Premature refactoring tends to backfire.

#3 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 3 lines · Darrick J. Wong

I wonder if we ought to have a filemap_fbatch_next() that would take care of the relocking, revalidation, and stabilization... but this spot fix is good as-is.

Let's wait until we have another user or two. Premature refactoring tends to backfire.

I agree on not being too aggressive on that... I do like the idea though, so I'll try to keep it in mind if this happens to expand down the road. Thanks for the fix.

Brian

#4 lore raw
Quoted 6 lines · Brian Foster
Quoted 5 lines · Christoph Hellwig
Quoted 3 lines · Darrick J. Wong

I wonder if we ought to have a filemap_fbatch_next() that would take care of the relocking, revalidation, and stabilization... but this spot fix is good as-is.

Quoted 7 lines
Quoted 3 lines

Let's wait until we have another user or two. Premature refactoring tends to backfire.

I agree on not being too aggressive on that... I do like the idea though, so I'll try to keep it in mind if this happens to expand down the road. Thanks for the fix.

<nod> Making the second user do the refactoring is ok with me. :)

--D

Quoted 3 lines

Brian

Reviewed-by on v1 1/1
#5 lore raw
In reply to Christoph Hellwig
Quoted 10 lines · Christoph Hellwig

__iomap_get_folio needs to wait for writeback to finish if the file requires folios to be stable for writes. For the regular path this is taken care of by __filemap_get_folio, but for the newly added batch lookup it has to be done manually.

This fixes xfs/131 failures when running on PI-capable hardware.

Fixes 395ed1ef0012 ("iomap: optional zero range dirty folio processing")

---

Quoted 19 lines
 fs/iomap/buffered-io.c | 1 +
 1 file changed, 1 insertion(+)
fs/iomap/buffered-io.c +1 -0
index fd9a2cf95620..6beb876658c0 100644
@@ -851,6 +851,7 @@ static struct folio *__iomap_get_folio(struct iomap_iter *iter,
 		}
 
 		folio_get(folio);
+		folio_wait_stable(folio);
 		return folio;
 	}
 
Signature · 1 line
2.47.3
maintainer Applied
#6 lore raw
In reply to Christoph Hellwig
Quoted 8 lines · Christoph Hellwig

__iomap_get_folio needs to wait for writeback to finish if the file requires folios to be stable for writes. For the regular path this is taken care of by __filemap_get_folio, but for the newly added batch lookup it has to be done manually.

This fixes xfs/131 failures when running on PI-capable hardware.

[...]

Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/1] iomap: wait for batched folios to be stable in __iomap_get_folio

      https://git.kernel.org/vfs/vfs/c/561940a7ee81