]> Git Repo - linux.git/commitdiff
erofs: fix missing xas_retry() in fscache mode
authorJingbo Xu <[email protected]>
Mon, 14 Nov 2022 12:19:43 +0000 (20:19 +0800)
committerGao Xiang <[email protected]>
Mon, 14 Nov 2022 15:48:38 +0000 (23:48 +0800)
The xarray iteration only holds the RCU read lock and thus may encounter
XA_RETRY_ENTRY if there's process modifying the xarray concurrently.
This will cause oops when referring to the invalid entry.

Fix this by adding the missing xas_retry(), which will make the
iteration wind back to the root node if XA_RETRY_ENTRY is encountered.

Fixes: d435d53228dd ("erofs: change to use asynchronous io for fscache readpage/readahead")
Suggested-by: David Howells <[email protected]>
Reviewed-by: Gao Xiang <[email protected]>
Reviewed-by: Jia Zhu <[email protected]>
Signed-off-by: Jingbo Xu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Gao Xiang <[email protected]>
fs/erofs/fscache.c

index 6eaf4a4ab95ca1ec669a5481327e390e4849c29d..af5ed6b9c54dd868246135e8394380cd47726061 100644 (file)
@@ -75,11 +75,15 @@ static void erofs_fscache_rreq_unlock_folios(struct netfs_io_request *rreq)
 
        rcu_read_lock();
        xas_for_each(&xas, folio, last_page) {
-               unsigned int pgpos =
-                       (folio_index(folio) - start_page) * PAGE_SIZE;
-               unsigned int pgend = pgpos + folio_size(folio);
+               unsigned int pgpos, pgend;
                bool pg_failed = false;
 
+               if (xas_retry(&xas, folio))
+                       continue;
+
+               pgpos = (folio_index(folio) - start_page) * PAGE_SIZE;
+               pgend = pgpos + folio_size(folio);
+
                for (;;) {
                        if (!subreq) {
                                pg_failed = true;
This page took 0.060936 seconds and 4 git commands to generate.