[07/12] fscache: Fix hanging wait on page discarded by writeback
diff mbox

Message ID 152287965062.14760.14864676977070188285.stgit@warthog.procyon.org.uk
State New
Headers show

Commit Message

David Howells April 4, 2018, 10:07 p.m. UTC
If the fscache asynchronous write operation elects to discard a page that's
pending storage to the cache because the page would be over the store limit
then it needs to wake the page as someone may be waiting on completion of
the write.

The problem is that the store limit may be updated by a different
asynchronous operation - and so may miss the write - and that the store
limit may not even get updated until later by the netfs.

Fix the kernel hang by making fscache_write_op() mark as written any pages
that are over the limit.

Signed-off-by: David Howells <dhowells@redhat.com>

 fs/fscache/page.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

diff mbox

diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index adc39c0c62df..b9f18bf4227d 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -778,6 +778,7 @@  static void fscache_write_op(struct fscache_operation *_op)
 	_enter("{OP%x,%d}", op->op.debug_id, atomic_read(&op->op.usage));
 	cookie = object->cookie;
@@ -819,10 +820,6 @@  static void fscache_write_op(struct fscache_operation *_op)
 		goto superseded;
 	page = results[0];
 	_debug("gang %d [%lx]", n, page->index);
-	if (page->index >= op->store_limit) {
-		fscache_stat(&fscache_n_store_pages_over_limit);
-		goto superseded;
-	}
 	radix_tree_tag_set(&cookie->stores, page->index,
@@ -832,6 +829,9 @@  static void fscache_write_op(struct fscache_operation *_op)
+	if (page->index >= op->store_limit)
+		goto discard_page;
 	ret = object->cache->ops->write_page(op, page);
@@ -847,6 +847,11 @@  static void fscache_write_op(struct fscache_operation *_op)
+	fscache_stat(&fscache_n_store_pages_over_limit);
+	fscache_end_page_write(object, page);
+	goto again;
 	/* this writer is going away and there aren't any more things to
 	 * write */