Take a reference on a page when PG_private_2 is set and drop it once the bit is unlocked.
Reported-by: Linus Torvalds <[email protected]> Signed-off-by: David Howells <[email protected]> cc: Matthew Wilcox <[email protected]> cc: Linus Torvalds <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] Link: https://lore.kernel.org/linux-fsdevel/[email protected]/ --- fs/netfs/read_helper.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c index 156941e0de61..9191a3617d91 100644 --- a/fs/netfs/read_helper.c +++ b/fs/netfs/read_helper.c @@ -10,6 +10,7 @@ #include <linux/fs.h> #include <linux/mm.h> #include <linux/pagemap.h> +#include <linux/pagevec.h> #include <linux/slab.h> #include <linux/uio.h> #include <linux/sched/mm.h> @@ -230,10 +231,13 @@ static void netfs_rreq_completed(struct netfs_read_request *rreq) static void netfs_rreq_unmark_after_write(struct netfs_read_request *rreq) { struct netfs_read_subrequest *subreq; + struct pagevec pvec; struct page *page; pgoff_t unlocked = 0; bool have_unlocked = false; + pagevec_init(&pvec); + rcu_read_lock(); list_for_each_entry(subreq, &rreq->subrequests, rreq_link) { @@ -247,6 +251,8 @@ static void netfs_rreq_unmark_after_write(struct netfs_read_request *rreq) continue; unlocked = page->index; unlock_page_fscache(page); + if (pagevec_add(&pvec, page) == 0) + pagevec_release(&pvec); have_unlocked = true; } } @@ -403,8 +409,10 @@ static void netfs_rreq_unlock(struct netfs_read_request *rreq) pg_failed = true; break; } - if (test_bit(NETFS_SREQ_WRITE_TO_CACHE, &subreq->flags)) + if (test_bit(NETFS_SREQ_WRITE_TO_CACHE, &subreq->flags)) { + get_page(page); SetPageFsCache(page); + } pg_failed |= subreq_failed; if (pgend < iopos + subreq->len) break; -- Linux-cachefs mailing list [email protected] https://listman.redhat.com/mailman/listinfo/linux-cachefs
