Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2296923imm; Mon, 28 May 2018 05:36:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo01cJUBHTVgm7TR0RzEc3B9OJVBeJV1BuMPw3MDxL3U7Lfhv4z3N67KYGw/3KspwK2/nQ8 X-Received: by 2002:a17:902:740a:: with SMTP id g10-v6mr13849393pll.246.1527511003505; Mon, 28 May 2018 05:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527511003; cv=none; d=google.com; s=arc-20160816; b=Q2/OYnLHjuO+mqUOOayf76wUZUZoKx8k5NNpHx7PfE3qg5qczaJMTeverz1GiuLmkx WbuG5jPQK9D30FnDwuAeCR349q02YozjnUIjFpRDc9FLEQIMFea/3flWK/bW0yJhhmb6 TxH7P9qaqaVS72AprEeJQECu7zrm+LuzG2DxtlYSP4cUpSOZ58Daamxs8aRm94YG6gbu yOSK6z8RZ0xofSfTiEO4ROW7djiH4yXl8c/9VUzw9nB4+DC2UaJ6ZZIgS+xpFwZHpNM0 3UoCNF+UsIo5A4QCD0CKZgDsxv0ILdTKbrM01jk4LurY9F4p9/JdPgZFLuN4aDmdjCHJ Zvog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=t1rv67DvMBWIUTZK9eMUiAxEdB1BK04qsIEGpi7FH88=; b=0ghBIuNcJ4mXiONXRux95cMtBk8NhLBvMdio83uqKixAWZiWMyPK7obPsJ+yfn7q+7 rGr0fnMNGktlTgv15SrWAziKYNyUK9NbMQEqaqd9PTjxFqZXHTyDSFkkOwU22tJDZz1p UsvUx1Xl2zg+dzCrXvtqmpqjoZioHMDAuvnmPcl/e0OJKQgIhcP1qgjin94KiU7XvkuG RqKsoPZUxOQOdvqn2hjIW0ECfOzLdBeL03qaELPi5w8PKC6tadbxqYWzMXcj6aObJKnP UB2yu6CDikSyRC44U6yhs2lOAhU79N8sKmLKuwInBtP+hqH5EQ3VfgIj00yA6o6BHRhr /W8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sW7z8jCH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6-v6si13780433pgp.482.2018.05.28.05.36.28; Mon, 28 May 2018 05:36:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sW7z8jCH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163902AbeE1K7E (ORCPT + 99 others); Mon, 28 May 2018 06:59:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:46946 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938038AbeE1K65 (ORCPT ); Mon, 28 May 2018 06:58:57 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB29C2087E; Mon, 28 May 2018 10:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505137; bh=TugmjWPiSAlUdIwsvYdKv+lz3Oe4OwKupLQJuz29npc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sW7z8jCHekgtCm2w+E5MwDmUGDY/DwvAzpSsiu4nLMXrsZhl05UxrwjXNyf45Dp06 MJCqCJ+3B5Wi2KxuW9LEm8FV1AYIuAILpL46UAnir1u20M/j3Y/gB24KZb9YF5ve3S FkdL5CuY+YLW4tJo0AynjG9CsjbKdn46M1sCoYNg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells , Sasha Levin Subject: [PATCH 4.14 348/496] fscache: Fix hanging wait on page discarded by writeback Date: Mon, 28 May 2018 12:02:13 +0200 Message-Id: <20180528100334.471042227@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Howells [ Upstream commit 2c98425720233ae3e135add0c7e869b32913502f ] 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 Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/fscache/page.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/fs/fscache/page.c +++ b/fs/fscache/page.c @@ -776,6 +776,7 @@ static void fscache_write_op(struct fsca _enter("{OP%x,%d}", op->op.debug_id, atomic_read(&op->op.usage)); +again: spin_lock(&object->lock); cookie = object->cookie; @@ -816,10 +817,6 @@ static void fscache_write_op(struct fsca 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, FSCACHE_COOKIE_STORING_TAG); @@ -829,6 +826,9 @@ static void fscache_write_op(struct fsca spin_unlock(&cookie->stores_lock); spin_unlock(&object->lock); + if (page->index >= op->store_limit) + goto discard_page; + fscache_stat(&fscache_n_store_pages); fscache_stat(&fscache_n_cop_write_page); ret = object->cache->ops->write_page(op, page); @@ -844,6 +844,11 @@ static void fscache_write_op(struct fsca _leave(""); return; +discard_page: + fscache_stat(&fscache_n_store_pages_over_limit); + fscache_end_page_write(object, page); + goto again; + superseded: /* this writer is going away and there aren't any more things to * write */