Skip to content

Commit 807c6d0

Browse files
committed
netfs: Fix the loop that unmarks folios after writing to the cache
In the loop in netfs_rreq_unmark_after_write() that removes the PG_fscache from folios after they've been written to the cache, as soon as we remove the mark from a multipage folio, it can get split - and then we might see a fragment of folio again. Guard against this by advancing the 'unlocked' tracker to the index of the last page in the folio to avoid a double removal of the PG_fscache mark. Reported-by: Marc Dionne <marc.dionne@auristor.com> Signed-off-by: David Howells <dhowells@redhat.com> cc: Matthew Wilcox <willy@infradead.org> cc: linux-afs@lists.infradead.org cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org
1 parent 92a714d commit 807c6d0

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

fs/netfs/buffered_write.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ static void netfs_pages_written_back(struct netfs_io_request *wreq)
698698
end_wb:
699699
if (folio_test_fscache(folio))
700700
folio_end_fscache(folio);
701+
xas_advance(&xas, folio_next_index(folio) - 1);
701702
folio_end_writeback(folio);
702703
}
703704

fs/netfs/io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static void netfs_rreq_unmark_after_write(struct netfs_io_request *rreq,
126126
*/
127127
if (have_unlocked && folio_index(folio) <= unlocked)
128128
continue;
129-
unlocked = folio_index(folio);
129+
unlocked = folio_next_index(folio) - 1;
130130
trace_netfs_folio(folio, netfs_folio_trace_end_copy);
131131
folio_end_fscache(folio);
132132
have_unlocked = true;

0 commit comments

Comments
 (0)